Chris Lattner | 2e9fe0a | 2002-09-10 15:34:41 +0000 | [diff] [blame] | 1 | //===-- llvm/iOperators.h - Binary Operator node definitions ----*- C++ -*-===// |
John Criswell | 6fbcc26 | 2003-10-20 20:19:47 +0000 | [diff] [blame^] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 9 | // |
Chris Lattner | 2e9fe0a | 2002-09-10 15:34:41 +0000 | [diff] [blame] | 10 | // This file contains the declarations of the Binary Operator classes. |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Chris Lattner | 2e9fe0a | 2002-09-10 15:34:41 +0000 | [diff] [blame] | 14 | #ifndef LLVM_IOPERATORS_H |
| 15 | #define LLVM_IOPERATORS_H |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 16 | |
| 17 | #include "llvm/InstrTypes.h" |
| 18 | |
Chris Lattner | 2e9fe0a | 2002-09-10 15:34:41 +0000 | [diff] [blame] | 19 | /// SetCondInst class - Represent a setCC operator, where CC is eq, ne, lt, gt, |
| 20 | /// le, or ge. |
| 21 | /// |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 22 | class SetCondInst : public BinaryOperator { |
| 23 | BinaryOps OpType; |
| 24 | public: |
Chris Lattner | 3d92ac2 | 2002-09-01 19:46:36 +0000 | [diff] [blame] | 25 | SetCondInst(BinaryOps Opcode, Value *LHS, Value *RHS, |
Chris Lattner | 2e9fe0a | 2002-09-10 15:34:41 +0000 | [diff] [blame] | 26 | const std::string &Name = "", Instruction *InsertBefore = 0); |
Chris Lattner | bacb8b9 | 2002-08-20 18:17:09 +0000 | [diff] [blame] | 27 | |
Chris Lattner | 3d92ac2 | 2002-09-01 19:46:36 +0000 | [diff] [blame] | 28 | /// getInverseCondition - Return the inverse of the current condition opcode. |
| 29 | /// For example seteq -> setne, setgt -> setle, setlt -> setge, etc... |
| 30 | /// |
| 31 | BinaryOps getInverseCondition() const { |
| 32 | return getInverseCondition(getOpcode()); |
| 33 | } |
| 34 | |
| 35 | /// getInverseCondition - Static version that you can use without an |
| 36 | /// instruction available. |
| 37 | /// |
| 38 | static BinaryOps getInverseCondition(BinaryOps Opcode); |
| 39 | |
| 40 | /// getSwappedCondition - Return the condition opcode that would be the result |
| 41 | /// of exchanging the two operands of the setcc instruction without changing |
| 42 | /// the result produced. Thus, seteq->seteq, setle->setge, setlt->setgt, etc. |
| 43 | /// |
| 44 | BinaryOps getSwappedCondition() const { |
| 45 | return getSwappedCondition(getOpcode()); |
| 46 | } |
| 47 | |
| 48 | /// getSwappedCondition - Static version that you can use without an |
| 49 | /// instruction available. |
| 50 | /// |
| 51 | static BinaryOps getSwappedCondition(BinaryOps Opcode); |
| 52 | |
Chris Lattner | 615cdb9 | 2002-08-23 18:30:58 +0000 | [diff] [blame] | 53 | |
| 54 | // Methods for support type inquiry through isa, cast, and dyn_cast: |
| 55 | static inline bool classof(const SetCondInst *) { return true; } |
| 56 | static inline bool classof(const Instruction *I) { |
| 57 | return I->getOpcode() == SetEQ || I->getOpcode() == SetNE || |
| 58 | I->getOpcode() == SetLE || I->getOpcode() == SetGE || |
| 59 | I->getOpcode() == SetLT || I->getOpcode() == SetGT; |
| 60 | } |
| 61 | static inline bool classof(const Value *V) { |
| 62 | return isa<Instruction>(V) && classof(cast<Instruction>(V)); |
| 63 | } |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | #endif |