Home | History | Annotate | Download | only in VMCore

Lines Matching refs:Ty

81 Constant *Constant::getNullValue(Type *Ty) {
82 switch (Ty->getTypeID()) {
84 return ConstantInt::get(Ty, 0);
86 return ConstantFP::get(Ty->getContext(),
89 return ConstantFP::get(Ty->getContext(),
92 return ConstantFP::get(Ty->getContext(),
95 return ConstantFP::get(Ty->getContext(),
98 return ConstantFP::get(Ty->getContext(),
101 return ConstantPointerNull::get(cast<PointerType>(Ty));
105 return ConstantAggregateZero::get(Ty);
113 Constant *Constant::getIntegerValue(Type *Ty, const APInt &V) {
114 Type *ScalarTy = Ty->getScalarType();
117 Constant *C = ConstantInt::get(Ty->getContext(), V);
124 if (VectorType *VTy = dyn_cast<VectorType>(Ty))
130 Constant *Constant::getAllOnesValue(Type *Ty) {
131 if (IntegerType *ITy = dyn_cast<IntegerType>(Ty))
132 return ConstantInt::get(Ty->getContext(),
135 if (Ty->isFloatingPointTy()) {
136 APFloat FL = APFloat::getAllOnesValue(Ty->getPrimitiveSizeInBits(),
137 !Ty->isPPC_FP128Ty());
138 return ConstantFP::get(Ty->getContext(), FL);
142 VectorType *VTy = cast<VectorType>(Ty);
361 ConstantInt::ConstantInt(IntegerType *Ty, const APInt& V)
362 : Constant(Ty, ConstantIntVal, 0, 0), Val(V) {
363 assert(V.getBitWidth() == Ty->getBitWidth() && "Invalid constant for type");
380 Constant *ConstantInt::getTrue(Type *Ty) {
381 VectorType *VTy = dyn_cast<VectorType>(Ty);
383 assert(Ty->isIntegerTy(1) && "True must be i1 or vector of i1.");
384 return ConstantInt::getTrue(Ty->getContext());
389 ConstantInt::getTrue(Ty->getContext()));
393 Constant *ConstantInt::getFalse(Type *Ty) {
394 VectorType *VTy = dyn_cast<VectorType>(Ty);
396 assert(Ty->isIntegerTy(1) && "False must be i1 or vector of i1.");
397 return ConstantInt::getFalse(Ty->getContext());
402 ConstantInt::getFalse(Ty->getContext()));
422 Constant *ConstantInt::get(Type *Ty, uint64_t V, bool isSigned) {
423 Constant *C = get(cast<IntegerType>(Ty->getScalarType()), V, isSigned);
426 if (VectorType *VTy = dyn_cast<VectorType>(Ty))
433 ConstantInt* ConstantInt::get(IntegerType* Ty, uint64_t V,
435 return get(Ty->getContext(), APInt(Ty->getBitWidth(), V, isSigned));
438 ConstantInt* ConstantInt::getSigned(IntegerType* Ty, int64_t V) {
439 return get(Ty, V, true);
442 Constant *ConstantInt::getSigned(Type *Ty, int64_t V) {
443 return get(Ty, V, true);
446 Constant *ConstantInt::get(Type* Ty, const APInt& V) {
447 ConstantInt *C = get(Ty->getContext(), V);
448 assert(C->getType() == Ty->getScalarType() &&
452 if (VectorType *VTy = dyn_cast<VectorType>(Ty))
459 ConstantInt* ConstantInt::get(IntegerType* Ty, StringRef Str,
461 return get(Ty->getContext(), APInt(Ty->getBitWidth(), Str, radix));
468 static const fltSemantics *TypeToFloatSemantics(Type *Ty) {
469 if (Ty->isFloatTy())
471 if (Ty->isDoubleTy())
473 if (Ty->isX86_FP80Ty())
475 else if (Ty->isFP128Ty())
478 assert(Ty->isPPC_FP128Ty() && "Unknown FP format");
485 Constant *ConstantFP::get(Type* Ty, double V) {
486 LLVMContext &Context = Ty->getContext();
490 FV.convert(*TypeToFloatSemantics(Ty->getScalarType()),
495 if (VectorType *VTy = dyn_cast<VectorType>(Ty))
503 Constant *ConstantFP::get(Type* Ty, StringRef Str) {
504 LLVMContext &Context = Ty->getContext();
506 APFloat FV(*TypeToFloatSemantics(Ty->getScalarType()), Str);
510 if (VectorType *VTy = dyn_cast<VectorType>(Ty))
518 ConstantFP* ConstantFP::getNegativeZero(Type* Ty) {
519 LLVMContext &Context = Ty->getContext();
520 APFloat apf = cast <ConstantFP>(Constant::getNullValue(Ty))->getValueAPF();
526 Constant *ConstantFP::getZeroValueForNegation(Type* Ty) {
527 if (VectorType *PTy = dyn_cast<VectorType>(Ty))
534 if (Ty->isFloatingPointTy())
535 return getNegativeZero(Ty);
537 return Constant::getNullValue(Ty);
550 Type *Ty;
552 Ty = Type::getFloatTy(Context);
554 Ty = Type::getDoubleTy(Context);
556 Ty = Type::getX86_FP80Ty(Context);
558 Ty = Type::getFP128Ty(Context);
562 Ty = Type::getPPC_FP128Ty(Context);
564 Slot = new ConstantFP(Ty, V);
570 ConstantFP *ConstantFP::getInfinity(Type *Ty, bool Negative) {
571 const fltSemantics &Semantics = *TypeToFloatSemantics(Ty);
572 return ConstantFP::get(Ty->getContext(),
576 ConstantFP::ConstantFP(Type *Ty, const APFloat& V)
577 : Constant(Ty, ConstantFPVal, 0, 0), Val(V) {
578 assert(&V.getSemantics() == TypeToFloatSemantics(Ty) &&
603 Constant *ConstantArray::get(ArrayType *Ty, ArrayRef<Constant*> V) {
605 assert(V[i]->getType() == Ty->getElementType() &&
608 LLVMContextImpl *pImpl = Ty->getContext().pImpl;
613 return pImpl->ArrayConstants.getOrCreate(Ty, V);
617 return pImpl->ArrayConstants.getOrCreate(Ty, V);
620 return ConstantAggregateZero::get(Ty);
862 getWithOperands(ArrayRef<Constant*> Ops, Type *Ty) const {
864 bool AnyChange = Ty != getType();
884 return ConstantExpr::getCast(getOpcode(), Ops[0], Ty);
910 bool ConstantInt::isValueValidForType(Type *Ty, uint64_t Val) {
911 unsigned NumBits = cast<IntegerType>(Ty)->getBitWidth(); // assert okay
912 if (Ty == Type::getInt1Ty(Ty->getContext()))
920 bool ConstantInt::isValueValidForType(Type *Ty, int64_t Val) {
921 Ty)->getBitWidth(); // assert okay
922 if (Ty == Type::getInt1Ty(Ty->getContext()))
931 bool ConstantFP::isValueValidForType(Type *Ty, const APFloat& Val) {
935 switch (Ty->getTypeID()) {
971 ConstantAggregateZero* ConstantAggregateZero::get(Type* Ty) {
972 assert((Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()) &&
975 LLVMContextImpl *pImpl = Ty->getContext().pImpl;
976 return pImpl->AggZeroConstants.getOrCreate(Ty, 0);
1109 ConstantPointerNull *ConstantPointerNull::get(PointerType *Ty) {
1110 return Ty->getContext().pImpl->NullPtrConstants.getOrCreate(Ty, 0);
1124 UndefValue *UndefValue::get(Type *Ty) {
1125 return Ty->getContext().pImpl->UndefValueConstants.getOrCreate(Ty, 0);
1215 Instruction::CastOps opc, Constant *C, Type *Ty) {
1216 assert(Ty->isFirstClassType() && "Cannot cast to an aggregate type!");
1218 if (Constant *FC = ConstantFoldCastInstruction(opc, C, Ty))
1221 LLVMContextImpl *pImpl = Ty->getContext().pImpl;
1227 return pImpl->ExprConstants.getOrCreate(Ty, Key);
1230 Constant *ConstantExpr::getCast(unsigned oc, Constant *C, Type *Ty) {
1233 assert(C && Ty && "Null arguments to getCast");
1234 assert(CastInst::castIsValid(opc, C, Ty) && "Invalid constantexpr cast!");
1240 case Instruction::Trunc: return getTrunc(C, Ty);
1241 case Instruction::ZExt: return getZExt(C, Ty);
1242 case Instruction::SExt: return getSExt(C, Ty);
1243 case Instruction::FPTrunc: return getFPTrunc(C, Ty);
1244 case Instruction::FPExt: return getFPExtend(C, Ty);
1245 case Instruction::UIToFP: return getUIToFP(C, Ty);
1246 case Instruction::SIToFP: return getSIToFP(C, Ty);
1247 case Instruction::FPToUI: return getFPToUI(C, Ty);
1248 case Instruction::FPToSI: return getFPToSI(C, Ty);
1249 case Instruction::PtrToInt: return getPtrToInt(C, Ty);
1250 case Instruction::IntToPtr: return getIntToPtr(C, Ty);
1251 case Instruction::BitCast: return getBitCast(C, Ty);
1256 Constant *ConstantExpr::getZExtOrBitCast(Constant *C, Type *Ty) {
1257 if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
1258 return getBitCast(C, Ty);
1259 return getZExt(C, Ty);
1262 Constant *ConstantExpr::getSExtOrBitCast(Constant *C, Type *Ty) {
1263 if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
1264 return getBitCast(C, Ty);
1265 return getSExt(C, Ty);
1268 Constant *ConstantExpr::getTruncOrBitCast(Constant *C, Type *Ty) {
1269 if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
1270 return getBitCast(C, Ty);
1271 return getTrunc(C, Ty);
1274 Constant *ConstantExpr::getPointerCast(Constant *S, Type *Ty) {
1276 assert((Ty->isIntegerTy() || Ty->isPointerTy()) && "Invalid cast");
1278 if (Ty->isIntegerTy())
1279 return getPtrToInt(S, Ty);
1280 return getBitCast(S, Ty);
1283 Constant *ConstantExpr::getIntegerCast(Constant *C, Type *Ty,
1286 Ty->isIntOrIntVectorTy() && "Invalid cast");
1288 unsigned DstBits = Ty->getScalarSizeInBits();
1293 return getCast(opcode, C, Ty);
1296 Constant *ConstantExpr::getFPCast(Constant *C, Type *Ty) {
1297 assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() &&
1300 unsigned DstBits = Ty->getScalarSizeInBits();
1305 return getCast(opcode, C, Ty);
1308 Constant *ConstantExpr::getTrunc(Constant *C, Type *Ty) {
1311 bool toVec = Ty->getTypeID() == Type::VectorTyID;
1315 assert(Ty->isIntOrIntVectorTy() && "Trunc produces only integral");
1316 assert(C->getType()->getScalarSizeInBits() > Ty->getScalarSizeInBits()&&
1319 return getFoldedCast(Instruction::Trunc, C, Ty);
1322 Constant *ConstantExpr::getSExt(Constant *C, Type *Ty) {
1325 bool toVec = Ty->getTypeID() == Type::VectorTyID;
1329 assert(Ty->isIntOrIntVectorTy() && "SExt produces only integer");
1330 assert(C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&&
1333 return getFoldedCast(Instruction::SExt, C, Ty);
1336 Constant *ConstantExpr::getZExt(Constant *C, Type *Ty) {
1339 bool toVec = Ty->getTypeID() == Type::VectorTyID;
1343 assert(Ty->isIntOrIntVectorTy() && "ZExt produces only integer");
1344 assert(C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&&
1347 return getFoldedCast(Instruction::ZExt, C, Ty);
1350 Constant *ConstantExpr::getFPTrunc(Constant *C, Type *Ty) {
1353 bool toVec = Ty->getTypeID() == Type::VectorTyID;
1356 assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() &&
1357 C->getType()->getScalarSizeInBits() > Ty->getScalarSizeInBits()&&
1359 return getFoldedCast(Instruction::FPTrunc, C, Ty);
1362 Constant *ConstantExpr::getFPExtend(Constant *C, Type *Ty) {
1365 bool toVec = Ty->getTypeID() == Type::VectorTyID;
1368 assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() &&
1369 C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&&
1371 return getFoldedCast(Instruction::FPExt, C, Ty);
1374 Constant *ConstantExpr::getUIToFP(Constant *C, Type *Ty) {
1377 bool toVec = Ty->getTypeID() == Type::VectorTyID;
1380 assert(C->getType()->isIntOrIntVectorTy() && Ty->isFPOrFPVectorTy() &&
1382 return getFoldedCast(Instruction::UIToFP, C, Ty);
1385 Constant *ConstantExpr::getSIToFP(Constant *C, Type *Ty) {
1388 bool toVec = Ty->getTypeID() == Type::VectorTyID;
1391 assert(C->getType()->isIntOrIntVectorTy() && Ty->isFPOrFPVectorTy() &&
1393 return getFoldedCast(Instruction::SIToFP, C, Ty);
1396 Constant *ConstantExpr::getFPToUI(Constant *C, Type *Ty) {
1399 bool toVec = Ty->getTypeID() == Type::VectorTyID;
1402 assert(C->getType()->isFPOrFPVectorTy() && Ty->isIntOrIntVectorTy() &&
1404 return getFoldedCast(Instruction::FPToUI, C, Ty);
1407 Constant *ConstantExpr::getFPToSI(Constant *C, Type *Ty) {
1410 bool toVec = Ty->getTypeID() == Type::VectorTyID;
1413 assert(C->getType()->isFPOrFPVectorTy() && Ty->isIntOrIntVectorTy() &&
1415 return getFoldedCast(Instruction::FPToSI, C, Ty);
1519 Constant *ConstantExpr::getSizeOf(Type* Ty) {
1520 // sizeof is implemented as: (i64) gep (Ty*)null, 1
1522 Constant *GEPIdx = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1);
1524 Constant::getNullValue(PointerType::getUnqual(Ty)), GEPIdx);
1526 Type::getInt64Ty(Ty->getContext()));
1529 Constant *ConstantExpr::getAlignOf(Type* Ty) {
1530 // alignof is implemented as: (i64) gep ({i1,Ty}*)null, 0, 1
1533 StructType::get(Type::getInt1Ty(Ty->getContext()), Ty, NULL);
1535 Constant *Zero = ConstantInt::get(Type::getInt64Ty(Ty->getContext()), 0);
1536 Constant *One = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1);
1540 Type::getInt64Ty(Ty->getContext()));
1548 Constant *ConstantExpr::getOffsetOf(Type* Ty, Constant *FieldNo) {
1549 // offsetof is implemented as: (i64) gep (Ty*)null, 0, FieldNo
1552 ConstantInt::get(Type::getInt64Ty(Ty->getContext()), 0),
1556 Constant::getNullValue(PointerType::getUnqual(Ty)), GEPIdx);
1558 Type::getInt64Ty(Ty->getContext()));
1604 Type *Ty = GetElementPtrInst::getIndexedType(C->getType(), Idxs);
1605 assert(Ty && "GEP indices invalid!");
1607 Type *ReqTy = Ty->getPointerTo(AS);