45#define DEBUG_TYPE "jit"
47STATISTIC(NumInitBytes,
"Number of bytes of global vars initialized");
48STATISTIC(NumGlobals ,
"Number of global vars initialized");
51 std::unique_ptr<Module> M, std::string *ErrorStr,
52 std::shared_ptr<MCJITMemoryManager> MemMgr,
53 std::shared_ptr<LegacyJITSymbolResolver>
Resolver,
54 std::unique_ptr<TargetMachine>
TM) =
nullptr;
56ExecutionEngine *(*ExecutionEngine::InterpCtor)(std::unique_ptr<Module> M,
57 std::string *ErrorStr) =
nullptr;
59void JITEventListener::anchor() {}
61void ObjectCache::anchor() {}
63void ExecutionEngine::Init(std::unique_ptr<Module> M) {
64 CompilingLazily =
false;
65 GVCompilationDisabled =
false;
66 SymbolSearchingDisabled =
false;
73 VerifyModules =
false;
76 assert(M &&
"Module is null?");
77 Modules.push_back(std::move(M));
81 :
DL(M->getDataLayout()), LazyFunctionCreator(nullptr) {
107 void *RawMemory = ::operator
new(
109 new(RawMemory) GVMemoryBlock(GV);
110 return static_cast<char*
>(RawMemory) +
sizeof(GVMemoryBlock);
113 void deleted()
override {
117 this->~GVMemoryBlock();
118 ::operator
delete(
this);
128 llvm_unreachable(
"ExecutionEngine subclass doesn't implement addObjectFile.");
133 llvm_unreachable(
"ExecutionEngine subclass doesn't implement addObjectFile.");
154 for (
unsigned i = 0, e =
Modules.size(); i != e; ++i) {
156 if (
F && !
F->isDeclaration())
163 for (
unsigned i = 0, e =
Modules.size(); i != e; ++i) {
177 if (
I == GlobalAddressMap.
end())
180 GlobalAddressReverseMap.erase(
I->second);
182 GlobalAddressMap.
erase(
I);
191 std::lock_guard<sys::Mutex> locked(
lock);
200 return std::string(FullName.
str());
204 std::lock_guard<sys::Mutex> locked(
lock);
209 std::lock_guard<sys::Mutex> locked(
lock);
211 assert(!
Name.empty() &&
"Empty GlobalMapping symbol name!");
215 assert((!CurVal || !
Addr) &&
"GlobalMapping already established!");
222 "GlobalMapping already established!");
223 V = std::string(
Name);
228 std::lock_guard<sys::Mutex> locked(
lock);
235 std::lock_guard<sys::Mutex> locked(
lock);
243 std::lock_guard<sys::Mutex> locked(
lock);
248 std::lock_guard<sys::Mutex> locked(
lock);
268 "GlobalMapping already established!");
269 V = std::string(
Name);
275 std::lock_guard<sys::Mutex> locked(
lock);
286 std::lock_guard<sys::Mutex> locked(
lock);
293 std::lock_guard<sys::Mutex> locked(
lock);
298 std::lock_guard<sys::Mutex> locked(
lock);
308 std::make_pair(
Addr, std::string(
Name)));
312 std::map<uint64_t, std::string>::iterator
I =
317 for (
unsigned i = 0, e =
Modules.size(); i != e; ++i)
326 std::unique_ptr<char[]> Array;
327 std::vector<std::unique_ptr<char[]>> Values;
332 const std::vector<std::string> &InputArgv);
336 const std::vector<std::string> &InputArgv) {
338 Values.reserve(InputArgv.size());
340 Array = std::make_unique<char[]>((InputArgv.size()+1)*PtrSize);
345 for (
unsigned i = 0; i != InputArgv.size(); ++i) {
346 unsigned Size = InputArgv[i].size()+1;
347 auto Dest = std::make_unique<char[]>(
Size);
348 LLVM_DEBUG(
dbgs() <<
"JIT: ARGV[" << i <<
"] = " << (
void *)Dest.get()
351 std::copy(InputArgv[i].
begin(), InputArgv[i].
end(), Dest.get());
357 Values.push_back(std::move(Dest));
369 StringRef Name(isDtors ?
"llvm.global_dtors" :
"llvm.global_ctors");
383 for (
unsigned i = 0, e = InitList->
getNumOperands(); i != e; ++i) {
388 if (
FP->isNullValue())
394 FP = CE->getOperand(0);
408 for (std::unique_ptr<Module> &M :
Modules)
416 for (
unsigned i = 0; i < PtrSize; ++i)
417 if (*(i + (uint8_t*)Loc))
424 const std::vector<std::string> &argv,
425 const char *
const * envp) {
426 std::vector<GenericValue> GVArgs;
451 GVArgs.push_back(GVArgc);
456 "argv[0] was null after CreateArgv");
458 std::vector<std::string> EnvVars;
459 for (
unsigned i = 0; envp[i]; ++i)
460 EnvVars.emplace_back(envp[i]);
473 : M(
std::
move(M)), WhichEngine(EngineKind::Either), ErrorStr(nullptr),
478 VerifyModules =
true;
480 VerifyModules =
false;
487 std::unique_ptr<RTDyldMemoryManager> mcjmm) {
488 auto SharedMM = std::shared_ptr<RTDyldMemoryManager>(std::move(mcjmm));
496 MemMgr = std::shared_ptr<MCJITMemoryManager>(std::move(MM));
502 Resolver = std::shared_ptr<LegacyJITSymbolResolver>(std::move(SR));
507 std::unique_ptr<TargetMachine> TheTM(
TM);
522 *ErrorStr =
"Cannot create an interpreter with a memory manager.";
530 if (!
TM->getTarget().hasJIT()) {
531 errs() <<
"WARNING: This target JIT is not designed for the host"
532 <<
" you are running. If bad things happen, please choose"
533 <<
" a different -march switch.\n";
539 std::move(
Resolver), std::move(TheTM));
553 *ErrorStr =
"Interpreter has not been linked in.";
559 *ErrorStr =
"JIT has not been linked in.";
569 std::lock_guard<sys::Mutex> locked(
lock);
587 if (isa<UndefValue>(
C)) {
589 switch (
C->getType()->getTypeID()) {
598 Result.IntVal =
APInt(
C->getType()->getPrimitiveSizeInBits(), 0);
602 if(
StructType *STy = dyn_cast<StructType>(
C->getType())) {
603 unsigned int elemNum = STy->getNumElements();
604 Result.AggregateVal.resize(elemNum);
605 for (
unsigned int i = 0; i < elemNum; ++i) {
606 Type *ElemTy = STy->getElementType(i);
608 Result.AggregateVal[i].IntVal =
620 "Scalable vector support not yet implemented in ExecutionEngine");
623 auto *VTy = cast<FixedVectorType>(
C->getType());
624 Type *ElemTy = VTy->getElementType();
625 unsigned int elemNum = VTy->getNumElements();
626 Result.AggregateVal.resize(elemNum);
628 for (
unsigned int i = 0; i < elemNum; ++i)
629 Result.AggregateVal[i].IntVal =
639 switch (CE->getOpcode()) {
640 case Instruction::GetElementPtr: {
644 cast<GEPOperator>(CE)->accumulateConstantOffset(DL,
Offset);
646 char* tmp = (
char*) Result.PointerVal;
650 case Instruction::Trunc: {
656 case Instruction::ZExt: {
662 case Instruction::SExt: {
668 case Instruction::FPTrunc: {
674 case Instruction::FPExt:{
680 case Instruction::UIToFP: {
682 if (CE->getType()->isFloatTy())
684 else if (CE->getType()->isDoubleTy())
686 else if (CE->getType()->isX86_FP80Ty()) {
695 case Instruction::SIToFP: {
697 if (CE->getType()->isFloatTy())
699 else if (CE->getType()->isDoubleTy())
701 else if (CE->getType()->isX86_FP80Ty()) {
710 case Instruction::FPToUI:
711 case Instruction::FPToSI: {
723 CE->getOpcode()==Instruction::FPToSI,
729 case Instruction::PtrToInt: {
732 assert(PtrWidth <= 64 &&
"Bad pointer width");
738 case Instruction::IntToPtr: {
746 case Instruction::BitCast: {
748 Type* DestTy = CE->getType();
772 case Instruction::Add:
773 case Instruction::FAdd:
774 case Instruction::Sub:
775 case Instruction::FSub:
776 case Instruction::Mul:
777 case Instruction::FMul:
778 case Instruction::UDiv:
779 case Instruction::SDiv:
780 case Instruction::URem:
781 case Instruction::SRem:
782 case Instruction::And:
783 case Instruction::Or:
784 case Instruction::Xor: {
788 switch (CE->getOperand(0)->getType()->getTypeID()) {
791 switch (CE->getOpcode()) {
793 case Instruction::Add: GV.
IntVal =
LHS.IntVal +
RHS.IntVal;
break;
794 case Instruction::Sub: GV.
IntVal =
LHS.IntVal -
RHS.IntVal;
break;
795 case Instruction::Mul: GV.
IntVal =
LHS.IntVal *
RHS.IntVal;
break;
796 case Instruction::UDiv:GV.
IntVal =
LHS.IntVal.udiv(
RHS.IntVal);
break;
797 case Instruction::SDiv:GV.
IntVal =
LHS.IntVal.sdiv(
RHS.IntVal);
break;
798 case Instruction::URem:GV.
IntVal =
LHS.IntVal.urem(
RHS.IntVal);
break;
799 case Instruction::SRem:GV.
IntVal =
LHS.IntVal.srem(
RHS.IntVal);
break;
800 case Instruction::And: GV.
IntVal =
LHS.IntVal &
RHS.IntVal;
break;
801 case Instruction::Or: GV.
IntVal =
LHS.IntVal |
RHS.IntVal;
break;
802 case Instruction::Xor: GV.
IntVal =
LHS.IntVal ^
RHS.IntVal;
break;
806 switch (CE->getOpcode()) {
808 case Instruction::FAdd:
810 case Instruction::FSub:
812 case Instruction::FMul:
814 case Instruction::FDiv:
816 case Instruction::FRem:
821 switch (CE->getOpcode()) {
823 case Instruction::FAdd:
825 case Instruction::FSub:
827 case Instruction::FMul:
829 case Instruction::FDiv:
831 case Instruction::FRem:
838 const fltSemantics &Sem = CE->getOperand(0)->getType()->getFltSemantics();
840 switch (CE->getOpcode()) {
842 case Instruction::FAdd:
846 case Instruction::FSub:
851 case Instruction::FMul:
856 case Instruction::FDiv:
861 case Instruction::FRem:
877 OS <<
"ConstantExpr not handled: " << *CE;
881 if (
auto *TETy = dyn_cast<TargetExtType>(
C->getType())) {
883 "TargetExtType only supports null constant value");
889 switch (
C->getType()->getTypeID()) {
891 Result.FloatVal = cast<ConstantFP>(
C)->getValueAPF().convertToFloat();
894 Result.DoubleVal = cast<ConstantFP>(
C)->getValueAPF().convertToDouble();
899 Result.IntVal = cast <ConstantFP>(
C)->getValueAPF().bitcastToAPInt();
902 Result.IntVal = cast<ConstantInt>(
C)->getValue();
905 while (
auto *
A = dyn_cast<GlobalAlias>(
C)) {
908 if (isa<ConstantPointerNull>(
C))
909 Result.PointerVal =
nullptr;
910 else if (
const Function *
F = dyn_cast<Function>(
C))
919 "Scalable vector support not yet implemented in ExecutionEngine");
930 }
else if (CV || CAZ) {
931 auto *VTy = cast<FixedVectorType>(
C->getType());
932 elemNum = VTy->getNumElements();
933 ElemTy = VTy->getElementType();
938 Result.AggregateVal.resize(elemNum);
944 std::fill(Result.AggregateVal.begin(), Result.AggregateVal.end(),
949 for (
unsigned i = 0; i < elemNum; ++i)
951 Result.AggregateVal[i].FloatVal = cast<ConstantFP>(
952 CV->
getOperand(i))->getValueAPF().convertToFloat();
956 for (
unsigned i = 0; i < elemNum; ++i)
966 std::fill(Result.AggregateVal.begin(), Result.AggregateVal.end(),
971 for (
unsigned i = 0; i < elemNum; ++i)
973 Result.AggregateVal[i].DoubleVal = cast<ConstantFP>(
974 CV->
getOperand(i))->getValueAPF().convertToDouble();
978 for (
unsigned i = 0; i < elemNum; ++i)
988 std::fill(Result.AggregateVal.begin(), Result.AggregateVal.end(),
993 for (
unsigned i = 0; i < elemNum; ++i)
995 Result.AggregateVal[i].IntVal = cast<ConstantInt>(
998 Result.AggregateVal[i].IntVal =
1004 for (
unsigned i = 0; i < elemNum; ++i)
1005 Result.AggregateVal[i].IntVal =
APInt(
1017 OS <<
"ERROR: Constant unimplemented for type: " << *
C->getType();
1028 if (
auto *TETy = dyn_cast<TargetExtType>(Ty))
1029 Ty = TETy->getLayoutType();
1035 dbgs() <<
"Cannot store value of type " << *Ty <<
"!\n";
1052 memset(&(
Ptr->PointerVal), 0, StoreBytes);
1058 for (
unsigned i = 0; i < Val.
AggregateVal.size(); ++i) {
1059 if (cast<VectorType>(Ty)->getElementType()->isDoubleTy())
1061 if (cast<VectorType>(Ty)->getElementType()->isFloatTy())
1063 if (cast<VectorType>(Ty)->getElementType()->isIntegerTy()) {
1064 unsigned numOfBytes =(Val.
AggregateVal[i].IntVal.getBitWidth()+7)/8;
1066 (uint8_t*)
Ptr + numOfBytes*i, numOfBytes);
1074 std::reverse((uint8_t*)
Ptr, StoreBytes + (uint8_t*)
Ptr);
1082 if (
auto *TETy = dyn_cast<TargetExtType>(Ty))
1083 Ty = TETy->getLayoutType();
1094 Result.FloatVal = *((
float*)
Ptr);
1097 Result.DoubleVal = *((
double*)
Ptr);
1107 Result.IntVal =
APInt(80, y);
1112 "Scalable vector support not yet implemented in ExecutionEngine");
1114 auto *VT = cast<FixedVectorType>(Ty);
1115 Type *ElemT = VT->getElementType();
1116 const unsigned numElems = VT->getNumElements();
1118 Result.AggregateVal.resize(numElems);
1119 for (
unsigned i = 0; i < numElems; ++i)
1120 Result.AggregateVal[i].FloatVal = *((
float*)
Ptr+i);
1123 Result.AggregateVal.resize(numElems);
1124 for (
unsigned i = 0; i < numElems; ++i)
1125 Result.AggregateVal[i].DoubleVal = *((
double*)
Ptr+i);
1129 const unsigned elemBitWidth = cast<IntegerType>(ElemT)->getBitWidth();
1131 Result.AggregateVal.resize(numElems, intZero);
1132 for (
unsigned i = 0; i < numElems; ++i)
1134 (uint8_t*)
Ptr+((elemBitWidth+7)/8)*i, (elemBitWidth+7)/8);
1141 OS <<
"Cannot load value of type " << *Ty <<
"!";
1149 if (isa<UndefValue>(
Init))
1153 unsigned ElementSize =
1155 for (
unsigned i = 0, e = CP->getNumOperands(); i != e; ++i)
1160 if (isa<ConstantAggregateZero>(
Init)) {
1166 unsigned ElementSize =
1168 for (
unsigned i = 0, e = CPA->getNumOperands(); i != e; ++i)
1176 for (
unsigned i = 0, e = CPS->getNumOperands(); i != e; ++i)
1182 dyn_cast<ConstantDataSequential>(
Init)) {
1189 if (
Init->getType()->isFirstClassType()) {
1206 std::map<std::pair<std::string, Type*>,
1210 for (
unsigned m = 0, e =
Modules.size(); m != e; ++m) {
1212 for (
const auto &GV : M.globals()) {
1217 const GlobalValue *&GVEntry = LinkedGlobalsMap[std::make_pair(
1239 std::vector<const GlobalValue*> NonCanonicalGlobals;
1240 for (
unsigned m = 0, e =
Modules.size(); m != e; ++m) {
1242 for (
const auto &GV : M.globals()) {
1244 if (!LinkedGlobalsMap.empty()) {
1245 if (
const GlobalValue *GVEntry = LinkedGlobalsMap[std::make_pair(
1248 if (GVEntry != &GV) {
1249 NonCanonicalGlobals.push_back(&GV);
1272 if (!NonCanonicalGlobals.empty()) {
1273 for (
const GlobalValue *GV : NonCanonicalGlobals) {
1274 const GlobalValue *CGV = LinkedGlobalsMap[std::make_pair(
1277 assert(
Ptr &&
"Canonical global wasn't codegen'd!");
1284 for (
const auto &GV : M.globals()) {
1286 if (!LinkedGlobalsMap.empty()) {
1287 if (
const GlobalValue *GVEntry = LinkedGlobalsMap[std::make_pair(
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Looks at all the uses of the given value Returns the Liveness deduced from the uses of this value Adds all uses that cause the result to be MaybeLive to MaybeLiveRetUses If the result is MaybeLiveUses might be modified but its content should be ignored(since it might not be complete). DeadArgumentEliminationPass
static bool isTargetNullPtr(ExecutionEngine *EE, void *Loc)
isTargetNullPtr - Return whether the target pointer stored at Loc is null.
Module.h This file contains the declarations for the Module class.
const char LLVMTargetMachineRef TM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
opStatus divide(const APFloat &RHS, roundingMode RM)
opStatus subtract(const APFloat &RHS, roundingMode RM)
opStatus add(const APFloat &RHS, roundingMode RM)
opStatus convertFromAPInt(const APInt &Input, bool IsSigned, roundingMode RM)
opStatus multiply(const APFloat &RHS, roundingMode RM)
APInt bitcastToAPInt() const
opStatus convertToInteger(MutableArrayRef< integerPart > Input, unsigned int Width, bool IsSigned, roundingMode RM, bool *IsExact) const
opStatus mod(const APFloat &RHS)
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
Class for arbitrary precision integers.
APInt zext(unsigned width) const
Zero extend to a new width.
uint64_t getZExtValue() const
Get zero extended value.
APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
APInt trunc(unsigned width) const
Truncate to new width.
static APInt floatToBits(float V)
Converts a float to APInt bits.
unsigned getBitWidth() const
Return the number of bits in the APInt.
double signedRoundToDouble() const
Converts this signed APInt to a double value.
float bitsToFloat() const
Converts APInt bits to a float.
static APInt doubleToBits(double V)
Converts a double to APInt bits.
APInt sext(unsigned width) const
Sign extend to a new width.
double bitsToDouble() const
Converts APInt bits to a double.
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
double roundToDouble(bool isSigned) const
Converts this APInt to a double value.
Value handle with callbacks on RAUW and destruction.
All zero aggregate value.
ConstantArray - Constant Array Declarations.
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
double getElementAsDouble(unsigned i) const
If this is an sequential container of doubles, return the specified element as a double.
float getElementAsFloat(unsigned i) const
If this is an sequential container of floats, return the specified element as a float.
uint64_t getElementAsInteger(unsigned i) const
If this is a sequential container of integers (of any size), return the specified element in the low ...
unsigned getNumElements() const
Return the number of elements in the array or vector.
Type * getElementType() const
Return the element type of the array/vector.
A vector constant whose element type is a simple 1/2/4/8-byte integer or float/double,...
A constant value that is initialized with an expression using other constant values.
Constant Vector Declarations.
This is an important base class in LLVM.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
A parsed version of the target data layout string in and methods for querying it.
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
bool isDefault() const
Test if the DataLayout was constructed from an empty string.
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Align getPreferredAlign(const GlobalVariable *GV) const
Returns the preferred alignment of the specified global.
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size in bytes, rounded up to a whole number of bytes.
TypeSize getTypeSizeInBits(Type *Ty) const
Size examples:
TypeSize 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.
EngineBuilder()
Default constructor for EngineBuilder.
EngineBuilder & setSymbolResolver(std::unique_ptr< LegacyJITSymbolResolver > SR)
EngineBuilder & setMemoryManager(std::unique_ptr< MCJITMemoryManager > MM)
ExecutionEngine * create()
std::map< uint64_t, std::string > & getGlobalAddressReverseMap()
uint64_t RemoveMapping(StringRef Name)
Erase an entry from the mapping table.
GlobalAddressMapTy & getGlobalAddressMap()
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter...
void setVerifyModules(bool Verify)
Enable/Disable IR module verification.
void StoreValueToMemory(const GenericValue &Val, GenericValue *Ptr, Type *Ty)
StoreValueToMemory - Stores the data in Val of type Ty at address Ptr.
GenericValue getConstantValue(const Constant *C)
Converts a Constant* into a GenericValue, including handling of ConstantExpr values.
const DataLayout & getDataLayout() const
void * getPointerToGlobalIfAvailable(StringRef S)
getPointerToGlobalIfAvailable - This returns the address of the specified global value if it is has a...
void clearAllGlobalMappings()
clearAllGlobalMappings - Clear all global mappings and start over again, for use in dynamic compilati...
virtual void addArchive(object::OwningBinary< object::Archive > A)
addArchive - Add an Archive to the execution engine.
void InitializeMemory(const Constant *Init, void *Addr)
virtual void * getPointerToFunctionOrStub(Function *F)
getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the f...
std::string getMangledName(const GlobalValue *GV)
getMangledName - Get mangled name.
virtual bool removeModule(Module *M)
removeModule - Removes a Module from the list of modules, but does not free the module's memory.
virtual void * getPointerToFunction(Function *F)=0
getPointerToFunction - The different EE's represent function bodies in different ways.
sys::Mutex lock
lock - This lock protects the ExecutionEngine and MCJIT classes.
static ExecutionEngine *(* InterpCtor)(std::unique_ptr< Module > M, std::string *ErrorStr)
virtual void runStaticConstructorsDestructors(bool isDtors)
runStaticConstructorsDestructors - This method is used to execute all of the static constructors or d...
static ExecutionEngine *(* MCJITCtor)(std::unique_ptr< Module > M, std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MM, std::shared_ptr< LegacyJITSymbolResolver > SR, std::unique_ptr< TargetMachine > TM)
void addGlobalMapping(const GlobalValue *GV, void *Addr)
addGlobalMapping - Tell the execution engine that the specified global is at the specified location.
SmallVector< std::unique_ptr< Module >, 1 > Modules
The list of Modules that we are JIT'ing from.
const GlobalValue * getGlobalValueAtAddress(void *Addr)
getGlobalValueAtAddress - Return the LLVM global value object that starts at the specified address.
ExecutionEngine(DataLayout DL)
void clearGlobalMappingsFromModule(Module *M)
clearGlobalMappingsFromModule - Clear all global mappings that came from a particular module,...
void * getPointerToGlobal(const GlobalValue *GV)
getPointerToGlobal - This returns the address of the specified global value.
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...
virtual void addObjectFile(std::unique_ptr< object::ObjectFile > O)
addObjectFile - Add an ObjectFile to the execution engine.
virtual void * getOrEmitGlobalVariable(const GlobalVariable *GV)
getOrEmitGlobalVariable - Return the address of the specified global variable, possibly emitting it t...
uint64_t getAddressToGlobalIfAvailable(StringRef S)
getAddressToGlobalIfAvailable - This returns the address of the specified global symbol.
void emitGlobalVariable(const GlobalVariable *GV)
virtual GlobalVariable * FindGlobalVariableNamed(StringRef Name, bool AllowInternal=false)
FindGlobalVariableNamed - Search all of the active modules to find the global variable that defines N...
virtual GenericValue runFunction(Function *F, ArrayRef< GenericValue > ArgValues)=0
runFunction - Execute the specified function with the specified arguments, and return the result.
void emitGlobals()
EmitGlobals - Emit all of the global variables to memory, storing their addresses into GlobalAddress.
void LoadValueFromMemory(GenericValue &Result, GenericValue *Ptr, Type *Ty)
FIXME: document.
uint64_t updateGlobalMapping(const GlobalValue *GV, void *Addr)
updateGlobalMapping - Replace an existing mapping for GV with a new address.
virtual char * getMemoryForGV(const GlobalVariable *GV)
getMemoryforGV - Allocate memory for a global variable.
virtual ~ExecutionEngine()
virtual Function * FindFunctionNamed(StringRef FnName)
FindFunctionNamed - Search all of the active modules to find the function that defines FnName.
Class to represent function types.
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
Type * getParamType(unsigned i) const
Parameter type accessors.
Type * getReturnType() const
FunctionType * getFunctionType() const
Returns the FunctionType for me.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
bool hasExternalLinkage() const
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
bool hasLocalLinkage() const
bool hasExternalWeakLinkage() const
Module * getParent()
Get the module that this global value is contained inside of...
PointerType * getType() const
Global values are always pointers.
bool hasAppendingLinkage() const
Type * getValueType() const
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
void dump() const
Debugging method that may be called through a debugger; just invokes print on stderr.
This is an important class for using LLVM in a threaded context.
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
A Module instance is used to store all the information related to an LLVM module.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef str() const
Explicit conversion to StringRef.
iterator find(StringRef Key)
StringRef - Represent a constant reference to a string, i.e.
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
TypeSize getElementOffset(unsigned Idx) const
Class to represent struct types.
@ HasZeroInit
zeroinitializer is valid for this target extension type.
Primary interface to the complete machine description for the target machine.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isX86_FP80Ty() const
Return true if this is x86 long double.
bool isPointerTy() const
True if this is an instance of PointerType.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
@ ScalableVectorTyID
Scalable SIMD vector type.
@ FloatTyID
32-bit floating point type
@ IntegerTyID
Arbitrary bit width integers.
@ FixedVectorTyID
Fixed width SIMD vector type.
@ DoubleTyID
64-bit floating point type
@ X86_FP80TyID
80-bit floating point type (X87)
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
@ FP128TyID
128-bit floating point type (112-bit significand)
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
bool isAggregateType() const
Return true if the type is an aggregate type.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
bool isIntegerTy() const
True if this is an instance of IntegerType.
TypeID getTypeID() const
Return the type id for the type.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
bool isVoidTy() const
Return true if this is 'void'.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
Type * getType() const
All values are typed, get the type of this value.
StringRef getName() const
Return a constant reference to the value's name.
A raw_ostream that writes to an SmallVector or SmallString.
static bool LoadLibraryPermanently(const char *Filename, std::string *ErrMsg=nullptr)
This function permanently loads the dynamic library at the given path.
static void * SearchForAddressOfSymbol(const char *symbolName)
This function will search through all previously loaded dynamic libraries for the symbol symbolName.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
APInt RoundFloatToAPInt(float Float, unsigned width)
Converts a float value into a APInt.
APInt RoundDoubleToAPInt(double Double, unsigned width)
Converts the given double value into a APInt.
@ C
The default llvm calling convention, compatible with C.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
const_iterator end(StringRef path)
Get end iterator over path.
static const bool IsLittleEndianHost
This is an optimization pass for GlobalISel generic memory operations.
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...
GenericValue PTOGV(void *P)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
CodeGenOptLevel
Code generation optimization level.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
constexpr unsigned BitWidth
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
void * GVTOP(const GenericValue &GV)
@ Default
The result values are uniform if and only if all operands are uniform.
void LoadIntFromMemory(APInt &IntVal, const uint8_t *Src, unsigned LoadBytes)
LoadIntFromMemory - Loads the integer stored in the LoadBytes bytes starting from Src into IntVal,...
Implement std::hash so that hash_code can be used in STL containers.
static constexpr roundingMode rmNearestTiesToEven
static constexpr roundingMode rmTowardZero
static const fltSemantics & x87DoubleExtended() LLVM_READNONE
std::vector< GenericValue > AggregateVal