diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-07-14 22:48:20 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-07-14 22:48:20 +0000 |
commit | 5814008f4b77774c8563578e1562c9c24a6750c2 (patch) | |
tree | 9743ae14c322aa57ec4cf1bb13b7dad94bf23415 /include/llvm | |
parent | 29ab9f83481cd21abf3055c7c32ea1df953ae167 (diff) | |
download | external_llvm-5814008f4b77774c8563578e1562c9c24a6750c2.zip external_llvm-5814008f4b77774c8563578e1562c9c24a6750c2.tar.gz external_llvm-5814008f4b77774c8563578e1562c9c24a6750c2.tar.bz2 |
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
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/InstrTypes.h | 5 | ||||
-rw-r--r-- | include/llvm/Instruction.h | 5 | ||||
-rw-r--r-- | include/llvm/iMemory.h | 10 | ||||
-rw-r--r-- | include/llvm/iOperators.h | 6 | ||||
-rw-r--r-- | include/llvm/iOther.h | 6 | ||||
-rw-r--r-- | include/llvm/iPHINode.h | 1 | ||||
-rw-r--r-- | include/llvm/iTerminators.h | 8 |
7 files changed, 4 insertions, 37 deletions
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index e990db7..9a28d64 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -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 diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index 7cdee5d..e13d1b7 100644 --- a/include/llvm/Instruction.h +++ b/include/llvm/Instruction.h @@ -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; diff --git a/include/llvm/iMemory.h b/include/llvm/iMemory.h index 8a88c32..1820e3c 100644 --- a/include/llvm/iMemory.h +++ b/include/llvm/iMemory.h @@ -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... diff --git a/include/llvm/iOperators.h b/include/llvm/iOperators.h index f9cba9f..f9fc88a 100644 --- a/include/llvm/iOperators.h +++ b/include/llvm/iOperators.h @@ -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 diff --git a/include/llvm/iOther.h b/include/llvm/iOther.h index 96d2c7e..31c50fe 100644 --- a/include/llvm/iOther.h +++ b/include/llvm/iOther.h @@ -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; } diff --git a/include/llvm/iPHINode.h b/include/llvm/iPHINode.h index 0ac0d44..081c57a 100644 --- a/include/llvm/iPHINode.h +++ b/include/llvm/iPHINode.h @@ -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; } diff --git a/include/llvm/iTerminators.h b/include/llvm/iTerminators.h index b17029b..9a42152 100644 --- a/include/llvm/iTerminators.h +++ b/include/llvm/iTerminators.h @@ -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(); |