Create a static version of Instruction::getOpcodeName(opCode) that

can be invoked with only an opcode (i.e., without an instruction).
Move all opCode->opCodeName translations there.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2892 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Vikram S. Adve 2002-07-14 22:48:20 +00:00
parent 29ab9f8348
commit 5814008f4b
7 changed files with 4 additions and 37 deletions

View File

@ -27,7 +27,6 @@ public:
// Terminators must implement the methods required by Instruction...
virtual Instruction *clone() const = 0;
virtual const char *getOpcodeName() const = 0;
// Additionally, they must provide a method to get at the successors of this
// terminator instruction. 'idx' may not be >= the number of successors
@ -80,8 +79,6 @@ public:
return create(getOpcode(), Operands[0]);
}
virtual const char *getOpcodeName() const = 0;
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const UnaryOperator *) { return true; }
static inline bool classof(const Instruction *I) {
@ -126,8 +123,6 @@ public:
return create(getOpcode(), Operands[0], Operands[1]);
}
virtual const char *getOpcodeName() const = 0;
// 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

View File

@ -59,8 +59,11 @@ public:
// Subclass classification... getOpcode() returns a member of
// one of the enums that is coming soon (down below)...
//
virtual const char *getOpcodeName() const = 0;
unsigned getOpcode() const { return iType; }
virtual const char *getOpcodeName() const {
return getOpcodeName(getOpcode());
}
static const char* getOpcodeName(unsigned OpCode);
inline bool isTerminator() const { // Instance of TerminatorInst?
return iType >= FirstTermOp && iType < NumTermOps;

View File

@ -71,8 +71,6 @@ struct MallocInst : public AllocationInst {
return new MallocInst((Type*)getType(), (Value*)Operands[0].get());
}
virtual const char *getOpcodeName() const { return "malloc"; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const MallocInst *) { return true; }
static inline bool classof(const Instruction *I) {
@ -96,8 +94,6 @@ struct AllocaInst : public AllocationInst {
return new AllocaInst((Type*)getType(), (Value*)Operands[0].get());
}
virtual const char *getOpcodeName() const { return "alloca"; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const AllocaInst *) { return true; }
static inline bool classof(const Instruction *I) {
@ -118,8 +114,6 @@ struct FreeInst : public Instruction {
virtual Instruction *clone() const { return new FreeInst(Operands[0]); }
virtual const char *getOpcodeName() const { return "free"; }
virtual bool hasSideEffects() const { return true; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
@ -210,7 +204,6 @@ public:
LoadInst(Value *Ptr, const std::string &Name = "");
virtual Instruction *clone() const { return new LoadInst(*this); }
virtual const char *getOpcodeName() const { return "load"; }
virtual unsigned getFirstIndexOperandNumber() const { return 1; }
@ -240,8 +233,6 @@ public:
StoreInst(Value *Val, Value *Ptr);
virtual Instruction *clone() const { return new StoreInst(*this); }
virtual const char *getOpcodeName() const { return "store"; }
virtual bool hasSideEffects() const { return true; }
virtual unsigned getFirstIndexOperandNumber() const { return 2; }
@ -271,7 +262,6 @@ public:
GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
const std::string &Name = "");
virtual Instruction *clone() const { return new GetElementPtrInst(*this); }
virtual const char *getOpcodeName() const { return "getelementptr"; }
virtual unsigned getFirstIndexOperandNumber() const { return 1; }
// getType - Overload to return most specific pointer type...

View File

@ -18,8 +18,6 @@ public:
GenericUnaryInst(UnaryOps Opcode, Value *S1, const std::string &Name = "")
: UnaryOperator(S1, Opcode, Name) {
}
virtual const char *getOpcodeName() const;
};
//===----------------------------------------------------------------------===//
@ -35,8 +33,6 @@ public:
const std::string &Name = "")
: BinaryOperator(Opcode, S1, S2, Name) {
}
virtual const char *getOpcodeName() const;
};
class SetCondInst : public BinaryOperator {
@ -44,8 +40,6 @@ class SetCondInst : public BinaryOperator {
public:
SetCondInst(BinaryOps opType, Value *S1, Value *S2,
const std::string &Name = "");
virtual const char *getOpcodeName() const;
};
#endif

View File

@ -30,7 +30,6 @@ public:
}
virtual Instruction *clone() const { return new CastInst(*this); }
virtual const char *getOpcodeName() const { return "cast"; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const CastInst *) { return true; }
@ -52,8 +51,6 @@ class CallInst : public Instruction {
public:
CallInst(Value *M, const std::vector<Value*> &Par, const std::string & = "");
virtual const char *getOpcodeName() const { return "call"; }
virtual Instruction *clone() const { return new CallInst(*this); }
bool hasSideEffects() const { return true; }
@ -103,9 +100,6 @@ public:
OtherOps getOpcode() const { return (OtherOps)Instruction::getOpcode(); }
virtual Instruction *clone() const { return new ShiftInst(*this); }
virtual const char *getOpcodeName() const {
return getOpcode() == Shl ? "shl" : "shr";
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ShiftInst *) { return true; }

View File

@ -24,7 +24,6 @@ public:
PHINode(const Type *Ty, const std::string &Name = "");
virtual Instruction *clone() const { return new PHINode(*this); }
virtual const char *getOpcodeName() const { return "phi"; }
// getNumIncomingValues - Return the number of incoming edges the PHI node has
inline unsigned getNumIncomingValues() const { return Operands.size()/2; }

View File

@ -39,8 +39,6 @@ public:
virtual Instruction *clone() const { return new ReturnInst(*this); }
virtual const char *getOpcodeName() const { return "ret"; }
inline const Value *getReturnValue() const {
return Operands.size() ? Operands[0].get() : 0;
}
@ -89,8 +87,6 @@ public:
return isUnconditional() ? 0 : Operands[2].get();
}
virtual const char *getOpcodeName() const { return "br"; }
// setUnconditionalDest - Change the current branch to an unconditional branch
// targeting the specified block.
//
@ -153,8 +149,6 @@ public:
void dest_push_back(Constant *OnVal, BasicBlock *Dest);
virtual const char *getOpcodeName() const { return "switch"; }
virtual const BasicBlock *getSuccessor(unsigned idx) const {
assert(idx < getNumSuccessors() &&"Successor idx out of range for switch!");
return cast<BasicBlock>(Operands[idx*2+1].get());
@ -241,8 +235,6 @@ public:
Operands[2] = (Value*)B;
}
virtual const char *getOpcodeName() const { return "invoke"; }
virtual const BasicBlock *getSuccessor(unsigned i) const {
assert(i < 2 && "Successor # out of range for invoke!");
return i == 0 ? getNormalDest() : getExceptionalDest();