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;
102 create(std::string TT, std::vector<const char *> &ClangArgv);
107 std::vector<const char *> UserArgs;
108 std::optional<std::string> TargetTriple;
111 llvm::StringRef RocmSDKPath;
112 llvm::StringRef CudaSDKPath;
114 std::string OffloadCUID;
116 std::optional<std::function<DriverCompilationFn>> CompilationCB;
119class IncrementalAction;
120class InProcessPrintingASTConsumer;
125 friend InProcessPrintingASTConsumer;
127 std::unique_ptr<llvm::orc::ThreadSafeContext> TSCtx;
129 std::unique_ptr<IncrementalAction> Act;
130 std::unique_ptr<IncrementalParser> IncrParser;
131 std::unique_ptr<IncrementalExecutor> IncrExecutor;
134 std::unique_ptr<IncrementalCUDADeviceParser> DeviceParser;
137 std::unique_ptr<IncrementalAction> DeviceAct;
140 std::list<PartialTranslationUnit> PTUs;
142 unsigned InitPTUSize = 0;
150 std::unique_ptr<CompilerInstance> CI;
153 std::unique_ptr<CompilerInstance> DeviceCI;
157 Interpreter(std::unique_ptr<CompilerInstance> Instance, llvm::Error &Err,
158 std::unique_ptr<IncrementalExecutorBuilder> IEB =
nullptr,
159 std::unique_ptr<clang::ASTConsumer> Consumer =
nullptr);
172 create(std::unique_ptr<CompilerInstance> CI,
173 std::unique_ptr<IncrementalExecutorBuilder> IEB =
nullptr);
176 std::unique_ptr<CompilerInstance> DCI);
189 llvm::Error
Undo(
unsigned N = 1);
209 return *IncrExecutorBuilder;
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<IncrementalExecutorBuilder> IncrExecutorBuilder;
228 std::string ValueDataToString(
const Value &
V)
const;
229 std::string ValueTypeToString(
const Value &
V)
const;
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.
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 SetCudaSDK(llvm::StringRef Path)
void SetDriverCompilationCallback(std::function< DriverCompilationFn > C)
void SetTargetTriple(std::string TT)
llvm::Expected< std::unique_ptr< CompilerInstance > > CreateCpp()
llvm::Expected< std::unique_ptr< CompilerInstance > > CreateHost(OffloadType Type)
IncrementalCompilerBuilder()
void SetDeviceSDK(OffloadType Type, llvm::StringRef Path)
void SetOffloadArch(llvm::StringRef Arch)
llvm::Expected< std::unique_ptr< CompilerInstance > > CreateDevice(OffloadType Type)
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.
llvm::Expected< llvm::orc::ExecutorAddr > getSymbolAddressFromLinkerName(llvm::StringRef LinkerName) const
static llvm::Expected< std::unique_ptr< Interpreter > > createWithDevice(OffloadType Type, std::unique_ptr< CompilerInstance > CI, std::unique_ptr< CompilerInstance > DCI)
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)
A processor an offloading action can target.
The base class of the type hierarchy.
Compilation - A set of tasks to perform for a single driver invocation.
Top level wrappers for InstallAPI frontend operations.
@ 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.