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