1 //===-- llvm/CodeGen/MachineInstrAnnot.h ------------------------*- C++ -*-===//
3 // Annotations used to pass information between code generation phases.
5 //===----------------------------------------------------------------------===//
7 #ifndef MACHINE_INSTR_ANNOT_h
8 #define MACHINE_INSTR_ANNOT_h
10 #include "llvm/CodeGen/MachineInstr.h"
11 #include "llvm/Target/TargetRegInfo.h"
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;
23 const 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
30 CallArgInfo(const Value* _argVal)
31 : argVal(_argVal), argCopyReg(TargetRegInfo::getInvalidRegNum()),
34 CallArgInfo(const CallArgInfo& obj)
35 : argVal(obj.argVal), argCopyReg(obj.argCopyReg),
36 passingMethod(obj.passingMethod) {}
39 const 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);}
46 void replaceArgVal(const 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; }
54 class CallArgsDescriptor {
56 std::vector<CallArgInfo> argInfoVec; // Descriptor for each argument
57 const CallInst* callInstr; // The call instruction == result value
58 const 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?
64 CallArgsDescriptor(const CallInst* _callInstr, TmpInstruction* _retAddrReg,
65 bool _isVarArgs, bool _noPrototype);
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 const CallInst* getCallInst() const { return callInstr; }
73 const CallInst* getReturnValue() const;
74 const Value* getIndirectFuncPtr() const { return funcPtr; }
75 TmpInstruction* getReturnAddrReg() const { return retAddrReg; }
76 bool isVarArgsFunc() const { return isVarArgs; }
77 bool hasNoPrototype() const { return noPrototype; }
79 // Mechanism to get the descriptor for a CALL MachineInstr.
81 static CallArgsDescriptor *get(const MachineInstr* MI);