Initial revision
[oota-llvm.git] / lib / VMCore / iOperators.cpp
1 //===-- iBinaryOperators.cpp - Implement the BinaryOperators -----*- C++ -*--=//
2 //
3 // This file implements the nontrivial binary operator instructions.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #include "llvm/iBinary.h"
8 #include "llvm/Type.h"
9
10 //===----------------------------------------------------------------------===//
11 //                             SetCondInst Class
12 //===----------------------------------------------------------------------===//
13
14 SetCondInst::SetCondInst(BinaryOps opType, Value *S1, Value *S2, 
15                          const string &Name) 
16   : BinaryOperator(opType, S1, S2, Name) {
17
18   OpType = opType;
19   setType(Type::BoolTy);   // setcc instructions always return bool type.
20
21   // Make sure it's a valid type...
22   assert(getOpcode() != "Invalid opcode type to SetCondInst class!");
23 }
24
25 string SetCondInst::getOpcode() const {
26   switch (OpType) {
27   case SetLE:  return "setle";
28   case SetGE:  return "setge";
29   case SetLT:  return "setlt";
30   case SetGT:  return "setgt";
31   case SetEQ:  return "seteq";
32   case SetNE:  return "setne";
33   default:
34     assert(0 && "Invalid opcode type to SetCondInst class!");
35     return "invalid opcode type to SetCondInst";
36   }
37 }