* Removed extraneous #includes
[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/Annotation.h"
11 #include "llvm/CodeGen/MachineInstr.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   const Value* argVal;                  // this argument
24   const Value* argValCopy;              // second copy of arg. when multiple 
25                                         // copies must be passed in registers
26   unsigned char passingMethod;          // flags recording passing methods
27   
28 public:
29   // Constructors
30   CallArgInfo(const Value* _argVal)
31     : argVal(_argVal), argValCopy(NULL), passingMethod(0x0) {}
32   
33   CallArgInfo(const CallArgInfo& obj)
34     : argVal(obj.argVal), argValCopy(obj.argValCopy),
35       passingMethod(obj.passingMethod) {}
36   
37   // Accessor methods
38   const Value*  getArgVal()       { return argVal; }
39   const Value*  getArgCopy()      { return argValCopy; }
40   bool          usesIntArgReg()   { return (bool) (passingMethod & IntArgReg);} 
41   bool          usesFPArgReg()    { return (bool) (passingMethod & FPArgReg); } 
42   bool          usesStackSlot()   { return (bool) (passingMethod & StackSlot);} 
43   
44   // Modifier methods
45   void          replaceArgVal(const Value* newVal) { argVal = newVal; }
46   void          setUseIntArgReg() { passingMethod |= IntArgReg; }
47   void          setUseFPArgReg()  { passingMethod |= FPArgReg; }
48   void          setUseStackSlot() { passingMethod |= StackSlot; }
49   void          setArgCopy(const Value* tmp) { argValCopy = tmp; }
50 };
51
52
53 class CallArgsDescriptor: public Annotation { // Annotation for a MachineInstr
54   static AnnotationID AID;              // AnnotationID for this class
55   std::vector<CallArgInfo> argInfoVec;  // Descriptor for each argument
56   const CallInst* callInstr;            // The call instruction == result value
57   const Value* funcPtr;                 // Pointer for indirect calls 
58   TmpInstruction* retAddrReg;           // Tmp value for return address reg.
59   bool isVarArgs;                       // Is this a varargs call?
60   bool noPrototype;                     // Is this a call with no prototype?
61   
62 public:
63   CallArgsDescriptor(const CallInst* _callInstr, TmpInstruction* _retAddrReg,
64                      bool _isVarArgs, bool _noPrototype);
65   
66   // Accessor methods to retrieve information about the call
67   // Note that operands are numbered 1..#CallArgs
68   unsigned int    getNumArgs() const          { return argInfoVec.size(); }
69   CallArgInfo&    getArgInfo(unsigned int op) { assert(op < argInfoVec.size());
70                                                 return argInfoVec[op]; }
71   const CallInst* getReturnValue() const      { return callInstr; }
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   // Annotation mechanism to annotate a MachineInstr with the descriptor.
78   // This is not demand-driven because annotations can only be created
79   // at restricted points during code generation.
80   static inline CallArgsDescriptor *get(const MachineInstr* MI) {
81     return (CallArgsDescriptor *) MI->getAnnotation(AID);
82   }
83 };
84
85
86 #endif