1 //===-- 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 SparcV9 code generation phases.
12 //===----------------------------------------------------------------------===//
14 #ifndef MACHINEINSTRANNOT_H
15 #define MACHINEINSTRANNOT_H
17 #include "llvm/CodeGen/MachineInstr.h"
18 #include "SparcV9RegInfo.h"
27 // Flag values for different argument passing methods
28 static const unsigned char IntArgReg = 0x1;
29 static const unsigned char FPArgReg = 0x2;
30 static const unsigned char StackSlot = 0x4;
32 Value* argVal; // this argument
33 int argCopyReg; // register used for second copy of arg. when
34 // multiple copies must be passed in registers
35 unsigned char passingMethod; // flags recording passing methods
39 CallArgInfo(Value* _argVal)
40 : argVal(_argVal), argCopyReg(SparcV9RegInfo::getInvalidRegNum()),
43 CallArgInfo(const CallArgInfo& obj)
44 : argVal(obj.argVal), argCopyReg(obj.argCopyReg),
45 passingMethod(obj.passingMethod) {}
48 Value* getArgVal() { return argVal; }
49 int getArgCopy() { return argCopyReg; }
50 bool usesIntArgReg() { return (bool) (passingMethod & IntArgReg);}
51 bool usesFPArgReg() { return (bool) (passingMethod & FPArgReg); }
52 bool usesStackSlot() { return (bool) (passingMethod & StackSlot);}
55 void replaceArgVal(Value* newVal) { argVal = newVal; }
56 void setUseIntArgReg() { passingMethod |= IntArgReg; }
57 void setUseFPArgReg() { passingMethod |= FPArgReg; }
58 void setUseStackSlot() { passingMethod |= StackSlot; }
59 void setArgCopy(int copyReg) { argCopyReg = copyReg; }
63 class CallArgsDescriptor {
65 std::vector<CallArgInfo> argInfoVec; // Descriptor for each argument
66 CallInst* callInstr; // The call instruction == result value
67 Value* funcPtr; // Pointer for indirect calls
68 TmpInstruction* retAddrReg; // Tmp value for return address reg.
69 bool isVarArgs; // Is this a varargs call?
70 bool noPrototype; // Is this a call with no prototype?
73 CallArgsDescriptor(CallInst* _callInstr, TmpInstruction* _retAddrReg,
74 bool _isVarArgs, bool _noPrototype);
76 // Accessor methods to retrieve information about the call
77 // Note that operands are numbered 1..#CallArgs
78 unsigned int getNumArgs() const { return argInfoVec.size(); }
79 CallArgInfo& getArgInfo(unsigned int op) { assert(op < argInfoVec.size());
80 return argInfoVec[op]; }
81 CallInst* getCallInst() const { return callInstr; }
82 CallInst* getReturnValue() const;
83 Value* getIndirectFuncPtr() const { return funcPtr; }
84 TmpInstruction* getReturnAddrReg() const { return retAddrReg; }
85 bool isVarArgsFunc() const { return isVarArgs; }
86 bool hasNoPrototype() const { return noPrototype; }
88 // Mechanism to get the descriptor for a CALL MachineInstr.
90 static CallArgsDescriptor *get(const MachineInstr* MI);
93 } // End llvm namespace