Create a static version of Instruction::getOpcodeName(opCode) that
authorVikram S. Adve <vadve@cs.uiuc.edu>
Sun, 14 Jul 2002 22:48:20 +0000 (22:48 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Sun, 14 Jul 2002 22:48:20 +0000 (22:48 +0000)
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

include/llvm/InstrTypes.h
include/llvm/Instruction.h
include/llvm/iMemory.h
include/llvm/iOperators.h
include/llvm/iOther.h
include/llvm/iPHINode.h
include/llvm/iTerminators.h

index e990db769766f3374ed9e4013e5ecc58edaeb896..9a28d64fb9c057894c7f33fd94500491a3bae8f5 100644 (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
index 7cdee5d2c1d0e068caeded6abd8fbfcb7d2998bb..e13d1b747b7dc52f7e7a796863f83a8b115f89bc 100644 (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;
index 8a88c321810c78d41fae0912768661cf98eb8aa5..1820e3c6b21bef00469b84ef2b6d0b5744f396f5 100644 (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...
index f9cba9f68cada3c472b83e4f1b110432e3d258b4..f9fc88ac41a85a2198a35fffa1bee96dc39e7f25 100644 (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
index 96d2c7e1b19fe59d1cda37da27de8ec0aa9206f3..31c50fe32ee286da9371e2c3c8ff747989816086 100644 (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; }
index 0ac0d44c6694d47bf9d87f7b9209b477184b63e8..081c57a7d446573722a346d3b11f289adc885461 100644 (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; }
index b17029be75064a4afaaf70f170b5da831e2886fa..9a421527b51671d4150386b5277a8c40a0095daf 100644 (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();