clang 24.0.0git
IncrementalExecutor.h
Go to the documentation of this file.
1//===--- IncrementalExecutor.h - Base 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 base class that 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/Support/Error.h"
17
18#include <memory>
19#include <string>
20#include <vector>
21
22namespace llvm {
23class Triple;
24namespace orc {
25class ExecutorAddr;
26class ThreadSafeContext;
27} // namespace orc
28} // namespace llvm
29
30namespace clang {
31class IncrementalExecutor;
32class IncrementalCompilerBuilder;
33class TargetInfo;
34
35/// Common configuration and interface for incremental executor builders.
37public:
38 /// Options passed to the backend when configuring execution.
39 struct Options {
40 bool IsOutOfProcess = false;
41 std::string ExecutorPath;
42 std::string RuntimePath;
43 unsigned SlabAllocateSize = 0;
44 bool UseSharedMemory = false;
45 };
46
47 /// An optional external IncrementalExecutor.
48 std::unique_ptr<IncrementalExecutor> IE;
49 /// Frontend -mllvm arguments for backends that need to restore LLVM options.
50 std::vector<std::string> LLVMArgs;
51
53
54 /// Create the default builder for the platform clangInterpreter is built for.
55 /// The selected backend provides this definition.
56 static std::unique_ptr<IncrementalExecutorBuilder> createDefault();
57
58 /// Apply execution options and configure the compiler for this backend.
59 virtual llvm::Error configure(IncrementalCompilerBuilder &CB,
60 const Options &Opts) = 0;
61
62 /// Probe whether this backend can JIT code for the host.
63 virtual bool supportsJIT() const = 0;
64
65 /// Return the host triple used by this backend.
67
68 /// Return the supplied executor, or create one using the selected backend.
70 create(llvm::orc::ThreadSafeContext &TSC, const clang::TargetInfo &TI);
71
72private:
74 createExecutor(llvm::orc::ThreadSafeContext &TSC,
75 const clang::TargetInfo &TI) = 0;
76};
77
79
81public:
83
84 virtual ~IncrementalExecutor() = default;
85
86 virtual llvm::Error addModule(PartialTranslationUnit &PTU) = 0;
87 virtual llvm::Error removeModule(PartialTranslationUnit &PTU) = 0;
88 virtual llvm::Error runCtors() const = 0;
89 virtual llvm::Error cleanUp() = 0;
90
92 getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const = 0;
93 virtual llvm::Error LoadDynamicLibrary(const char *name) = 0;
94};
95
96} // namespace clang
97
98#endif // LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
Create a pre-configured CompilerInstance for incremental processing.
Definition Interpreter.h:54
Common configuration and interface for incremental executor builders.
static std::unique_ptr< IncrementalExecutorBuilder > createDefault()
Create the default builder for the platform clangInterpreter is built for.
virtual llvm::Error configure(IncrementalCompilerBuilder &CB, const Options &Opts)=0
Apply execution options and configure the compiler for this backend.
std::unique_ptr< IncrementalExecutor > IE
An optional external IncrementalExecutor.
virtual bool supportsJIT() const =0
Probe whether this backend can JIT code for the host.
llvm::Expected< std::unique_ptr< IncrementalExecutor > > create(llvm::orc::ThreadSafeContext &TSC, const clang::TargetInfo &TI)
Return the supplied executor, or create one using the selected backend.
virtual llvm::Expected< llvm::Triple > getHostJITTriple() const =0
Return the host triple used by this backend.
std::vector< std::string > LLVMArgs
Frontend -mllvm arguments for backends that need to restore LLVM options.
virtual llvm::Error LoadDynamicLibrary(const char *name)=0
virtual llvm::Error cleanUp()=0
virtual llvm::Error runCtors() const =0
virtual llvm::Error removeModule(PartialTranslationUnit &PTU)=0
virtual llvm::Expected< llvm::orc::ExecutorAddr > getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const =0
virtual ~IncrementalExecutor()=default
virtual llvm::Error addModule(PartialTranslationUnit &PTU)=0
Exposes information about the current target.
Definition TargetInfo.h:228
Top level wrappers for InstallAPI frontend operations.
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
Options passed to the backend when configuring execution.
The class keeps track of various objects created as part of processing incremental inputs.