diff options
Diffstat (limited to 'llvm/lib/VMCore')
| -rw-r--r-- | llvm/lib/VMCore/AsmWriter.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/VMCore/ConstantHandling.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/VMCore/InstrTypes.cpp | 9 | ||||
| -rw-r--r-- | llvm/lib/VMCore/iOperators.cpp | 32 |
4 files changed, 34 insertions, 19 deletions
diff --git a/llvm/lib/VMCore/AsmWriter.cpp b/llvm/lib/VMCore/AsmWriter.cpp index 398f7a87b8e..d84cba0752b 100644 --- a/llvm/lib/VMCore/AsmWriter.cpp +++ b/llvm/lib/VMCore/AsmWriter.cpp @@ -207,7 +207,9 @@ bool AssemblyWriter::processInstruction(const Instruction *I) { Out << ","; writeOperand(I->getOperand(0), true); } - + } else if (I->getOpcode() == Instruction::Cast) { + writeOperand(Operand, true); + Out << " to " << I->getType(); } else if (Operand) { // Print the normal way... // PrintAllTypes - Instructions who have operands of all the same type diff --git a/llvm/lib/VMCore/ConstantHandling.cpp b/llvm/lib/VMCore/ConstantHandling.cpp index 54a79804818..e0a4ffbfb05 100644 --- a/llvm/lib/VMCore/ConstantHandling.cpp +++ b/llvm/lib/VMCore/ConstantHandling.cpp @@ -27,10 +27,6 @@ class TemplateRules : public ConstRules { // Redirecting functions that cast to the appropriate types //===--------------------------------------------------------------------===// - virtual ConstPoolVal *neg(const ConstPoolVal *V) const { - return SubClassName::Neg((const ArgType *)V); - } - virtual ConstPoolVal *not(const ConstPoolVal *V) const { return SubClassName::Not((const ArgType *)V); } @@ -55,7 +51,6 @@ class TemplateRules : public ConstRules { // Default "noop" implementations //===--------------------------------------------------------------------===// - inline static ConstPoolVal *Neg(const ArgType *V) { return 0; } inline static ConstPoolVal *Not(const ArgType *V) { return 0; } inline static ConstPoolVal *Add(const ArgType *V1, const ArgType *V2) { @@ -125,9 +120,6 @@ struct DirectRules : public TemplateRules<ConstPoolClass, DirectRules<ConstPoolClass, BuiltinType, Ty> > { - inline static ConstPoolVal *Neg(const ConstPoolClass *V) { - return new ConstPoolClass(*Ty, -(BuiltinType)V->getValue());; - } inline static ConstPoolVal *Not(const ConstPoolClass *V) { return new ConstPoolClass(*Ty, !(BuiltinType)V->getValue());; } diff --git a/llvm/lib/VMCore/InstrTypes.cpp b/llvm/lib/VMCore/InstrTypes.cpp index 9d3262cbda7..d0c410051a5 100644 --- a/llvm/lib/VMCore/InstrTypes.cpp +++ b/llvm/lib/VMCore/InstrTypes.cpp @@ -11,15 +11,6 @@ #include "llvm/Type.h" #include <algorithm> // find -// TODO: Move to getUnaryOperator iUnary.cpp when and if it exists! -UnaryOperator *UnaryOperator::create(UnaryOps Op, Value *Source) { - switch (Op) { - default: - cerr << "Don't know how to GetUnaryOperator " << Op << endl; - return 0; - } -} - //===----------------------------------------------------------------------===// // TerminatorInst Class //===----------------------------------------------------------------------===// diff --git a/llvm/lib/VMCore/iOperators.cpp b/llvm/lib/VMCore/iOperators.cpp index 61d5d26d2b4..6f7c2f158eb 100644 --- a/llvm/lib/VMCore/iOperators.cpp +++ b/llvm/lib/VMCore/iOperators.cpp @@ -7,6 +7,32 @@ #include "llvm/iBinary.h" #include "llvm/Type.h" +UnaryOperator *UnaryOperator::create(UnaryOps Op, Value *Source, + const Type *DestTy = 0) { + if (DestTy == 0) DestTy = Source->getType(); + switch (Op) { + case Not: assert(DestTy == Source->getType()); + case Cast: return new GenericUnaryInst(Op, Source, DestTy); + default: + cerr << "Don't know how to GetUnaryOperator " << Op << endl; + return 0; + } +} + +const char *GenericUnaryInst::getOpcodeName() const { + switch (getOpcode()) { + case Not: return "not"; + case Cast: return "cast"; + default: + cerr << "Invalid unary operator type!" << getOpcode() << endl; + abort(); + } +} + +//===----------------------------------------------------------------------===// +// BinaryOperator Class +//===----------------------------------------------------------------------===// + BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2, const string &Name) { switch (Op) { @@ -20,6 +46,10 @@ BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2, } } +//===----------------------------------------------------------------------===// +// GenericBinaryInst Class +//===----------------------------------------------------------------------===// + const char *GenericBinaryInst::getOpcodeName() const { switch (getOpcode()) { // Standard binary operators... @@ -35,7 +65,7 @@ const char *GenericBinaryInst::getOpcodeName() const { case Xor: return "xor"; default: cerr << "Invalid binary operator type!" << getOpcode() << endl; - return 0; + abort(); } } |

