@@ -33,18 +33,24 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
33
33
34
34
if (DefInit *Init = dyn_cast<DefInit>(OutDI->getOperator ())) {
35
35
if (Init->getDef ()->getName () != " outs" )
36
- PrintFatalError (R->getName () + " : invalid def name for output list: use 'outs'" );
36
+ PrintFatalError (R->getLoc (),
37
+ R->getName () +
38
+ " : invalid def name for output list: use 'outs'" );
37
39
} else
38
- PrintFatalError (R->getName () + " : invalid output list: use 'outs'" );
40
+ PrintFatalError (R->getLoc (),
41
+ R->getName () + " : invalid output list: use 'outs'" );
39
42
40
43
NumDefs = OutDI->getNumArgs ();
41
44
42
45
DagInit *InDI = R->getValueAsDag (" InOperandList" );
43
46
if (DefInit *Init = dyn_cast<DefInit>(InDI->getOperator ())) {
44
47
if (Init->getDef ()->getName () != " ins" )
45
- PrintFatalError (R->getName () + " : invalid def name for input list: use 'ins'" );
48
+ PrintFatalError (R->getLoc (),
49
+ R->getName () +
50
+ " : invalid def name for input list: use 'ins'" );
46
51
} else
47
- PrintFatalError (R->getName () + " : invalid input list: use 'ins'" );
52
+ PrintFatalError (R->getLoc (),
53
+ R->getName () + " : invalid input list: use 'ins'" );
48
54
49
55
unsigned MIOperandNo = 0 ;
50
56
std::set<std::string> OperandNames;
@@ -63,7 +69,8 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
63
69
64
70
DefInit *Arg = dyn_cast<DefInit>(ArgInit);
65
71
if (!Arg)
66
- PrintFatalError (" Illegal operand for the '" + R->getName () + " ' instruction!" );
72
+ PrintFatalError (R->getLoc (), " Illegal operand for the '" + R->getName () +
73
+ " ' instruction!" );
67
74
68
75
Record *Rec = Arg->getDef ();
69
76
std::string PrintMethod = " printOperand" ;
@@ -88,8 +95,9 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
88
95
// Verify that MIOpInfo has an 'ops' root value.
89
96
if (!isa<DefInit>(MIOpInfo->getOperator ()) ||
90
97
cast<DefInit>(MIOpInfo->getOperator ())->getDef ()->getName () != " ops" )
91
- PrintFatalError (" Bad value for MIOperandInfo in operand '" + Rec->getName () +
92
- " '\n " );
98
+ PrintFatalError (R->getLoc (),
99
+ " Bad value for MIOperandInfo in operand '" +
100
+ Rec->getName () + " '\n " );
93
101
94
102
// If we have MIOpInfo, then we have #operands equal to number of entries
95
103
// in MIOperandInfo.
@@ -107,16 +115,20 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
107
115
OperandType = " OPERAND_REGISTER" ;
108
116
} else if (!Rec->isSubClassOf (" PointerLikeRegClass" ) &&
109
117
!Rec->isSubClassOf (" unknown_class" ))
110
- PrintFatalError (" Unknown operand class '" + Rec->getName () +
111
- " ' in '" + R->getName () + " ' instruction!" );
118
+ PrintFatalError (R->getLoc (), " Unknown operand class '" + Rec->getName () +
119
+ " ' in '" + R->getName () +
120
+ " ' instruction!" );
112
121
113
122
// Check that the operand has a name and that it's unique.
114
123
if (ArgName.empty ())
115
- PrintFatalError (" In instruction '" + R->getName () + " ', operand #" +
116
- Twine (i) + " has no name!" );
124
+ PrintFatalError (R->getLoc (), " In instruction '" + R->getName () +
125
+ " ', operand #" + Twine (i) +
126
+ " has no name!" );
117
127
if (!OperandNames.insert (ArgName).second )
118
- PrintFatalError (" In instruction '" + R->getName () + " ', operand #" +
119
- Twine (i) + " has the same name as a previous operand!" );
128
+ PrintFatalError (R->getLoc (),
129
+ " In instruction '" + R->getName () + " ', operand #" +
130
+ Twine (i) +
131
+ " has the same name as a previous operand!" );
120
132
121
133
OperandList.emplace_back (Rec, ArgName, PrintMethod, EncoderMethod,
122
134
OperandNamespace + " ::" + OperandType, MIOperandNo,
@@ -138,9 +150,11 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
138
150
// /
139
151
unsigned CGIOperandList::getOperandNamed (StringRef Name) const {
140
152
unsigned OpIdx;
141
- if (hasOperandNamed (Name, OpIdx)) return OpIdx;
142
- PrintFatalError (" '" + TheDef->getName () +
143
- " ' does not have an operand named '$" + Name + " '!" );
153
+ if (hasOperandNamed (Name, OpIdx))
154
+ return OpIdx;
155
+ PrintFatalError (TheDef->getLoc (), " '" + TheDef->getName () +
156
+ " ' does not have an operand named '$" +
157
+ Name + " '!" );
144
158
}
145
159
146
160
// / hasOperandNamed - Query whether the instruction has an operand of the
@@ -159,7 +173,8 @@ bool CGIOperandList::hasOperandNamed(StringRef Name, unsigned &OpIdx) const {
159
173
std::pair<unsigned ,unsigned >
160
174
CGIOperandList::ParseOperandName (const std::string &Op, bool AllowWholeOp) {
161
175
if (Op.empty () || Op[0 ] != ' $' )
162
- PrintFatalError (TheDef->getName () + " : Illegal operand name: '" + Op + " '" );
176
+ PrintFatalError (TheDef->getLoc (),
177
+ TheDef->getName () + " : Illegal operand name: '" + Op + " '" );
163
178
164
179
std::string OpName = Op.substr (1 );
165
180
std::string SubOpName;
@@ -169,7 +184,9 @@ CGIOperandList::ParseOperandName(const std::string &Op, bool AllowWholeOp) {
169
184
if (DotIdx != std::string::npos) {
170
185
SubOpName = OpName.substr (DotIdx+1 );
171
186
if (SubOpName.empty ())
172
- PrintFatalError (TheDef->getName () + " : illegal empty suboperand name in '" +Op +" '" );
187
+ PrintFatalError (TheDef->getLoc (),
188
+ TheDef->getName () +
189
+ " : illegal empty suboperand name in '" + Op + " '" );
173
190
OpName = OpName.substr (0 , DotIdx);
174
191
}
175
192
@@ -179,8 +196,11 @@ CGIOperandList::ParseOperandName(const std::string &Op, bool AllowWholeOp) {
179
196
// If one was needed, throw.
180
197
if (OperandList[OpIdx].MINumOperands > 1 && !AllowWholeOp &&
181
198
SubOpName.empty ())
182
- PrintFatalError (TheDef->getName () + " : Illegal to refer to"
183
- " whole operand part of complex operand '" + Op + " '" );
199
+ PrintFatalError (TheDef->getLoc (),
200
+ TheDef->getName () +
201
+ " : Illegal to refer to"
202
+ " whole operand part of complex operand '" +
203
+ Op + " '" );
184
204
185
205
// Otherwise, return the operand.
186
206
return std::make_pair (OpIdx, 0U );
@@ -189,15 +209,19 @@ CGIOperandList::ParseOperandName(const std::string &Op, bool AllowWholeOp) {
189
209
// Find the suboperand number involved.
190
210
DagInit *MIOpInfo = OperandList[OpIdx].MIOperandInfo ;
191
211
if (!MIOpInfo)
192
- PrintFatalError (TheDef->getName () + " : unknown suboperand name in '" + Op + " '" );
212
+ PrintFatalError (TheDef->getLoc (), TheDef->getName () +
213
+ " : unknown suboperand name in '" +
214
+ Op + " '" );
193
215
194
216
// Find the operand with the right name.
195
217
for (unsigned i = 0 , e = MIOpInfo->getNumArgs (); i != e; ++i)
196
218
if (MIOpInfo->getArgNameStr (i) == SubOpName)
197
219
return std::make_pair (OpIdx, i);
198
220
199
221
// Otherwise, didn't find it!
200
- PrintFatalError (TheDef->getName () + " : unknown suboperand name in '" + Op + " '" );
222
+ PrintFatalError (TheDef->getLoc (), TheDef->getName () +
223
+ " : unknown suboperand name in '" + Op +
224
+ " '" );
201
225
return std::make_pair (0U , 0U );
202
226
}
203
227
0 commit comments