a6a8fff40ce9707fdca087ee439378ebca94bbdb
[oota-llvm.git] / include / llvm / InstrTypes.h
1 //===-- llvm/InstrTypes.h - Important Instruction subclasses ----*- 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 defines various meta classes of instructions that exist in the VM
11 // representation.  Specific concrete subclasses of these may be found in the
12 // i*.h files...
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_INSTRUCTION_TYPES_H
17 #define LLVM_INSTRUCTION_TYPES_H
18
19 #include "llvm/Instruction.h"
20
21 namespace llvm {
22
23 //===----------------------------------------------------------------------===//
24 //                            TerminatorInst Class
25 //===----------------------------------------------------------------------===//
26
27 /// TerminatorInst - Subclasses of this class are all able to terminate a basic
28 /// block.  Thus, these are all the flow control type of operations.
29 ///
30 class TerminatorInst : public Instruction {
31 protected:
32   TerminatorInst(const Type *Ty, Instruction::TermOps iType,
33                  Use *Ops, unsigned NumOps,
34                  Instruction *InsertBefore = 0)
35     : Instruction(Ty, iType, Ops, NumOps, InsertBefore) {}
36
37   TerminatorInst(const Type *Ty, Instruction::TermOps iType,
38                  Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd)
39     : Instruction(Ty, iType, Ops, NumOps, InsertAtEnd) {}
40
41   // Out of line virtual method, so the vtable, etc has a home.
42   ~TerminatorInst();
43
44   /// Virtual methods - Terminators should overload these and provide inline
45   /// overrides of non-V methods.
46   virtual BasicBlock *getSuccessorV(unsigned idx) const = 0;
47   virtual unsigned getNumSuccessorsV() const = 0;
48   virtual void setSuccessorV(unsigned idx, BasicBlock *B) = 0;
49 public:
50
51   virtual Instruction *clone() const = 0;
52
53   /// getNumSuccessors - Return the number of successors that this terminator
54   /// has.
55   unsigned getNumSuccessors() const {
56     return getNumSuccessorsV();
57   }
58
59   /// getSuccessor - Return the specified successor.
60   ///
61   BasicBlock *getSuccessor(unsigned idx) const {
62     return getSuccessorV(idx);
63   }
64
65   /// setSuccessor - Update the specified successor to point at the provided
66   /// block.
67   void setSuccessor(unsigned idx, BasicBlock *B) {
68     setSuccessorV(idx, B);
69   }
70
71   // Methods for support type inquiry through isa, cast, and dyn_cast:
72   static inline bool classof(const TerminatorInst *) { return true; }
73   static inline bool classof(const Instruction *I) {
74     return I->getOpcode() >= TermOpsBegin && I->getOpcode() < TermOpsEnd;
75   }
76   static inline bool classof(const Value *V) {
77     return isa<Instruction>(V) && classof(cast<Instruction>(V));
78   }
79 };
80
81 //===----------------------------------------------------------------------===//
82 //                          UnaryInstruction Class
83 //===----------------------------------------------------------------------===//
84
85 class UnaryInstruction : public Instruction {
86   Use Op;
87   
88   // avoiding warning: 'this' : used in base member initializer list
89   UnaryInstruction* this_() { return this; }
90 protected:
91   UnaryInstruction(const Type *Ty, unsigned iType, Value *V, Instruction *IB =0)
92     : Instruction(Ty, iType, &Op, 1, IB), Op(V, this_()) {
93   }
94   UnaryInstruction(const Type *Ty, unsigned iType, Value *V, BasicBlock *IAE)
95     : Instruction(Ty, iType, &Op, 1, IAE), Op(V, this_()) {
96   }
97 public:
98   // Out of line virtual method, so the vtable, etc has a home.
99   ~UnaryInstruction();
100
101   // Transparently provide more efficient getOperand methods.
102   Value *getOperand(unsigned i) const {
103     assert(i == 0 && "getOperand() out of range!");
104     return Op;
105   }
106   void setOperand(unsigned i, Value *Val) {
107     assert(i == 0 && "setOperand() out of range!");
108     Op = Val;
109   }
110   unsigned getNumOperands() const { return 1; }
111   
112   // Methods for support type inquiry through isa, cast, and dyn_cast:
113   static inline bool classof(const UnaryInstruction *) { return true; }
114   static inline bool classof(const Instruction *I) {
115     return I->getOpcode() == Instruction::Malloc ||
116            I->getOpcode() == Instruction::Alloca ||
117            I->getOpcode() == Instruction::Free ||
118            I->getOpcode() == Instruction::Load ||
119            I->getOpcode() == Instruction::VAArg ||
120            (I->getOpcode() >= CastOpsBegin && I->getOpcode() < CastOpsEnd);
121   }
122   static inline bool classof(const Value *V) {
123     return isa<Instruction>(V) && classof(cast<Instruction>(V));
124   }
125 };
126
127 //===----------------------------------------------------------------------===//
128 //                           BinaryOperator Class
129 //===----------------------------------------------------------------------===//
130
131 class BinaryOperator : public Instruction {
132   Use Ops[2];
133 protected:
134   void init(BinaryOps iType);
135   BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
136                  const std::string &Name, Instruction *InsertBefore);
137   BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
138                  const std::string &Name, BasicBlock *InsertAtEnd);
139 public:
140
141   /// Transparently provide more efficient getOperand methods.
142   Value *getOperand(unsigned i) const {
143     assert(i < 2 && "getOperand() out of range!");
144     return Ops[i];
145   }
146   void setOperand(unsigned i, Value *Val) {
147     assert(i < 2 && "setOperand() out of range!");
148     Ops[i] = Val;
149   }
150   unsigned getNumOperands() const { return 2; }
151
152   /// create() - Construct a binary instruction, given the opcode and the two
153   /// operands.  Optionally (if InstBefore is specified) insert the instruction
154   /// into a BasicBlock right before the specified instruction.  The specified
155   /// Instruction is allowed to be a dereferenced end iterator.
156   ///
157   static BinaryOperator *create(BinaryOps Op, Value *S1, Value *S2,
158                                 const std::string &Name = "",
159                                 Instruction *InsertBefore = 0);
160
161   /// create() - Construct a binary instruction, given the opcode and the two
162   /// operands.  Also automatically insert this instruction to the end of the
163   /// BasicBlock specified.
164   ///
165   static BinaryOperator *create(BinaryOps Op, Value *S1, Value *S2,
166                                 const std::string &Name,
167                                 BasicBlock *InsertAtEnd);
168
169   /// create* - These methods just forward to create, and are useful when you
170   /// statically know what type of instruction you're going to create.  These
171   /// helpers just save some typing.
172 #define HANDLE_BINARY_INST(N, OPC, CLASS) \
173   static BinaryOperator *create##OPC(Value *V1, Value *V2, \
174                                      const std::string &Name = "") {\
175     return create(Instruction::OPC, V1, V2, Name);\
176   }
177 #include "llvm/Instruction.def"
178 #define HANDLE_BINARY_INST(N, OPC, CLASS) \
179   static BinaryOperator *create##OPC(Value *V1, Value *V2, \
180                                      const std::string &Name, BasicBlock *BB) {\
181     return create(Instruction::OPC, V1, V2, Name, BB);\
182   }
183 #include "llvm/Instruction.def"
184 #define HANDLE_BINARY_INST(N, OPC, CLASS) \
185   static BinaryOperator *create##OPC(Value *V1, Value *V2, \
186                                      const std::string &Name, Instruction *I) {\
187     return create(Instruction::OPC, V1, V2, Name, I);\
188   }
189 #include "llvm/Instruction.def"
190
191
192   /// Helper functions to construct and inspect unary operations (NEG and NOT)
193   /// via binary operators SUB and XOR:
194   ///
195   /// createNeg, createNot - Create the NEG and NOT
196   ///     instructions out of SUB and XOR instructions.
197   ///
198   static BinaryOperator *createNeg(Value *Op, const std::string &Name = "",
199                                    Instruction *InsertBefore = 0);
200   static BinaryOperator *createNeg(Value *Op, const std::string &Name,
201                                    BasicBlock *InsertAtEnd);
202   static BinaryOperator *createNot(Value *Op, const std::string &Name = "",
203                                    Instruction *InsertBefore = 0);
204   static BinaryOperator *createNot(Value *Op, const std::string &Name,
205                                    BasicBlock *InsertAtEnd);
206
207   /// isNeg, isNot - Check if the given Value is a NEG or NOT instruction.
208   ///
209   static bool isNeg(const Value *V);
210   static bool isNot(const Value *V);
211
212   /// getNegArgument, getNotArgument - Helper functions to extract the
213   ///     unary argument of a NEG or NOT operation implemented via Sub or Xor.
214   ///
215   static const Value *getNegArgument(const Value *BinOp);
216   static       Value *getNegArgument(      Value *BinOp);
217   static const Value *getNotArgument(const Value *BinOp);
218   static       Value *getNotArgument(      Value *BinOp);
219
220   BinaryOps getOpcode() const {
221     return static_cast<BinaryOps>(Instruction::getOpcode());
222   }
223
224   virtual BinaryOperator *clone() const;
225
226   /// swapOperands - Exchange the two operands to this instruction.
227   /// This instruction is safe to use on any binary instruction and
228   /// does not modify the semantics of the instruction.  If the
229   /// instruction is order dependent (SetLT f.e.) the opcode is
230   /// changed.  If the instruction cannot be reversed (ie, it's a Div),
231   /// then return true.
232   ///
233   bool swapOperands();
234
235   // Methods for support type inquiry through isa, cast, and dyn_cast:
236   static inline bool classof(const BinaryOperator *) { return true; }
237   static inline bool classof(const Instruction *I) {
238     return I->getOpcode() >= BinaryOpsBegin && I->getOpcode() < BinaryOpsEnd;
239   }
240   static inline bool classof(const Value *V) {
241     return isa<Instruction>(V) && classof(cast<Instruction>(V));
242   }
243 };
244
245 //===----------------------------------------------------------------------===//
246 //                               CastInst Class
247 //===----------------------------------------------------------------------===//
248
249 /// CastInst - This is the base class for all instructions that perform data
250 /// casts. It is simply provided so that instruction category testing
251 /// can be performed with code like:
252 ///
253 /// if (isa<CastInst>(Instr)) { ... }
254 /// @brief Base class of casting instructions.
255 class CastInst : public UnaryInstruction {
256   /// @brief Copy constructor
257   CastInst(const CastInst &CI)
258     : UnaryInstruction(CI.getType(), CI.getOpcode(), CI.getOperand(0)) {
259   }
260   /// @brief Do not allow default construction
261   CastInst(); 
262 protected:
263   /// @brief Constructor with insert-before-instruction semantics for subclasses
264   CastInst(const Type *Ty, unsigned iType, Value *S, 
265            const std::string &Name = "", Instruction *InsertBefore = 0)
266     : UnaryInstruction(Ty, iType, S, InsertBefore) {
267     setName(Name);
268   }
269   /// @brief Constructor with insert-at-end-of-block semantics for subclasses
270   CastInst(const Type *Ty, unsigned iType, Value *S, 
271            const std::string &Name, BasicBlock *InsertAtEnd)
272     : UnaryInstruction(Ty, iType, S, InsertAtEnd) {
273     setName(Name);
274   }
275 public:
276   /// Provides a way to construct any of the CastInst subclasses using an 
277   /// opcode instead of the subclass's constructor. The opcode must be in the
278   /// CastOps category (Instruction::isCast(opcode) returns true). This
279   /// constructor has insert-before-instruction semantics to automatically
280   /// insert the new CastInst before InsertBefore (if it is non-null).
281   /// @brief Construct any of the CastInst subclasses
282   static CastInst *create(
283     Instruction::CastOps,    ///< The opcode of the cast instruction
284     Value *S,                ///< The value to be casted (operand 0)
285     const Type *Ty,          ///< The type to which cast should be made
286     const std::string &Name = "", ///< Name for the instruction
287     Instruction *InsertBefore = 0 ///< Place to insert the instruction
288   );
289   /// Provides a way to construct any of the CastInst subclasses using an
290   /// opcode instead of the subclass's constructor. The opcode must be in the
291   /// CastOps category. This constructor has insert-at-end-of-block semantics
292   /// to automatically insert the new CastInst at the end of InsertAtEnd (if
293   /// its non-null).
294   /// @brief Construct any of the CastInst subclasses
295   static CastInst *create(
296     Instruction::CastOps,    ///< The opcode for the cast instruction
297     Value *S,                ///< The value to be casted (operand 0)
298     const Type *Ty,          ///< The type to which operand is casted
299     const std::string &Name, ///< The name for the instruction
300     BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
301   );
302
303   /// @brief Create a ZExt or BitCast cast instruction
304   static CastInst *createZExtOrBitCast(
305     Value *S,                ///< The value to be casted (operand 0)
306     const Type *Ty,          ///< The type to which cast should be made
307     const std::string &Name = "", ///< Name for the instruction
308     Instruction *InsertBefore = 0 ///< Place to insert the instruction
309   );
310
311   /// @brief Create a ZExt or BitCast cast instruction
312   static CastInst *createZExtOrBitCast(
313     Value *S,                ///< The value to be casted (operand 0)
314     const Type *Ty,          ///< The type to which operand is casted
315     const std::string &Name, ///< The name for the instruction
316     BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
317   );
318
319   /// @brief Create a SExt or BitCast cast instruction
320   static CastInst *createSExtOrBitCast(
321     Value *S,                ///< The value to be casted (operand 0)
322     const Type *Ty,          ///< The type to which cast should be made
323     const std::string &Name = "", ///< Name for the instruction
324     Instruction *InsertBefore = 0 ///< Place to insert the instruction
325   );
326
327   /// @brief Create a BitCast or a PtrToInt cast instruction
328   static CastInst *createPointerCast(
329     Value *S,                ///< The pointer value to be casted (operand 0)
330     const Type *Ty,          ///< The type to which operand is casted
331     const std::string &Name, ///< The name for the instruction
332     BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
333   );
334
335   /// @brief Create a BitCast or a PtrToInt cast instruction
336   static CastInst *createPointerCast(
337     Value *S,                ///< The pointer value to be casted (operand 0)
338     const Type *Ty,          ///< The type to which cast should be made
339     const std::string &Name = "", ///< Name for the instruction
340     Instruction *InsertBefore = 0 ///< Place to insert the instruction
341   );
342
343   /// @brief Create a ZExt, BitCast, or Trunc for int -> int casts.
344   static CastInst *createIntegerCast(
345     Value *S,                ///< The pointer value to be casted (operand 0)
346     const Type *Ty,          ///< The type to which cast should be made
347     bool isSigned,           ///< Whether to regard S as signed or not
348     const std::string &Name = "", ///< Name for the instruction
349     Instruction *InsertBefore = 0 ///< Place to insert the instruction
350   );
351
352   /// @brief Create a ZExt, BitCast, or Trunc for int -> int casts.
353   static CastInst *createIntegerCast(
354     Value *S,                ///< The integer value to be casted (operand 0)
355     const Type *Ty,          ///< The integer type to which operand is casted
356     bool isSigned,           ///< Whether to regard S as signed or not
357     const std::string &Name, ///< The name for the instruction
358     BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
359   );
360
361   /// @brief Create an FPExt, BitCast, or FPTrunc for fp -> fp casts
362   static CastInst *createFPCast(
363     Value *S,                ///< The floating point value to be casted 
364     const Type *Ty,          ///< The floating point type to cast to
365     const std::string &Name = "", ///< Name for the instruction
366     Instruction *InsertBefore = 0 ///< Place to insert the instruction
367   );
368
369   /// @brief Create an FPExt, BitCast, or FPTrunc for fp -> fp casts
370   static CastInst *createFPCast(
371     Value *S,                ///< The floating point value to be casted 
372     const Type *Ty,          ///< The floating point type to cast to
373     const std::string &Name, ///< The name for the instruction
374     BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
375   );
376
377   /// @brief Create a SExt or BitCast cast instruction
378   static CastInst *createSExtOrBitCast(
379     Value *S,                ///< The value to be casted (operand 0)
380     const Type *Ty,          ///< The type to which operand is casted
381     const std::string &Name, ///< The name for the instruction
382     BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
383   );
384
385   /// @brief Create a Trunc or BitCast cast instruction
386   static CastInst *createTruncOrBitCast(
387     Value *S,                ///< The value to be casted (operand 0)
388     const Type *Ty,          ///< The type to which cast should be made
389     const std::string &Name = "", ///< Name for the instruction
390     Instruction *InsertBefore = 0 ///< Place to insert the instruction
391   );
392
393   /// @brief Create a Trunc or BitCast cast instruction
394   static CastInst *createTruncOrBitCast(
395     Value *S,                ///< The value to be casted (operand 0)
396     const Type *Ty,          ///< The type to which operand is casted
397     const std::string &Name, ///< The name for the instruction
398     BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
399   );
400
401   /// Returns the opcode necessary to cast Val into Ty using usual casting
402   /// rules. 
403   /// @brief Infer the opcode for cast operand and type
404   static Instruction::CastOps getCastOpcode(
405     const Value *Val, ///< The value to cast
406     bool SrcIsSigned, ///< Whether to treat the source as signed
407     const Type *Ty,   ///< The Type to which the value should be casted
408     bool DstIsSigned  ///< Whether to treate the dest. as signed
409   );
410
411   /// There are several places where we need to know if a cast instruction 
412   /// only deals with integer source and destination types. To simplify that
413   /// logic, this method is provided.
414   /// @returns true iff the cast has only integral typed operand and dest type.
415   /// @brief Determine if this is an integer-only cast.
416   bool isIntegerCast() const;
417
418   /// A lossless cast is one that does not alter the basic value. It implies
419   /// a no-op cast but is more stringent, preventing things like int->float,
420   /// long->double, int->ptr, or vector->anything. 
421   /// @returns true iff the cast is lossless.
422   /// @brief Determine if this is a lossless cast.
423   bool isLosslessCast() const;
424
425   /// A no-op cast is one that can be effected without changing any bits. 
426   /// It implies that the source and destination types are the same size. The
427   /// IntPtrTy argument is used to make accurate determinations for casts 
428   /// involving Integer and Pointer types. They are no-op casts if the integer
429   /// is the same size as the pointer. However, pointer size varies with 
430   /// platform. Generally, the result of TargetData::getIntPtrType() should be
431   /// passed in. If that's not available, use Type::Int64Ty, which will make
432   /// the isNoopCast call conservative.
433   /// @brief Determine if this cast is a no-op cast. 
434   bool isNoopCast(
435     const Type *IntPtrTy ///< Integer type corresponding to pointer
436   ) const;
437
438   /// Determine how a pair of casts can be eliminated, if they can be at all.
439   /// This is a helper function for both CastInst and ConstantExpr.
440   /// @returns 0 if the CastInst pair can't be eliminated
441   /// @returns Instruction::CastOps value for a cast that can replace 
442   /// the pair, casting SrcTy to DstTy.
443   /// @brief Determine if a cast pair is eliminable
444   static unsigned isEliminableCastPair(
445     Instruction::CastOps firstOpcode,  ///< Opcode of first cast
446     Instruction::CastOps secondOpcode, ///< Opcode of second cast
447     const Type *SrcTy, ///< SrcTy of 1st cast
448     const Type *MidTy, ///< DstTy of 1st cast & SrcTy of 2nd cast
449     const Type *DstTy, ///< DstTy of 2nd cast
450     const Type *IntPtrTy ///< Integer type corresponding to Ptr types
451   );
452
453   /// @brief Return the opcode of this CastInst
454   Instruction::CastOps getOpcode() const { 
455     return Instruction::CastOps(Instruction::getOpcode()); 
456   }
457
458   /// @brief Return the source type, as a convenience
459   const Type* getSrcTy() const { return getOperand(0)->getType(); }
460   /// @brief Return the destination type, as a convenience
461   const Type* getDestTy() const { return getType(); }
462
463   /// This method can be used to determine if a cast from S to DstTy using
464   /// Opcode op is valid or not. 
465   /// @returns true iff the proposed cast is valid.
466   /// @brief Determine if a cast is valid without creating one.
467   static bool castIsValid(Instruction::CastOps op, Value *S, const Type *DstTy);
468
469   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
470   static inline bool classof(const CastInst *) { return true; }
471   static inline bool classof(const Instruction *I) {
472     return I->getOpcode() >= CastOpsBegin && I->getOpcode() < CastOpsEnd;
473   }
474   static inline bool classof(const Value *V) {
475     return isa<Instruction>(V) && classof(cast<Instruction>(V));
476   }
477 };
478
479 //===----------------------------------------------------------------------===//
480 //                               CmpInst Class
481 //===----------------------------------------------------------------------===//
482
483 /// This class is the base class for the comparison instructions. 
484 /// @brief Abstract base class of comparison instructions.
485 class CmpInst: public Instruction {
486   CmpInst(); // do not implement
487 protected:
488   CmpInst(Instruction::OtherOps op, unsigned short pred, Value *LHS, Value *RHS,
489           const std::string &Name = "", Instruction *InsertBefore = 0);
490   
491   CmpInst(Instruction::OtherOps op, unsigned short pred, Value *LHS, Value *RHS,
492           const std::string &Name, BasicBlock *InsertAtEnd);
493
494   Use Ops[2]; // CmpInst instructions always have 2 operands, optimize
495
496 public:
497   /// Construct a compare instruction, given the opcode, the predicate and 
498   /// the two operands.  Optionally (if InstBefore is specified) insert the 
499   /// instruction into a BasicBlock right before the specified instruction.  
500   /// The specified Instruction is allowed to be a dereferenced end iterator.
501   /// @brief Create a CmpInst
502   static CmpInst *create(OtherOps Op, unsigned short predicate, Value *S1, 
503                          Value *S2, const std::string &Name = "",
504                          Instruction *InsertBefore = 0);
505
506   /// Construct a compare instruction, given the opcode, the predicate and the 
507   /// two operands.  Also automatically insert this instruction to the end of 
508   /// the BasicBlock specified.
509   /// @brief Create a CmpInst
510   static CmpInst *create(OtherOps Op, unsigned short predicate, Value *S1, 
511                          Value *S2, const std::string &Name, 
512                          BasicBlock *InsertAtEnd);
513
514   /// @brief Get the opcode casted to the right type
515   OtherOps getOpcode() const {
516     return static_cast<OtherOps>(Instruction::getOpcode());
517   }
518
519   /// The predicate for CmpInst is defined by the subclasses but stored in 
520   /// the SubclassData field (see Value.h).  We allow it to be fetched here
521   /// as the predicate but there is no enum type for it, just the raw unsigned 
522   /// short. This facilitates comparison of CmpInst instances without delving
523   /// into the subclasses since predicate values are distinct between the
524   /// CmpInst subclasses.
525   /// @brief Return the predicate for this instruction.
526   unsigned short getPredicate() const {
527     return SubclassData;
528   }
529
530   /// @brief Provide more efficient getOperand methods.
531   Value *getOperand(unsigned i) const {
532     assert(i < 2 && "getOperand() out of range!");
533     return Ops[i];
534   }
535   void setOperand(unsigned i, Value *Val) {
536     assert(i < 2 && "setOperand() out of range!");
537     Ops[i] = Val;
538   }
539
540   /// @brief CmpInst instructions always have 2 operands.
541   unsigned getNumOperands() const { return 2; }
542
543   /// This is just a convenience that dispatches to the subclasses.
544   /// @brief Swap the operands and adjust predicate accordingly to retain
545   /// the same comparison.
546   void swapOperands();
547
548   /// This is just a convenience that dispatches to the subclasses.
549   /// @brief Determine if this CmpInst is commutative.
550   bool isCommutative();
551
552   /// This is just a convenience that dispatches to the subclasses.
553   /// @brief Determine if this is an equals/not equals predicate.
554   bool isEquality();
555
556   /// @returns true if the predicate is unsigned, false otherwise.
557   /// @brief Determine if the predicate is an unsigned operation.
558   static bool isUnsigned(unsigned short predicate);
559
560   /// @returns true if the predicate is signed, false otherwise.
561   /// @brief Determine if the predicate is an signed operation.
562   static bool isSigned(unsigned short predicate);
563
564   /// @brief Determine if the predicate is an ordered operation.
565   static bool isOrdered(unsigned short predicate);
566
567   /// @brief Determine if the predicate is an unordered operation.
568   static bool isUnordered(unsigned short predicate);
569
570   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
571   static inline bool classof(const CmpInst *) { return true; }
572   static inline bool classof(const Instruction *I) {
573     return I->getOpcode() == Instruction::ICmp || 
574            I->getOpcode() == Instruction::FCmp;
575   }
576   static inline bool classof(const Value *V) {
577     return isa<Instruction>(V) && classof(cast<Instruction>(V));
578   }
579 };
580
581 } // End llvm namespace
582
583 #endif