diff options
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 96 |
1 files changed, 2 insertions, 94 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 16072d2..4e48069 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -1968,18 +1968,6 @@ Constant *ConstantExpr::getCast(unsigned oc, Constant *C, Type *Ty, llvm_unreachable("Invalid cast opcode"); case Instruction::Trunc: return getTrunc(C, Ty, OnlyIfReduced); - case Instruction::FPTrunc: - return getFPTrunc(C, Ty, OnlyIfReduced); - case Instruction::FPExt: - return getFPExtend(C, Ty, OnlyIfReduced); - case Instruction::UIToFP: - return getUIToFP(C, Ty, OnlyIfReduced); - case Instruction::SIToFP: - return getSIToFP(C, Ty, OnlyIfReduced); - case Instruction::FPToUI: - return getFPToUI(C, Ty, OnlyIfReduced); - case Instruction::FPToSI: - return getFPToSI(C, Ty, OnlyIfReduced); case Instruction::PtrToInt: return getPtrToInt(C, Ty, OnlyIfReduced); case Instruction::IntToPtr: @@ -2023,18 +2011,6 @@ Constant *ConstantExpr::getPointerBitCastOrAddrSpaceCast(Constant *S, return getBitCast(S, Ty); } -Constant *ConstantExpr::getFPCast(Constant *C, Type *Ty) { - assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() && - "Invalid cast"); - unsigned SrcBits = C->getType()->getScalarSizeInBits(); - unsigned DstBits = Ty->getScalarSizeInBits(); - if (SrcBits == DstBits) - return C; // Avoid a useless cast - Instruction::CastOps opcode = - (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt); - return getCast(opcode, C, Ty); -} - Constant *ConstantExpr::getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) { #ifndef NDEBUG bool fromVec = isa<VectorType>(C->getType()); @@ -2049,74 +2025,6 @@ Constant *ConstantExpr::getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) { return getFoldedCast(Instruction::Trunc, C, Ty, OnlyIfReduced); } -Constant *ConstantExpr::getFPTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) { -#ifndef NDEBUG - bool fromVec = isa<VectorType>(C->getType()); - bool toVec = isa<VectorType>(Ty); -#endif - assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() && - C->getType()->getScalarSizeInBits() > Ty->getScalarSizeInBits()&& - "This is an illegal floating point truncation!"); - return getFoldedCast(Instruction::FPTrunc, C, Ty, OnlyIfReduced); -} - -Constant *ConstantExpr::getFPExtend(Constant *C, Type *Ty, bool OnlyIfReduced) { -#ifndef NDEBUG - bool fromVec = isa<VectorType>(C->getType()); - bool toVec = isa<VectorType>(Ty); -#endif - assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() && - C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&& - "This is an illegal floating point extension!"); - return getFoldedCast(Instruction::FPExt, C, Ty, OnlyIfReduced); -} - -Constant *ConstantExpr::getUIToFP(Constant *C, Type *Ty, bool OnlyIfReduced) { -#ifndef NDEBUG - bool fromVec = isa<VectorType>(C->getType()); - bool toVec = isa<VectorType>(Ty); -#endif - assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isIntOrIntVectorTy() && Ty->isFPOrFPVectorTy() && - "This is an illegal uint to floating point cast!"); - return getFoldedCast(Instruction::UIToFP, C, Ty, OnlyIfReduced); -} - -Constant *ConstantExpr::getSIToFP(Constant *C, Type *Ty, bool OnlyIfReduced) { -#ifndef NDEBUG - bool fromVec = isa<VectorType>(C->getType()); - bool toVec = isa<VectorType>(Ty); -#endif - assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isIntOrIntVectorTy() && Ty->isFPOrFPVectorTy() && - "This is an illegal sint to floating point cast!"); - return getFoldedCast(Instruction::SIToFP, C, Ty, OnlyIfReduced); -} - -Constant *ConstantExpr::getFPToUI(Constant *C, Type *Ty, bool OnlyIfReduced) { -#ifndef NDEBUG - bool fromVec = isa<VectorType>(C->getType()); - bool toVec = isa<VectorType>(Ty); -#endif - assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isFPOrFPVectorTy() && Ty->isIntOrIntVectorTy() && - "This is an illegal floating point to uint cast!"); - return getFoldedCast(Instruction::FPToUI, C, Ty, OnlyIfReduced); -} - -Constant *ConstantExpr::getFPToSI(Constant *C, Type *Ty, bool OnlyIfReduced) { -#ifndef NDEBUG - bool fromVec = isa<VectorType>(C->getType()); - bool toVec = isa<VectorType>(Ty); -#endif - assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isFPOrFPVectorTy() && Ty->isIntOrIntVectorTy() && - "This is an illegal floating point to sint cast!"); - return getFoldedCast(Instruction::FPToSI, C, Ty, OnlyIfReduced); -} - Constant *ConstantExpr::getPtrToInt(Constant *C, Type *DstTy, bool OnlyIfReduced) { assert(C->getType()->isPtrOrPtrVectorTy() && @@ -2292,14 +2200,14 @@ bool ConstantExpr::isSupportedCastOp(unsigned Opcode) { switch (Opcode) { case Instruction::ZExt: case Instruction::SExt: - return false; - case Instruction::Trunc: case Instruction::FPTrunc: case Instruction::FPExt: case Instruction::UIToFP: case Instruction::SIToFP: case Instruction::FPToUI: case Instruction::FPToSI: + return false; + case Instruction::Trunc: case Instruction::PtrToInt: case Instruction::IntToPtr: case Instruction::BitCast: |