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
21namespace llvm {
22class Triple;
23namespace orc {
24class ExecutorAddr;
25class ThreadSafeContext;
26} // namespace orc
27} // namespace llvm
28
29namespace clang {
30class IncrementalExecutor;
31class IncrementalCompilerBuilder;
32class TargetInfo;
33
34/// Common configuration and interface for incremental executor builders.
36public:
37 /// Options passed to the backend when configuring execution.
38 struct Options {
39 bool IsOutOfProcess = false;
40 std::string ExecutorPath;
41 std::string RuntimePath;
42 unsigned SlabAllocateSize = 0;
43 bool UseSharedMemory = false;
44 };
45
46 /// An optional external IncrementalExecutor.
47 std::unique_ptr<IncrementalExecutor> IE;
48
50
51 /// Create the default builder for the platform clangInterpreter is built for.
52 /// The selected backend provides this definition.
53 static std::unique_ptr<IncrementalExecutorBuilder> createDefault();
54
55 /// Apply execution options and configure the compiler for this backend.
56 virtual llvm::Error configure(IncrementalCompilerBuilder &CB,
57 const Options &Opts) = 0;
58
59 /// Probe whether this backend can JIT code for the host.
60 virtual bool supportsJIT() const = 0;
61
62 /// Return the host triple used by this backend.
64
65 /// Return the supplied executor, or create one using the selected backend.
67 create(llvm::orc::ThreadSafeContext &TSC, const clang::TargetInfo &TI);
68
69private:
71 createExecutor(llvm::orc::ThreadSafeContext &TSC,
72 const clang::TargetInfo &TI) = 0;
73};
74
76
78public:
80
81 virtual ~IncrementalExecutor() = default;
82
83 virtual llvm::Error addModule(PartialTranslationUnit &PTU) = 0;
84 virtual llvm::Error removeModule(PartialTranslationUnit &PTU) = 0;
85 virtual llvm::Error runCtors() const = 0;
86 virtual llvm::Error cleanUp() = 0;
87
89 getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const = 0;
90 virtual llvm::Error LoadDynamicLibrary(const char *name) = 0;
91};
92
93} // namespace clang
94
95#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.
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.