43 #define DEBUG_TYPE "jit"
45 STATISTIC(NumInitBytes,
"Number of bytes of global vars initialized");
46 STATISTIC(NumGlobals ,
"Number of global vars initialized");
49 std::unique_ptr<Module> M, std::string *ErrorStr,
50 std::shared_ptr<MCJITMemoryManager> MemMgr,
51 std::shared_ptr<RuntimeDyld::SymbolResolver> Resolver,
52 std::unique_ptr<TargetMachine>
TM) =
nullptr;
55 std::string *ErrorStr, std::shared_ptr<MCJITMemoryManager> MemMgr,
56 std::shared_ptr<RuntimeDyld::SymbolResolver> Resolver,
57 std::unique_ptr<TargetMachine>
TM) =
nullptr;
59 ExecutionEngine *(*ExecutionEngine::InterpCtor)(std::unique_ptr<Module> M,
60 std::string *ErrorStr) =
nullptr;
62 void JITEventListener::anchor() {}
65 : LazyFunctionCreator(nullptr) {
66 CompilingLazily =
false;
67 GVCompilationDisabled =
false;
68 SymbolSearchingDisabled =
false;
75 VerifyModules =
false;
78 assert(M &&
"Module is null?");
79 Modules.push_back(std::move(M));
99 void *RawMemory = ::operator
new(
103 new(RawMemory) GVMemoryBlock(GV);
104 return static_cast<char*
>(RawMemory) +
sizeof(GVMemoryBlock);
107 void deleted()
override {
111 this->~GVMemoryBlock();
112 ::operator
delete(
this);
122 llvm_unreachable(
"ExecutionEngine subclass doesn't implement addObjectFile.");
127 llvm_unreachable(
"ExecutionEngine subclass doesn't implement addObjectFile.");
148 for (
unsigned i = 0, e =
Modules.size(); i != e; ++i) {
157 for (
unsigned i = 0, e =
Modules.size(); i != e; ++i) {
171 if (I == GlobalAddressMap.
end())
174 GlobalAddressReverseMap.erase(I->second);
176 GlobalAddressMap.
erase(I);
183 assert(GV->
hasName() &&
"Global must have name.");
194 return FullName.
str();
205 assert(!Name.
empty() &&
"Empty GlobalMapping symbol name!");
207 DEBUG(
dbgs() <<
"JIT: Map \'" << Name <<
"\' to [" << Addr <<
"]\n";);
209 assert((!CurVal || !Addr) &&
"GlobalMapping already established!");
215 assert((!V.empty() || !Name.
empty()) &&
216 "GlobalMapping already established!");
254 uint64_t &CurVal = Map[
Name];
255 uint64_t OldVal = CurVal;
264 assert((!V.empty() || !Name.
empty()) &&
265 "GlobalMapping already established!");
303 uint64_t Addr =
I->second;
309 std::map<uint64_t, std::string>::iterator
I =
314 for (
unsigned i = 0, e =
Modules.size(); i != e; ++i)
323 std::unique_ptr<char[]> Array;
324 std::vector<std::unique_ptr<char[]>> Values;
329 const std::vector<std::string> &InputArgv);
333 const std::vector<std::string> &InputArgv) {
335 Values.reserve(InputArgv.size());
337 Array = make_unique<char[]>((InputArgv.size()+1)*PtrSize);
339 DEBUG(
dbgs() <<
"JIT: ARGV = " << (
void*)Array.get() <<
"\n");
342 for (
unsigned i = 0; i != InputArgv.size(); ++i) {
343 unsigned Size = InputArgv[i].size()+1;
344 auto Dest = make_unique<char[]>(Size);
345 DEBUG(
dbgs() <<
"JIT: ARGV[" << i <<
"] = " << (
void*)Dest.get() <<
"\n");
347 std::copy(InputArgv[i].
begin(), InputArgv[i].
end(), Dest.get());
353 Values.push_back(std::move(Dest));
365 const char *
Name = isDtors ?
"llvm.global_dtors" :
"llvm.global_ctors";
379 for (
unsigned i = 0, e = InitList->
getNumOperands(); i != e; ++i) {
390 FP = CE->getOperand(0);
393 if (
Function *
F = dyn_cast<Function>(FP))
404 for (std::unique_ptr<Module> &M :
Modules)
412 for (
unsigned i = 0; i < PtrSize; ++i)
413 if (*(i + (uint8_t*)Loc))
420 const std::vector<std::string> &argv,
421 const char *
const * envp) {
422 std::vector<GenericValue> GVArgs;
447 GVArgs.push_back(GVArgc);
452 "argv[0] was null after CreateArgv");
454 std::vector<std::string> EnvVars;
455 for (
unsigned i = 0; envp[i]; ++i)
456 EnvVars.emplace_back(envp[i]);
469 : M(std::move(M)), WhichEngine(EngineKind::
Either), ErrorStr(nullptr),
470 OptLevel(CodeGenOpt::
Default), MemMgr(nullptr), Resolver(nullptr),
472 UseOrcMCJITReplacement(
false) {
476 VerifyModules =
true;
478 VerifyModules =
false;
485 std::unique_ptr<RTDyldMemoryManager> mcjmm) {
486 auto SharedMM = std::shared_ptr<RTDyldMemoryManager>(std::move(mcjmm));
494 MemMgr = std::shared_ptr<MCJITMemoryManager>(std::move(MM));
500 Resolver = std::shared_ptr<RuntimeDyld::SymbolResolver>(std::move(SR));
505 std::unique_ptr<TargetMachine> TheTM(TM);
520 *ErrorStr =
"Cannot create an interpreter with a memory manager.";
528 Triple TT(M->getTargetTriple());
530 errs() <<
"WARNING: This target JIT is not designed for the host"
531 <<
" you are running. If bad things happen, please choose"
532 <<
" a different -march switch.\n";
543 std::move(Resolver), std::move(TheTM));
557 *ErrorStr =
"Interpreter has not been linked in.";
563 *ErrorStr =
"JIT has not been linked in.";
570 if (
Function *
F = const_cast<Function*>(dyn_cast<Function>(GV)))
579 const_cast<GlobalVariable *>(dyn_cast<GlobalVariable>(GV)))
591 if (isa<UndefValue>(C)) {
607 unsigned int elemNum = STy->getNumElements();
609 for (
unsigned int i = 0; i < elemNum; ++i) {
610 Type *ElemTy = STy->getElementType(i);
628 if (ElemTy->isIntegerTy())
629 for (
unsigned int i = 0; i < elemNum; ++i)
631 APInt(ElemTy->getPrimitiveSizeInBits(), 0);
638 if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
640 switch (CE->getOpcode()) {
641 case Instruction::GetElementPtr: {
645 cast<GEPOperator>(CE)->accumulateConstantOffset(*DL, Offset);
648 Result =
PTOGV(tmp + Offset.getSExtValue());
651 case Instruction::Trunc: {
653 uint32_t BitWidth = cast<IntegerType>(CE->getType())->
getBitWidth();
657 case Instruction::ZExt: {
659 uint32_t BitWidth = cast<IntegerType>(CE->getType())->
getBitWidth();
663 case Instruction::SExt: {
665 uint32_t BitWidth = cast<IntegerType>(CE->getType())->
getBitWidth();
669 case Instruction::FPTrunc: {
675 case Instruction::FPExt:{
681 case Instruction::UIToFP: {
683 if (CE->getType()->isFloatTy())
685 else if (CE->getType()->isDoubleTy())
687 else if (CE->getType()->isX86_FP80Ty()) {
696 case Instruction::SIToFP: {
698 if (CE->getType()->isFloatTy())
700 else if (CE->getType()->isDoubleTy())
702 else if (CE->getType()->isX86_FP80Ty()) {
711 case Instruction::FPToUI:
712 case Instruction::FPToSI: {
714 uint32_t BitWidth = cast<IntegerType>(CE->getType())->
getBitWidth();
724 CE->getOpcode()==Instruction::FPToSI,
730 case Instruction::PtrToInt: {
733 assert(PtrWidth <= 64 &&
"Bad pointer width");
739 case Instruction::IntToPtr: {
747 case Instruction::BitCast: {
749 Type* DestTy = CE->getType();
760 assert(DestTy->
isIntegerTy(32) &&
"Invalid bitcast");
764 assert(DestTy->
isIntegerTy(64) &&
"Invalid bitcast");
768 assert(DestTy->
isPointerTy() &&
"Invalid bitcast");
773 case Instruction::Add:
774 case Instruction::FAdd:
775 case Instruction::Sub:
776 case Instruction::FSub:
777 case Instruction::Mul:
778 case Instruction::FMul:
779 case Instruction::UDiv:
780 case Instruction::SDiv:
781 case Instruction::URem:
782 case Instruction::SRem:
789 switch (CE->getOperand(0)->getType()->getTypeID()) {
792 switch (CE->getOpcode()) {
794 case Instruction::Add: GV.IntVal = LHS.
IntVal + RHS.
IntVal;
break;
795 case Instruction::Sub: GV.IntVal = LHS.
IntVal - RHS.
IntVal;
break;
796 case Instruction::Mul: GV.IntVal = LHS.
IntVal * RHS.
IntVal;
break;
807 switch (CE->getOpcode()) {
809 case Instruction::FAdd:
811 case Instruction::FSub:
813 case Instruction::FMul:
815 case Instruction::FDiv:
817 case Instruction::FRem:
822 switch (CE->getOpcode()) {
824 case Instruction::FAdd:
826 case Instruction::FSub:
828 case Instruction::FMul:
830 case Instruction::FDiv:
832 case Instruction::FRem:
839 const fltSemantics &Sem = CE->getOperand(0)->getType()->getFltSemantics();
841 switch (CE->getOpcode()) {
843 case Instruction::FAdd:
847 case Instruction::FSub:
852 case Instruction::FMul:
857 case Instruction::FDiv:
862 case Instruction::FRem:
879 OS <<
"ConstantExpr not handled: " << *CE;
887 Result.
FloatVal = cast<ConstantFP>(
C)->getValueAPF().convertToFloat();
890 Result.
DoubleVal = cast<ConstantFP>(
C)->getValueAPF().convertToDouble();
895 Result.
IntVal = cast <ConstantFP>(
C)->getValueAPF().bitcastToAPInt();
898 Result.
IntVal = cast<ConstantInt>(
C)->getValue();
901 if (isa<ConstantPointerNull>(C))
903 else if (
const Function *
F = dyn_cast<Function>(C))
920 }
else if (CV || CAZ) {
939 for (
unsigned i = 0; i < elemNum; ++i)
940 if (!isa<UndefValue>(CV->getOperand(i)))
942 CV->getOperand(i))->getValueAPF().convertToFloat();
946 for (
unsigned i = 0; i < elemNum; ++i)
961 for (
unsigned i = 0; i < elemNum; ++i)
962 if (!isa<UndefValue>(CV->getOperand(i)))
964 CV->getOperand(i))->getValueAPF().convertToDouble();
968 for (
unsigned i = 0; i < elemNum; ++i)
983 for (
unsigned i = 0; i < elemNum; ++i)
984 if (!isa<UndefValue>(CV->getOperand(i)))
986 CV->getOperand(i))->getValue();
989 APInt(CV->getOperand(i)->getType()->getPrimitiveSizeInBits(), 0);
994 for (
unsigned i = 0; i < elemNum; ++i)
1008 OS <<
"ERROR: Constant unimplemented for type: " << *C->
getType();
1018 unsigned StoreBytes) {
1019 assert((IntVal.
getBitWidth()+7)/8 >= StoreBytes &&
"Integer too small!");
1020 const uint8_t *Src = (
const uint8_t *)IntVal.
getRawData();
1025 memcpy(Dst, Src, StoreBytes);
1030 while (StoreBytes >
sizeof(uint64_t)) {
1031 StoreBytes -=
sizeof(uint64_t);
1033 memcpy(Dst + StoreBytes, Src,
sizeof(uint64_t));
1034 Src +=
sizeof(uint64_t);
1037 memcpy(Dst, Src +
sizeof(uint64_t) - StoreBytes, StoreBytes);
1047 dbgs() <<
"Cannot store value of type " << *Ty <<
"!\n";
1069 for (
unsigned i = 0; i < Val.
AggregateVal.size(); ++i) {
1070 if (cast<VectorType>(Ty)->getElementType()->isDoubleTy())
1072 if (cast<VectorType>(Ty)->getElementType()->isFloatTy())
1074 if (cast<VectorType>(Ty)->getElementType()->isIntegerTy()) {
1075 unsigned numOfBytes =(Val.
AggregateVal[i].IntVal.getBitWidth()+7)/8;
1077 (uint8_t*)Ptr + numOfBytes*i, numOfBytes);
1085 std::reverse((uint8_t*)Ptr, StoreBytes + (uint8_t*)Ptr);
1091 assert((IntVal.
getBitWidth()+7)/8 >= LoadBytes &&
"Integer too small!");
1092 uint8_t *Dst =
reinterpret_cast<uint8_t *
>(
1093 const_cast<uint64_t *
>(IntVal.
getRawData()));
1098 memcpy(Dst, Src, LoadBytes);
1104 while (LoadBytes >
sizeof(uint64_t)) {
1105 LoadBytes -=
sizeof(uint64_t);
1107 memcpy(Dst, Src + LoadBytes,
sizeof(uint64_t));
1108 Dst +=
sizeof(uint64_t);
1111 memcpy(Dst +
sizeof(uint64_t) - LoadBytes, Src, LoadBytes);
1149 if (ElemT->isFloatTy()) {
1151 for (
unsigned i = 0; i < numElems; ++i)
1154 if (ElemT->isDoubleTy()) {
1156 for (
unsigned i = 0; i < numElems; ++i)
1159 if (ElemT->isIntegerTy()) {
1161 const unsigned elemBitWidth = cast<IntegerType>(ElemT)->
getBitWidth();
1164 for (
unsigned i = 0; i < numElems; ++i)
1166 (uint8_t*)Ptr+((elemBitWidth+7)/8)*i, (elemBitWidth+7)/8);
1173 OS <<
"Cannot load value of type " << *Ty <<
"!";
1179 DEBUG(
dbgs() <<
"JIT: Initializing " << Addr <<
" ");
1181 if (isa<UndefValue>(Init))
1185 unsigned ElementSize =
1187 for (
unsigned i = 0, e =
CP->getNumOperands(); i != e; ++i)
1192 if (isa<ConstantAggregateZero>(Init)) {
1197 if (
const ConstantArray *CPA = dyn_cast<ConstantArray>(Init)) {
1198 unsigned ElementSize =
1200 for (
unsigned i = 0, e = CPA->getNumOperands(); i != e; ++i)
1205 if (
const ConstantStruct *CPS = dyn_cast<ConstantStruct>(Init)) {
1208 for (
unsigned i = 0, e = CPS->getNumOperands(); i != e; ++i)
1214 dyn_cast<ConstantDataSequential>(Init)) {
1217 memcpy(Addr, Data.
data(), Data.
size());
1238 std::map<std::pair<std::string, Type*>,
1242 for (
unsigned m = 0, e =
Modules.size(); m != e; ++m) {
1244 for (
const auto &GV : M.
globals()) {
1271 std::vector<const GlobalValue*> NonCanonicalGlobals;
1272 for (
unsigned m = 0, e =
Modules.size(); m != e; ++m) {
1274 for (
const auto &GV : M.
globals()) {
1276 if (!LinkedGlobalsMap.empty()) {
1280 if (GVEntry != &GV) {
1281 NonCanonicalGlobals.push_back(&GV);
1304 if (!NonCanonicalGlobals.empty()) {
1305 for (
unsigned i = 0, e = NonCanonicalGlobals.size(); i != e; ++i) {
1310 assert(Ptr &&
"Canonical global wasn't codegen'd!");
1317 for (
const auto &GV : M.
globals()) {
1319 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).
ConstantDataVector - A vector constant whose element type is a simple 1/2/4/8-byte integer or float/d...
opStatus divide(const APFloat &, roundingMode)
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.
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.
static ExecutionEngine *(* OrcMCJITReplacementCtor)(std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MM, std::shared_ptr< RuntimeDyld::SymbolResolver > SR, std::unique_ptr< TargetMachine > TM)
STATISTIC(NumFunctions,"Total number of functions")
size_t size() const
size - Get the string size.
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
getNumParams - Return the number of fixed parameters this function type requires. ...
virtual bool removeModule(Module *M)
removeModule - Remove a Module from the list of modules.
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.
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
isDoubleTy - 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)
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 LLVM_ATTRIBUTE_UNUSED_RESULT zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
Reports a serious error, calling any installed error handler.
static ExecutionEngine *(* MCJITCtor)(std::unique_ptr< Module > M, std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MM, std::shared_ptr< RuntimeDyld::SymbolResolver > SR, std::unique_ptr< TargetMachine > TM)
StringRef getName() const
Return a constant reference to the value's name.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT urem(const APInt &RHS) const
Unsigned remainder operation.
static const fltSemantics x87DoubleExtended
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
virtual GlobalVariable * FindGlobalVariableNamed(const char *Name, bool AllowInternal=false)
FindGlobalVariableNamed - Search all of the active modules to find the global variable that defines N...
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...
void * getPointerToGlobal(const GlobalValue *GV)
getPointerToGlobal - This returns the address of the specified global value.
void InitializeMemory(const Constant *Init, void *Addr)
StructType - Class to represent struct types.
opStatus convertToInteger(integerPart *, unsigned int, bool, roundingMode, bool *) const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
EngineBuilder()
Default constructor for EngineBuilder.
double getElementAsDouble(unsigned i) const
getElementAsDouble - If this is an sequential container of doubles, return the specified element as a...
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.
ConstantAggregateZero - All zero aggregate value.
global_iterator global_begin()
static const bool IsLittleEndianHost
FunctionType - Class to represent function types.
ConstantExpr - 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...
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
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.
bool isFirstClassType() const
isFirstClassType - Return true if the type is "first class", meaning it is a valid type for a Value...
TypeID getTypeID() const
getTypeID - Return the type id for the type.
bool isFloatingPointTy() const
isFloatingPointTy - 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.
unsigned getNumElements() const
Return the number of elements in the Vector type.
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.
void StoreValueToMemory(const GenericValue &Val, GenericValue *Ptr, Type *Ty)
StoreValueToMemory - Stores the data in Val of type Ty at address Ptr.
Type * getElementType() const
opStatus mod(const APFloat &, roundingMode)
C fmod, or llvm frem.
opStatus convertFromAPInt(const APInt &, bool, roundingMode)
uint64_t getElementOffset(unsigned Idx) const
10: Arbitrary bit width integers
bool hasJIT() const
hasJIT - Check if this targets supports the just-in-time compilation.
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
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.
cl::opt< Reloc::Model > RelocModel("relocation-model", cl::desc("Choose relocation model"), cl::init(Reloc::Default), cl::values(clEnumValN(Reloc::Default,"default","Target default relocation model"), clEnumValN(Reloc::Static,"static","Non-relocatable code"), clEnumValN(Reloc::PIC_,"pic","Fully relocatable, position independent code"), clEnumValN(Reloc::DynamicNoPIC,"dynamic-no-pic","Relocatable external references, non-relocatable code"), clEnumValEnd))
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT 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
isFloatTy - 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.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT sext(unsigned width) const
Sign extend to a new width.
unsigned getBitWidth() const
Return the number of bits in the APInt.
6: 128-bit floating point type (two 64-bits, PowerPC)
APInt LLVM_ATTRIBUTE_UNUSED_RESULT sdiv(const APInt &RHS) const
Signed division function for APInt.
Value * getOperand(unsigned i) const
ConstantVector - 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()
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
uint64_t getElementAsInteger(unsigned i) const
getElementAsInteger - If this is a sequential container of integers (of any size), return the specified element in the low bits of a uint64_t.
bool isPointerTy() const
isPointerTy - True if this is an instance of PointerType.
static UndefValue * get(Type *T)
get() - Static factory methods - Return an 'undef' object of the specified type.
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"), clEnumValEnd))
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)
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 LLVM_ATTRIBUTE_UNUSED_RESULT 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()
global_iterator global_end()
bool hasExternalWeakLinkage() const
bool hasExternalLinkage() const
static APInt LLVM_ATTRIBUTE_UNUSED_RESULT doubleToBits(double V)
Converts a double to APInt bits.
15: 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...
opStatus add(const APFloat &, roundingMode)
unsigned getScalarSizeInBits() const LLVM_READONLY
getScalarSizeInBits - If this is a vector type, return the getPrimitiveSizeInBits value for the eleme...
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
opStatus multiply(const APFloat &, roundingMode)
GlobalVariable * getNamedGlobal(StringRef Name)
Return the global variable in the module with the specified name, of arbitrary type.
virtual Function * FindFunctionNamed(const char *FnName)
FindFunctionNamed - Search all of the active modules to find the function that defines FnName...
bool isNullValue() const
isNullValue - Return true if this is the value that would be returned by getNullValue.
void setVerifyModules(bool Verify)
Enable/Disable IR module verification.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
VectorType - 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
isIntegerTy - True if this is an instance of IntegerType.
APInt bitcastToAPInt() const
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
SmallVector< std::unique_ptr< Module >, 1 > Modules
The list of Modules that we are JIT'ing from.
uint64_t RoundUpToAlignment(uint64_t Value, uint64_t Align)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
double bitsToDouble() const
Converts APInt bits to a double.
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
EngineBuilder & setSymbolResolver(std::unique_ptr< RuntimeDyld::SymbolResolver > SR)
APInt RoundFloatToAPInt(float Float, unsigned width)
Converts a float value into a APInt.
StringRef str()
Flushes the stream contents to the target vector and return a StringRef for the vector contents...
virtual ~ExecutionEngine()
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
isX86_FP80Ty - 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
isAggregateType - 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 LLVM_ATTRIBUTE_UNUSED_RESULT 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
getElementAsFloat - If this is an sequential container of floats, return the specified element as a f...
const DataLayout * getDataLayout() const
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
static APInt LLVM_ATTRIBUTE_UNUSED_RESULT floatToBits(float V)
Converts a float to APInt bits.
FunctionType * getFunctionType() const
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
getNumElements - 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.
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
getElementType - Return the element type of the array/vector.
3: 64-bit floating point type
Type * getReturnType() const
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
getPrimitiveSizeInBits - 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:
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 LLVM_ATTRIBUTE_UNUSED_RESULT 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.
opStatus subtract(const APFloat &, roundingMode)
float bitsToFloat() const
Converts APInt bits to a double.
bool isVoidTy() const
isVoidTy - Return true if this is 'void'.
bool empty() const
empty - Check if the string is empty.
5: 128-bit floating point type (112-bit mantissa)