LLVM: include/llvm/ExecutionEngine/ExecutionEngine.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
15#define LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
16
33#include
34#include
35#include
36#include
37#include
38#include
39#include
40#include
41
42namespace llvm {
43
55
57
60
61}
62
63
64
66public:
68
69private:
70
71
73
74
75
76
77
78 std::map<uint64_t, std::string> GlobalAddressReverseMap;
79
80public:
82 return GlobalAddressMap;
83 }
84
86 return GlobalAddressReverseMap;
87 }
88
89
90
91
93};
94
95using FunctionCreator = std::function<void *(const std::string &)>;
96
97
98
99
101
102
103
104
105
107
108
109
110
111
112
113
115
116
117 bool CompilingLazily;
118
119
120 bool GVCompilationDisabled;
121
122
123
124 bool SymbolSearchingDisabled;
125
126
127 bool VerifyModules;
128
129 friend class EngineBuilder;
130
131protected:
132
133
135
136
138
140 std::unique_ptr M, std::string *ErrorStr,
141 std::shared_ptr MM,
142 std::shared_ptr SR,
143 std::unique_ptr TM);
144
146 std::string *ErrorStr);
147
148
149
150
152
153
155
157
158public:
159
160
162
163
164
165
166
168
169
170 virtual void addModule(std::unique_ptr M) {
171 Modules.push_back(std::move(M));
172 }
173
174
175
176
177
178
179
180
181
182
183
184 virtual void addObjectFile(std::unique_ptrobject::ObjectFile O);
186
187
188
189
190
191
192
194
195
196
198
199
200
201
202
203
204
205 virtual bool removeModule(Module *M);
206
207
208
209
211
212
213
214
215 virtual GlobalVariable *FindGlobalVariableNamed(StringRef Name, bool AllowInternal = false);
216
217
218
219
220
221
222
223
224
225
228
229
230
231
232
233
234
235
236
237
239 bool AbortOnFailure = true) = 0;
240
241
242
243
244
247 llvm_unreachable("Re-mapping of section addresses not supported with this "
248 "EE!");
249 }
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
267
268
269
270
271
272
273
274
275
276
277
279
280
282
283
285
286
288
289
290
291
292
293 virtual void runStaticConstructorsDestructors(bool isDtors);
294
295
296
297
298
299 void runStaticConstructorsDestructors(Module &module, bool isDtors);
300
301
302
303
304
305 int runFunctionAsMain(Function *Fn, const std::vectorstd::string &argv,
306 const char * const * envp);
307
308
309
310
311
312
313
314
315
316 void addGlobalMapping(const GlobalValue *GV, void *Addr);
318
319
320
321 void clearAllGlobalMappings();
322
323
324
325 void clearGlobalMappingsFromModule(Module *M);
326
327
328
329
330
333
334
335
337
338
339
340
341 void *getPointerToGlobalIfAvailable(StringRef S);
342 void *getPointerToGlobalIfAvailable(const GlobalValue *GV);
343
344
345
346
347
348
349 void *getPointerToGlobal(const GlobalValue *GV);
350
351
352
353
354
355
356
357
358
360
361
362
363
364
365
366
367
372
373
374
375
376
378
379
380 return 0;
381 }
382
383
384
386
387
388 return 0;
389 }
390
391
392
393
394 const GlobalValue *getGlobalValueAtAddress(void *Addr);
395
396
397
398
399
402
403 void InitializeMemory(const Constant *Init, void *Addr);
404
405
406
407
408
409
410
414
415
416
417
418
421
422
423
427
428
429
430
431
432
433
434
435
436
437
438
442
443
445
446
447
448
449
450
451
452
453
454
455
456
457
458
463 return CompilingLazily;
464 }
465
466
467
468
470 GVCompilationDisabled = Disabled;
471 }
473 return GVCompilationDisabled;
474 }
475
476
477
478
480 SymbolSearchingDisabled = Disabled;
481 }
483 return SymbolSearchingDisabled;
484 }
485
486
487
488
489
491 VerifyModules = Verify;
492 }
494 return VerifyModules;
495 }
496
497
498
499
503
504protected:
508
509 void emitGlobals();
510
512
516
517private:
518 void Init(std::unique_ptr M);
519};
520
531
532
533
534
536private:
537 std::unique_ptr M;
539 std::string *ErrorStr;
541 std::shared_ptr MemMgr;
542 std::shared_ptr Resolver;
544 std::optionalReloc::Model RelocModel;
545 std::optionalCodeModel::Model CMModel;
546 std::string MArch;
547 std::string MCPU;
549 bool VerifyModules;
550 bool EmulatedTLS = true;
551
552public:
553
555
556
558
559
561
562
563
565 WhichEngine = w;
566 return *this;
567 }
568
569
570
571
572
573
574
577
580
583
584
585
587 ErrorStr = e;
588 return *this;
589 }
590
591
592
594 OptLevel = l;
595 return *this;
596 }
597
598
599
601 Options = Opts;
602 return *this;
603 }
604
605
606
608 RelocModel = RM;
609 return *this;
610 }
611
612
613
614
616 CMModel = M;
617 return *this;
618 }
619
620
622 MArch.assign(march.begin(), march.end());
623 return *this;
624 }
625
626
628 MCPU.assign(mcpu.begin(), mcpu.end());
629 return *this;
630 }
631
632
633
635 VerifyModules = Verify;
636 return *this;
637 }
638
639
640 template
642 MAttrs.clear();
643 MAttrs.append(mattrs.begin(), mattrs.end());
644 return *this;
645 }
646
648 this->EmulatedTLS = EmulatedTLS;
649 }
650
652
653
654
658
662
664};
665
666
668
669}
670
671#endif
This file defines the StringMap class.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
Module.h This file contains the declarations for the Module class.
ppc ctr loops PowerPC CTR Loops Verify
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
Builder class for ExecutionEngines.
Definition ExecutionEngine.h:535
EngineBuilder & setTargetOptions(const TargetOptions &Opts)
setTargetOptions - Set the target options that the ExecutionEngine target is using.
Definition ExecutionEngine.h:600
LLVM_ABI EngineBuilder & setMCJITMemoryManager(std::unique_ptr< RTDyldMemoryManager > mcjmm)
setMCJITMemoryManager - Sets the MCJIT memory manager to use.
LLVM_ABI EngineBuilder()
Default constructor for EngineBuilder.
EngineBuilder & setMArch(StringRef march)
setMArch - Override the architecture set by the Module's triple.
Definition ExecutionEngine.h:621
EngineBuilder & setCodeModel(CodeModel::Model M)
setCodeModel - Set the CodeModel that the ExecutionEngine target data is using.
Definition ExecutionEngine.h:615
EngineBuilder & setOptLevel(CodeGenOptLevel l)
setOptLevel - Set the optimization level for the JIT.
Definition ExecutionEngine.h:593
LLVM_ABI EngineBuilder & setSymbolResolver(std::unique_ptr< LegacyJITSymbolResolver > SR)
LLVM_ABI ~EngineBuilder()
LLVM_ABI TargetMachine * selectTarget()
EngineBuilder & setErrorStr(std::string *e)
setErrorStr - Set the error string to write to on error.
Definition ExecutionEngine.h:586
EngineBuilder & setVerifyModules(bool Verify)
setVerifyModules - Set whether the JIT implementation should verify IR modules during compilation.
Definition ExecutionEngine.h:634
EngineBuilder & setEngineKind(EngineKind::Kind w)
setEngineKind - Controls whether the user wants the interpreter, the JIT, or whichever engine works.
Definition ExecutionEngine.h:564
LLVM_ABI EngineBuilder & setMemoryManager(std::unique_ptr< MCJITMemoryManager > MM)
ExecutionEngine * create()
Definition ExecutionEngine.h:659
EngineBuilder & setRelocationModel(Reloc::Model RM)
setRelocationModel - Set the relocation model that the ExecutionEngine target is using.
Definition ExecutionEngine.h:607
void setEmulatedTLS(bool EmulatedTLS)
Definition ExecutionEngine.h:647
EngineBuilder & setMAttrs(const StringSequence &mattrs)
setMAttrs - Set cpu-specific attributes.
Definition ExecutionEngine.h:641
EngineBuilder & setMCPU(StringRef mcpu)
setMCPU - Target a specific cpu type.
Definition ExecutionEngine.h:627
Helper class for helping synchronize access to the global address map table.
Definition ExecutionEngine.h:65
std::map< uint64_t, std::string > & getGlobalAddressReverseMap()
Definition ExecutionEngine.h:85
LLVM_ABI uint64_t RemoveMapping(StringRef Name)
Erase an entry from the mapping table.
GlobalAddressMapTy & getGlobalAddressMap()
Definition ExecutionEngine.h:81
StringMap< uint64_t > GlobalAddressMapTy
Definition ExecutionEngine.h:67
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter...
Definition ExecutionEngine.h:100
void setVerifyModules(bool Verify)
Enable/Disable IR module verification.
Definition ExecutionEngine.h:490
bool isCompilingLazily() const
Definition ExecutionEngine.h:462
virtual void setProcessAllSections(bool ProcessAllSections)
setProcessAllSections (MCJIT Only): By default, only sections that are "required for execution" are p...
Definition ExecutionEngine.h:439
const DataLayout & getDataLayout() const
Definition ExecutionEngine.h:197
bool getVerifyModules() const
Definition ExecutionEngine.h:493
void DisableGVCompilation(bool Disabled=true)
DisableGVCompilation - If called, the JIT will abort if it's asked to allocate space and populate a G...
Definition ExecutionEngine.h:469
const std::string & getErrorMessage() const
Returns the most recent error message.
Definition ExecutionEngine.h:287
void clearErrorMessage()
Clear the error message.
Definition ExecutionEngine.h:284
virtual void * getPointerToFunctionOrStub(Function *F)
getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the f...
Definition ExecutionEngine.h:368
std::string getMangledName(const GlobalValue *GV)
getMangledName - Get mangled name.
std::string ErrMsg
Definition ExecutionEngine.h:156
void DisableLazyCompilation(bool Disabled=true)
DisableLazyCompilation - When lazy compilation is off (the default), the JIT will eagerly compile eve...
Definition ExecutionEngine.h:459
virtual void * getPointerToFunction(Function *F)=0
getPointerToFunction - The different EE's represent function bodies in different ways.
virtual uint64_t getFunctionAddress(const std::string &Name)
getFunctionAddress - Return the address of the specified function.
Definition ExecutionEngine.h:385
sys::Mutex lock
lock - This lock protects the ExecutionEngine and MCJIT classes.
Definition ExecutionEngine.h:161
virtual void addModule(std::unique_ptr< Module > M)
Add a Module to the list of modules that we can JIT from.
Definition ExecutionEngine.h:170
virtual void generateCodeForModule(Module *M)
generateCodeForModule - Run code generation for the specified module and load it into memory.
Definition ExecutionEngine.h:266
FunctionCreator LazyFunctionCreator
LazyFunctionCreator - If an unknown function is needed, this function pointer is invoked to create it...
Definition ExecutionEngine.h:151
bool hasError() const
Returns true if an error has been recorded.
Definition ExecutionEngine.h:281
SmallVector< std::unique_ptr< Module >, 1 > Modules
The list of Modules that we are JIT'ing from.
Definition ExecutionEngine.h:134
virtual void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress)
mapSectionAddress - map a section to its target address space value.
Definition ExecutionEngine.h:245
ExecutionEngine(DataLayout DL)
Definition ExecutionEngine.h:505
void InstallLazyFunctionCreator(FunctionCreator C)
InstallLazyFunctionCreator - If an unknown function is needed, the specified function pointer is invo...
Definition ExecutionEngine.h:500
void * getPointerToGlobal(const GlobalValue *GV)
getPointerToGlobal - This returns the address of the specified global value.
virtual uint64_t getGlobalValueAddress(const std::string &Name)
getGlobalValueAddress - Return the address of the specified global value.
Definition ExecutionEngine.h:377
virtual void * getOrEmitGlobalVariable(const GlobalVariable *GV)
getOrEmitGlobalVariable - Return the address of the specified global variable, possibly emitting it t...
Definition ExecutionEngine.h:411
virtual TargetMachine * getTargetMachine()
Return the target machine (if available).
Definition ExecutionEngine.h:444
virtual void finalizeObject()
finalizeObject - ensure the module is fully processed and is usable.
Definition ExecutionEngine.h:278
friend class EngineBuilder
Definition ExecutionEngine.h:129
virtual void UnregisterJITEventListener(JITEventListener *)
Definition ExecutionEngine.h:420
virtual void setObjectCache(ObjectCache *)
Sets the pre-compiled object cache.
Definition ExecutionEngine.h:424
virtual GenericValue runFunction(Function *F, ArrayRef< GenericValue > ArgValues)=0
runFunction - Execute the specified function with the specified arguments, and return the result.
bool isGVCompilationDisabled() const
Definition ExecutionEngine.h:472
virtual char * getMemoryForGV(const GlobalVariable *GV)
getMemoryforGV - Allocate memory for a global variable.
virtual void * getPointerToNamedFunction(StringRef Name, bool AbortOnFailure=true)=0
getPointerToNamedFunction - This method returns the address of the specified function by using the dl...
void DisableSymbolSearching(bool Disabled=true)
DisableSymbolSearching - If called, the JIT will not try to lookup unknown symbols with dlsym.
Definition ExecutionEngine.h:479
bool isSymbolSearchingDisabled() const
Definition ExecutionEngine.h:482
virtual void RegisterJITEventListener(JITEventListener *)
Registers a listener to be called back on various events within the JIT.
Definition ExecutionEngine.h:419
JITEventListener - Abstract interface for use by the JIT to notify clients about significant events d...
A Module instance is used to store all the information related to an LLVM module.
This is the base ObjectCache type which can be provided to an ExecutionEngine for the purpose of avoi...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringRef - Represent a constant reference to a string, i.e.
Primary interface to the complete machine description for the target machine.
Triple - Helper class for working with autoconf configuration names.
The instances of the Type class are immutable: once they are created, they are never changed.
This class is the base class for all object file types.
struct LLVMOpaqueExecutionEngine * LLVMExecutionEngineRef
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Definition ExecutionEngine.h:521
Kind
Definition ExecutionEngine.h:524
@ JIT
Definition ExecutionEngine.h:525
@ Interpreter
Definition ExecutionEngine.h:526
static const Kind Either
Definition ExecutionEngine.h:528
SmartMutex< false > Mutex
Mutex - A standard, always enforced mutex.
This is an optimization pass for GlobalISel generic memory operations.
static bool getConstantValue(SDValue N, uint32_t &Out)
CodeGenOptLevel
Code generation optimization level.
std::function< void *(const std::string &)> FunctionCreator
Definition ExecutionEngine.h:95
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
@ Disabled
Don't do any conversion of .debug_str_offsets tables.
Implement std::hash so that hash_code can be used in STL containers.