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"
33class ThreadSafeContext;
39class CompilerInstance;
42class IncrementalExecutor;
43class IncrementalParser;
44class IncrementalCUDADeviceParser;
64 void SetCudaSDK(llvm::StringRef path) { CudaSDKPath = path; };
71 create(std::string TT, std::vector<const char *> &ClangArgv);
75 std::vector<const char *> UserArgs;
76 std::optional<std::string> TargetTriple;
79 llvm::StringRef CudaSDKPath;
82class IncrementalAction;
83class InProcessPrintingASTConsumer;
90 std::unique_ptr<llvm::orc::ThreadSafeContext> TSCtx;
92 std::unique_ptr<IncrementalAction> Act;
93 std::unique_ptr<IncrementalParser> IncrParser;
94 std::unique_ptr<IncrementalExecutor> IncrExecutor;
97 std::unique_ptr<IncrementalCUDADeviceParser> DeviceParser;
100 std::unique_ptr<IncrementalAction> DeviceAct;
103 std::list<PartialTranslationUnit> PTUs;
105 unsigned InitPTUSize = 0;
113 std::unique_ptr<CompilerInstance> CI;
116 std::unique_ptr<CompilerInstance> DeviceCI;
120 Interpreter(std::unique_ptr<CompilerInstance> Instance, llvm::Error &Err,
121 std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder =
nullptr,
122 std::unique_ptr<clang::ASTConsumer> Consumer =
nullptr);
135 create(std::unique_ptr<CompilerInstance> CI,
136 std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder =
nullptr);
139 std::unique_ptr<CompilerInstance> DCI);
142 llvm::StringRef OrcRuntimePath);
154 llvm::Error
Undo(
unsigned N = 1);
174 size_t getEffectivePTUSize()
const;
175 void markUserCodeStart();
179 mutable llvm::DenseMap<CXXRecordDecl *, llvm::orc::ExecutorAddr> Dtors;
181 std::array<Expr *, 4> ValuePrintingInfo = {0};
183 std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder;
189 std::string ValueDataToString(
const Value &
V)
const;
190 std::string ValueTypeToString(
const Value &
V)
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.
This represents one expression.
GlobalDecl - represents a global declaration.
Create a pre-configured CompilerInstance for incremental processing.
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 top-level interfaces for incremental compilation and execution.
llvm::Error ParseAndExecute(llvm::StringRef Code, Value *V=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
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::unique_ptr< Interpreter > > create(std::unique_ptr< CompilerInstance > CI, std::unique_ptr< llvm::orc::LLJITBuilder > JITBuilder=nullptr)
const ASTContext & getASTContext() const
llvm::Expected< llvm::orc::LLJIT & > getExecutionEngine()
llvm::Error Execute(PartialTranslationUnit &T)
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.
The class keeps track of various objects created as part of processing incremental inputs.