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;
87 create(std::string TT, std::vector<const char *> &ClangArgv);
92 std::vector<const char *> UserArgs;
93 std::optional<std::string> TargetTriple;
96 llvm::StringRef DeviceSDKPath;
98 std::string OffloadCUID;
100 std::optional<std::function<DriverCompilationFn>> CompilationCB;
103class IncrementalAction;
104class InProcessPrintingASTConsumer;
109 friend InProcessPrintingASTConsumer;
111 std::unique_ptr<llvm::orc::ThreadSafeContext> TSCtx;
113 std::unique_ptr<IncrementalAction> Act;
114 std::unique_ptr<IncrementalParser> IncrParser;
115 std::unique_ptr<IncrementalExecutor> IncrExecutor;
118 std::unique_ptr<IncrementalDeviceParser> DeviceParser;
121 std::unique_ptr<IncrementalAction> DeviceAct;
124 std::list<PartialTranslationUnit> PTUs;
126 unsigned InitPTUSize = 0;
134 std::unique_ptr<CompilerInstance> CI;
137 std::unique_ptr<CompilerInstance> DeviceCI;
141 Interpreter(std::unique_ptr<CompilerInstance> Instance, llvm::Error &Err,
142 std::unique_ptr<IncrementalExecutorBuilder> IEB =
nullptr,
143 std::unique_ptr<clang::ASTConsumer> Consumer =
nullptr);
156 create(std::unique_ptr<CompilerInstance> CI,
157 std::unique_ptr<IncrementalExecutorBuilder> IEB =
nullptr);
160 std::unique_ptr<CompilerInstance> DCI,
176 void setOptLevel(
unsigned OptLevel,
unsigned OptSize = 0);
179 llvm::Error
Undo(
unsigned N = 1);
199 return *IncrExecutorBuilder;
203 size_t getEffectivePTUSize()
const;
204 void markUserCodeStart();
208 mutable llvm::DenseMap<CXXRecordDecl *, llvm::orc::ExecutorAddr> Dtors;
210 std::array<Expr *, 4> ValuePrintingInfo = {0};
212 std::unique_ptr<IncrementalExecutorBuilder> IncrExecutorBuilder;
218 std::string ValueDataToString(
const Value &
V)
const;
219 std::string ValueTypeToString(
const Value &
V)
const;
226 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.
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()
llvm::Expected< std::unique_ptr< CompilerInstance > > CreateHost(OffloadType Type)
IncrementalCompilerBuilder()
void SetOffloadArch(llvm::StringRef Arch)
void SetDeviceSDK(llvm::StringRef Path)
llvm::Expected< std::unique_ptr< CompilerInstance > > CreateDevice(OffloadType Type)
Common configuration and interface for incremental executor builders.
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
void setOptLevel(unsigned OptLevel, unsigned OptSize=0)
Set the optimization level and size used to emit subsequently parsed input.
llvm::Error LoadDynamicLibrary(const char *name)
Link a dynamic library.
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
static llvm::Expected< std::unique_ptr< Interpreter > > createWithDevice(std::unique_ptr< CompilerInstance > CI, std::unique_ptr< CompilerInstance > DCI, OffloadType Type=OffloadType::Detect)
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.
OffloadType
The device language to offload to.
@ 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.