14#ifndef LLVM_CLANG_INTERPRETER_INTERPRETER_H
15#define LLVM_CLANG_INTERPRETER_INTERPRETER_H
22#include "llvm/ADT/DenseMap.h"
23#include "llvm/ExecutionEngine/JITSymbol.h"
24#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
25#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
26#include "llvm/Support/Error.h"
33class ThreadSafeContext;
69 void SetCudaSDK(llvm::StringRef path) { CudaSDKPath = path; };
81 create(std::string TT, std::vector<const char *> &ClangArgv);
85 std::vector<const char *> UserArgs;
86 std::optional<std::string> TargetTriple;
89 llvm::StringRef CudaSDKPath;
91 std::optional<std::function<DriverCompilationFn>> CompilationCB;
94class IncrementalAction;
95class InProcessPrintingASTConsumer;
100 friend InProcessPrintingASTConsumer;
102 std::unique_ptr<llvm::orc::ThreadSafeContext> TSCtx;
104 std::unique_ptr<IncrementalAction> Act;
105 std::unique_ptr<IncrementalParser> IncrParser;
106 std::unique_ptr<IncrementalExecutor> IncrExecutor;
109 std::unique_ptr<IncrementalCUDADeviceParser> DeviceParser;
112 std::unique_ptr<IncrementalAction> DeviceAct;
115 std::list<PartialTranslationUnit> PTUs;
117 unsigned InitPTUSize = 0;
125 std::unique_ptr<CompilerInstance> CI;
128 std::unique_ptr<CompilerInstance> DeviceCI;
132 Interpreter(std::unique_ptr<CompilerInstance> Instance, llvm::Error &Err,
133 std::unique_ptr<IncrementalExecutorBuilder> IEB =
nullptr,
134 std::unique_ptr<clang::ASTConsumer> Consumer =
nullptr);
147 create(std::unique_ptr<CompilerInstance> CI,
148 std::unique_ptr<IncrementalExecutorBuilder> IEB =
nullptr);
151 std::unique_ptr<CompilerInstance> DCI);
164 llvm::Error
Undo(
unsigned N = 1);
184 return *IncrExecutorBuilder;
188 size_t getEffectivePTUSize()
const;
189 void markUserCodeStart();
193 mutable llvm::DenseMap<CXXRecordDecl *, llvm::orc::ExecutorAddr> Dtors;
195 std::array<Expr *, 4> ValuePrintingInfo = {0};
197 std::unique_ptr<IncrementalExecutorBuilder> IncrExecutorBuilder;
203 std::string ValueDataToString(
const Value &
V)
const;
204 std::string ValueTypeToString(
const Value &
V)
const;
211 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.
GlobalDecl - represents a global declaration.
llvm::Expected< std::unique_ptr< CompilerInstance > > CreateCudaHost()
llvm::Expected< std::unique_ptr< CompilerInstance > > CreateCudaDevice()
void SetCompilerArgs(const std::vector< const char * > &Args)
void SetDriverCompilationCallback(std::function< DriverCompilationFn > C)
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.
const IncrementalExecutorBuilder & getIncrementalExecutorBuilder() const
llvm::Expected< IncrementalExecutor & > getExecutionEngine()
llvm::Error ParseAndExecute(llvm::StringRef Code, Value *V=nullptr)
static llvm::Expected< std::unique_ptr< Interpreter > > create(std::unique_ptr< CompilerInstance > CI, std::unique_ptr< IncrementalExecutorBuilder > IEB=nullptr)
llvm::Error CreateExecutor()
llvm::Expected< llvm::orc::ExecutorAddr > getSymbolAddress(GlobalDecl GD) const
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::Expected< llvm::orc::ExecutorAddr > getSymbolAddressFromLinkerName(llvm::StringRef LinkerName) const
Interpreter(std::unique_ptr< CompilerInstance > Instance, llvm::Error &Err, std::unique_ptr< IncrementalExecutorBuilder > IEB=nullptr, std::unique_ptr< clang::ASTConsumer > Consumer=nullptr)
llvm::Error Undo(unsigned N=1)
Undo N previous incremental inputs.
const CompilerInstance * getCompilerInstance() const
const ASTContext & getASTContext() const
llvm::Error Execute(PartialTranslationUnit &T)
Compilation - A set of tasks to perform for a single driver invocation.
The JSON file list parser is used to communicate input to InstallAPI.
@ Parse
Parse the block; this code is always used.
const FunctionProtoType * T
Diagnostic wrappers for TextAPI types for error reporting.
int const char * function
The class keeps track of various objects created as part of processing incremental inputs.