14
14
#ifndef LLVM_CLANG_INTERPRETER_INTERPRETER_H
15
15
#define LLVM_CLANG_INTERPRETER_INTERPRETER_H
16
16
17
- #include " clang/AST/Decl.h"
18
- #include " clang/AST/GlobalDecl.h"
19
17
#include " clang/Interpreter/PartialTranslationUnit.h"
20
- #include " clang/Interpreter/Value.h"
21
18
22
- #include " llvm/ADT/DenseMap.h"
19
+ #include " clang/AST/GlobalDecl.h"
20
+
23
21
#include " llvm/ExecutionEngine/JITSymbol.h"
24
22
#include " llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
25
23
#include " llvm/Support/Error.h"
24
+
26
25
#include < memory>
27
26
#include < vector>
28
27
@@ -42,34 +41,8 @@ class IncrementalParser;
42
41
// / Create a pre-configured \c CompilerInstance for incremental processing.
43
42
class IncrementalCompilerBuilder {
44
43
public:
45
- IncrementalCompilerBuilder () {}
46
-
47
- void SetCompilerArgs (const std::vector<const char *> &Args) {
48
- UserArgs = Args;
49
- }
50
-
51
- // General C++
52
- llvm::Expected<std::unique_ptr<CompilerInstance>> CreateCpp ();
53
-
54
- // Offload options
55
- void SetOffloadArch (llvm::StringRef Arch) { OffloadArch = Arch; };
56
-
57
- // CUDA specific
58
- void SetCudaSDK (llvm::StringRef path) { CudaSDKPath = path; };
59
-
60
- llvm::Expected<std::unique_ptr<CompilerInstance>> CreateCudaHost ();
61
- llvm::Expected<std::unique_ptr<CompilerInstance>> CreateCudaDevice ();
62
-
63
- private:
64
44
static llvm::Expected<std::unique_ptr<CompilerInstance>>
65
45
create (std::vector<const char *> &ClangArgv);
66
-
67
- llvm::Expected<std::unique_ptr<CompilerInstance>> createCuda (bool device);
68
-
69
- std::vector<const char *> UserArgs;
70
-
71
- llvm::StringRef OffloadArch;
72
- llvm::StringRef CudaSDKPath;
73
46
};
74
47
75
48
// / Provides top-level interfaces for incremental compilation and execution.
@@ -78,35 +51,27 @@ class Interpreter {
78
51
std::unique_ptr<IncrementalParser> IncrParser;
79
52
std::unique_ptr<IncrementalExecutor> IncrExecutor;
80
53
81
- // An optional parser for CUDA offloading
82
- std::unique_ptr<IncrementalParser> DeviceParser;
83
-
84
54
Interpreter (std::unique_ptr<CompilerInstance> CI, llvm::Error &Err);
85
55
86
56
llvm::Error CreateExecutor ();
87
- unsigned InitPTUSize = 0 ;
88
-
89
- // This member holds the last result of the value printing. It's a class
90
- // member because we might want to access it after more inputs. If no value
91
- // printing happens, it's in an invalid state.
92
- Value LastValue;
93
57
94
58
public:
95
59
~Interpreter ();
96
60
static llvm::Expected<std::unique_ptr<Interpreter>>
97
61
create (std::unique_ptr<CompilerInstance> CI);
98
- static llvm::Expected<std::unique_ptr<Interpreter>>
99
- createWithCUDA (std::unique_ptr<CompilerInstance> CI,
100
- std::unique_ptr<CompilerInstance> DCI);
101
- const ASTContext &getASTContext () const ;
102
- ASTContext &getASTContext ();
103
62
const CompilerInstance *getCompilerInstance () const ;
104
63
llvm::Expected<llvm::orc::LLJIT &> getExecutionEngine ();
105
64
106
65
llvm::Expected<PartialTranslationUnit &> Parse (llvm::StringRef Code);
107
66
llvm::Error Execute (PartialTranslationUnit &T);
108
- llvm::Error ParseAndExecute (llvm::StringRef Code, Value *V = nullptr );
109
- llvm::Expected<llvm::orc::ExecutorAddr> CompileDtorCall (CXXRecordDecl *CXXRD);
67
+ llvm::Error ParseAndExecute (llvm::StringRef Code) {
68
+ auto PTU = Parse (Code);
69
+ if (!PTU)
70
+ return PTU.takeError ();
71
+ if (PTU->TheModule )
72
+ return Execute (*PTU);
73
+ return llvm::Error::success ();
74
+ }
110
75
111
76
// / Undo N previous incremental inputs.
112
77
llvm::Error Undo (unsigned N = 1 );
@@ -127,23 +92,6 @@ class Interpreter {
127
92
// / file.
128
93
llvm::Expected<llvm::orc::ExecutorAddr>
129
94
getSymbolAddressFromLinkerName (llvm::StringRef LinkerName) const ;
130
-
131
- enum InterfaceKind { NoAlloc, WithAlloc, CopyArray };
132
-
133
- const llvm::SmallVectorImpl<Expr *> &getValuePrintingInfo () const {
134
- return ValuePrintingInfo;
135
- }
136
-
137
- Expr *SynthesizeExpr (Expr *E);
138
-
139
- private:
140
- size_t getEffectivePTUSize () const ;
141
-
142
- bool FindRuntimeInterface ();
143
-
144
- llvm::DenseMap<CXXRecordDecl *, llvm::orc::ExecutorAddr> Dtors;
145
-
146
- llvm::SmallVector<Expr *, 3 > ValuePrintingInfo;
147
95
};
148
96
} // namespace clang
149
97
0 commit comments