Instead of checking op.getType() against MO_VirtualRegister and
[oota-llvm.git] / include / llvm / CodeGen / MachineInstrAnnot.h
1 //===-- llvm/CodeGen/MachineInstrAnnot.h ------------------------*- C++ -*-===//
2 //
3 //  Annotations used to pass information between code generation phases.
4 // 
5 //===----------------------------------------------------------------------===//
6
7 #ifndef MACHINE_INSTR_ANNOT_h
8 #define MACHINE_INSTR_ANNOT_h
9
10 #include "llvm/CodeGen/MachineInstr.h"
11
12 class Value;
13 class TmpInstruction;
14 class CallInst;
15
16 class CallArgInfo {
17   // Flag values for different argument passing methods
18   static const unsigned char IntArgReg = 0x1;
19   static const unsigned char FPArgReg  = 0x2;
20   static const unsigned char StackSlot = 0x4;
21   
22   const Value* argVal;                  // this argument
23   const Value* argValCopy;              // second copy of arg. when multiple 
24                                         // copies must be passed in registers
25   unsigned char passingMethod;          // flags recording passing methods
26   
27 public:
28   // Constructors
29   CallArgInfo(const Value* _argVal)
30     : argVal(_argVal), argValCopy(NULL), passingMethod(0x0) {}
31   
32   CallArgInfo(const CallArgInfo& obj)
33     : argVal(obj.argVal), argValCopy(obj.argValCopy),
34       passingMethod(obj.passingMethod) {}
35   
36   // Accessor methods
37   const Value*  getArgVal()       { return argVal; }
38   const Value*  getArgCopy()      { return argValCopy; }
39   bool          usesIntArgReg()   { return (bool) (passingMethod & IntArgReg);} 
40   bool          usesFPArgReg()    { return (bool) (passingMethod & FPArgReg); } 
41   bool          usesStackSlot()   { return (bool) (passingMethod & StackSlot);} 
42   
43   // Modifier methods
44   void          replaceArgVal(const Value* newVal) { argVal = newVal; }
45   void          setUseIntArgReg() { passingMethod |= IntArgReg; }
46   void          setUseFPArgReg()  { passingMethod |= FPArgReg; }
47   void          setUseStackSlot() { passingMethod |= StackSlot; }
48   void          setArgCopy(const Value* tmp) { argValCopy = tmp; }
49 };
50
51
52 class CallArgsDescriptor {
53
54   std::vector<CallArgInfo> argInfoVec;  // Descriptor for each argument
55   const CallInst* callInstr;            // The call instruction == result value
56   const Value* funcPtr;                 // Pointer for indirect calls 
57   TmpInstruction* retAddrReg;           // Tmp value for return address reg.
58   bool isVarArgs;                       // Is this a varargs call?
59   bool noPrototype;                     // Is this a call with no prototype?
60   
61 public:
62   CallArgsDescriptor(const CallInst* _callInstr, TmpInstruction* _retAddrReg,
63                      bool _isVarArgs, bool _noPrototype);
64   
65   // Accessor methods to retrieve information about the call
66   // Note that operands are numbered 1..#CallArgs
67   unsigned int    getNumArgs() const          { return argInfoVec.size(); }
68   CallArgInfo&    getArgInfo(unsigned int op) { assert(op < argInfoVec.size());
69                                                 return argInfoVec[op]; }
70   const CallInst* getCallInst() const         { return callInstr; }
71   const CallInst* getReturnValue() const;
72   const Value*    getIndirectFuncPtr() const  { return funcPtr; }
73   TmpInstruction* getReturnAddrReg() const    { return retAddrReg; }
74   bool            isVarArgsFunc() const       { return isVarArgs; }
75   bool            hasNoPrototype() const      { return noPrototype; }
76
77   // Mechanism to get the descriptor for a CALL MachineInstr.
78   // 
79   static CallArgsDescriptor *get(const MachineInstr* MI);
80 };
81
82
83 #endif