14#ifndef LLVM_CLANG_INTERPRETER_INTERPRETER_H
15#define LLVM_CLANG_INTERPRETER_INTERPRETER_H
21#include "llvm/ADT/DenseMap.h"
22#include "llvm/ExecutionEngine/JITSymbol.h"
23#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
24#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
25#include "llvm/Support/Error.h"
34class ThreadSafeContext;
69 void SetCudaSDK(llvm::StringRef path) { CudaSDKPath = path; };
76 create(std::string TT, std::vector<const char *> &ClangArgv);
80 std::vector<const char *> UserArgs;
81 std::optional<std::string> TargetTriple;
84 llvm::StringRef CudaSDKPath;
87class IncrementalAction;
88class InProcessPrintingASTConsumer;
93 friend InProcessPrintingASTConsumer;
95 std::unique_ptr<llvm::orc::ThreadSafeContext> TSCtx;
97 std::unique_ptr<IncrementalAction> Act;
98 std::unique_ptr<IncrementalParser> IncrParser;
99 std::unique_ptr<IncrementalExecutor> IncrExecutor;
102 std::unique_ptr<IncrementalCUDADeviceParser> DeviceParser;
105 std::unique_ptr<IncrementalAction> DeviceAct;
108 std::list<PartialTranslationUnit> PTUs;
110 unsigned InitPTUSize = 0;
118 std::unique_ptr<CompilerInstance> CI;
121 std::unique_ptr<CompilerInstance> DeviceCI;
141 std::optional<llvm::CodeModel::Model>
CM = std::nullopt;
151 Interpreter(std::unique_ptr<CompilerInstance> Instance, llvm::Error &Err,
152 std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder =
nullptr,
153 std::unique_ptr<clang::ASTConsumer> Consumer =
nullptr,
154 JITConfig Config = JITConfig());
167 create(std::unique_ptr<CompilerInstance> CI, JITConfig Config = {});
170 std::unique_ptr<CompilerInstance> DCI);
173 llvm::StringRef OrcRuntimePath);
175 std::pair<std::unique_ptr<llvm::orc::LLJITBuilder>, uint32_t>>
187 llvm::Error
Execute(PartialTranslationUnit &T);
191 llvm::Error
Undo(
unsigned N = 1);
213 size_t getEffectivePTUSize()
const;
214 void markUserCodeStart();
218 mutable llvm::DenseMap<CXXRecordDecl *, llvm::orc::ExecutorAddr> Dtors;
220 std::array<Expr *, 4> ValuePrintingInfo = {0};
222 std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder;
228 std::string ValueDataToString(
const Value &
V)
const;
229 std::string ValueTypeToString(
const Value &
V)
const;
231 llvm::Expected<Expr *> convertExprToValue(Expr *E);
235 llvm::Expected<llvm::orc::ExecutorAddr>
236 CompileDtorCall(CXXRecordDecl *CXXRD)
const;
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Represents a C++ struct/union/class.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Decl - This represents one declaration (or definition), e.g.
llvm::Expected< std::unique_ptr< CompilerInstance > > CreateCudaHost()
llvm::Expected< std::unique_ptr< CompilerInstance > > CreateCudaDevice()
void SetCompilerArgs(const std::vector< const char * > &Args)
void SetTargetTriple(std::string TT)
llvm::Expected< std::unique_ptr< CompilerInstance > > CreateCpp()
IncrementalCompilerBuilder()
void SetCudaSDK(llvm::StringRef path)
void SetOffloadArch(llvm::StringRef Arch)
Provides support for incremental compilation.
llvm::Error ParseAndExecute(llvm::StringRef Code, Value *V=nullptr)
uint32_t getOutOfProcessExecutorPID() const
llvm::Expected< llvm::orc::ExecutorAddr > getSymbolAddress(GlobalDecl GD) const
static llvm::Expected< std::pair< std::unique_ptr< llvm::orc::LLJITBuilder >, uint32_t > > outOfProcessJITBuilder(JITConfig Config)
llvm::Error LoadDynamicLibrary(const char *name)
Link a dynamic library.
static llvm::Expected< std::unique_ptr< Interpreter > > createWithCUDA(std::unique_ptr< CompilerInstance > CI, std::unique_ptr< CompilerInstance > DCI)
llvm::Error CreateExecutor(JITConfig Config=JITConfig())
llvm::Expected< llvm::orc::ExecutorAddr > getSymbolAddressFromLinkerName(llvm::StringRef LinkerName) const
llvm::Error Undo(unsigned N=1)
Undo N previous incremental inputs.
const CompilerInstance * getCompilerInstance() const
static llvm::Expected< std::unique_ptr< llvm::orc::LLJITBuilder > > createLLJITBuilder(std::unique_ptr< llvm::orc::ExecutorProcessControl > EPC, llvm::StringRef OrcRuntimePath)
static llvm::Expected< std::string > getOrcRuntimePath(const driver::ToolChain &TC)
const ASTContext & getASTContext() const
llvm::Expected< llvm::orc::LLJIT & > getExecutionEngine()
static llvm::Expected< std::unique_ptr< Interpreter > > create(std::unique_ptr< CompilerInstance > CI, JITConfig Config={})
llvm::Error Execute(PartialTranslationUnit &T)
Interpreter(std::unique_ptr< CompilerInstance > Instance, llvm::Error &Err, std::unique_ptr< llvm::orc::LLJITBuilder > JITBuilder=nullptr, std::unique_ptr< clang::ASTConsumer > Consumer=nullptr, JITConfig Config=JITConfig())
The JSON file list parser is used to communicate input to InstallAPI.
nullptr
This class represents a compute construct, representing a 'Kind' of βparallelβ, 'serial',...
@ Parse
Parse the block; this code is always used.
Diagnostic wrappers for TextAPI types for error reporting.
int const char * function
uint32_t ExecutorPID
PID of the out-of-process JIT executor.
std::function< void()> CustomizeFork
Custom lambda to be executed inside child process/executor.
bool IsOutOfProcess
Indicates whether out-of-process JIT execution is enabled.
std::string OrcRuntimePath
Path to the ORC runtime library.
std::optional< llvm::CodeModel::Model > CM
An optional code model to provide to the JITTargetMachineBuilder.
unsigned SlabAllocateSize
Representing the slab allocation size for memory management in kb.
bool UseSharedMemory
Indicates whether to use shared memory for communication.
std::string OOPExecutor
Path to the out-of-process JIT executor.
std::string OOPExecutorConnect