Lines Matching refs:GV
89 GVMemoryBlock(const GlobalVariable *GV)
90 : CallbackVH(const_cast<GlobalVariable*>(GV)) {}
95 static char *Create(const GlobalVariable *GV, const DataLayout& TD) {
96 Type *ElTy = GV->getType()->getElementType();
100 TD.getPreferredAlignment(GV))
102 new(RawMemory) GVMemoryBlock(GV);
116 char *ExecutionEngine::getMemoryForGV(const GlobalVariable *GV) {
117 return GVMemoryBlock::Create(GV, *getDataLayout());
160 void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) {
163 DEBUG(dbgs() << "JIT: Map \'" << GV->getName()
165 void *&CurVal = EEState.getGlobalAddressMap(locked)[GV];
173 assert((V == 0 || GV == 0) && "GlobalMapping already established!");
174 V = GV;
195 void *ExecutionEngine::updateGlobalMapping(const GlobalValue *GV, void *Addr) {
203 return EEState.RemoveMapping(locked, GV);
205 void *&CurVal = Map[GV];
216 assert((V == 0 || GV == 0) && "GlobalMapping already established!");
217 V = GV;
222 void *ExecutionEngine::getPointerToGlobalIfAvailable(const GlobalValue *GV) {
226 EEState.getGlobalAddressMap(locked).find(GV);
301 GlobalVariable *GV = module->getNamedGlobal(Name);
307 if (!GV || GV->isDeclaration() || GV->hasLocalLinkage()) return;
311 ConstantArray *InitList = dyn_cast<ConstantArray>(GV->getInitializer());
524 void *ExecutionEngine::getPointerToGlobal(const GlobalValue *GV) {
525 if (Function *F = const_cast<Function*>(dyn_cast<Function>(GV)))
529 if (void *P = EEState.getGlobalAddressMap(locked)[GV])
534 const_cast<GlobalVariable *>(dyn_cast<GlobalVariable>(GV)))
539 return EEState.getGlobalAddressMap(locked)[GV];
589 GenericValue GV = getConstantValue(Op0);
591 GV.IntVal = GV.IntVal.trunc(BitWidth);
592 return GV;
595 GenericValue GV = getConstantValue(Op0);
597 GV.IntVal = GV.IntVal.zext(BitWidth);
598 return GV;
601 GenericValue GV = getConstantValue(Op0);
603 GV.IntVal = GV.IntVal.sext(BitWidth);
604 return GV;
608 GenericValue GV = getConstantValue(Op0);
609 GV.FloatVal = float(GV.DoubleVal);
610 return GV;
614 GenericValue GV = getConstantValue(Op0);
615 GV.DoubleVal = double(GV.FloatVal);
616 return GV;
619 GenericValue GV = getConstantValue(Op0);
621 GV.FloatVal = float(GV.IntVal.roundToDouble());
623 GV.DoubleVal = GV.IntVal.roundToDouble();
626 (void)apf.convertFromAPInt(GV.IntVal,
629 GV.IntVal = apf.bitcastToAPInt();
631 return GV;
634 GenericValue GV = getConstantValue(Op0);
636 GV.FloatVal = float(GV.IntVal.signedRoundToDouble());
638 GV.DoubleVal = GV.IntVal.signedRoundToDouble();
641 (void)apf.convertFromAPInt(GV.IntVal,
644 GV.IntVal = apf.bitcastToAPInt();
646 return GV;
650 GenericValue GV = getConstantValue(Op0);
653 GV.IntVal = APIntOps::RoundFloatToAPInt(GV.FloatVal, BitWidth);
655 GV.IntVal = APIntOps::RoundDoubleToAPInt(GV.DoubleVal, BitWidth);
657 APFloat apf = APFloat(APFloat::x87DoubleExtended, GV.IntVal);
663 GV.IntVal = v; // endian?
665 return GV;
668 GenericValue GV = getConstantValue(Op0);
671 GV.IntVal = APInt(PtrWidth, uintptr_t(GV.PointerVal));
673 GV.IntVal = GV.IntVal.zextOrTrunc(IntWidth);
674 return GV;
677 GenericValue GV = getConstantValue(Op0);
679 GV.IntVal = GV.IntVal.zextOrTrunc(PtrWidth);
680 assert(GV.IntVal.getBitWidth() <= 64 && "Bad pointer width");
681 GV.PointerVal = PointerTy(uintptr_t(GV.IntVal.getZExtValue()));
682 return GV;
685 GenericValue GV = getConstantValue(Op0);
692 GV.FloatVal = GV.IntVal.bitsToFloat();
694 GV.DoubleVal = GV.IntVal.bitsToDouble();
698 GV.IntVal = APInt::floatToBits(GV.FloatVal);
702 GV.IntVal = APInt::doubleToBits(GV.DoubleVal);
708 return GV;
725 GenericValue GV;
731 case Instruction::Add: GV.IntVal = LHS.IntVal + RHS.IntVal; break;
732 case Instruction::Sub: GV.IntVal = LHS.IntVal - RHS.IntVal; break;
733 case Instruction::Mul: GV.IntVal = LHS.IntVal * RHS.IntVal; break;
734 case Instruction::UDiv:GV.IntVal = LHS.IntVal.udiv(RHS.IntVal); break;
735 case Instruction::SDiv:GV.IntVal = LHS.IntVal.sdiv(RHS.IntVal); break;
736 case Instruction::URem:GV.IntVal = LHS.IntVal.urem(RHS.IntVal); break;
737 case Instruction::SRem:GV.IntVal = LHS.IntVal.srem(RHS.IntVal); break;
738 case Instruction::And: GV.IntVal = LHS.IntVal & RHS.IntVal; break;
739 case Instruction::Or: GV.IntVal = LHS.IntVal | RHS.IntVal; break;
740 case Instruction::Xor: GV.IntVal = LHS.IntVal ^ RHS.IntVal; break;
747 GV.FloatVal = LHS.FloatVal + RHS.FloatVal; break;
749 GV.FloatVal = LHS.FloatVal - RHS.FloatVal; break;
751 GV.FloatVal = LHS.FloatVal * RHS.FloatVal; break;
753 GV.FloatVal = LHS.FloatVal / RHS.FloatVal; break;
755 GV.FloatVal = std::fmod(LHS.FloatVal,RHS.FloatVal); break;
762 GV.DoubleVal = LHS.DoubleVal + RHS.DoubleVal; break;
764 GV.DoubleVal = LHS.DoubleVal - RHS.DoubleVal; break;
766 GV.DoubleVal = LHS.DoubleVal * RHS.DoubleVal; break;
768 GV.DoubleVal = LHS.DoubleVal / RHS.DoubleVal; break;
770 GV.DoubleVal = std::fmod(LHS.DoubleVal,RHS.DoubleVal); break;
782 GV.IntVal = apfLHS.bitcastToAPInt();
787 GV.IntVal = apfLHS.bitcastToAPInt();
792 GV.IntVal = apfLHS.bitcastToAPInt();
797 GV.IntVal = apfLHS.bitcastToAPInt();
802 GV.IntVal = apfLHS.bitcastToAPInt();
808 return GV;
842 else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
843 Result = PTOGV(getOrEmitGlobalVariable(const_cast<GlobalVariable*>(GV)));
1186 const GlobalValue *GV = I;
1187 if (GV->hasLocalLinkage() || GV->isDeclaration() ||
1188 GV->hasAppendingLinkage() || !GV->hasName())
1192 LinkedGlobalsMap[std::make_pair(GV->getName(), GV->getType())];
1197 GVEntry = GV;
1209 if (GV->hasExternalLinkage() || GVEntry->hasExternalWeakLinkage())
1210 GVEntry = GV;
1251 const GlobalValue *GV = NonCanonicalGlobals[i];
1253 LinkedGlobalsMap[std::make_pair(GV->getName(), GV->getType())];
1256 addGlobalMapping(GV, Ptr);
1280 void ExecutionEngine::EmitGlobalVariable(const GlobalVariable *GV) {
1281 void *GA = getPointerToGlobalIfAvailable(GV);
1285 GA = getMemoryForGV(GV);
1286 addGlobalMapping(GV, GA);
1290 if (!GV->isThreadLocal())
1291 InitializeMemory(GV->getInitializer(), GA);
1293 Type *ElTy = GV->getType()->getElementType();