Implement two constructor functions for "unary" instructions
authorChris Lattner <sabre@nondot.org>
Wed, 14 Aug 2002 17:52:27 +0000 (17:52 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 14 Aug 2002 17:52:27 +0000 (17:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3317 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/iOperators.cpp

index bc37df5cb7f1bb03fde0d477c41ff4d3384ed2cc..f520ff52f5b0859d678389ed3ad922039c77c1bc 100644 (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