@@ -38,6 +38,7 @@ class ThreadSafeContext;
38
38
namespace clang {
39
39
40
40
class CompilerInstance ;
41
+ class CodeGenerator ;
41
42
42
43
class IncrementalExecutor ;
43
44
class IncrementalParser ;
@@ -78,30 +79,25 @@ class IncrementalCompilerBuilder {
78
79
llvm::StringRef CudaSDKPath;
79
80
};
80
81
81
- class Interpreter ;
82
- // / Provides a callback class allowing to listen to interpreter events and to
83
- // / specialize some operations.
84
- class InterpreterCallbacks {
85
- Interpreter &Interp;
86
-
87
- public:
88
- InterpreterCallbacks (Interpreter &I) : Interp(I) {}
89
- virtual ~InterpreterCallbacks ();
90
- virtual void ProcessingTopLevelStmtDecl (TopLevelStmtDecl *D);
91
- };
82
+ class IncrementalAction ;
83
+ class InProcessPrintingASTConsumer ;
92
84
93
85
// / Provides top-level interfaces for incremental compilation and execution.
94
86
class Interpreter {
95
- friend Value;
87
+ friend class Value ;
88
+ friend InProcessPrintingASTConsumer;
96
89
97
90
std::unique_ptr<llvm::orc::ThreadSafeContext> TSCtx;
98
- std::unique_ptr<InterpreterCallbacks> InterpreterCB;
91
+ // / Long-lived, incremental parsing action.
92
+ std::unique_ptr<IncrementalAction> Act;
99
93
std::unique_ptr<IncrementalParser> IncrParser;
100
94
std::unique_ptr<IncrementalExecutor> IncrExecutor;
101
95
102
96
// An optional parser for CUDA offloading
103
97
std::unique_ptr<IncrementalParser> DeviceParser;
104
98
99
+ std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder;
100
+
105
101
unsigned InitPTUSize = 0 ;
106
102
107
103
// This member holds the last result of the value printing. It's a class
@@ -120,10 +116,15 @@ class Interpreter {
120
116
121
117
std::array<Expr *, 4 > ValuePrintingInfo = {0 };
122
118
119
+ // / When CodeGen is created the first llvm::Module gets cached in many places
120
+ // / and we must keep it alive.
121
+ std::unique_ptr<llvm::Module> CachedInCodeGenModule;
122
+
123
123
protected:
124
124
// Derived classes can use an extended interface of the Interpreter.
125
125
Interpreter (std::unique_ptr<CompilerInstance> CI, llvm::Error &Err,
126
- std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder = nullptr );
126
+ std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder = nullptr ,
127
+ std::unique_ptr<clang::ASTConsumer> Consumer = nullptr );
127
128
128
129
// Create the internal IncrementalExecutor, or re-create it after calling
129
130
// ResetExecutor().
@@ -170,32 +171,29 @@ class Interpreter {
170
171
llvm::Expected<llvm::orc::ExecutorAddr>
171
172
getSymbolAddressFromLinkerName (llvm::StringRef LinkerName) const ;
172
173
173
- InterpreterCallbacks *getInterpreterCallbacks () {
174
- return InterpreterCB.get ();
175
- }
176
- const InterpreterCallbacks *getInterpreterCallbacks () const {
177
- return const_cast <Interpreter *>(this )->getInterpreterCallbacks ();
178
- }
179
- void setInterpreterCallbacks (std::unique_ptr<InterpreterCallbacks> CB) {
180
- InterpreterCB = std::move (CB);
181
- }
182
-
183
- llvm::Expected<Expr *> SynthesizeExpr (Expr *E);
184
-
185
174
std::unique_ptr<llvm::Module> GenModule ();
186
175
187
176
private:
188
177
size_t getEffectivePTUSize () const ;
189
178
void markUserCodeStart ();
190
179
191
- std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder;
180
+ // / @}
181
+ // / @name Value and pretty printing support
182
+ // / @{
192
183
193
184
std::string ValueDataToString (const Value &V);
194
185
std::string ValueTypeToString (const Value &V) const ;
195
186
187
+ llvm::Expected<Expr *> AttachValuePrinting (Expr *E);
188
+
196
189
// When we deallocate clang::Value we need to run the destructor of the type.
197
190
// This function forces emission of the needed dtor.
198
191
llvm::Expected<llvm::orc::ExecutorAddr> CompileDtorCall (CXXRecordDecl *CXXRD);
192
+
193
+ // / @}
194
+ // / @name Code generation
195
+ // / @{
196
+ CodeGenerator *getCodeGen () const ;
199
197
};
200
198
} // namespace clang
201
199
0 commit comments