1 //===-- iBinaryOperators.cpp - Implement the BinaryOperators -----*- C++ -*--=//
3 // This file implements the nontrivial binary operator instructions.
5 //===----------------------------------------------------------------------===//
7 #include "llvm/iBinary.h"
10 BinaryOperator *BinaryOperator::create(unsigned Op, Value *S1, Value *S2,
13 case Add: return new AddInst(S1, S2, Name);
14 case Sub: return new SubInst(S1, S2, Name);
21 return new SetCondInst((BinaryOps)Op, S1, S2, Name);
24 cerr << "Don't know how to GetBinaryOperator " << Op << endl;
29 //===----------------------------------------------------------------------===//
31 //===----------------------------------------------------------------------===//
33 SetCondInst::SetCondInst(BinaryOps opType, Value *S1, Value *S2,
35 : BinaryOperator(opType, S1, S2, Name) {
38 setType(Type::BoolTy); // setcc instructions always return bool type.
40 // Make sure it's a valid type...
41 assert(getOpcode() != "Invalid opcode type to SetCondInst class!");
44 string SetCondInst::getOpcode() const {
46 case SetLE: return "setle";
47 case SetGE: return "setge";
48 case SetLT: return "setlt";
49 case SetGT: return "setgt";
50 case SetEQ: return "seteq";
51 case SetNE: return "setne";
53 assert(0 && "Invalid opcode type to SetCondInst class!");
54 return "invalid opcode type to SetCondInst";