Added support for type inquiry in subclasses of InstTreeNode.
[oota-llvm.git] / include / llvm / iOperators.h
1 //===-- llvm/iBinary.h - Binary Operator node definitions --------*- C++ -*--=//
2 //
3 // This file contains the declarations of all of the Binary Operator classes.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #ifndef LLVM_IBINARY_H
8 #define LLVM_IBINARY_H
9
10 #include "llvm/InstrTypes.h"
11
12 //===----------------------------------------------------------------------===//
13 //                 Classes to represent Binary operators
14 //===----------------------------------------------------------------------===//
15 //
16 // All of these classes are subclasses of the BinaryOperator class...
17 //
18
19 class GenericBinaryInst : public BinaryOperator {
20 public:
21   GenericBinaryInst(BinaryOps Opcode, Value *S1, Value *S2, 
22                     const std::string &Name = "")
23     : BinaryOperator(Opcode, S1, S2, Name) {
24   }
25 };
26
27 class SetCondInst : public BinaryOperator {
28   BinaryOps OpType;
29 public:
30   SetCondInst(BinaryOps opType, Value *S1, Value *S2, 
31               const std::string &Name = "");
32
33   // getInverseCondition - Return the inverse of the current condition opcode.
34   // For example seteq -> setne, setgt -> setle, setlt -> setge, etc...
35   //
36   BinaryOps getInverseCondition() const;
37
38   // Methods for support type inquiry through isa, cast, and dyn_cast:
39   static inline bool classof(const SetCondInst *) { return true; }
40   static inline bool classof(const Instruction *I) {
41     return I->getOpcode() == SetEQ || I->getOpcode() == SetNE ||
42            I->getOpcode() == SetLE || I->getOpcode() == SetGE ||
43            I->getOpcode() == SetLT || I->getOpcode() == SetGT;
44   }
45   static inline bool classof(const Value *V) {
46     return isa<Instruction>(V) && classof(cast<Instruction>(V));
47   }
48 };
49
50 #endif