Implement two constructor functions for "unary" instructions

llvm-svn: 3317
This commit is contained in:
Chris Lattner 2002-08-14 17:52:27 +00:00
parent 4ec79c3e6f
commit 3733c7374e
1 changed files with 13 additions and 0 deletions

View File

@ -6,6 +6,7 @@
#include "llvm/iOperators.h"
#include "llvm/Type.h"
#include "llvm/Constants.h"
using std::cerr;
//===----------------------------------------------------------------------===//
@ -40,6 +41,18 @@ BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2,
}
}
BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name) {
return new GenericBinaryInst(Instruction::Sub,
Constant::getNullValue(Op->getType()), Op, Name);
}
BinaryOperator *BinaryOperator::createNot(Value *Op, const std::string &Name) {
return new GenericBinaryInst(Instruction::Xor, Op,
ConstantIntegral::getAllOnesValue(Op->getType()),
Name);
}
// swapOperands - Exchange the two operands to this instruction. This
// instruction is safe to use on any binary instruction and does not
// modify the semantics of the instruction. If the instruction is