Simplify condition, this does not change the predicate at all though
[oota-llvm.git] / include / llvm / iOperators.h
1 //===-- llvm/iOperators.h - Binary Operator node definitions ----*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the declarations of the Binary Operator classes.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_IOPERATORS_H
15 #define LLVM_IOPERATORS_H
16
17 #include "llvm/InstrTypes.h"
18
19 namespace llvm {
20
21 /// SetCondInst class - Represent a setCC operator, where CC is eq, ne, lt, gt,
22 /// le, or ge.
23 ///
24 class SetCondInst : public BinaryOperator {
25   BinaryOps OpType;
26 public:
27   SetCondInst(BinaryOps Opcode, Value *LHS, Value *RHS,
28               const std::string &Name = "", Instruction *InsertBefore = 0);
29
30   /// getInverseCondition - Return the inverse of the current condition opcode.
31   /// For example seteq -> setne, setgt -> setle, setlt -> setge, etc...
32   ///
33   BinaryOps getInverseCondition() const {
34     return getInverseCondition(getOpcode());
35   }
36
37   /// getInverseCondition - Static version that you can use without an
38   /// instruction available.
39   ///
40   static BinaryOps getInverseCondition(BinaryOps Opcode);
41
42   /// getSwappedCondition - Return the condition opcode that would be the result
43   /// of exchanging the two operands of the setcc instruction without changing
44   /// the result produced.  Thus, seteq->seteq, setle->setge, setlt->setgt, etc.
45   ///
46   BinaryOps getSwappedCondition() const {
47     return getSwappedCondition(getOpcode());
48   }
49
50   /// getSwappedCondition - Static version that you can use without an
51   /// instruction available.
52   ///
53   static BinaryOps getSwappedCondition(BinaryOps Opcode);
54
55
56   // Methods for support type inquiry through isa, cast, and dyn_cast:
57   static inline bool classof(const SetCondInst *) { return true; }
58   static inline bool classof(const Instruction *I) {
59     return I->getOpcode() == SetEQ || I->getOpcode() == SetNE ||
60            I->getOpcode() == SetLE || I->getOpcode() == SetGE ||
61            I->getOpcode() == SetLT || I->getOpcode() == SetGT;
62   }
63   static inline bool classof(const Value *V) {
64     return isa<Instruction>(V) && classof(cast<Instruction>(V));
65   }
66 };
67
68 } // End llvm namespace
69
70 #endif