1 //===-- llvm/CodeGen/MachineInstrAnnot.h ------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // Annotations used to pass information between code generation phases.
12 //===----------------------------------------------------------------------===//
14 #ifndef MACHINE_INSTR_ANNOT_h
15 #define MACHINE_INSTR_ANNOT_h
17 #include "llvm/CodeGen/MachineInstr.h"
18 #include "llvm/Target/TargetRegInfo.h"
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;
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
37 CallArgInfo(Value* _argVal)
38 : argVal(_argVal), argCopyReg(TargetRegInfo::getInvalidRegNum()),
41 CallArgInfo(const CallArgInfo& obj)
42 : argVal(obj.argVal), argCopyReg(obj.argCopyReg),
43 passingMethod(obj.passingMethod) {}
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);}
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; }
61 class CallArgsDescriptor {
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?
71 CallArgsDescriptor(CallInst* _callInstr, TmpInstruction* _retAddrReg,
72 bool _isVarArgs, bool _noPrototype);
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; }
86 // Mechanism to get the descriptor for a CALL MachineInstr.
88 static CallArgsDescriptor *get(const MachineInstr* MI);