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"
17 // Flag values for different argument passing methods
18 static const unsigned char IntArgReg = 0x1;
19 static const unsigned char FPArgReg = 0x2;
20 static const unsigned char StackSlot = 0x4;
22 const Value* argVal; // this argument
23 const Value* argValCopy; // second copy of arg. when multiple
24 // copies must be passed in registers
25 unsigned char passingMethod; // flags recording passing methods
29 CallArgInfo(const Value* _argVal)
30 : argVal(_argVal), argValCopy(NULL), passingMethod(0x0) {}
32 CallArgInfo(const CallArgInfo& obj)
33 : argVal(obj.argVal), argValCopy(obj.argValCopy),
34 passingMethod(obj.passingMethod) {}
37 const Value* getArgVal() { return argVal; }
38 const Value* getArgCopy() { return argValCopy; }
39 bool usesIntArgReg() { return (bool) (passingMethod & IntArgReg);}
40 bool usesFPArgReg() { return (bool) (passingMethod & FPArgReg); }
41 bool usesStackSlot() { return (bool) (passingMethod & StackSlot);}
44 void replaceArgVal(const Value* newVal) { argVal = newVal; }
45 void setUseIntArgReg() { passingMethod |= IntArgReg; }
46 void setUseFPArgReg() { passingMethod |= FPArgReg; }
47 void setUseStackSlot() { passingMethod |= StackSlot; }
48 void setArgCopy(const Value* tmp) { argValCopy = tmp; }
52 class CallArgsDescriptor {
54 std::vector<CallArgInfo> argInfoVec; // Descriptor for each argument
55 const CallInst* callInstr; // The call instruction == result value
56 const Value* funcPtr; // Pointer for indirect calls
57 TmpInstruction* retAddrReg; // Tmp value for return address reg.
58 bool isVarArgs; // Is this a varargs call?
59 bool noPrototype; // Is this a call with no prototype?
62 CallArgsDescriptor(const CallInst* _callInstr, TmpInstruction* _retAddrReg,
63 bool _isVarArgs, bool _noPrototype);
65 // Accessor methods to retrieve information about the call
66 // Note that operands are numbered 1..#CallArgs
67 unsigned int getNumArgs() const { return argInfoVec.size(); }
68 CallArgInfo& getArgInfo(unsigned int op) { assert(op < argInfoVec.size());
69 return argInfoVec[op]; }
70 const CallInst* getCallInst() const { return callInstr; }
71 const CallInst* getReturnValue() const;
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; }
77 // Mechanism to get the descriptor for a CALL MachineInstr.
79 static CallArgsDescriptor *get(const MachineInstr* MI);