From: Dan Gohman Date: Mon, 12 Apr 2010 22:12:29 +0000 (+0000) Subject: Simplify this code. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=3b49063a83eecaa9dc05c29d27768f85c0622163;p=oota-llvm.git Simplify this code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101074 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 1553bd51342..d969dbb60d3 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -1224,20 +1224,20 @@ Constant *ConstantExpr::getCast(unsigned oc, Constant *C, const Type *Ty) { Constant *ConstantExpr::getZExtOrBitCast(Constant *C, const Type *Ty) { if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits()) - return getCast(Instruction::BitCast, C, Ty); - return getCast(Instruction::ZExt, C, Ty); + return getBitCast(C, Ty); + return getZExt(C, Ty); } Constant *ConstantExpr::getSExtOrBitCast(Constant *C, const Type *Ty) { if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits()) - return getCast(Instruction::BitCast, C, Ty); - return getCast(Instruction::SExt, C, Ty); + return getBitCast(C, Ty); + return getSExt(C, Ty); } Constant *ConstantExpr::getTruncOrBitCast(Constant *C, const Type *Ty) { if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits()) - return getCast(Instruction::BitCast, C, Ty); - return getCast(Instruction::Trunc, C, Ty); + return getBitCast(C, Ty); + return getTrunc(C, Ty); } Constant *ConstantExpr::getPointerCast(Constant *S, const Type *Ty) { @@ -1245,8 +1245,8 @@ Constant *ConstantExpr::getPointerCast(Constant *S, const Type *Ty) { assert((Ty->isIntegerTy() || Ty->isPointerTy()) && "Invalid cast"); if (Ty->isIntegerTy()) - return getCast(Instruction::PtrToInt, S, Ty); - return getCast(Instruction::BitCast, S, Ty); + return getPtrToInt(S, Ty); + return getBitCast(S, Ty); } Constant *ConstantExpr::getIntegerCast(Constant *C, const Type *Ty, @@ -1523,8 +1523,8 @@ Constant* ConstantExpr::getSizeOf(const Type* Ty) { Constant *GEPIdx = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1); Constant *GEP = getGetElementPtr( Constant::getNullValue(PointerType::getUnqual(Ty)), &GEPIdx, 1); - return getCast(Instruction::PtrToInt, GEP, - Type::getInt64Ty(Ty->getContext())); + return getPtrToInt(GEP, + Type::getInt64Ty(Ty->getContext())); } Constant* ConstantExpr::getAlignOf(const Type* Ty) { @@ -1537,8 +1537,8 @@ Constant* ConstantExpr::getAlignOf(const Type* Ty) { Constant *One = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1); Constant *Indices[2] = { Zero, One }; Constant *GEP = getGetElementPtr(NullPtr, Indices, 2); - return getCast(Instruction::PtrToInt, GEP, - Type::getInt64Ty(Ty->getContext())); + return getPtrToInt(GEP, + Type::getInt64Ty(Ty->getContext())); } Constant* ConstantExpr::getOffsetOf(const StructType* STy, unsigned FieldNo) { @@ -1555,8 +1555,8 @@ Constant* ConstantExpr::getOffsetOf(const Type* Ty, Constant *FieldNo) { }; Constant *GEP = getGetElementPtr( Constant::getNullValue(PointerType::getUnqual(Ty)), GEPIdx, 2); - return getCast(Instruction::PtrToInt, GEP, - Type::getInt64Ty(Ty->getContext())); + return getPtrToInt(GEP, + Type::getInt64Ty(Ty->getContext())); } Constant *ConstantExpr::getCompare(unsigned short pred,