Add new VarArgInst class for the va_arg instruction
authorChris Lattner <sabre@nondot.org>
Thu, 8 May 2003 02:42:50 +0000 (02:42 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 8 May 2003 02:42:50 +0000 (02:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6027 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Instruction.def
include/llvm/iOther.h

index 465db502afa549b63d9e1a27f30dcae5ea3dda12..2b9c1a7a848e01857f1c206d499488e170f386f3 100644 (file)
@@ -119,10 +119,11 @@ HANDLE_OTHER_INST(28, Call   , CallInst   )  // Call a function
 
 HANDLE_OTHER_INST(29, Shl    , ShiftInst  )  // Shift operations
 HANDLE_OTHER_INST(30, Shr    , ShiftInst  )
+HANDLE_OTHER_INST(31, VarArg , VarArgInst )  // va_arg instruction
 
-HANDLE_OTHER_INST(31, UserOp1, Instruction)  // May be used internally in a pass
-HANDLE_OTHER_INST(32, UserOp2, Instruction)
-  LAST_OTHER_INST(32)
+HANDLE_OTHER_INST(32, UserOp1, Instruction)  // May be used internally in a pass
+HANDLE_OTHER_INST(33, UserOp2, Instruction)
+  LAST_OTHER_INST(33)
 
 #undef  FIRST_TERM_INST
 #undef HANDLE_TERM_INST
index 5ad3d0a66d0c23790288e6da7acbb44b42b753e4..88ee4cff7cac1a08864de61dc139097cf0f43d7f 100644 (file)
@@ -121,4 +121,40 @@ public:
   }
 };
 
+
+//===----------------------------------------------------------------------===//
+//                               VarArgInst Class
+//===----------------------------------------------------------------------===//
+
+/// VarArgInst - This class represents the va_arg llvm instruction, which reads
+/// an argument of the destination type from the va_list operand pointed to by
+/// the only operand.
+///
+class VarArgInst : public Instruction {
+  VarArgInst(const VarArgInst &VAI) : Instruction(VAI.getType(), VarArg) {
+    Operands.reserve(1);
+    Operands.push_back(Use(VAI.Operands[0], this));
+  }
+public:
+  VarArgInst(Value *S, const Type *Ty, const std::string &Name = "",
+             Instruction *InsertBefore = 0)
+    : Instruction(Ty, VarArg, Name, InsertBefore) {
+    Operands.reserve(1);
+    Operands.push_back(Use(S, this));
+  }
+
+  virtual Instruction *clone() const { return new VarArgInst(*this); }
+
+  bool mayWriteToMemory() const { return true; }
+
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const VarArgInst *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return I->getOpcode() == VarArg;
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
+};
+
 #endif