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"
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;
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
32 CallArgInfo(const Value* _argVal)
33 : argVal(_argVal), argCopyReg(TargetRegInfo::getInvalidRegNum()),
36 CallArgInfo(const CallArgInfo& obj)
37 : argVal(obj.argVal), argCopyReg(obj.argCopyReg),
38 passingMethod(obj.passingMethod) {}
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);}
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; }
56 class CallArgsDescriptor {
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?
66 CallArgsDescriptor(const CallInst* _callInstr, TmpInstruction* _retAddrReg,
67 bool _isVarArgs, bool _noPrototype);
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; }
81 // Mechanism to get the descriptor for a CALL MachineInstr.
83 static CallArgsDescriptor *get(const MachineInstr* MI);