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