diff options
author | Dan Gohman <gohman@apple.com> | 2008-05-31 02:47:54 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-05-31 02:47:54 +0000 |
commit | 7e2dd6628e398f369a110856ec69455f65d17638 (patch) | |
tree | a8ed30e2b4d47ef8c8e09882f764f61ebc8a026a /include | |
parent | e4c67cdab4a2ad2ff53183ad32e77e8608c9262d (diff) | |
download | external_llvm-7e2dd6628e398f369a110856ec69455f65d17638.zip external_llvm-7e2dd6628e398f369a110856ec69455f65d17638.tar.gz external_llvm-7e2dd6628e398f369a110856ec69455f65d17638.tar.bz2 |
Factor several methods, including getInversePredicate and
getSwappedPredicate, from ICmpInst and FCmpInst into common
methods in CmpInst. This allows CmpInsts to be manipulated
generically.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51810 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/InstrTypes.h | 42 | ||||
-rw-r--r-- | include/llvm/Instructions.h | 64 |
2 files changed, 33 insertions, 73 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. |