1//===--- IncrementalExecutor.h - Incremental Execution ----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the class which performs incremental code execution.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
14#define LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
15
16#include "llvm/ADT/DenseMap.h"
17#include "llvm/ADT/StringRef.h"
18#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
19#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
20
21#include <memory>
22
23namespace llvm {
24class Error;
25namespace orc {
26class JITTargetMachineBuilder;
27class LLJIT;
28class LLJITBuilder;
29class ThreadSafeContext;
30} // namespace orc
31} // namespace llvm
32
33namespace clang {
34
35struct PartialTranslationUnit;
36class TargetInfo;
37
38class IncrementalExecutor {
39 using CtorDtorIterator = llvm::orc::CtorDtorIterator;
40 std::unique_ptr<llvm::orc::LLJIT> Jit;
41 llvm::orc::ThreadSafeContext &TSCtx;
42
43 llvm::DenseMap<const PartialTranslationUnit *, llvm::orc::ResourceTrackerSP>
44 ResourceTrackers;
45
46public:
47 enum SymbolNameKind { IRName, LinkerName };
48
49 IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC,
50 llvm::orc::LLJITBuilder &JITBuilder, llvm::Error &Err);
51 ~IncrementalExecutor();
52
53 llvm::Error addModule(PartialTranslationUnit &PTU);
54 llvm::Error removeModule(PartialTranslationUnit &PTU);
55 llvm::Error runCtors() const;
56 llvm::Error cleanUp();
57 llvm::Expected<llvm::orc::ExecutorAddr>
58 getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
59
60 llvm::orc::LLJIT &GetExecutionEngine() { return *Jit; }
61
62 static llvm::Expected<std::unique_ptr<llvm::orc::LLJITBuilder>>
63 createDefaultJITBuilder(llvm::orc::JITTargetMachineBuilder JTMB);
64};
65
66} // end namespace clang
67
68#endif // LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
69

source code of clang/lib/Interpreter/IncrementalExecutor.h