diff options
Diffstat (limited to 'llvm/lib/ExecutionEngine/ExecutionEngine.cpp')
-rw-r--r-- | llvm/lib/ExecutionEngine/ExecutionEngine.cpp | 89 |
1 files changed, 50 insertions, 39 deletions
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp index ee7a7cb60bc98..d8bd671c66619 100644 --- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp @@ -9,6 +9,8 @@ // This file defines the common interface used by the various execution engine // subclasses. // +// FIXME: This file needs to be updated to support scalable vectors +// //===----------------------------------------------------------------------===// #include "llvm/ExecutionEngine/ExecutionEngine.h" @@ -108,7 +110,7 @@ public: Type *ElTy = GV->getValueType(); size_t GVSize = (size_t)TD.getTypeAllocSize(ElTy); void *RawMemory = ::operator new( - alignTo(sizeof(GVMemoryBlock), TD.getPreferredAlignment(GV)) + GVSize); + alignTo(sizeof(GVMemoryBlock), TD.getPreferredAlign(GV)) + GVSize); new(RawMemory) GVMemoryBlock(GV); return static_cast<char*>(RawMemory) + sizeof(GVMemoryBlock); } @@ -200,7 +202,7 @@ std::string ExecutionEngine::getMangledName(const GlobalValue *GV) { : GV->getParent()->getDataLayout(); Mangler::getNameWithPrefix(FullName, GV->getName(), DL); - return FullName.str(); + return std::string(FullName.str()); } void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) { @@ -223,7 +225,7 @@ void ExecutionEngine::addGlobalMapping(StringRef Name, uint64_t Addr) { std::string &V = EEState.getGlobalAddressReverseMap()[CurVal]; assert((!V.empty() || !Name.empty()) && "GlobalMapping already established!"); - V = Name; + V = std::string(Name); } } @@ -269,7 +271,7 @@ uint64_t ExecutionEngine::updateGlobalMapping(StringRef Name, uint64_t Addr) { std::string &V = EEState.getGlobalAddressReverseMap()[CurVal]; assert((!V.empty() || !Name.empty()) && "GlobalMapping already established!"); - V = Name; + V = std::string(Name); } return OldVal; } @@ -307,8 +309,8 @@ const GlobalValue *ExecutionEngine::getGlobalValueAtAddress(void *Addr) { E = EEState.getGlobalAddressMap().end(); I != E; ++I) { StringRef Name = I->first(); uint64_t Addr = I->second; - EEState.getGlobalAddressReverseMap().insert(std::make_pair( - Addr, Name)); + EEState.getGlobalAddressReverseMap().insert( + std::make_pair(Addr, std::string(Name))); } } @@ -582,7 +584,7 @@ void *ExecutionEngine::getPointerToGlobal(const GlobalValue *GV) { // Global variable might have been added since interpreter started. if (GlobalVariable *GVar = const_cast<GlobalVariable *>(dyn_cast<GlobalVariable>(GV))) - EmitGlobalVariable(GVar); + emitGlobalVariable(GVar); else llvm_unreachable("Global hasn't had an address allocated yet!"); @@ -624,17 +626,20 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) { } } break; - case Type::VectorTyID: - // if the whole vector is 'undef' just reserve memory for the value. - auto* VTy = cast<VectorType>(C->getType()); - Type *ElemTy = VTy->getElementType(); - unsigned int elemNum = VTy->getNumElements(); - Result.AggregateVal.resize(elemNum); - if (ElemTy->isIntegerTy()) - for (unsigned int i = 0; i < elemNum; ++i) - Result.AggregateVal[i].IntVal = - APInt(ElemTy->getPrimitiveSizeInBits(), 0); - break; + case Type::ScalableVectorTyID: + report_fatal_error( + "Scalable vector support not yet implemented in ExecutionEngine"); + case Type::FixedVectorTyID: + // if the whole vector is 'undef' just reserve memory for the value. + auto *VTy = cast<FixedVectorType>(C->getType()); + Type *ElemTy = VTy->getElementType(); + unsigned int elemNum = VTy->getNumElements(); + Result.AggregateVal.resize(elemNum); + if (ElemTy->isIntegerTy()) + for (unsigned int i = 0; i < elemNum; ++i) + Result.AggregateVal[i].IntVal = + APInt(ElemTy->getPrimitiveSizeInBits(), 0); + break; } return Result; } @@ -914,7 +919,10 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) { else llvm_unreachable("Unknown constant pointer type!"); break; - case Type::VectorTyID: { + case Type::ScalableVectorTyID: + report_fatal_error( + "Scalable vector support not yet implemented in ExecutionEngine"); + case Type::FixedVectorTyID: { unsigned elemNum; Type* ElemTy; const ConstantDataVector *CDV = dyn_cast<ConstantDataVector>(C); @@ -925,9 +933,9 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) { elemNum = CDV->getNumElements(); ElemTy = CDV->getElementType(); } else if (CV || CAZ) { - auto* VTy = cast<VectorType>(C->getType()); - elemNum = VTy->getNumElements(); - ElemTy = VTy->getElementType(); + auto *VTy = cast<FixedVectorType>(C->getType()); + elemNum = VTy->getNumElements(); + ElemTy = VTy->getElementType(); } else { llvm_unreachable("Unknown constant vector type!"); } @@ -1006,8 +1014,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) { break; } llvm_unreachable("Unknown constant pointer type!"); - } - break; + } break; default: SmallString<256> Msg; @@ -1046,7 +1053,8 @@ void ExecutionEngine::StoreValueToMemory(const GenericValue &Val, *((PointerTy*)Ptr) = Val.PointerVal; break; - case Type::VectorTyID: + case Type::FixedVectorTyID: + case Type::ScalableVectorTyID: for (unsigned i = 0; i < Val.AggregateVal.size(); ++i) { if (cast<VectorType>(Ty)->getElementType()->isDoubleTy()) *(((double*)Ptr)+i) = Val.AggregateVal[i].DoubleVal; @@ -1096,8 +1104,11 @@ void ExecutionEngine::LoadValueFromMemory(GenericValue &Result, Result.IntVal = APInt(80, y); break; } - case Type::VectorTyID: { - auto *VT = cast<VectorType>(Ty); + case Type::ScalableVectorTyID: + report_fatal_error( + "Scalable vector support not yet implemented in ExecutionEngine"); + case Type::FixedVectorTyID: { + auto *VT = cast<FixedVectorType>(Ty); Type *ElemT = VT->getElementType(); const unsigned numElems = VT->getNumElements(); if (ElemT->isFloatTy()) { @@ -1200,8 +1211,8 @@ void ExecutionEngine::emitGlobals() { GV.hasAppendingLinkage() || !GV.hasName()) continue;// Ignore external globals and globals with internal linkage. - const GlobalValue *&GVEntry = - LinkedGlobalsMap[std::make_pair(GV.getName(), GV.getType())]; + const GlobalValue *&GVEntry = LinkedGlobalsMap[std::make_pair( + std::string(GV.getName()), GV.getType())]; // If this is the first time we've seen this global, it is the canonical // version. @@ -1228,8 +1239,8 @@ void ExecutionEngine::emitGlobals() { for (const auto &GV : M.globals()) { // In the multi-module case, see what this global maps to. if (!LinkedGlobalsMap.empty()) { - if (const GlobalValue *GVEntry = - LinkedGlobalsMap[std::make_pair(GV.getName(), GV.getType())]) { + if (const GlobalValue *GVEntry = LinkedGlobalsMap[std::make_pair( + std::string(GV.getName()), GV.getType())]) { // If something else is the canonical global, ignore this one. if (GVEntry != &GV) { NonCanonicalGlobals.push_back(&GV); @@ -1243,8 +1254,8 @@ void ExecutionEngine::emitGlobals() { } else { // External variable reference. Try to use the dynamic loader to // get a pointer to it. - if (void *SymAddr = - sys::DynamicLibrary::SearchForAddressOfSymbol(GV.getName())) + if (void *SymAddr = sys::DynamicLibrary::SearchForAddressOfSymbol( + std::string(GV.getName()))) addGlobalMapping(&GV, SymAddr); else { report_fatal_error("Could not resolve external global address: " @@ -1258,8 +1269,8 @@ void ExecutionEngine::emitGlobals() { if (!NonCanonicalGlobals.empty()) { for (unsigned i = 0, e = NonCanonicalGlobals.size(); i != e; ++i) { const GlobalValue *GV = NonCanonicalGlobals[i]; - const GlobalValue *CGV = - LinkedGlobalsMap[std::make_pair(GV->getName(), GV->getType())]; + const GlobalValue *CGV = LinkedGlobalsMap[std::make_pair( + std::string(GV->getName()), GV->getType())]; void *Ptr = getPointerToGlobalIfAvailable(CGV); assert(Ptr && "Canonical global wasn't codegen'd!"); addGlobalMapping(GV, Ptr); @@ -1271,12 +1282,12 @@ void ExecutionEngine::emitGlobals() { for (const auto &GV : M.globals()) { if (!GV.isDeclaration()) { if (!LinkedGlobalsMap.empty()) { - if (const GlobalValue *GVEntry = - LinkedGlobalsMap[std::make_pair(GV.getName(), GV.getType())]) + if (const GlobalValue *GVEntry = LinkedGlobalsMap[std::make_pair( + std::string(GV.getName()), GV.getType())]) if (GVEntry != &GV) // Not the canonical variable. continue; } - EmitGlobalVariable(&GV); + emitGlobalVariable(&GV); } } } @@ -1285,7 +1296,7 @@ void ExecutionEngine::emitGlobals() { // EmitGlobalVariable - This method emits the specified global variable to the // address specified in GlobalAddresses, or allocates new memory if it's not // already in the map. -void ExecutionEngine::EmitGlobalVariable(const GlobalVariable *GV) { +void ExecutionEngine::emitGlobalVariable(const GlobalVariable *GV) { void *GA = getPointerToGlobalIfAvailable(GV); if (!GA) { |