- BinaryOperator(unsigned iType, Value *S1, Value *S2,
- const string &Name = "")
- : Instruction(S1->getType(), iType, Name), Source1(S1, this),
- Source2(S2, this){
- assert(S1 && S2 && S1->getType() == S2->getType());
+ /// create() - Construct a binary instruction, given the opcode and the two
+ /// operands. Optionally (if InstBefore is specified) insert the instruction
+ /// into a BasicBlock right before the specified instruction. The specified
+ /// Instruction is allowed to be a dereferenced end iterator.
+ ///
+ static BinaryOperator *create(BinaryOps Op, Value *S1, Value *S2,
+ const std::string &Name = "",
+ Instruction *InsertBefore = 0);
+
+
+ /// Helper functions to construct and inspect unary operations (NEG and NOT)
+ /// via binary operators SUB and XOR:
+ ///
+ /// createNeg, createNot - Create the NEG and NOT
+ /// instructions out of SUB and XOR instructions.
+ ///
+ static BinaryOperator *createNeg(Value *Op, const std::string &Name = "",
+ Instruction *InsertBefore = 0);
+ static BinaryOperator *createNot(Value *Op, const std::string &Name = "",
+ Instruction *InsertBefore = 0);
+
+ /// isNeg, isNot - Check if the given Value is a NEG or NOT instruction.
+ ///
+ static bool isNeg(const Value *V);
+ static bool isNot(const Value *V);
+
+ /// getNegArgument, getNotArgument - Helper functions to extract the
+ /// unary argument of a NEG or NOT operation implemented via Sub or Xor.
+ ///
+ static const Value* getNegArgument(const BinaryOperator* Bop);
+ static Value* getNegArgument( BinaryOperator* Bop);
+ static const Value* getNotArgument(const BinaryOperator* Bop);
+ static Value* getNotArgument( BinaryOperator* Bop);
+
+ BinaryOps getOpcode() const {
+ return (BinaryOps)Instruction::getOpcode();