diff options
Diffstat (limited to 'lib/VMCore/Constants.cpp')
-rw-r--r-- | lib/VMCore/Constants.cpp | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index bcfd3879db..ee855ca732 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -498,20 +498,11 @@ Constant *ConstantExpr::getSetGE(Constant *C1, Constant *C2) { Constant *ConstantExpr::getShl(Constant *C1, Constant *C2) { return get(Instruction::Shl, C1, C2); } -Constant *ConstantExpr::getShr(Constant *C1, Constant *C2) { - return get(Instruction::Shr, C1, C2); +Constant *ConstantExpr::getLShr(Constant *C1, Constant *C2) { + return get(Instruction::LShr, C1, C2); } - -Constant *ConstantExpr::getUShr(Constant *C1, Constant *C2) { - if (C1->getType()->isUnsigned()) return getShr(C1, C2); - return getCast(getShr(getCast(C1, - C1->getType()->getUnsignedVersion()), C2), C1->getType()); -} - -Constant *ConstantExpr::getSShr(Constant *C1, Constant *C2) { - if (C1->getType()->isSigned()) return getShr(C1, C2); - return getCast(getShr(getCast(C1, - C1->getType()->getSignedVersion()), C2), C1->getType()); +Constant *ConstantExpr::getAShr(Constant *C1, Constant *C2) { + return get(Instruction::AShr, C1, C2); } /// getWithOperandReplaced - Return a constant expression identical to this @@ -1330,7 +1321,9 @@ namespace llvm { return new UnaryConstantExpr(Instruction::Cast, V.second[0], Ty); if ((V.first >= Instruction::BinaryOpsBegin && V.first < Instruction::BinaryOpsEnd) || - V.first == Instruction::Shl || V.first == Instruction::Shr) + V.first == Instruction::Shl || + V.first == Instruction::LShr || + V.first == Instruction::AShr) return new BinaryConstantExpr(V.first, V.second[0], V.second[1]); if (V.first == Instruction::Select) return new SelectConstantExpr(V.second[0], V.second[1], V.second[2]); @@ -1364,7 +1357,8 @@ namespace llvm { OldC->getOperand(2)); break; case Instruction::Shl: - case Instruction::Shr: + case Instruction::LShr: + case Instruction::AShr: New = ConstantExpr::getShiftTy(NewTy, OldC->getOpcode(), OldC->getOperand(0), OldC->getOperand(1)); break; @@ -1453,7 +1447,8 @@ Constant *ConstantExpr::getPtrPtrFromArrayPtr(Constant *C) { Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode, Constant *C1, Constant *C2) { - if (Opcode == Instruction::Shl || Opcode == Instruction::Shr) + if (Opcode == Instruction::Shl || Opcode == Instruction::LShr || + Opcode == Instruction::AShr) return getShiftTy(ReqTy, Opcode, C1, C2); // Check the operands for consistency first assert(Opcode >= Instruction::BinaryOpsBegin && @@ -1521,9 +1516,10 @@ Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) { assert(C1->getType() == C2->getType() && "Op types should be identical!"); break; case Instruction::Shl: - case Instruction::Shr: + case Instruction::LShr: + case Instruction::AShr: assert(C2->getType() == Type::UByteTy && "Shift should be by ubyte!"); - assert((C1->getType()->isInteger() || isa<PackedType>(C1->getType())) && + assert(C1->getType()->isInteger() && "Tried to create a shift operation on a non-integer type!"); break; default: @@ -1558,8 +1554,9 @@ Constant *ConstantExpr::getSelectTy(const Type *ReqTy, Constant *C, Constant *ConstantExpr::getShiftTy(const Type *ReqTy, unsigned Opcode, Constant *C1, Constant *C2) { // Check the operands for consistency first - assert((Opcode == Instruction::Shl || - Opcode == Instruction::Shr) && + assert((Opcode == Instruction::Shl || + Opcode == Instruction::LShr || + Opcode == Instruction::AShr) && "Invalid opcode in binary constant expression"); assert(C1->getType()->isIntegral() && C2->getType() == Type::UByteTy && "Invalid operand types for Shift constant expr!"); |