diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-13 04:09:18 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-13 04:09:18 +0000 |
commit | 0a5372ed3e8cda10d724feda3c1a1c998db05ca0 (patch) | |
tree | 89dc39f73d938c223b4e192bc6fd918490a60218 /lib/VMCore/Instructions.cpp | |
parent | f1db120d0494ec55d9265cea7dab22e80dcae10c (diff) |
Begin the painful process of tearing apart the rat'ss nest that is Constants.cpp and ConstantFold.cpp.
This involves temporarily hard wiring some parts to use the global context. This isn't ideal, but it's
the only way I could figure out to make this process vaguely incremental.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75445 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Instructions.cpp')
-rw-r--r-- | lib/VMCore/Instructions.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 475d8cdd56..74bcc10041 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -1633,33 +1633,37 @@ BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2, return Res; } -BinaryOperator *BinaryOperator::CreateNeg(Value *Op, const std::string &Name, +BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context, + Value *Op, const std::string &Name, Instruction *InsertBefore) { - Value *zero = ConstantExpr::getZeroValueForNegationExpr(Op->getType()); + Value *zero = Context.getZeroValueForNegation(Op->getType()); return new BinaryOperator(Instruction::Sub, zero, Op, Op->getType(), Name, InsertBefore); } -BinaryOperator *BinaryOperator::CreateNeg(Value *Op, const std::string &Name, +BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context, + Value *Op, const std::string &Name, BasicBlock *InsertAtEnd) { - Value *zero = ConstantExpr::getZeroValueForNegationExpr(Op->getType()); + Value *zero = Context.getZeroValueForNegation(Op->getType()); return new BinaryOperator(Instruction::Sub, zero, Op, Op->getType(), Name, InsertAtEnd); } -BinaryOperator *BinaryOperator::CreateFNeg(Value *Op, const std::string &Name, +BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context, + Value *Op, const std::string &Name, Instruction *InsertBefore) { - Value *zero = ConstantExpr::getZeroValueForNegationExpr(Op->getType()); + Value *zero = Context.getZeroValueForNegation(Op->getType()); return new BinaryOperator(Instruction::FSub, zero, Op, Op->getType(), Name, InsertBefore); } -BinaryOperator *BinaryOperator::CreateFNeg(Value *Op, const std::string &Name, +BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context, + Value *Op, const std::string &Name, BasicBlock *InsertAtEnd) { - Value *zero = ConstantExpr::getZeroValueForNegationExpr(Op->getType()); + Value *zero = Context.getZeroValueForNegation(Op->getType()); return new BinaryOperator(Instruction::FSub, zero, Op, Op->getType(), Name, InsertAtEnd); @@ -1705,19 +1709,19 @@ static inline bool isConstantAllOnes(const Value *V) { return false; } -bool BinaryOperator::isNeg(const Value *V) { +bool BinaryOperator::isNeg(LLVMContext &Context, const Value *V) { if (const BinaryOperator *Bop = dyn_cast<BinaryOperator>(V)) if (Bop->getOpcode() == Instruction::Sub) return Bop->getOperand(0) == - ConstantExpr::getZeroValueForNegationExpr(Bop->getType()); + Context.getZeroValueForNegation(Bop->getType()); return false; } -bool BinaryOperator::isFNeg(const Value *V) { +bool BinaryOperator::isFNeg(LLVMContext &Context, const Value *V) { if (const BinaryOperator *Bop = dyn_cast<BinaryOperator>(V)) if (Bop->getOpcode() == Instruction::FSub) return Bop->getOperand(0) == - ConstantExpr::getZeroValueForNegationExpr(Bop->getType()); + Context.getZeroValueForNegation(Bop->getType()); return false; } @@ -1730,7 +1734,6 @@ bool BinaryOperator::isNot(const Value *V) { } Value *BinaryOperator::getNegArgument(Value *BinOp) { - assert(isNeg(BinOp) && "getNegArgument from non-'neg' instruction!"); return cast<BinaryOperator>(BinOp)->getOperand(1); } @@ -1739,7 +1742,6 @@ const Value *BinaryOperator::getNegArgument(const Value *BinOp) { } Value *BinaryOperator::getFNegArgument(Value *BinOp) { - assert(isFNeg(BinOp) && "getFNegArgument from non-'fneg' instruction!"); return cast<BinaryOperator>(BinOp)->getOperand(1); } |