44 #define DEBUG_TYPE "jit"
46 STATISTIC(NumInitBytes,
"Number of bytes of global vars initialized");
47 STATISTIC(NumGlobals ,
"Number of global vars initialized");
50 std::unique_ptr<Module> M, std::string *ErrorStr,
51 std::shared_ptr<MCJITMemoryManager> MemMgr,
53 std::shared_ptr<JITSymbolResolver> Resolver,
54 std::unique_ptr<TargetMachine>
TM) =
nullptr;
57 std::string *ErrorStr, std::shared_ptr<MCJITMemoryManager> MemMgr,
58 std::shared_ptr<JITSymbolResolver> Resolver,
59 std::unique_ptr<TargetMachine>
TM) =
nullptr;
61 ExecutionEngine *(*ExecutionEngine::InterpCtor)(std::unique_ptr<Module> M,
62 std::string *ErrorStr) =
nullptr;
64 void JITEventListener::anchor() {}
66 void ObjectCache::anchor() {}
68 void ExecutionEngine::Init(std::unique_ptr<Module> M) {
69 CompilingLazily =
false;
70 GVCompilationDisabled =
false;
71 SymbolSearchingDisabled =
false;
78 VerifyModules =
false;
81 assert(M &&
"Module is null?");
82 Modules.push_back(std::move(M));
86 : DL(M->getDataLayout()), LazyFunctionCreator(nullptr) {
91 : DL(std::move(DL)), LazyFunctionCreator(nullptr) {
102 class GVMemoryBlock final :
public CallbackVH {
112 void *RawMemory = ::operator
new(
114 new(RawMemory) GVMemoryBlock(GV);
115 return static_cast<char*
>(RawMemory) +
sizeof(GVMemoryBlock);
118 void deleted()
override {
122 this->~GVMemoryBlock();
123 ::operator
delete(
this);
133 llvm_unreachable(
"ExecutionEngine subclass doesn't implement addObjectFile.");
138 llvm_unreachable(
"ExecutionEngine subclass doesn't implement addObjectFile.");
159 for (
unsigned i = 0, e =
Modules.size();
i != e; ++
i) {
168 for (
unsigned i = 0, e =
Modules.size();
i != e; ++
i) {
182 if (I == GlobalAddressMap.
end())
185 GlobalAddressReverseMap.erase(I->second);
187 GlobalAddressMap.
erase(I);
205 return FullName.
str();
216 assert(!Name.
empty() &&
"Empty GlobalMapping symbol name!");
218 DEBUG(
dbgs() <<
"JIT: Map \'" << Name <<
"\' to [" << Addr <<
"]\n";);
220 assert((!CurVal || !Addr) &&
"GlobalMapping already established!");
227 "GlobalMapping already established!");
262 uint64_t &CurVal = Map[
Name];
263 uint64_t OldVal = CurVal;
273 "GlobalMapping already established!");
311 uint64_t Addr =
I->second;
317 std::map<uint64_t, std::string>::iterator
I =
322 for (
unsigned i = 0, e =
Modules.size();
i != e; ++
i)
331 std::unique_ptr<char[]> Array;
332 std::vector<std::unique_ptr<char[]>> Values;
337 const std::vector<std::string> &InputArgv);
341 const std::vector<std::string> &InputArgv) {
343 Values.reserve(InputArgv.size());
345 Array = make_unique<char[]>((InputArgv.size()+1)*PtrSize);
347 DEBUG(
dbgs() <<
"JIT: ARGV = " << (
void*)Array.get() <<
"\n");
350 for (
unsigned i = 0;
i != InputArgv.size(); ++
i) {
351 unsigned Size = InputArgv[
i].size()+1;
352 auto Dest = make_unique<char[]>(Size);
353 DEBUG(
dbgs() <<
"JIT: ARGV[" <<
i <<
"] = " << (
void*)Dest.get() <<
"\n");
355 std::copy(InputArgv[
i].
begin(), InputArgv[
i].
end(), Dest.get());
361 Values.push_back(std::move(Dest));
373 StringRef Name(isDtors ?
"llvm.global_dtors" :
"llvm.global_ctors");
398 FP = CE->getOperand(0);
401 if (
Function *
F = dyn_cast<Function>(FP))
412 for (std::unique_ptr<Module> &M :
Modules)
420 for (
unsigned i = 0;
i < PtrSize; ++
i)
421 if (*(
i + (uint8_t*)Loc))
428 const std::vector<std::string> &
argv,
429 const char *
const * envp) {
430 std::vector<GenericValue> GVArgs;
455 GVArgs.push_back(GVArgc);
460 "argv[0] was null after CreateArgv");
462 std::vector<std::string> EnvVars;
463 for (
unsigned i = 0; envp[
i]; ++
i)
464 EnvVars.emplace_back(envp[
i]);
477 : M(std::move(M)), WhichEngine(EngineKind::
Either), ErrorStr(nullptr),
478 OptLevel(CodeGenOpt::Default), MemMgr(nullptr), Resolver(nullptr),
483 VerifyModules =
true;
485 VerifyModules =
false;
492 std::unique_ptr<RTDyldMemoryManager> mcjmm) {
493 auto SharedMM = std::shared_ptr<RTDyldMemoryManager>(std::move(mcjmm));
501 MemMgr = std::shared_ptr<MCJITMemoryManager>(std::move(MM));
507 Resolver = std::shared_ptr<JITSymbolResolver>(std::move(SR));
512 std::unique_ptr<TargetMachine> TheTM(TM);
527 *ErrorStr =
"Cannot create an interpreter with a memory manager.";
535 Triple TT(M->getTargetTriple());
537 errs() <<
"WARNING: This target JIT is not designed for the host"
538 <<
" you are running. If bad things happen, please choose"
539 <<
" a different -march switch.\n";
550 std::move(Resolver), std::move(TheTM));
564 *ErrorStr =
"Interpreter has not been linked in.";
570 *ErrorStr =
"JIT has not been linked in.";
577 if (
Function *
F = const_cast<Function*>(dyn_cast<Function>(GV)))
586 const_cast<GlobalVariable *>(dyn_cast<GlobalVariable>(GV)))
598 if (isa<UndefValue>(C)) {
614 unsigned int elemNum = STy->getNumElements();
616 for (
unsigned int i = 0;
i < elemNum; ++
i) {
617 Type *ElemTy = STy->getElementType(
i);
632 Type *ElemTy = VTy->getElementType();
633 unsigned int elemNum = VTy->getNumElements();
635 if (ElemTy->isIntegerTy())
636 for (
unsigned int i = 0;
i < elemNum; ++
i)
638 APInt(ElemTy->getPrimitiveSizeInBits(), 0);
645 if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
647 switch (CE->getOpcode()) {
648 case Instruction::GetElementPtr: {
652 cast<GEPOperator>(CE)->accumulateConstantOffset(DL,
Offset);
658 case Instruction::Trunc: {
664 case Instruction::ZExt: {
670 case Instruction::SExt: {
676 case Instruction::FPTrunc: {
682 case Instruction::FPExt:{
688 case Instruction::UIToFP: {
690 if (CE->getType()->isFloatTy())
692 else if (CE->getType()->isDoubleTy())
694 else if (CE->getType()->isX86_FP80Ty()) {
703 case Instruction::SIToFP: {
705 if (CE->getType()->isFloatTy())
707 else if (CE->getType()->isDoubleTy())
709 else if (CE->getType()->isX86_FP80Ty()) {
718 case Instruction::FPToUI:
719 case Instruction::FPToSI: {
731 CE->getOpcode()==Instruction::FPToSI,
737 case Instruction::PtrToInt: {
740 assert(PtrWidth <= 64 &&
"Bad pointer width");
746 case Instruction::IntToPtr: {
754 case Instruction::BitCast: {
756 Type* DestTy = CE->getType();
781 case Instruction::FAdd:
782 case Instruction::Sub:
783 case Instruction::FSub:
784 case Instruction::Mul:
785 case Instruction::FMul:
786 case Instruction::UDiv:
787 case Instruction::SDiv:
788 case Instruction::URem:
789 case Instruction::SRem:
796 switch (CE->getOperand(0)->getType()->getTypeID()) {
799 switch (CE->getOpcode()) {
802 case Instruction::Sub: GV.IntVal = LHS.
IntVal - RHS.
IntVal;
break;
803 case Instruction::Mul: GV.IntVal = LHS.
IntVal * RHS.
IntVal;
break;
814 switch (CE->getOpcode()) {
816 case Instruction::FAdd:
818 case Instruction::FSub:
820 case Instruction::FMul:
822 case Instruction::FDiv:
824 case Instruction::FRem:
829 switch (CE->getOpcode()) {
831 case Instruction::FAdd:
833 case Instruction::FSub:
835 case Instruction::FMul:
837 case Instruction::FDiv:
839 case Instruction::FRem:
846 const fltSemantics &Sem = CE->getOperand(0)->getType()->getFltSemantics();
848 switch (CE->getOpcode()) {
850 case Instruction::FAdd:
854 case Instruction::FSub:
859 case Instruction::FMul:
864 case Instruction::FDiv:
869 case Instruction::FRem:
885 OS <<
"ConstantExpr not handled: " << *CE;
893 Result.
FloatVal = cast<ConstantFP>(
C)->getValueAPF().convertToFloat();
896 Result.
DoubleVal = cast<ConstantFP>(
C)->getValueAPF().convertToDouble();
901 Result.
IntVal = cast <ConstantFP>(
C)->getValueAPF().bitcastToAPInt();
904 Result.
IntVal = cast<ConstantInt>(
C)->getValue();
907 if (isa<ConstantPointerNull>(C))
909 else if (
const Function *
F = dyn_cast<Function>(C))
926 }
else if (CV || CAZ) {
945 for (
unsigned i = 0;
i < elemNum; ++
i)
946 if (!isa<UndefValue>(CV->getOperand(
i)))
948 CV->getOperand(
i))->getValueAPF().convertToFloat();
952 for (
unsigned i = 0;
i < elemNum; ++
i)
967 for (
unsigned i = 0;
i < elemNum; ++
i)
968 if (!isa<UndefValue>(CV->getOperand(
i)))
970 CV->getOperand(
i))->getValueAPF().convertToDouble();
974 for (
unsigned i = 0;
i < elemNum; ++
i)
989 for (
unsigned i = 0;
i < elemNum; ++
i)
990 if (!isa<UndefValue>(CV->getOperand(
i)))
992 CV->getOperand(
i))->getValue();
995 APInt(CV->getOperand(
i)->getType()->getPrimitiveSizeInBits(), 0);
1000 for (
unsigned i = 0;
i < elemNum; ++
i)
1014 OS <<
"ERROR: Constant unimplemented for type: " << *C->
getType();
1024 unsigned StoreBytes) {
1026 const uint8_t *Src = (
const uint8_t *)IntVal.
getRawData();
1031 memcpy(Dst, Src, StoreBytes);
1036 while (StoreBytes >
sizeof(uint64_t)) {
1037 StoreBytes -=
sizeof(uint64_t);
1039 memcpy(Dst + StoreBytes, Src,
sizeof(uint64_t));
1040 Src +=
sizeof(uint64_t);
1043 memcpy(Dst, Src +
sizeof(uint64_t) - StoreBytes, StoreBytes);
1053 dbgs() <<
"Cannot store value of type " << *Ty <<
"!\n";
1076 if (cast<VectorType>(Ty)->getElementType()->isDoubleTy())
1078 if (cast<VectorType>(Ty)->getElementType()->isFloatTy())
1080 if (cast<VectorType>(Ty)->getElementType()->isIntegerTy()) {
1081 unsigned numOfBytes =(Val.
AggregateVal[
i].IntVal.getBitWidth()+7)/8;
1083 (uint8_t*)Ptr + numOfBytes*
i, numOfBytes);
1091 std::reverse((uint8_t*)Ptr, StoreBytes + (uint8_t*)Ptr);
1098 uint8_t *Dst =
reinterpret_cast<uint8_t *
>(
1099 const_cast<uint64_t *
>(IntVal.
getRawData()));
1104 memcpy(Dst, Src, LoadBytes);
1110 while (LoadBytes >
sizeof(uint64_t)) {
1111 LoadBytes -=
sizeof(uint64_t);
1113 memcpy(Dst, Src + LoadBytes,
sizeof(uint64_t));
1114 Dst +=
sizeof(uint64_t);
1117 memcpy(Dst +
sizeof(uint64_t) - LoadBytes, Src, LoadBytes);
1152 auto *VT = cast<VectorType>(Ty);
1153 Type *ElemT = VT->getElementType();
1154 const unsigned numElems = VT->getNumElements();
1155 if (ElemT->isFloatTy()) {
1157 for (
unsigned i = 0;
i < numElems; ++
i)
1160 if (ElemT->isDoubleTy()) {
1162 for (
unsigned i = 0;
i < numElems; ++
i)
1165 if (ElemT->isIntegerTy()) {
1167 const unsigned elemBitWidth = cast<IntegerType>(ElemT)->
getBitWidth();
1170 for (
unsigned i = 0;
i < numElems; ++
i)
1172 (uint8_t*)Ptr+((elemBitWidth+7)/8)*
i, (elemBitWidth+7)/8);
1179 OS <<
"Cannot load value of type " << *Ty <<
"!";
1185 DEBUG(
dbgs() <<
"JIT: Initializing " << Addr <<
" ");
1187 if (isa<UndefValue>(Init))
1191 unsigned ElementSize =
1193 for (
unsigned i = 0, e =
CP->getNumOperands();
i != e; ++
i)
1198 if (isa<ConstantAggregateZero>(Init)) {
1203 if (
const ConstantArray *CPA = dyn_cast<ConstantArray>(Init)) {
1204 unsigned ElementSize =
1206 for (
unsigned i = 0, e = CPA->getNumOperands();
i != e; ++
i)
1211 if (
const ConstantStruct *CPS = dyn_cast<ConstantStruct>(Init)) {
1214 for (
unsigned i = 0, e = CPS->getNumOperands();
i != e; ++
i)
1220 dyn_cast<ConstantDataSequential>(Init)) {
1222 StringRef Data = CDS->getRawDataValues();
1223 memcpy(Addr, Data.
data(), Data.
size());
1244 std::map<std::pair<std::string, Type*>,
1248 for (
unsigned m = 0, e =
Modules.size(); m != e; ++m) {
1250 for (
const auto &GV : M.
globals()) {
1277 std::vector<const GlobalValue*> NonCanonicalGlobals;
1278 for (
unsigned m = 0, e =
Modules.size(); m != e; ++m) {
1280 for (
const auto &GV : M.
globals()) {
1282 if (!LinkedGlobalsMap.empty()) {
1286 if (GVEntry != &GV) {
1287 NonCanonicalGlobals.push_back(&GV);
1310 if (!NonCanonicalGlobals.empty()) {
1311 for (
unsigned i = 0, e = NonCanonicalGlobals.size();
i != e; ++
i) {
1316 assert(Ptr &&
"Canonical global wasn't codegen'd!");
1323 for (
const auto &GV : M.
globals()) {
1325 if (!LinkedGlobalsMap.empty()) {
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type (if unknown returns 0).
A vector constant whose element type is a simple 1/2/4/8-byte integer or float/double, and whose elements are just simple data values (i.e.
A parsed version of the target data layout string in and methods for querying it. ...
const_iterator end(StringRef path)
Get end iterator over path.
std::vector< GenericValue > AggregateVal
static void * SearchForAddressOfSymbol(const char *symbolName)
This function will search through all previously loaded dynamic libraries for the symbol symbolName...
double signedRoundToDouble() const
Converts this signed APInt to a double value.
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
opStatus convertFromAPInt(const APInt &Input, bool IsSigned, roundingMode RM)
virtual void * getOrEmitGlobalVariable(const GlobalVariable *GV)
getOrEmitGlobalVariable - Return the address of the specified global variable, possibly emitting it t...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
std::string getMangledName(const GlobalValue *GV)
getMangledName - Get mangled name.
void clearAllGlobalMappings()
clearAllGlobalMappings - Clear all global mappings and start over again, for use in dynamic compilati...
uint64_t getZExtValue() const
Get zero extended value.
STATISTIC(NumFunctions,"Total number of functions")
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
int runFunctionAsMain(Function *Fn, const std::vector< std::string > &argv, const char *const *envp)
runFunctionAsMain - This is a helper function which wraps runFunction to handle the common task of st...
A Module instance is used to store all the information related to an LLVM module. ...
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
virtual bool removeModule(Module *M)
removeModule - Removes a Module from the list of modules, but does not free the module's memory...
2: 32-bit floating point type
void * getPointerToGlobalIfAvailable(StringRef S)
getPointerToGlobalIfAvailable - This returns the address of the specified global value if it is has a...
sys::Mutex lock
lock - This lock protects the ExecutionEngine and MCJIT classes.
unsigned getNumOperands() const
uint64_t updateGlobalMapping(const GlobalValue *GV, void *Addr)
updateGlobalMapping - Replace an existing mapping for GV with a new address.
Type * getValueType() const
virtual GenericValue runFunction(Function *F, ArrayRef< GenericValue > ArgValues)=0
runFunction - Execute the specified function with the specified arguments, and return the result...
bool hasAppendingLinkage() const
iterator find(StringRef Key)
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
A raw_ostream that writes to an SmallVector or SmallString.
void EmitGlobalVariable(const GlobalVariable *GV)
const_iterator begin(StringRef path)
Get begin iterator over path.
virtual void * getPointerToFunctionOrStub(Function *F)
getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the f...
4: 80-bit floating point type (X87)
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
double roundToDouble(bool isSigned) const
Converts this APInt to a double value.
bool isDefault() const
Test if the DataLayout was constructed from an empty string.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
EngineBuilder & setSymbolResolver(std::unique_ptr< JITSymbolResolver > SR)
StringRef getName() const
Return a constant reference to the value's name.
const DataLayout & getDataLayout() const
iterator_range< global_object_iterator > global_objects()
opStatus divide(const APFloat &RHS, roundingMode RM)
APInt urem(const APInt &RHS) const
Unsigned remainder operation.
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
static const fltSemantics & x87DoubleExtended()
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
virtual void runStaticConstructorsDestructors(bool isDtors)
runStaticConstructorsDestructors - This method is used to execute all of the static constructors or d...
cl::opt< llvm::CodeModel::Model > CMModel("code-model", cl::desc("Choose code model"), cl::init(CodeModel::Default), cl::values(clEnumValN(CodeModel::Default,"default","Target default code model"), clEnumValN(CodeModel::Small,"small","Small code model"), clEnumValN(CodeModel::Kernel,"kernel","Kernel code model"), clEnumValN(CodeModel::Medium,"medium","Medium code model"), clEnumValN(CodeModel::Large,"large","Large code model")))
static APInt doubleToBits(double V)
Converts a double to APInt bits.
void * getPointerToGlobal(const GlobalValue *GV)
getPointerToGlobal - This returns the address of the specified global value.
void InitializeMemory(const Constant *Init, void *Addr)
Class to represent struct types.
EngineBuilder()
Default constructor for EngineBuilder.
double getElementAsDouble(unsigned i) const
If this is an sequential container of doubles, return the specified element as a double.
APInt bitcastToAPInt() const
static bool LoadLibraryPermanently(const char *Filename, std::string *ErrMsg=nullptr)
This function permanently loads the dynamic library at the given path.
virtual void addModule(std::unique_ptr< Module > M)
Add a Module to the list of modules that we can JIT from.
All zero aggregate value.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
static const bool IsLittleEndianHost
Class to represent function types.
A constant value that is initialized with an expression using other constant values.
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
static void LoadIntFromMemory(APInt &IntVal, uint8_t *Src, unsigned LoadBytes)
LoadIntFromMemory - Loads the integer stored in the LoadBytes bytes starting from Src into IntVal...
virtual char * getMemoryForGV(const GlobalVariable *GV)
getMemoryforGV - Allocate memory for a global variable.
void LoadValueFromMemory(GenericValue &Result, GenericValue *Ptr, Type *Ty)
FIXME: document.
static bool isTargetNullPtr(ExecutionEngine *EE, void *Loc)
isTargetNullPtr - Return whether the target pointer stored at Loc is null.
Function Alias Analysis false
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value. ...
TypeID getTypeID() const
Return the type id for the type.
opStatus subtract(const APFloat &RHS, roundingMode RM)
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
GenericValue getConstantValue(const Constant *C)
Converts a Constant* into a GenericValue, including handling of ConstantExpr values.
void emitGlobals()
EmitGlobals - Emit all of the global variables to memory, storing their addresses into GlobalAddress...
uint64_t RemoveMapping(StringRef Name)
Erase an entry from the mapping table.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
void StoreValueToMemory(const GenericValue &Val, GenericValue *Ptr, Type *Ty)
StoreValueToMemory - Stores the data in Val of type Ty at address Ptr.
Type * getElementType() const
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
uint64_t getElementOffset(unsigned Idx) const
11: Arbitrary bit width integers
bool hasJIT() const
hasJIT - Check if this targets supports the just-in-time compilation.
Instances of this class acquire a given Mutex Lock when constructed and hold that lock until destruct...
Type * getParamType(unsigned i) const
Parameter type accessors.
static ExecutionEngine *(* OrcMCJITReplacementCtor)(std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MM, std::shared_ptr< JITSymbolResolver > SR, std::unique_ptr< TargetMachine > TM)
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
APInt trunc(unsigned width) const
Truncate to new width.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
EngineBuilder & setMemoryManager(std::unique_ptr< MCJITMemoryManager > MM)
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
APInt Xor(const APInt &LHS, const APInt &RHS)
Bitwise XOR function for APInt.
virtual void addObjectFile(std::unique_ptr< object::ObjectFile > O)
addObjectFile - Add an ObjectFile to the execution engine.
static ExecutionEngine *(* MCJITCtor)(std::unique_ptr< Module > M, std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MM, std::shared_ptr< JITSymbolResolver > SR, std::unique_ptr< TargetMachine > TM)
APInt sext(unsigned width) const
Sign extend to a new width.
unsigned getBitWidth() const
Return the number of bits in the APInt.
opStatus multiply(const APFloat &RHS, roundingMode RM)
uint64_t getNumElements() const
6: 128-bit floating point type (two 64-bits, PowerPC)
APInt sdiv(const APInt &RHS) const
Signed division function for APInt.
Value * getOperand(unsigned i) const
Constant Vector Declarations.
static void StoreIntToMemory(const APInt &IntVal, uint8_t *Dst, unsigned StoreBytes)
StoreIntToMemory - Fills the StoreBytes bytes of memory starting from Dst with the integer held in In...
GlobalAddressMapTy & getGlobalAddressMap()
opStatus convertToInteger(integerPart *Input, unsigned int Width, bool IsSigned, roundingMode RM, bool *IsExact) const
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
uint64_t getElementAsInteger(unsigned i) const
If this is a sequential container of integers (of any size), return the specified element in the low ...
bool isPointerTy() const
True if this is an instance of PointerType.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
void clearGlobalMappingsFromModule(Module *M)
clearGlobalMappingsFromModule - Clear all global mappings that came from a particular module...
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
static ExecutionEngine *(* InterpCtor)(std::unique_ptr< Module > M, std::string *ErrorStr)
virtual Function * FindFunctionNamed(StringRef FnName)
FindFunctionNamed - Search all of the active modules to find the function that defines FnName...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned getPreferredAlignment(const GlobalVariable *GV) const
Returns the preferred alignment of the specified global.
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter...
Triple - Helper class for working with autoconf configuration names.
std::map< uint64_t, std::string > & getGlobalAddressReverseMap()
APInt srem(const APInt &RHS) const
Function for signed remainder operation.
void * GVTOP(const GenericValue &GV)
void dump() const
Support for debugging, callable in GDB: V->dump()
bool hasExternalWeakLinkage() const
bool hasExternalLinkage() const
ExecutionEngine(DataLayout DL)
16: SIMD 'packed' format, or other vector type
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
GlobalVariable * getNamedGlobal(StringRef Name)
Return the global variable in the module with the specified name, of arbitrary type.
StringRef str()
Return a StringRef for the vector contents.
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
void setVerifyModules(bool Verify)
Enable/Disable IR module verification.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Class to represent vector types.
virtual void addArchive(object::OwningBinary< object::Archive > A)
addArchive - Add an Archive to the execution engine.
GenericValue PTOGV(void *P)
Class for arbitrary precision integers.
ConstantArray - Constant Array Declarations.
virtual void * getPointerToFunction(Function *F)=0
getPointerToFunction - The different EE's represent function bodies in different ways.
StringRef str() const
Explicit conversion to StringRef.
bool isIntegerTy() const
True if this is an instance of IntegerType.
opStatus mod(const APFloat &RHS)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
SmallVector< std::unique_ptr< Module >, 1 > Modules
The list of Modules that we are JIT'ing from.
double bitsToDouble() const
Converts APInt bits to a double.
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
APInt RoundFloatToAPInt(float Float, unsigned width)
Converts a float value into a APInt.
virtual ~ExecutionEngine()
opStatus add(const APFloat &RHS, roundingMode RM)
ExecutionEngine * create()
PointerType * getType() const
Global values are always pointers.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
bool isX86_FP80Ty() const
Return true if this is x86 long double.
void addGlobalMapping(const GlobalValue *GV, void *Addr)
addGlobalMapping - Tell the execution engine that the specified global is at the specified location...
bool isAggregateType() const
Return true if the type is an aggregate type.
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
APInt udiv(const APInt &RHS) const
Unsigned division operation.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
float getElementAsFloat(unsigned i) const
If this is an sequential container of floats, return the specified element as a float.
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
unsigned getNumElements() const
Return the number of elements in the array or vector.
uint64_t getAddressToGlobalIfAvailable(StringRef S)
getAddressToGlobalIfAvailable - This returns the address of the specified global symbol.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
const GlobalValue * getGlobalValueAtAddress(void *Addr)
getGlobalValueAtAddress - Return the LLVM global value object that starts at the specified address...
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
Builder class for ExecutionEngines.
EngineBuilder & setMCJITMemoryManager(std::unique_ptr< RTDyldMemoryManager > mcjmm)
setMCJITMemoryManager - Sets the MCJIT memory manager to use.
bool hasLocalLinkage() const
Type * getElementType() const
Return the element type of the array/vector.
3: 64-bit floating point type
Type * getReturnType() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Module * getParent()
Get the module that this global value is contained inside of...
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
const Target & getTarget() const
Primary interface to the complete machine description for the target machine.
iterator_range< global_iterator > globals()
Value handle with callbacks on RAUW and destruction.
StringRef - Represent a constant reference to a string, i.e.
APInt zext(unsigned width) const
Zero extend to a new width.
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size FIXME: The defaults need to be removed once all of the backends/clients are updat...
APInt RoundDoubleToAPInt(double Double, unsigned width)
Converts the given double value into a APInt.
static APInt floatToBits(float V)
Converts a float to APInt bits.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
virtual GlobalVariable * FindGlobalVariableNamed(StringRef Name, bool AllowInternal=false)
FindGlobalVariableNamed - Search all of the active modules to find the global variable that defines N...
float bitsToFloat() const
Converts APInt bits to a double.
bool isVoidTy() const
Return true if this is 'void'.
5: 128-bit floating point type (112-bit mantissa)