diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-11-09 23:28:39 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-11-09 23:28:39 +0000 |
| commit | 9dbb42944c4d7caddab21016b24cca31019a3faf (patch) | |
| tree | 26a4ee2c7012d277e6747bf7a8290ecf5699b1d7 /include | |
| parent | 803b48a155eb2b3f9fe3823ecd7cbbd0089b2809 (diff) | |
| download | external_llvm-9dbb42944c4d7caddab21016b24cca31019a3faf.zip external_llvm-9dbb42944c4d7caddab21016b24cca31019a3faf.tar.gz external_llvm-9dbb42944c4d7caddab21016b24cca31019a3faf.tar.bz2 | |
rename SimplifyCompare -> SimplifyCmpInst and split it into
Simplify[IF]Cmp pieces. Add some predicates to CmpInst to
determine whether a predicate is fp or int.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86624 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
| -rw-r--r-- | include/llvm/Analysis/InstructionSimplify.h | 17 | ||||
| -rw-r--r-- | include/llvm/InstrTypes.h | 14 |
2 files changed, 28 insertions, 3 deletions
diff --git a/include/llvm/Analysis/InstructionSimplify.h b/include/llvm/Analysis/InstructionSimplify.h index 7d75435..7d452ba 100644 --- a/include/llvm/Analysis/InstructionSimplify.h +++ b/include/llvm/Analysis/InstructionSimplify.h @@ -20,11 +20,24 @@ namespace llvm { class Value; class TargetData; - /// SimplifyCompare - Given operands for a CmpInst, see if we can + /// SimplifyICmpInst - Given operands for an ICmpInst, see if we can /// fold the result. If not, this returns null. - Value *SimplifyCompare(unsigned Predicate, Value *LHS, Value *RHS, + Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, const TargetData *TD = 0); + /// SimplifyFCmpInst - Given operands for an FCmpInst, see if we can + /// fold the result. If not, this returns null. + Value *SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, + const TargetData *TD = 0); + + + //=== Helper functions for higher up the class hierarchy. + + + /// SimplifyCmpInst - Given operands for a CmpInst, see if we can + /// fold the result. If not, this returns null. + Value *SimplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS, + const TargetData *TD = 0); /// SimplifyBinOp - Given operands for a BinaryOperator, see if we can /// fold the result. If not, this returns null. diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index df7eb43..12fa97d 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -658,7 +658,7 @@ public: /// @brief Create a CmpInst static CmpInst *Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, const Twine &Name, BasicBlock *InsertAtEnd); - + /// @brief Get the opcode casted to the right type OtherOps getOpcode() const { return static_cast<OtherOps>(Instruction::getOpcode()); @@ -670,6 +670,18 @@ public: /// @brief Set the predicate for this instruction to the specified value. void setPredicate(Predicate P) { SubclassData = P; } + static bool isFPPredicate(Predicate P) { + return P >= FIRST_FCMP_PREDICATE && P <= LAST_FCMP_PREDICATE; + } + + static bool isIntPredicate(Predicate P) { + return P >= FIRST_ICMP_PREDICATE && P <= LAST_ICMP_PREDICATE; + } + + bool isFPPredicate() const { return isFPPredicate(getPredicate()); } + bool isIntPredicate() const { return isIntPredicate(getPredicate()); } + + /// 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. |
