Moved Cast from being a Unary instruction to being an "Other" instruction

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2001-07-08 19:03:27 +00:00
parent 72f1e9929a
commit 71496b3b50
11 changed files with 143 additions and 114 deletions

View File

@@ -55,12 +55,10 @@ public:
// create() - Construct a unary instruction, given the opcode
// and its operand.
//
static UnaryOperator *create(UnaryOps Op, Value *Source,
const Type *DestTy = 0);
static UnaryOperator *create(UnaryOps Op, Value *Source);
UnaryOperator(Value *S, UnaryOps iType, const Type *ResultType,
const string &Name = "")
: Instruction(ResultType, iType, Name) {
UnaryOperator(Value *S, UnaryOps iType, const string &Name = "")
: Instruction(S->getType(), iType, Name) {
Operands.reserve(1);
Operands.push_back(Use(S, this));
}

View File

@@ -78,7 +78,6 @@ public:
enum UnaryOps {
FirstUnaryOp = NumTermOps,
Not = NumTermOps, // Binary inverse
Cast, // Type cast...
NumUnaryOps // Must remain at end of enum
};
@@ -112,6 +111,7 @@ public:
enum OtherOps {
FirstOtherOp = NumMemoryOps,
PHINode = NumMemoryOps, // PHI node instruction
Cast, // Type cast...
Call, // Call a function
Shl, Shr, // Shift operations...

View File

@@ -15,9 +15,8 @@
//
class GenericUnaryInst : public UnaryOperator {
public:
GenericUnaryInst(UnaryOps Opcode, Value *S1, const Type *ResultTy = 0,
const string &Name = "")
: UnaryOperator(S1, Opcode, ResultTy, Name) {
GenericUnaryInst(UnaryOps Opcode, Value *S1, const string &Name = "")
: UnaryOperator(S1, Opcode, Name) {
}
virtual const char *getOpcodeName() const;

View File

@@ -12,6 +12,30 @@
#include "llvm/Method.h"
#include <vector>
//===----------------------------------------------------------------------===//
// CastInst Class
//===----------------------------------------------------------------------===//
// CastInst - This function represents a cast from Operand[0] to the type of
// the instruction (i->getType()).
//
class CastInst : public Instruction {
CastInst(const CastInst &CI) : Instruction(CI.getType(), Cast) {
Operands.reserve(1);
Operands.push_back(Use((Value*)CI.getOperand(0), this));
}
public:
CastInst(Value *S, const Type *Ty, const string &Name = "")
: Instruction(Ty, Cast, Name) {
Operands.reserve(1);
Operands.push_back(Use(S, this));
}
virtual Instruction *clone() const { return new CastInst(*this); }
virtual const char *getOpcodeName() const { return "cast"; }
};
//===----------------------------------------------------------------------===//
// PHINode Class
//===----------------------------------------------------------------------===//