Lines Matching refs:Ty
370 Constant *Constant::getNullValue(Type *Ty) { in getNullValue() argument
371 switch (Ty->getTypeID()) { in getNullValue()
373 return ConstantInt::get(Ty, 0); in getNullValue()
381 return ConstantFP::get(Ty->getContext(), in getNullValue()
382 APFloat::getZero(Ty->getFltSemantics())); in getNullValue()
384 return ConstantPointerNull::get(cast<PointerType>(Ty)); in getNullValue()
389 return ConstantAggregateZero::get(Ty); in getNullValue()
391 return ConstantTokenNone::get(Ty->getContext()); in getNullValue()
393 return ConstantTargetNone::get(cast<TargetExtType>(Ty)); in getNullValue()
400 Constant *Constant::getIntegerValue(Type *Ty, const APInt &V) { in getIntegerValue() argument
401 Type *ScalarTy = Ty->getScalarType(); in getIntegerValue()
404 Constant *C = ConstantInt::get(Ty->getContext(), V); in getIntegerValue()
411 if (VectorType *VTy = dyn_cast<VectorType>(Ty)) in getIntegerValue()
417 Constant *Constant::getAllOnesValue(Type *Ty) { in getAllOnesValue() argument
418 if (IntegerType *ITy = dyn_cast<IntegerType>(Ty)) in getAllOnesValue()
419 return ConstantInt::get(Ty->getContext(), in getAllOnesValue()
422 if (Ty->isFloatingPointTy()) { in getAllOnesValue()
423 APFloat FL = APFloat::getAllOnesValue(Ty->getFltSemantics()); in getAllOnesValue()
424 return ConstantFP::get(Ty->getContext(), FL); in getAllOnesValue()
427 VectorType *VTy = cast<VectorType>(Ty); in getAllOnesValue()
770 Type *Ty = C->getType(); in replaceUndefsWith() local
772 assert(Ty == Replacement->getType() && "Expected matching types"); in replaceUndefsWith()
777 auto *VTy = dyn_cast<FixedVectorType>(Ty); in replaceUndefsWith()
797 Type *Ty = C->getType(); in mergeUndefsWith() local
799 return UndefValue::get(Ty); in mergeUndefsWith()
801 auto *VTy = dyn_cast<FixedVectorType>(Ty); in mergeUndefsWith()
843 ConstantInt::ConstantInt(Type *Ty, const APInt &V) in ConstantInt() argument
844 : ConstantData(Ty, ConstantIntVal), Val(V) { in ConstantInt()
846 cast<IntegerType>(Ty->getScalarType())->getBitWidth() && in ConstantInt()
868 Constant *ConstantInt::getTrue(Type *Ty) { in getTrue() argument
869 assert(Ty->isIntOrIntVectorTy(1) && "Type not i1 or vector of i1."); in getTrue()
870 ConstantInt *TrueC = ConstantInt::getTrue(Ty->getContext()); in getTrue()
871 if (auto *VTy = dyn_cast<VectorType>(Ty)) in getTrue()
876 Constant *ConstantInt::getFalse(Type *Ty) { in getFalse() argument
877 assert(Ty->isIntOrIntVectorTy(1) && "Type not i1 or vector of i1."); in getFalse()
878 ConstantInt *FalseC = ConstantInt::getFalse(Ty->getContext()); in getFalse()
879 if (auto *VTy = dyn_cast<VectorType>(Ty)) in getFalse()
884 Constant *ConstantInt::getBool(Type *Ty, bool V) { in getBool() argument
885 return V ? getTrue(Ty) : getFalse(Ty); in getBool()
925 Constant *ConstantInt::get(Type *Ty, uint64_t V, bool isSigned) { in get() argument
926 Constant *C = get(cast<IntegerType>(Ty->getScalarType()), V, isSigned); in get()
929 if (VectorType *VTy = dyn_cast<VectorType>(Ty)) in get()
935 ConstantInt *ConstantInt::get(IntegerType *Ty, uint64_t V, bool isSigned) { in get() argument
936 return get(Ty->getContext(), APInt(Ty->getBitWidth(), V, isSigned)); in get()
939 Constant *ConstantInt::get(Type *Ty, const APInt& V) { in get() argument
940 ConstantInt *C = get(Ty->getContext(), V); in get()
941 assert(C->getType() == Ty->getScalarType() && in get()
945 if (VectorType *VTy = dyn_cast<VectorType>(Ty)) in get()
951 ConstantInt *ConstantInt::get(IntegerType* Ty, StringRef Str, uint8_t radix) { in get() argument
952 return get(Ty->getContext(), APInt(Ty->getBitWidth(), Str, radix)); in get()
964 Constant *ConstantFP::get(Type *Ty, double V) { in get() argument
965 LLVMContext &Context = Ty->getContext(); in get()
969 FV.convert(Ty->getScalarType()->getFltSemantics(), in get()
974 if (VectorType *VTy = dyn_cast<VectorType>(Ty)) in get()
980 Constant *ConstantFP::get(Type *Ty, const APFloat &V) { in get() argument
981 ConstantFP *C = get(Ty->getContext(), V); in get()
982 assert(C->getType() == Ty->getScalarType() && in get()
986 if (auto *VTy = dyn_cast<VectorType>(Ty)) in get()
992 Constant *ConstantFP::get(Type *Ty, StringRef Str) { in get() argument
993 LLVMContext &Context = Ty->getContext(); in get()
995 APFloat FV(Ty->getScalarType()->getFltSemantics(), Str); in get()
999 if (VectorType *VTy = dyn_cast<VectorType>(Ty)) in get()
1005 Constant *ConstantFP::getNaN(Type *Ty, bool Negative, uint64_t Payload) { in getNaN() argument
1006 const fltSemantics &Semantics = Ty->getScalarType()->getFltSemantics(); in getNaN()
1008 Constant *C = get(Ty->getContext(), NaN); in getNaN()
1010 if (VectorType *VTy = dyn_cast<VectorType>(Ty)) in getNaN()
1016 Constant *ConstantFP::getQNaN(Type *Ty, bool Negative, APInt *Payload) { in getQNaN() argument
1017 const fltSemantics &Semantics = Ty->getScalarType()->getFltSemantics(); in getQNaN()
1019 Constant *C = get(Ty->getContext(), NaN); in getQNaN()
1021 if (VectorType *VTy = dyn_cast<VectorType>(Ty)) in getQNaN()
1027 Constant *ConstantFP::getSNaN(Type *Ty, bool Negative, APInt *Payload) { in getSNaN() argument
1028 const fltSemantics &Semantics = Ty->getScalarType()->getFltSemantics(); in getSNaN()
1030 Constant *C = get(Ty->getContext(), NaN); in getSNaN()
1032 if (VectorType *VTy = dyn_cast<VectorType>(Ty)) in getSNaN()
1038 Constant *ConstantFP::getZero(Type *Ty, bool Negative) { in getZero() argument
1039 const fltSemantics &Semantics = Ty->getScalarType()->getFltSemantics(); in getZero()
1041 Constant *C = get(Ty->getContext(), NegZero); in getZero()
1043 if (VectorType *VTy = dyn_cast<VectorType>(Ty)) in getZero()
1057 Type *Ty = Type::getFloatingPointTy(Context, V.getSemantics()); in get() local
1058 Slot.reset(new ConstantFP(Ty, V)); in get()
1084 Constant *ConstantFP::getInfinity(Type *Ty, bool Negative) { in getInfinity() argument
1085 const fltSemantics &Semantics = Ty->getScalarType()->getFltSemantics(); in getInfinity()
1086 Constant *C = get(Ty->getContext(), APFloat::getInf(Semantics, Negative)); in getInfinity()
1088 if (VectorType *VTy = dyn_cast<VectorType>(Ty)) in getInfinity()
1094 ConstantFP::ConstantFP(Type *Ty, const APFloat &V) in ConstantFP() argument
1095 : ConstantData(Ty, ConstantFPVal), Val(V) { in ConstantFP()
1096 assert(&V.getSemantics() == &Ty->getScalarType()->getFltSemantics() && in ConstantFP()
1136 Type *Ty = getType(); in getElementCount() local
1137 if (auto *AT = dyn_cast<ArrayType>(Ty)) in getElementCount()
1139 if (auto *VT = dyn_cast<VectorType>(Ty)) in getElementCount()
1141 return ElementCount::getFixed(Ty->getStructNumElements()); in getElementCount()
1171 Type *Ty = getType(); in getNumElements() local
1172 if (auto *AT = dyn_cast<ArrayType>(Ty)) in getNumElements()
1174 if (auto *VT = dyn_cast<VectorType>(Ty)) in getNumElements()
1176 return Ty->getStructNumElements(); in getNumElements()
1292 Constant *ConstantArray::get(ArrayType *Ty, ArrayRef<Constant*> V) { in get() argument
1293 if (Constant *C = getImpl(Ty, V)) in get()
1295 return Ty->getContext().pImpl->ArrayConstants.getOrCreate(Ty, V); in get()
1298 Constant *ConstantArray::getImpl(ArrayType *Ty, ArrayRef<Constant*> V) { in getImpl() argument
1301 return ConstantAggregateZero::get(Ty); in getImpl()
1304 assert(C->getType() == Ty->getElementType() && in getImpl()
1314 return PoisonValue::get(Ty); in getImpl()
1317 return UndefValue::get(Ty); in getImpl()
1320 return ConstantAggregateZero::get(Ty); in getImpl()
1402 auto *Ty = FixedVectorType::get(V.front()->getType(), V.size()); in get() local
1403 return Ty->getContext().pImpl->VectorConstants.getOrCreate(Ty, V); in get()
1525 Constant *ConstantExpr::getWithOperands(ArrayRef<Constant *> Ops, Type *Ty, in getWithOperands() argument
1530 if (Ty == getType() && std::equal(Ops.begin(), Ops.end(), op_begin())) in getWithOperands()
1533 Type *OnlyIfReducedTy = OnlyIfReduced ? Ty : nullptr; in getWithOperands()
1548 return ConstantExpr::getCast(getOpcode(), Ops[0], Ty, OnlyIfReduced); in getWithOperands()
1575 bool ConstantInt::isValueValidForType(Type *Ty, uint64_t Val) { in isValueValidForType() argument
1576 unsigned NumBits = Ty->getIntegerBitWidth(); // assert okay in isValueValidForType()
1577 if (Ty->isIntegerTy(1)) in isValueValidForType()
1582 bool ConstantInt::isValueValidForType(Type *Ty, int64_t Val) { in isValueValidForType() argument
1583 unsigned NumBits = Ty->getIntegerBitWidth(); in isValueValidForType()
1584 if (Ty->isIntegerTy(1)) in isValueValidForType()
1589 bool ConstantFP::isValueValidForType(Type *Ty, const APFloat& Val) { in isValueValidForType() argument
1593 switch (Ty->getTypeID()) { in isValueValidForType()
1650 ConstantAggregateZero *ConstantAggregateZero::get(Type *Ty) { in get() argument
1651 assert((Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()) && in get()
1655 Ty->getContext().pImpl->CAZConstants[Ty]; in get()
1657 Entry.reset(new ConstantAggregateZero(Ty)); in get()
1800 ConstantPointerNull *ConstantPointerNull::get(PointerType *Ty) { in get() argument
1802 Ty->getContext().pImpl->CPNConstants[Ty]; in get()
1804 Entry.reset(new ConstantPointerNull(Ty)); in get()
1817 ConstantTargetNone *ConstantTargetNone::get(TargetExtType *Ty) { in get() argument
1818 assert(Ty->hasProperty(TargetExtType::HasZeroInit) && in get()
1821 Ty->getContext().pImpl->CTNConstants[Ty]; in get()
1823 Entry.reset(new ConstantTargetNone(Ty)); in get()
1833 UndefValue *UndefValue::get(Type *Ty) { in get() argument
1834 std::unique_ptr<UndefValue> &Entry = Ty->getContext().pImpl->UVConstants[Ty]; in get()
1836 Entry.reset(new UndefValue(Ty)); in get()
1852 PoisonValue *PoisonValue::get(Type *Ty) { in get() argument
1853 std::unique_ptr<PoisonValue> &Entry = Ty->getContext().pImpl->PVConstants[Ty]; in get()
1855 Entry.reset(new PoisonValue(Ty)); in get()
2166 static Constant *getFoldedCast(Instruction::CastOps opc, Constant *C, Type *Ty, in getFoldedCast() argument
2168 assert(Ty->isFirstClassType() && "Cannot cast to an aggregate type!"); in getFoldedCast()
2170 if (Constant *FC = ConstantFoldCastInstruction(opc, C, Ty)) in getFoldedCast()
2176 LLVMContextImpl *pImpl = Ty->getContext().pImpl; in getFoldedCast()
2181 return pImpl->ExprConstants.getOrCreate(Ty, Key); in getFoldedCast()
2184 Constant *ConstantExpr::getCast(unsigned oc, Constant *C, Type *Ty, in getCast() argument
2190 assert(C && Ty && "Null arguments to getCast"); in getCast()
2191 assert(CastInst::castIsValid(opc, C, Ty) && "Invalid constantexpr cast!"); in getCast()
2197 return getTrunc(C, Ty, OnlyIfReduced); in getCast()
2199 return getPtrToInt(C, Ty, OnlyIfReduced); in getCast()
2201 return getIntToPtr(C, Ty, OnlyIfReduced); in getCast()
2203 return getBitCast(C, Ty, OnlyIfReduced); in getCast()
2205 return getAddrSpaceCast(C, Ty, OnlyIfReduced); in getCast()
2209 Constant *ConstantExpr::getTruncOrBitCast(Constant *C, Type *Ty) { in getTruncOrBitCast() argument
2210 if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits()) in getTruncOrBitCast()
2211 return getBitCast(C, Ty); in getTruncOrBitCast()
2212 return getTrunc(C, Ty); in getTruncOrBitCast()
2215 Constant *ConstantExpr::getPointerCast(Constant *S, Type *Ty) { in getPointerCast() argument
2217 assert((Ty->isIntOrIntVectorTy() || Ty->isPtrOrPtrVectorTy()) && in getPointerCast()
2220 if (Ty->isIntOrIntVectorTy()) in getPointerCast()
2221 return getPtrToInt(S, Ty); in getPointerCast()
2224 if (Ty->isPtrOrPtrVectorTy() && SrcAS != Ty->getPointerAddressSpace()) in getPointerCast()
2225 return getAddrSpaceCast(S, Ty); in getPointerCast()
2227 return getBitCast(S, Ty); in getPointerCast()
2231 Type *Ty) { in getPointerBitCastOrAddrSpaceCast() argument
2233 assert(Ty->isPtrOrPtrVectorTy() && "Invalid cast"); in getPointerBitCastOrAddrSpaceCast()
2235 if (S->getType()->getPointerAddressSpace() != Ty->getPointerAddressSpace()) in getPointerBitCastOrAddrSpaceCast()
2236 return getAddrSpaceCast(S, Ty); in getPointerBitCastOrAddrSpaceCast()
2238 return getBitCast(S, Ty); in getPointerBitCastOrAddrSpaceCast()
2241 Constant *ConstantExpr::getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) { in getTrunc() argument
2244 bool toVec = isa<VectorType>(Ty); in getTrunc()
2248 assert(Ty->isIntOrIntVectorTy() && "Trunc produces only integral"); in getTrunc()
2249 assert(C->getType()->getScalarSizeInBits() > Ty->getScalarSizeInBits()&& in getTrunc()
2252 return getFoldedCast(Instruction::Trunc, C, Ty, OnlyIfReduced); in getTrunc()
2442 Constant *ConstantExpr::getSizeOf(Type* Ty) { in getSizeOf() argument
2445 Constant *GEPIdx = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1); in getSizeOf()
2447 Ty, Constant::getNullValue(PointerType::getUnqual(Ty)), GEPIdx); in getSizeOf()
2449 Type::getInt64Ty(Ty->getContext())); in getSizeOf()
2452 Constant *ConstantExpr::getAlignOf(Type* Ty) { in getAlignOf() argument
2455 Type *AligningTy = StructType::get(Type::getInt1Ty(Ty->getContext()), Ty); in getAlignOf()
2458 Constant *Zero = ConstantInt::get(Type::getInt64Ty(Ty->getContext()), 0); in getAlignOf()
2459 Constant *One = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1); in getAlignOf()
2462 return getPtrToInt(GEP, Type::getInt64Ty(Ty->getContext())); in getAlignOf()
2465 Constant *ConstantExpr::getGetElementPtr(Type *Ty, Constant *C, in getGetElementPtr() argument
2470 assert(Ty && "Must specify element type"); in getGetElementPtr()
2471 assert(isSupportedGetElementPtr(Ty) && "Element type is unsupported!"); in getGetElementPtr()
2473 if (Constant *FC = ConstantFoldGetElementPtr(Ty, C, InRange, Idxs)) in getGetElementPtr()
2476 assert(GetElementPtrInst::getIndexedType(Ty, Idxs) && "GEP indices invalid!"); in getGetElementPtr()
2492 auto GTI = gep_type_begin(Ty, Idxs), GTE = gep_type_end(Ty, Idxs); in getGetElementPtr()
2510 std::nullopt, Ty, InRange); in getGetElementPtr()
2625 Type *Ty = C->getType(); in getExactLogBase2() local
2628 return ConstantInt::get(Ty, IVal->logBase2()); in getExactLogBase2()
2631 auto *VecTy = dyn_cast<FixedVectorType>(Ty); in getExactLogBase2()
2642 Elts.push_back(Constant::getNullValue(Ty->getScalarType())); in getExactLogBase2()
2647 Elts.push_back(ConstantInt::get(Ty->getScalarType(), IVal->logBase2())); in getExactLogBase2()
2653 Constant *ConstantExpr::getBinOpIdentity(unsigned Opcode, Type *Ty, in getBinOpIdentity() argument
2663 return Constant::getNullValue(Ty); in getBinOpIdentity()
2665 return ConstantInt::get(Ty, 1); in getBinOpIdentity()
2667 return Constant::getAllOnesValue(Ty); in getBinOpIdentity()
2669 return ConstantFP::getZero(Ty, !NSZ); in getBinOpIdentity()
2671 return ConstantFP::get(Ty, 1.0); in getBinOpIdentity()
2687 return Constant::getNullValue(Ty); in getBinOpIdentity()
2690 return ConstantInt::get(Ty, 1); in getBinOpIdentity()
2692 return ConstantFP::get(Ty, 1.0); in getBinOpIdentity()
2698 Constant *ConstantExpr::getIntrinsicIdentity(Intrinsic::ID ID, Type *Ty) { in getIntrinsicIdentity() argument
2701 return Constant::getNullValue(Ty); in getIntrinsicIdentity()
2703 return Constant::getAllOnesValue(Ty); in getIntrinsicIdentity()
2706 Ty, APInt::getSignedMinValue(Ty->getIntegerBitWidth())); in getIntrinsicIdentity()
2709 Ty, APInt::getSignedMaxValue(Ty->getIntegerBitWidth())); in getIntrinsicIdentity()
2715 Constant *ConstantExpr::getIdentity(Instruction *I, Type *Ty, in getIdentity() argument
2718 return getBinOpIdentity(I->getOpcode(), Ty, AllowRHSConstant, NSZ); in getIdentity()
2720 return getIntrinsicIdentity(II->getIntrinsicID(), Ty); in getIdentity()
2724 Constant *ConstantExpr::getBinOpAbsorber(unsigned Opcode, Type *Ty) { in getBinOpAbsorber() argument
2731 return Constant::getAllOnesValue(Ty); in getBinOpAbsorber()
2735 return Constant::getNullValue(Ty); in getBinOpAbsorber()
2789 bool ConstantDataSequential::isElementTypeCompatible(Type *Ty) { in isElementTypeCompatible() argument
2790 if (Ty->isHalfTy() || Ty->isBFloatTy() || Ty->isFloatTy() || Ty->isDoubleTy()) in isElementTypeCompatible()
2792 if (auto *IT = dyn_cast<IntegerType>(Ty)) { in isElementTypeCompatible()
2835 Constant *ConstantDataSequential::getImpl(StringRef Elements, Type *Ty) { in getImpl() argument
2837 if (ArrayType *ATy = dyn_cast<ArrayType>(Ty)) in getImpl()
2840 assert(isElementTypeCompatible(cast<VectorType>(Ty)->getElementType())); in getImpl()
2845 return ConstantAggregateZero::get(Ty); in getImpl()
2849 *Ty->getContext() in getImpl()
2859 if ((*Entry)->getType() == Ty) in getImpl()
2864 if (isa<ArrayType>(Ty)) { in getImpl()
2866 Entry->reset(new ConstantDataArray(Ty, Slot.first().data())); in getImpl()
2870 assert(isa<VectorType>(Ty)); in getImpl()
2872 Entry->reset(new ConstantDataVector(Ty, Slot.first().data())); in getImpl()
2920 Type *Ty = ArrayType::get(ElementType, Elts.size()); in getFP() local
2922 return getImpl(StringRef(Data, Elts.size() * 2), Ty); in getFP()
2926 Type *Ty = ArrayType::get(ElementType, Elts.size()); in getFP() local
2928 return getImpl(StringRef(Data, Elts.size() * 4), Ty); in getFP()
2933 Type *Ty = ArrayType::get(ElementType, Elts.size()); in getFP() local
2935 return getImpl(StringRef(Data, Elts.size() * 8), Ty); in getFP()
2955 auto *Ty = FixedVectorType::get(Type::getInt8Ty(Context), Elts.size()); in get() local
2957 return getImpl(StringRef(Data, Elts.size() * 1), Ty); in get()
2960 auto *Ty = FixedVectorType::get(Type::getInt16Ty(Context), Elts.size()); in get() local
2962 return getImpl(StringRef(Data, Elts.size() * 2), Ty); in get()
2965 auto *Ty = FixedVectorType::get(Type::getInt32Ty(Context), Elts.size()); in get() local
2967 return getImpl(StringRef(Data, Elts.size() * 4), Ty); in get()
2970 auto *Ty = FixedVectorType::get(Type::getInt64Ty(Context), Elts.size()); in get() local
2972 return getImpl(StringRef(Data, Elts.size() * 8), Ty); in get()
2975 auto *Ty = FixedVectorType::get(Type::getFloatTy(Context), Elts.size()); in get() local
2977 return getImpl(StringRef(Data, Elts.size() * 4), Ty); in get()
2980 auto *Ty = FixedVectorType::get(Type::getDoubleTy(Context), Elts.size()); in get() local
2982 return getImpl(StringRef(Data, Elts.size() * 8), Ty); in get()
2995 auto *Ty = FixedVectorType::get(ElementType, Elts.size()); in getFP() local
2997 return getImpl(StringRef(Data, Elts.size() * 2), Ty); in getFP()
3002 auto *Ty = FixedVectorType::get(ElementType, Elts.size()); in getFP() local
3004 return getImpl(StringRef(Data, Elts.size() * 4), Ty); in getFP()
3010 auto *Ty = FixedVectorType::get(ElementType, Elts.size()); in getFP() local
3012 return getImpl(StringRef(Data, Elts.size() * 8), Ty); in getFP()