llvm.org GIT mirror llvm / fb39f99
add methods to analyze calls and formals. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34736 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
2 changed file(s) with 54 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
2020 namespace llvm {
2121 class MRegisterInfo;
2222 class TargetMachine;
23
23 class CCState;
24 class SDNode;
25
2426 /// CCValAssign - Represent assignment of one arg/retval to a location.
2527 class CCValAssign {
2628 public:
9092 };
9193
9294
95 /// CCAssignFn - This function assigns a location for Val, updating State to
96 /// reflect the change.
97 typedef bool CCAssignFn(unsigned ValNo, MVT::ValueType ValVT,
98 MVT::ValueType LocVT, CCValAssign::LocInfo LocInfo,
99 unsigned ArgFlags, CCState &State);
100
93101
94102 /// CCState - This class holds information needed while lowering arguments and
95103 /// return values. It captures which registers are already assigned and which
120128 bool isAllocated(unsigned Reg) const {
121129 return UsedRegs[Reg/32] & (1 << (Reg&31));
122130 }
131
132 /// AnalyzeCallOperands - Analyze an ISD::CALL node, incorporating info
133 /// about the passed values into this state.
134 void AnalyzeCallOperands(SDNode *TheCall, CCAssignFn Fn);
135
136 /// AnalyzeFormalArguments - Analyze an ISD::FORMAL_ARGUMENTS node,
137 /// incorporating info about the formals into this state.
138 void AnalyzeFormalArguments(SDNode *TheArgs, CCAssignFn Fn);
139
123140
124141 /// getFirstUnallocated - Return the first unallocated register in the set, or
125142 /// NumRegs if they are all allocated.
167184 void MarkAllocated(unsigned Reg);
168185 };
169186
187
188
170189 } // end namespace llvm
171190
172191 #endif
1212 //===----------------------------------------------------------------------===//
1313
1414 #include "llvm/CodeGen/CallingConvLower.h"
15 #include "llvm/CodeGen/SelectionDAGNodes.h"
1516 #include "llvm/Target/MRegisterInfo.h"
1617 #include "llvm/Target/TargetMachine.h"
1718 using namespace llvm;
3435 for (; (Reg = *RegAliases); ++RegAliases)
3536 UsedRegs[Reg/32] |= 1 << (Reg&31);
3637 }
38
39 /// AnalyzeCallOperands - Analyze an ISD::CALL node, incorporating info
40 /// about the passed values into this state.
41 void CCState::AnalyzeCallOperands(SDNode *TheCall, CCAssignFn Fn) {
42 unsigned NumOps = (TheCall->getNumOperands() - 5) / 2;
43 for (unsigned i = 0; i != NumOps; ++i) {
44 MVT::ValueType ArgVT = TheCall->getOperand(5+2*i).getValueType();
45 SDOperand FlagOp = TheCall->getOperand(5+2*i+1);
46 unsigned ArgFlags =cast(FlagOp)->getValue();
47 if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) {
48 cerr << "Call operand #" << i << " has unhandled type "
49 << MVT::getValueTypeString(ArgVT) << "\n";
50 abort();
51 }
52 }
53 }
54
55 /// AnalyzeFormalArguments - Analyze an ISD::FORMAL_ARGUMENTS node,
56 /// incorporating info about the formals into this state.
57 void CCState::AnalyzeFormalArguments(SDNode *TheArgs, CCAssignFn Fn) {
58 unsigned NumArgs = TheArgs->getNumValues()-1;
59
60 for (unsigned i = 0; i != NumArgs; ++i) {
61 MVT::ValueType ArgVT = TheArgs->getValueType(i);
62 SDOperand FlagOp = TheArgs->getOperand(3+i);
63 unsigned ArgFlags = cast(FlagOp)->getValue();
64 if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) {
65 cerr << "Formal argument #" << i << " has unhandled type "
66 << MVT::getValueTypeString(ArgVT) << "\n";
67 abort();
68 }
69 }
70 }