aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/llvm/InstrTypes.h42
-rw-r--r--include/llvm/Instructions.h64
-rw-r--r--lib/VMCore/Instructions.cpp74
3 files changed, 64 insertions, 116 deletions
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h
index 527ee89..386c001 100644
--- a/include/llvm/InstrTypes.h
+++ b/include/llvm/InstrTypes.h
@@ -656,16 +656,40 @@ public:
return static_cast<OtherOps>(Instruction::getOpcode());
}
- /// The predicate for CmpInst is defined by the subclasses but stored in
- /// the SubclassData field (see Value.h). We allow it to be fetched here
- /// as the predicate but there is no enum type for it, just the raw unsigned
- /// short. This facilitates comparison of CmpInst instances without delving
- /// into the subclasses since predicate values are distinct between the
- /// CmpInst subclasses.
/// @brief Return the predicate for this instruction.
- unsigned short getPredicate() const {
- return SubclassData;
- }
+ Predicate getPredicate() const { return Predicate(SubclassData); }
+
+ /// @brief Set the predicate for this instruction to the specified value.
+ void setPredicate(Predicate P) { SubclassData = P; }
+
+ /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE,
+ /// OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
+ /// @returns the inverse predicate for the instruction's current predicate.
+ /// @brief Return the inverse of the instruction's predicate.
+ Predicate getInversePredicate() const {
+ return getInversePredicate(getPredicate());
+ }
+
+ /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE,
+ /// OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
+ /// @returns the inverse predicate for predicate provided in \p pred.
+ /// @brief Return the inverse of a given predicate
+ static Predicate getInversePredicate(Predicate pred);
+
+ /// For example, EQ->EQ, SLE->SGE, ULT->UGT,
+ /// OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
+ /// @returns the predicate that would be the result of exchanging the two
+ /// operands of the CmpInst instruction without changing the result
+ /// produced.
+ /// @brief Return the predicate as if the operands were swapped
+ Predicate getSwappedPredicate() const {
+ return getSwappedPredicate(getPredicate());
+ }
+
+ /// This is a static version that you can use without an instruction
+ /// available.
+ /// @brief Return the predicate as if the operands were swapped.
+ static Predicate getSwappedPredicate(Predicate pred);
/// @brief Provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h
index fc06b8c..2e69243 100644
--- a/include/llvm/Instructions.h
+++ b/include/llvm/Instructions.h
@@ -650,38 +650,6 @@ public:
"Invalid operand types for ICmp instruction");
}
- /// @brief Return the predicate for this instruction.
- Predicate getPredicate() const { return Predicate(SubclassData); }
-
- /// @brief Set the predicate for this instruction to the specified value.
- void setPredicate(Predicate P) { SubclassData = P; }
-
- /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE, etc.
- /// @returns the inverse predicate for the instruction's current predicate.
- /// @brief Return the inverse of the instruction's predicate.
- Predicate getInversePredicate() const {
- return getInversePredicate(getPredicate());
- }
-
- /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE, etc.
- /// @returns the inverse predicate for predicate provided in \p pred.
- /// @brief Return the inverse of a given predicate
- static Predicate getInversePredicate(Predicate pred);
-
- /// For example, EQ->EQ, SLE->SGE, ULT->UGT, etc.
- /// @returns the predicate that would be the result of exchanging the two
- /// operands of the ICmpInst instruction without changing the result
- /// produced.
- /// @brief Return the predicate as if the operands were swapped
- Predicate getSwappedPredicate() const {
- return getSwappedPredicate(getPredicate());
- }
-
- /// This is a static version that you can use without an instruction
- /// available.
- /// @brief Return the predicate as if the operands were swapped.
- static Predicate getSwappedPredicate(Predicate pred);
-
/// For example, EQ->EQ, SLE->SLE, UGT->SGT, etc.
/// @returns the predicate that would be the result if the operand were
/// regarded as signed.
@@ -830,38 +798,6 @@ public:
"Invalid operand types for FCmp instruction");
}
- /// @brief Return the predicate for this instruction.
- Predicate getPredicate() const { return Predicate(SubclassData); }
-
- /// @brief Set the predicate for this instruction to the specified value.
- void setPredicate(Predicate P) { SubclassData = P; }
-
- /// For example, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
- /// @returns the inverse predicate for the instructions current predicate.
- /// @brief Return the inverse of the predicate
- Predicate getInversePredicate() const {
- return getInversePredicate(getPredicate());
- }
-
- /// For example, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
- /// @returns the inverse predicate for \p pred.
- /// @brief Return the inverse of a given predicate
- static Predicate getInversePredicate(Predicate pred);
-
- /// For example, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
- /// @returns the predicate that would be the result of exchanging the two
- /// operands of the ICmpInst instruction without changing the result
- /// produced.
- /// @brief Return the predicate as if the operands were swapped
- Predicate getSwappedPredicate() const {
- return getSwappedPredicate(getPredicate());
- }
-
- /// This is a static version that you can use without an instruction
- /// available.
- /// @brief Return the predicate as if the operands were swapped.
- static Predicate getSwappedPredicate(Predicate Opcode);
-
/// This also tests for commutativity. If isEquality() returns true then
/// the predicate is also commutative. Only the equality predicates are
/// commutative.
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index e9b7979..656a51b 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -2497,10 +2497,9 @@ bool CmpInst::isEquality() {
}
-ICmpInst::Predicate ICmpInst::getInversePredicate(Predicate pred) {
+CmpInst::Predicate CmpInst::getInversePredicate(Predicate pred) {
switch (pred) {
- default:
- assert(!"Unknown icmp predicate!");
+ default: assert(!"Unknown cmp predicate!");
case ICMP_EQ: return ICMP_NE;
case ICMP_NE: return ICMP_EQ;
case ICMP_UGT: return ICMP_ULE;
@@ -2511,22 +2510,23 @@ ICmpInst::Predicate ICmpInst::getInversePredicate(Predicate pred) {
case ICMP_SLT: return ICMP_SGE;
case ICMP_SGE: return ICMP_SLT;
case ICMP_SLE: return ICMP_SGT;
- }
-}
-ICmpInst::Predicate ICmpInst::getSwappedPredicate(Predicate pred) {
- switch (pred) {
- default: assert(! "Unknown icmp predicate!");
- case ICMP_EQ: case ICMP_NE:
- return pred;
- case ICMP_SGT: return ICMP_SLT;
- case ICMP_SLT: return ICMP_SGT;
- case ICMP_SGE: return ICMP_SLE;
- case ICMP_SLE: return ICMP_SGE;
- case ICMP_UGT: return ICMP_ULT;
- case ICMP_ULT: return ICMP_UGT;
- case ICMP_UGE: return ICMP_ULE;
- case ICMP_ULE: return ICMP_UGE;
+ case FCMP_OEQ: return FCMP_UNE;
+ case FCMP_ONE: return FCMP_UEQ;
+ case FCMP_OGT: return FCMP_ULE;
+ case FCMP_OLT: return FCMP_UGE;
+ case FCMP_OGE: return FCMP_ULT;
+ case FCMP_OLE: return FCMP_UGT;
+ case FCMP_UEQ: return FCMP_ONE;
+ case FCMP_UNE: return FCMP_OEQ;
+ case FCMP_UGT: return FCMP_OLE;
+ case FCMP_ULT: return FCMP_OGE;
+ case FCMP_UGE: return FCMP_OLT;
+ case FCMP_ULE: return FCMP_OGT;
+ case FCMP_ORD: return FCMP_UNO;
+ case FCMP_UNO: return FCMP_ORD;
+ case FCMP_TRUE: return FCMP_FALSE;
+ case FCMP_FALSE: return FCMP_TRUE;
}
}
@@ -2602,32 +2602,20 @@ ICmpInst::makeConstantRange(Predicate pred, const APInt &C) {
return ConstantRange(Lower, Upper);
}
-FCmpInst::Predicate FCmpInst::getInversePredicate(Predicate pred) {
+CmpInst::Predicate CmpInst::getSwappedPredicate(Predicate pred) {
switch (pred) {
- default:
- assert(!"Unknown icmp predicate!");
- case FCMP_OEQ: return FCMP_UNE;
- case FCMP_ONE: return FCMP_UEQ;
- case FCMP_OGT: return FCMP_ULE;
- case FCMP_OLT: return FCMP_UGE;
- case FCMP_OGE: return FCMP_ULT;
- case FCMP_OLE: return FCMP_UGT;
- case FCMP_UEQ: return FCMP_ONE;
- case FCMP_UNE: return FCMP_OEQ;
- case FCMP_UGT: return FCMP_OLE;
- case FCMP_ULT: return FCMP_OGE;
- case FCMP_UGE: return FCMP_OLT;
- case FCMP_ULE: return FCMP_OGT;
- case FCMP_ORD: return FCMP_UNO;
- case FCMP_UNO: return FCMP_ORD;
- case FCMP_TRUE: return FCMP_FALSE;
- case FCMP_FALSE: return FCMP_TRUE;
- }
-}
-
-FCmpInst::Predicate FCmpInst::getSwappedPredicate(Predicate pred) {
- switch (pred) {
- default: assert(!"Unknown fcmp predicate!");
+ default: assert(!"Unknown cmp predicate!");
+ case ICMP_EQ: case ICMP_NE:
+ return pred;
+ case ICMP_SGT: return ICMP_SLT;
+ case ICMP_SLT: return ICMP_SGT;
+ case ICMP_SGE: return ICMP_SLE;
+ case ICMP_SLE: return ICMP_SGE;
+ case ICMP_UGT: return ICMP_ULT;
+ case ICMP_ULT: return ICMP_UGT;
+ case ICMP_UGE: return ICMP_ULE;
+ case ICMP_ULE: return ICMP_UGE;
+
case FCMP_FALSE: case FCMP_TRUE:
case FCMP_OEQ: case FCMP_ONE:
case FCMP_UEQ: case FCMP_UNE: