Lines Matching refs:GV
98 GVMemoryBlock(const GlobalVariable *GV) in GVMemoryBlock() argument
99 : CallbackVH(const_cast<GlobalVariable*>(GV)) {} in GVMemoryBlock()
104 static char *Create(const GlobalVariable *GV, const DataLayout& TD) { in Create() argument
105 Type *ElTy = GV->getValueType(); in Create()
108 alignTo(sizeof(GVMemoryBlock), TD.getPreferredAlign(GV)) + GVSize); in Create()
109 new(RawMemory) GVMemoryBlock(GV); in Create()
123 char *ExecutionEngine::getMemoryForGV(const GlobalVariable *GV) { in getMemoryForGV() argument
124 return GVMemoryBlock::Create(GV, getDataLayout()); in getMemoryForGV()
164 GlobalVariable *GV = M->getGlobalVariable(Name, AllowInternal); in FindGlobalVariableNamed() local
165 if (GV && !GV->isDeclaration()) in FindGlobalVariableNamed()
166 return GV; in FindGlobalVariableNamed()
188 std::string ExecutionEngine::getMangledName(const GlobalValue *GV) { in getMangledName() argument
189 assert(GV->hasName() && "Global must have name."); in getMangledName()
195 GV->getDataLayout().isDefault() in getMangledName()
197 : GV->getDataLayout(); in getMangledName()
199 Mangler::getNameWithPrefix(FullName, GV->getName(), DL); in getMangledName()
203 void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) { in addGlobalMapping() argument
205 addGlobalMapping(getMangledName(GV), (uint64_t) Addr); in addGlobalMapping()
241 uint64_t ExecutionEngine::updateGlobalMapping(const GlobalValue *GV, in updateGlobalMapping() argument
244 return updateGlobalMapping(getMangledName(GV), (uint64_t) Addr); in updateGlobalMapping()
292 void *ExecutionEngine::getPointerToGlobalIfAvailable(const GlobalValue *GV) { in getPointerToGlobalIfAvailable() argument
294 return getPointerToGlobalIfAvailable(getMangledName(GV)); in getPointerToGlobalIfAvailable()
318 if (GlobalValue *GV = M->getNamedValue(Name)) in getGlobalValueAtAddress() local
319 return GV; in getGlobalValueAtAddress()
370 GlobalVariable *GV = module.getNamedGlobal(Name); in runStaticConstructorsDestructors() local
376 if (!GV || GV->isDeclaration() || GV->hasLocalLinkage()) return; in runStaticConstructorsDestructors()
380 ConstantArray *InitList = dyn_cast<ConstantArray>(GV->getInitializer()); in runStaticConstructorsDestructors()
565 void *ExecutionEngine::getPointerToGlobal(const GlobalValue *GV) { in getPointerToGlobal() argument
566 if (Function *F = const_cast<Function*>(dyn_cast<Function>(GV))) in getPointerToGlobal()
570 if (void* P = getPointerToGlobalIfAvailable(GV)) in getPointerToGlobal()
575 const_cast<GlobalVariable *>(dyn_cast<GlobalVariable>(GV))) in getPointerToGlobal()
580 return getPointerToGlobalIfAvailable(GV); in getPointerToGlobal()
663 GenericValue GV = getConstantValue(Op0); in getConstantValue() local
665 GV.IntVal = GV.IntVal.trunc(BitWidth); in getConstantValue()
666 return GV; in getConstantValue()
669 GenericValue GV = getConstantValue(Op0); in getConstantValue() local
671 GV.IntVal = GV.IntVal.zext(BitWidth); in getConstantValue()
672 return GV; in getConstantValue()
675 GenericValue GV = getConstantValue(Op0); in getConstantValue() local
677 GV.IntVal = GV.IntVal.sext(BitWidth); in getConstantValue()
678 return GV; in getConstantValue()
682 GenericValue GV = getConstantValue(Op0); in getConstantValue() local
683 GV.FloatVal = float(GV.DoubleVal); in getConstantValue()
684 return GV; in getConstantValue()
688 GenericValue GV = getConstantValue(Op0); in getConstantValue() local
689 GV.DoubleVal = double(GV.FloatVal); in getConstantValue()
690 return GV; in getConstantValue()
693 GenericValue GV = getConstantValue(Op0); in getConstantValue() local
695 GV.FloatVal = float(GV.IntVal.roundToDouble()); in getConstantValue()
697 GV.DoubleVal = GV.IntVal.roundToDouble(); in getConstantValue()
700 (void)apf.convertFromAPInt(GV.IntVal, in getConstantValue()
703 GV.IntVal = apf.bitcastToAPInt(); in getConstantValue()
705 return GV; in getConstantValue()
708 GenericValue GV = getConstantValue(Op0); in getConstantValue() local
710 GV.FloatVal = float(GV.IntVal.signedRoundToDouble()); in getConstantValue()
712 GV.DoubleVal = GV.IntVal.signedRoundToDouble(); in getConstantValue()
715 (void)apf.convertFromAPInt(GV.IntVal, in getConstantValue()
718 GV.IntVal = apf.bitcastToAPInt(); in getConstantValue()
720 return GV; in getConstantValue()
724 GenericValue GV = getConstantValue(Op0); in getConstantValue() local
727 GV.IntVal = APIntOps::RoundFloatToAPInt(GV.FloatVal, BitWidth); in getConstantValue()
729 GV.IntVal = APIntOps::RoundDoubleToAPInt(GV.DoubleVal, BitWidth); in getConstantValue()
731 APFloat apf = APFloat(APFloat::x87DoubleExtended(), GV.IntVal); in getConstantValue()
737 GV.IntVal = v; // endian? in getConstantValue()
739 return GV; in getConstantValue()
742 GenericValue GV = getConstantValue(Op0); in getConstantValue() local
745 GV.IntVal = APInt(PtrWidth, uintptr_t(GV.PointerVal)); in getConstantValue()
747 GV.IntVal = GV.IntVal.zextOrTrunc(IntWidth); in getConstantValue()
748 return GV; in getConstantValue()
751 GenericValue GV = getConstantValue(Op0); in getConstantValue() local
753 GV.IntVal = GV.IntVal.zextOrTrunc(PtrWidth); in getConstantValue()
754 assert(GV.IntVal.getBitWidth() <= 64 && "Bad pointer width"); in getConstantValue()
755 GV.PointerVal = PointerTy(uintptr_t(GV.IntVal.getZExtValue())); in getConstantValue()
756 return GV; in getConstantValue()
759 GenericValue GV = getConstantValue(Op0); in getConstantValue() local
766 GV.FloatVal = GV.IntVal.bitsToFloat(); in getConstantValue()
768 GV.DoubleVal = GV.IntVal.bitsToDouble(); in getConstantValue()
772 GV.IntVal = APInt::floatToBits(GV.FloatVal); in getConstantValue()
776 GV.IntVal = APInt::doubleToBits(GV.DoubleVal); in getConstantValue()
782 return GV; in getConstantValue()
799 GenericValue GV; in getConstantValue() local
805 case Instruction::Add: GV.IntVal = LHS.IntVal + RHS.IntVal; break; in getConstantValue()
806 case Instruction::Sub: GV.IntVal = LHS.IntVal - RHS.IntVal; break; in getConstantValue()
807 case Instruction::Mul: GV.IntVal = LHS.IntVal * RHS.IntVal; break; in getConstantValue()
808 case Instruction::UDiv:GV.IntVal = LHS.IntVal.udiv(RHS.IntVal); break; in getConstantValue()
809 case Instruction::SDiv:GV.IntVal = LHS.IntVal.sdiv(RHS.IntVal); break; in getConstantValue()
810 case Instruction::URem:GV.IntVal = LHS.IntVal.urem(RHS.IntVal); break; in getConstantValue()
811 case Instruction::SRem:GV.IntVal = LHS.IntVal.srem(RHS.IntVal); break; in getConstantValue()
812 case Instruction::And: GV.IntVal = LHS.IntVal & RHS.IntVal; break; in getConstantValue()
813 case Instruction::Or: GV.IntVal = LHS.IntVal | RHS.IntVal; break; in getConstantValue()
814 case Instruction::Xor: GV.IntVal = LHS.IntVal ^ RHS.IntVal; break; in getConstantValue()
821 GV.FloatVal = LHS.FloatVal + RHS.FloatVal; break; in getConstantValue()
823 GV.FloatVal = LHS.FloatVal - RHS.FloatVal; break; in getConstantValue()
825 GV.FloatVal = LHS.FloatVal * RHS.FloatVal; break; in getConstantValue()
827 GV.FloatVal = LHS.FloatVal / RHS.FloatVal; break; in getConstantValue()
829 GV.FloatVal = std::fmod(LHS.FloatVal,RHS.FloatVal); break; in getConstantValue()
836 GV.DoubleVal = LHS.DoubleVal + RHS.DoubleVal; break; in getConstantValue()
838 GV.DoubleVal = LHS.DoubleVal - RHS.DoubleVal; break; in getConstantValue()
840 GV.DoubleVal = LHS.DoubleVal * RHS.DoubleVal; break; in getConstantValue()
842 GV.DoubleVal = LHS.DoubleVal / RHS.DoubleVal; break; in getConstantValue()
844 GV.DoubleVal = std::fmod(LHS.DoubleVal,RHS.DoubleVal); break; in getConstantValue()
856 GV.IntVal = apfLHS.bitcastToAPInt(); in getConstantValue()
861 GV.IntVal = apfLHS.bitcastToAPInt(); in getConstantValue()
866 GV.IntVal = apfLHS.bitcastToAPInt(); in getConstantValue()
871 GV.IntVal = apfLHS.bitcastToAPInt(); in getConstantValue()
875 GV.IntVal = apfLHS.bitcastToAPInt(); in getConstantValue()
881 return GV; in getConstantValue()
924 else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) in getConstantValue() local
925 Result = PTOGV(getOrEmitGlobalVariable(const_cast<GlobalVariable*>(GV))); in getConstantValue()
1223 for (const auto &GV : M->globals()) { in emitGlobals() local
1224 if (GV.hasLocalLinkage() || GV.isDeclaration() || in emitGlobals()
1225 GV.hasAppendingLinkage() || !GV.hasName()) in emitGlobals()
1229 std::string(GV.getName()), GV.getType())]; in emitGlobals()
1234 GVEntry = &GV; in emitGlobals()
1244 if (GV.hasExternalLinkage() || GVEntry->hasExternalWeakLinkage()) in emitGlobals()
1245 GVEntry = &GV; in emitGlobals()
1252 for (const auto &GV : M->globals()) { in emitGlobals() local
1256 std::string(GV.getName()), GV.getType())]) { in emitGlobals()
1258 if (GVEntry != &GV) { in emitGlobals()
1259 NonCanonicalGlobals.push_back(&GV); in emitGlobals()
1265 if (!GV.isDeclaration()) { in emitGlobals()
1266 addGlobalMapping(&GV, getMemoryForGV(&GV)); in emitGlobals()
1271 std::string(GV.getName()))) in emitGlobals()
1272 addGlobalMapping(&GV, SymAddr); in emitGlobals()
1275 +GV.getName()); in emitGlobals()
1283 for (const GlobalValue *GV : NonCanonicalGlobals) { in emitGlobals() local
1285 std::string(GV->getName()), GV->getType())]; in emitGlobals()
1288 addGlobalMapping(GV, Ptr); in emitGlobals()
1294 for (const auto &GV : M->globals()) { in emitGlobals() local
1295 if (!GV.isDeclaration()) { in emitGlobals()
1298 std::string(GV.getName()), GV.getType())]) in emitGlobals()
1299 if (GVEntry != &GV) // Not the canonical variable. in emitGlobals()
1302 emitGlobalVariable(&GV); in emitGlobals()
1311 void ExecutionEngine::emitGlobalVariable(const GlobalVariable *GV) { in emitGlobalVariable() argument
1312 void *GA = getPointerToGlobalIfAvailable(GV); in emitGlobalVariable()
1316 GA = getMemoryForGV(GV); in emitGlobalVariable()
1321 addGlobalMapping(GV, GA); in emitGlobalVariable()
1325 if (!GV->isThreadLocal()) in emitGlobalVariable()
1326 InitializeMemory(GV->getInitializer(), GA); in emitGlobalVariable()
1328 Type *ElTy = GV->getValueType(); in emitGlobalVariable()