diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-12-04 21:35:24 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-12-04 21:35:24 +0000 |
commit | 67263fec757aa7b8a3c7efe1290dc5415aa59c35 (patch) | |
tree | 0afe7519e8c37abeb834d43acf073f6523eb2aac /lib | |
parent | 90fdf9c6debbdcc61076a1e020c3dff4dc71d838 (diff) | |
download | external_llvm-67263fec757aa7b8a3c7efe1290dc5415aa59c35.zip external_llvm-67263fec757aa7b8a3c7efe1290dc5415aa59c35.tar.gz external_llvm-67263fec757aa7b8a3c7efe1290dc5415aa59c35.tar.bz2 |
Separate getCompare from get and getCompareTy from getTy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32200 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VMCore/Constants.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 9661087..3238ad0 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -1660,14 +1660,10 @@ Constant *ConstantExpr::getPtrPtrFromArrayPtr(Constant *C) { } Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode, - Constant *C1, Constant *C2, unsigned short pred) { + Constant *C1, Constant *C2) { if (Opcode == Instruction::Shl || Opcode == Instruction::LShr || Opcode == Instruction::AShr) return getShiftTy(ReqTy, Opcode, C1, C2); - if (Opcode == Instruction::ICmp) - return getICmp(pred, C1, C2); - if (Opcode == Instruction::FCmp) - return getFCmp(pred, C1, C2); // Check the operands for consistency first assert(Opcode >= Instruction::BinaryOpsBegin && @@ -1682,11 +1678,18 @@ Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode, return FC; // Fold a few common cases... std::vector<Constant*> argVec(1, C1); argVec.push_back(C2); - ExprMapKeyType Key(Opcode, argVec, pred); + ExprMapKeyType Key(Opcode, argVec); return ExprConstants->getOrCreate(ReqTy, Key); } -Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2, unsigned short pred) { +Constant *ConstantExpr::getCompareTy(unsigned Opcode, unsigned short predicate, + Constant *C1, Constant *C2) { + if (Opcode == Instruction::ICmp) + return getICmp(predicate, C1, C2); + return getFCmp(predicate, C1, C2); +} + +Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) { #ifndef NDEBUG switch (Opcode) { case Instruction::Add: @@ -1734,10 +1737,6 @@ Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2, unsigne case Instruction::SetGE: case Instruction::SetEQ: case Instruction::SetNE: assert(C1->getType() == C2->getType() && "Op types should be identical!"); break; - case Instruction::FCmp: - case Instruction::ICmp: - assert(C1->getType() == C2->getType() && "Op types should be identical!"); - break; case Instruction::Shl: case Instruction::LShr: case Instruction::AShr: @@ -1750,10 +1749,13 @@ Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2, unsigne } #endif - if (Instruction::isComparison(Opcode)) - return getTy(Type::BoolTy, Opcode, C1, C2, pred); - else - return getTy(C1->getType(), Opcode, C1, C2, pred); + return getTy(C1->getType(), Opcode, C1, C2); +} + +Constant *ConstantExpr::getCompare(unsigned Opcode, unsigned short pred, + Constant *C1, Constant *C2) { + assert(C1->getType() == C2->getType() && "Op types should be identical!"); + return getCompareTy(Opcode, pred, C1, C2); } Constant *ConstantExpr::getSelectTy(const Type *ReqTy, Constant *C, @@ -1793,7 +1795,6 @@ Constant *ConstantExpr::getShiftTy(const Type *ReqTy, unsigned Opcode, return ExprConstants->getOrCreate(ReqTy, Key); } - Constant *ConstantExpr::getGetElementPtrTy(const Type *ReqTy, Constant *C, const std::vector<Value*> &IdxList) { assert(GetElementPtrInst::getIndexedType(C->getType(), IdxList, true) && |