summaryrefslogtreecommitdiff
path: root/lib/VMCore
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-07-08 04:57:15 +0000
committerChris Lattner <sabre@nondot.org>2001-07-08 04:57:15 +0000
commit0908309e3c4b4f423e88d8d8fe8060cb10eaa1c9 (patch)
treedcdecdda0cd3e1168527d832f3824e0c94b3ef60 /lib/VMCore
parentf22696f209701bff12edbe41c646d1ef179c685d (diff)
downloadllvm-0908309e3c4b4f423e88d8d8fe8060cb10eaa1c9.tar.gz
llvm-0908309e3c4b4f423e88d8d8fe8060cb10eaa1c9.tar.bz2
llvm-0908309e3c4b4f423e88d8d8fe8060cb10eaa1c9.tar.xz
Neg instruction removed. Cast instruction implemented.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/AsmWriter.cpp4
-rw-r--r--lib/VMCore/ConstantFold.cpp8
-rw-r--r--lib/VMCore/ConstantFold.h6
-rw-r--r--lib/VMCore/ConstantFolding.h6
-rw-r--r--lib/VMCore/InstrTypes.cpp9
-rw-r--r--lib/VMCore/iOperators.cpp32
6 files changed, 34 insertions, 31 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index 398f7a87b8..d84cba0752 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/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/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 54a7980481..e0a4ffbfb0 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.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/lib/VMCore/ConstantFold.h b/lib/VMCore/ConstantFold.h
index cf18ef8cea..79dd21c2c6 100644
--- a/lib/VMCore/ConstantFold.h
+++ b/lib/VMCore/ConstantFold.h
@@ -60,7 +60,6 @@ protected:
inline ConstRules() {} // Can only be subclassed...
public:
// Unary Operators...
- virtual ConstPoolVal *neg(const ConstPoolVal *V) const = 0;
virtual ConstPoolVal *not(const ConstPoolVal *V) const = 0;
// Binary Operators...
@@ -88,10 +87,6 @@ private :
};
-inline ConstPoolVal *operator-(const ConstPoolVal &V) {
- return ConstRules::get(V)->neg(&V);
-}
-
inline ConstPoolVal *operator!(const ConstPoolVal &V) {
return ConstRules::get(V)->not(&V);
}
@@ -154,7 +149,6 @@ inline ConstPoolVal *ConstantFoldUnaryInstruction(unsigned Opcode,
ConstPoolVal *V) {
switch (Opcode) {
case Instruction::Not: return !*V;
- case Instruction::Neg: return -*V;
}
return 0;
}
diff --git a/lib/VMCore/ConstantFolding.h b/lib/VMCore/ConstantFolding.h
index cf18ef8cea..79dd21c2c6 100644
--- a/lib/VMCore/ConstantFolding.h
+++ b/lib/VMCore/ConstantFolding.h
@@ -60,7 +60,6 @@ protected:
inline ConstRules() {} // Can only be subclassed...
public:
// Unary Operators...
- virtual ConstPoolVal *neg(const ConstPoolVal *V) const = 0;
virtual ConstPoolVal *not(const ConstPoolVal *V) const = 0;
// Binary Operators...
@@ -88,10 +87,6 @@ private :
};
-inline ConstPoolVal *operator-(const ConstPoolVal &V) {
- return ConstRules::get(V)->neg(&V);
-}
-
inline ConstPoolVal *operator!(const ConstPoolVal &V) {
return ConstRules::get(V)->not(&V);
}
@@ -154,7 +149,6 @@ inline ConstPoolVal *ConstantFoldUnaryInstruction(unsigned Opcode,
ConstPoolVal *V) {
switch (Opcode) {
case Instruction::Not: return !*V;
- case Instruction::Neg: return -*V;
}
return 0;
}
diff --git a/lib/VMCore/InstrTypes.cpp b/lib/VMCore/InstrTypes.cpp
index 9d3262cbda..d0c410051a 100644
--- a/lib/VMCore/InstrTypes.cpp
+++ b/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/lib/VMCore/iOperators.cpp b/lib/VMCore/iOperators.cpp
index 61d5d26d2b..6f7c2f158e 100644
--- a/lib/VMCore/iOperators.cpp
+++ b/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();
}
}