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