Go to the documentation of this file.
27 #define DEBUG_TYPE "jit"
70 return unwrap(GenValRef)->IntVal.getBitWidth();
83 return unwrap(GenVal)->PointerVal;
89 return unwrap(GenVal)->FloatVal;
91 return unwrap(GenVal)->DoubleVal;
109 .setErrorStr(&
Error);
114 *OutError = strdup(
Error.c_str());
124 .setErrorStr(&
Error);
126 *OutInterp =
wrap(Interp);
129 *OutError = strdup(
Error.c_str());
146 *OutError = strdup(
Error.c_str());
151 size_t SizeOfPassedOptions) {
167 if (SizeOfPassedOptions >
sizeof(
options)) {
169 "Refusing to use options struct that is larger than my own; assuming "
170 "LLVM library mismatch.");
188 for (
auto &
F : *
Mod) {
189 auto Attrs =
F.getAttributes();
200 .setTargetOptions(targetOptions);
206 std::unique_ptr<RTDyldMemoryManager>(
unwrap(
options.MCJMM)));
211 *OutError = strdup(
Error.c_str());
220 unwrap(EE)->finalizeObject();
221 unwrap(EE)->runStaticConstructorsDestructors(
false);
225 unwrap(EE)->finalizeObject();
226 unwrap(EE)->runStaticConstructorsDestructors(
true);
230 unsigned ArgC,
const char *
const *ArgV,
231 const char *
const *EnvP) {
232 unwrap(EE)->finalizeObject();
234 std::vector<std::string> ArgVec(ArgV, ArgV + ArgC);
235 return unwrap(EE)->runFunctionAsMain(unwrap<Function>(
F), ArgVec, EnvP);
241 unwrap(EE)->finalizeObject();
243 std::vector<GenericValue> ArgVec;
244 ArgVec.reserve(NumArgs);
245 for (
unsigned I = 0;
I != NumArgs; ++
I)
249 *Result =
unwrap(EE)->runFunction(unwrap<Function>(
F), ArgVec);
293 unwrap(EE)->addGlobalMapping(unwrap<GlobalValue>(Global),
Addr);
297 unwrap(EE)->finalizeObject();
299 return unwrap(EE)->getPointerToGlobal(unwrap<GlobalValue>(Global));
303 return unwrap(EE)->getGlobalValueAddress(
Name);
312 assert(OutError &&
"OutError must be non-null");
313 auto *ExecEngine =
unwrap(EE);
314 if (ExecEngine->hasError()) {
315 *OutError = strdup(ExecEngine->getErrorMessage().c_str());
316 ExecEngine->clearErrorMessage();
326 struct SimpleBindingMMFunctions {
335 SimpleBindingMemoryManager(
const SimpleBindingMMFunctions& Functions,
337 ~SimpleBindingMemoryManager()
override;
339 uint8_t *allocateCodeSection(uintptr_t Size,
unsigned Alignment,
343 uint8_t *allocateDataSection(uintptr_t Size,
unsigned Alignment,
345 bool isReadOnly)
override;
347 bool finalizeMemory(std::string *ErrMsg)
override;
350 SimpleBindingMMFunctions Functions;
354 SimpleBindingMemoryManager::SimpleBindingMemoryManager(
355 const SimpleBindingMMFunctions& Functions,
357 : Functions(Functions), Opaque(Opaque) {
358 assert(Functions.AllocateCodeSection &&
359 "No AllocateCodeSection function provided!");
360 assert(Functions.AllocateDataSection &&
361 "No AllocateDataSection function provided!");
362 assert(Functions.FinalizeMemory &&
363 "No FinalizeMemory function provided!");
364 assert(Functions.Destroy &&
365 "No Destroy function provided!");
368 SimpleBindingMemoryManager::~SimpleBindingMemoryManager() {
369 Functions.Destroy(Opaque);
372 uint8_t *SimpleBindingMemoryManager::allocateCodeSection(
373 uintptr_t
Size,
unsigned Alignment,
unsigned SectionID,
375 return Functions.AllocateCodeSection(Opaque,
Size, Alignment, SectionID,
379 uint8_t *SimpleBindingMemoryManager::allocateDataSection(
380 uintptr_t
Size,
unsigned Alignment,
unsigned SectionID,
382 return Functions.AllocateDataSection(Opaque,
Size, Alignment, SectionID,
387 bool SimpleBindingMemoryManager::finalizeMemory(std::string *ErrMsg) {
388 char *errMsgCString =
nullptr;
389 bool result = Functions.FinalizeMemory(Opaque, &errMsgCString);
391 "Did not expect an error message if FinalizeMemory succeeded");
394 *ErrMsg = errMsgCString;
409 if (!AllocateCodeSection || !AllocateDataSection || !FinalizeMemory ||
414 functions.AllocateCodeSection = AllocateCodeSection;
415 functions.AllocateDataSection = AllocateDataSection;
416 functions.FinalizeMemory = FinalizeMemory;
418 return wrap(
new SimpleBindingMemoryManager(
functions, Opaque));
428 #if !LLVM_USE_INTEL_JITEVENTS
435 #if !LLVM_USE_OPROFILE
void LLVMInitializeMCJITCompilerOptions(LLVMMCJITCompilerOptions *PassedOptions, size_t SizeOfPassedOptions)
amdgpu propagate attributes Late propagate attributes from kernels to functions
@ FloatTyID
32-bit floating point type
static LLVMTargetMachineRef wrap(const TargetMachine *P)
LLVMBool LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name, LLVMValueRef *OutFn)
@ DoubleTyID
64-bit floating point type
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
void LLVMDisposeGenericValue(LLVMGenericValueRef GenVal)
uint8_t *(* LLVMMemoryManagerAllocateCodeSectionCallback)(void *Opaque, uintptr_t Size, unsigned Alignment, unsigned SectionID, const char *SectionName)
LLVMGenericValueRef LLVMCreateGenericValueOfFloat(LLVMTypeRef TyRef, double N)
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
struct LLVMOpaqueExecutionEngine * LLVMExecutionEngineRef
int64_t getSExtValue() const
Get sign extended value.
LLVMBool LLVMCreateJITCompilerForModule(LLVMExecutionEngineRef *OutJIT, LLVMModuleRef M, unsigned OptLevel, char **OutError)
void LLVMRunStaticConstructors(LLVMExecutionEngineRef EE)
Builder class for ExecutionEngines.
double LLVMGenericValueToFloat(LLVMTypeRef TyRef, LLVMGenericValueRef GenVal)
struct LLVMOpaqueMCJITMemoryManager * LLVMMCJITMemoryManagerRef
void * LLVMRecompileAndRelinkFunction(LLVMExecutionEngineRef EE, LLVMValueRef Fn)
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global, void *Addr)
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
struct LLVMOpaqueTargetData * LLVMTargetDataRef
It looks like we only need to define PPCfmarto for these because according to these instructions perform RTO on fma s result
void * LLVMGenericValueToPointer(LLVMGenericValueRef GenVal)
LLVMJITEventListenerRef LLVMCreateOProfileJITEventListener(void)
uint64_t LLVMGetFunctionAddress(LLVMExecutionEngineRef EE, const char *Name)
LLVMGenericValueRef LLVMCreateGenericValueOfPointer(void *P)
LLVMMCJITMemoryManagerRef LLVMCreateSimpleMCJITMemoryManager(void *Opaque, LLVMMemoryManagerAllocateCodeSectionCallback AllocateCodeSection, LLVMMemoryManagerAllocateDataSectionCallback AllocateDataSection, LLVMMemoryManagerFinalizeMemoryCallback FinalizeMemory, LLVMMemoryManagerDestroyCallback Destroy)
Create a simple custom MCJIT memory manager.
int LLVMRunFunctionAsMain(LLVMExecutionEngineRef EE, LLVMValueRef F, unsigned ArgC, const char *const *ArgV, const char *const *EnvP)
Attribute unwrap(LLVMAttributeRef Attr)
uint64_t getZExtValue() const
Get zero extended value.
struct LLVMOpaqueType * LLVMTypeRef
Each value in the LLVM IR has a type, an LLVMTypeRef.
LLVMJITEventListenerRef LLVMCreateIntelJITEventListener(void)
LLVMJITEventListenerRef LLVMCreatePerfJITEventListener(void)
LLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty, unsigned long long N, LLVMBool IsSigned)
LLVMBool(* LLVMMemoryManagerFinalizeMemoryCallback)(void *Opaque, char **ErrMsg)
void LLVMDisposeMCJITMemoryManager(LLVMMCJITMemoryManagerRef MM)
void LLVMDisposeExecutionEngine(LLVMExecutionEngineRef EE)
LLVMBool LLVMCreateExecutionEngineForModule(LLVMExecutionEngineRef *OutEE, LLVMModuleRef M, char **OutError)
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Primary interface to the complete machine description for the target machine.
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
void * LLVMGetPointerToGlobal(LLVMExecutionEngineRef EE, LLVMValueRef Global)
uint8_t *(* LLVMMemoryManagerAllocateDataSectionCallback)(void *Opaque, uintptr_t Size, unsigned Alignment, unsigned SectionID, const char *SectionName, LLVMBool IsReadOnly)
A Module instance is used to store all the information related to an LLVM module.
unsigned EnableFastISel
EnableFastISel - This flag enables fast-path instruction selection which trades away generated code q...
Class for arbitrary precision integers.
LLVMAttributeRef wrap(Attribute Attr)
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void LLVMAddModule(LLVMExecutionEngineRef EE, LLVMModuleRef M)
void LLVMRunStaticDestructors(LLVMExecutionEngineRef EE)
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter...
@ LLVMCodeModelJITDefault
unsigned long long LLVMGenericValueToInt(LLVMGenericValueRef GenValRef, LLVMBool IsSigned)
Lightweight error class with error context and mandatory checking.
The object format emitted by the WebAssembly backed is documented see the home and packaging for producing WebAssembly applications that can run in browsers and other environments wasi sdk provides a more minimal C C SDK based on llvm and a libc based on for producing WebAssemmbly applictions that use the WASI ABI Rust provides WebAssembly support integrated into Cargo There are two main options
LLVMBool LLVMCreateInterpreterForModule(LLVMExecutionEngineRef *OutInterp, LLVMModuleRef M, char **OutError)
static char getTypeID(Type *Ty)
LLVMBool LLVMExecutionEngineGetErrMsg(LLVMExecutionEngineRef EE, char **OutError)
Returns true on error, false on success.
LLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F, unsigned NumArgs, LLVMGenericValueRef *Args)
LLVMBool LLVMCreateMCJITCompilerForModule(LLVMExecutionEngineRef *OutJIT, LLVMModuleRef M, LLVMMCJITCompilerOptions *PassedOptions, size_t SizeOfPassedOptions, char **OutError)
Create an MCJIT execution engine for a module, with the given options.
unsigned LLVMGenericValueIntWidth(LLVMGenericValueRef GenValRef)
LLVMTargetMachineRef LLVMGetExecutionEngineTargetMachine(LLVMExecutionEngineRef EE)
void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F)
uint64_t LLVMGetGlobalValueAddress(LLVMExecutionEngineRef EE, const char *Name)
struct LLVMOpaqueValue * LLVMValueRef
Represents an individual value in LLVM IR.
void(* LLVMMemoryManagerDestroyCallback)(void *Opaque)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
LLVMBool LLVMRemoveModule(LLVMExecutionEngineRef EE, LLVMModuleRef M, LLVMModuleRef *OutMod, char **OutError)
struct LLVMOpaqueJITEventListener * LLVMJITEventListenerRef
LLVM Value Representation.
struct LLVMOpaqueTargetMachine * LLVMTargetMachineRef
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
struct LLVMOpaqueGenericValue * LLVMGenericValueRef