2 /* A Bison parser, made from /Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
7 #define yyparse Fileparse
9 #define yyerror Fileerror
10 #define yylval Filelval
11 #define yychar Filechar
12 #define yydebug Filedebug
13 #define yynerrs Filenerrs
23 #define MULTICLASS 266
31 #define STRCONCATTOK 274
36 #define CODEFRAGMENT 279
38 #line 14 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
41 #include "llvm/ADT/StringExtras.h"
44 #define YYERROR_VERBOSE 1
46 int yyerror(const char *ErrorMsg);
51 Record Rec; // Placeholder for template args and Name.
52 std::vector<Record*> DefPrototypes;
54 MultiClass(const std::string &Name) : Rec(Name) {}
58 static std::map<std::string, MultiClass*> MultiClasses;
60 extern int Filelineno;
61 static MultiClass *CurMultiClass = 0; // Set while parsing a multiclass.
62 static std::string *CurDefmPrefix = 0; // Set while parsing defm.
63 static Record *CurRec = 0;
64 static bool ParsingTemplateArgs = false;
66 typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
70 std::vector<unsigned> Bits;
73 LetRecord(const std::string &N, std::vector<unsigned> *B, Init *V)
74 : Name(N), Value(V), HasBits(B != 0) {
75 if (HasBits) Bits = *B;
79 static std::vector<std::vector<LetRecord> > LetStack;
82 extern std::ostream &err();
84 /// getActiveRec - If inside a def/class definition, return the def/class.
85 /// Otherwise, if within a multidef, return it.
86 static Record *getActiveRec() {
87 return CurRec ? CurRec : &CurMultiClass->Rec;
90 static void addValue(const RecordVal &RV) {
91 Record *TheRec = getActiveRec();
93 if (RecordVal *ERV = TheRec->getValue(RV.getName())) {
94 // The value already exists in the class, treat this as a set...
95 if (ERV->setValue(RV.getValue())) {
96 err() << "New definition of '" << RV.getName() << "' of type '"
97 << *RV.getType() << "' is incompatible with previous "
98 << "definition of type '" << *ERV->getType() << "'!\n";
102 TheRec->addValue(RV);
106 static void addSuperClass(Record *SC) {
107 if (CurRec->isSubClassOf(SC)) {
108 err() << "Already subclass of '" << SC->getName() << "'!\n";
111 CurRec->addSuperClass(SC);
114 static void setValue(const std::string &ValName,
115 std::vector<unsigned> *BitList, Init *V) {
118 RecordVal *RV = CurRec->getValue(ValName);
120 err() << "Value '" << ValName << "' unknown!\n";
124 // Do not allow assignments like 'X = X'. This will just cause infinite loops
125 // in the resolution machinery.
127 if (VarInit *VI = dynamic_cast<VarInit*>(V))
128 if (VI->getName() == ValName)
131 // If we are assigning to a subset of the bits in the value... then we must be
132 // assigning to a field of BitsRecTy, which must have a BitsInit
136 BitsInit *CurVal = dynamic_cast<BitsInit*>(RV->getValue());
138 err() << "Value '" << ValName << "' is not a bits type!\n";
142 // Convert the incoming value to a bits type of the appropriate size...
143 Init *BI = V->convertInitializerTo(new BitsRecTy(BitList->size()));
145 V->convertInitializerTo(new BitsRecTy(BitList->size()));
146 err() << "Initializer '" << *V << "' not compatible with bit range!\n";
150 // We should have a BitsInit type now...
151 assert(dynamic_cast<BitsInit*>(BI) != 0 || &(std::cerr << *BI) == 0);
152 BitsInit *BInit = (BitsInit*)BI;
154 BitsInit *NewVal = new BitsInit(CurVal->getNumBits());
156 // Loop over bits, assigning values as appropriate...
157 for (unsigned i = 0, e = BitList->size(); i != e; ++i) {
158 unsigned Bit = (*BitList)[i];
159 if (NewVal->getBit(Bit)) {
160 err() << "Cannot set bit #" << Bit << " of value '" << ValName
161 << "' more than once!\n";
164 NewVal->setBit(Bit, BInit->getBit(i));
167 for (unsigned i = 0, e = CurVal->getNumBits(); i != e; ++i)
168 if (NewVal->getBit(i) == 0)
169 NewVal->setBit(i, CurVal->getBit(i));
174 if (RV->setValue(V)) {
175 err() << "Value '" << ValName << "' of type '" << *RV->getType()
176 << "' is incompatible with initializer '" << *V << "'!\n";
181 // addSubClass - Add SC as a subclass to CurRec, resolving TemplateArgs as SC's
182 // template arguments.
183 static void addSubClass(Record *SC, const std::vector<Init*> &TemplateArgs) {
184 // Add all of the values in the subclass into the current class...
185 const std::vector<RecordVal> &Vals = SC->getValues();
186 for (unsigned i = 0, e = Vals.size(); i != e; ++i)
189 const std::vector<std::string> &TArgs = SC->getTemplateArgs();
191 // Ensure that an appropriate number of template arguments are specified...
192 if (TArgs.size() < TemplateArgs.size()) {
193 err() << "ERROR: More template args specified than expected!\n";
197 // Loop over all of the template arguments, setting them to the specified
198 // value or leaving them as the default if necessary.
199 for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
200 if (i < TemplateArgs.size()) { // A value is specified for this temp-arg?
202 setValue(TArgs[i], 0, TemplateArgs[i]);
205 CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i]));
209 CurRec->removeValue(TArgs[i]);
211 } else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) {
212 err() << "ERROR: Value not specified for template argument #"
213 << i << " (" << TArgs[i] << ") of subclass '" << SC->getName()
219 // Since everything went well, we can now set the "superclass" list for the
221 const std::vector<Record*> &SCs = SC->getSuperClasses();
222 for (unsigned i = 0, e = SCs.size(); i != e; ++i)
223 addSuperClass(SCs[i]);
227 } // End llvm namespace
229 using namespace llvm;
232 #line 208 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
237 llvm::Init* Initializer;
238 std::vector<llvm::Init*>* FieldList;
239 std::vector<unsigned>* BitList;
241 std::vector<llvm::Record*>* RecList;
242 SubClassRefTy* SubClassRef;
243 std::vector<SubClassRefTy>* SubClassList;
244 std::vector<std::pair<llvm::Init*, std::string> >* DagValueList;
257 #define YYFLAG -32768
260 #define YYTRANSLATE(x) ((unsigned)(x) <= 279 ? yytranslate[x] : 90)
262 static const char yytranslate[] = { 0,
263 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
264 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
265 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
266 2, 2, 2, 2, 2, 2, 2, 2, 2, 35,
267 36, 2, 2, 37, 39, 34, 2, 2, 2, 2,
268 2, 2, 2, 2, 2, 2, 2, 38, 40, 26,
269 28, 27, 29, 2, 2, 2, 2, 2, 2, 2,
270 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
271 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
272 32, 2, 33, 2, 2, 2, 2, 2, 2, 2,
273 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
274 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
275 2, 2, 30, 2, 31, 2, 2, 2, 2, 2,
276 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
277 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
278 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
279 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
280 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
281 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
282 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
283 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
284 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
285 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
286 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
287 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
288 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
289 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
290 17, 18, 19, 20, 21, 22, 23, 24, 25
294 static const short yyprhs[] = { 0,
295 0, 2, 4, 6, 11, 13, 18, 20, 22, 24,
296 25, 27, 28, 31, 33, 35, 37, 39, 41, 43,
297 47, 52, 57, 61, 65, 70, 75, 82, 89, 96,
298 103, 104, 107, 110, 115, 116, 118, 120, 124, 127,
299 131, 137, 142, 144, 145, 149, 150, 152, 154, 158,
300 163, 166, 173, 174, 177, 179, 183, 185, 190, 192,
301 196, 197, 200, 202, 206, 210, 211, 213, 215, 216,
302 218, 220, 222, 223, 227, 228, 229, 236, 240, 242,
303 244, 247, 249, 250, 251, 260, 261, 268, 270, 272,
304 274, 276, 281, 283, 287, 288, 293, 298, 301, 303,
308 static const short yyrhs[] = { 22,
309 0, 5, 0, 4, 0, 6, 26, 21, 27, 0,
310 3, 0, 7, 26, 42, 27, 0, 8, 0, 9,
311 0, 41, 0, 0, 14, 0, 0, 28, 46, 0,
312 22, 0, 45, 0, 21, 0, 24, 0, 25, 0,
313 29, 0, 30, 53, 31, 0, 22, 26, 54, 27,
314 0, 46, 30, 51, 31, 0, 32, 53, 33, 0,
315 46, 34, 22, 0, 35, 45, 49, 36, 0, 46,
316 32, 51, 33, 0, 17, 35, 46, 37, 46, 36,
317 0, 18, 35, 46, 37, 46, 36, 0, 19, 35,
318 46, 37, 46, 36, 0, 20, 35, 46, 37, 46,
319 36, 0, 0, 38, 23, 0, 46, 47, 0, 48,
320 37, 46, 47, 0, 0, 48, 0, 21, 0, 21,
321 39, 21, 0, 21, 21, 0, 50, 37, 21, 0,
322 50, 37, 21, 39, 21, 0, 50, 37, 21, 21,
323 0, 50, 0, 0, 30, 51, 31, 0, 0, 54,
324 0, 46, 0, 54, 37, 46, 0, 43, 42, 22,
325 44, 0, 55, 40, 0, 15, 22, 52, 28, 46,
326 40, 0, 0, 57, 56, 0, 40, 0, 30, 57,
327 31, 0, 41, 0, 41, 26, 54, 27, 0, 59,
328 0, 60, 37, 59, 0, 0, 38, 60, 0, 55,
329 0, 62, 37, 55, 0, 26, 62, 27, 0, 0,
330 63, 0, 22, 0, 0, 65, 0, 66, 0, 66,
331 0, 0, 61, 70, 58, 0, 0, 0, 10, 67,
332 72, 64, 73, 69, 0, 11, 68, 69, 0, 74,
333 0, 75, 0, 76, 75, 0, 22, 0, 0, 0,
334 12, 77, 79, 64, 80, 30, 76, 31, 0, 0,
335 13, 22, 82, 38, 59, 40, 0, 71, 0, 74,
336 0, 78, 0, 81, 0, 22, 52, 28, 46, 0,
337 84, 0, 85, 37, 84, 0, 0, 15, 87, 85,
338 16, 0, 86, 30, 88, 31, 0, 86, 83, 0,
339 83, 0, 88, 83, 0, 88, 0
345 static const short yyrline[] = { 0,
346 244, 266, 268, 270, 272, 274, 276, 278, 280, 284,
347 284, 286, 286, 288, 311, 313, 315, 318, 321, 323,
348 336, 364, 371, 374, 381, 384, 392, 394, 396, 398,
349 402, 405, 409, 414, 420, 423, 426, 429, 442, 456,
350 458, 471, 487, 489, 489, 493, 495, 499, 502, 506,
351 523, 525, 531, 531, 532, 532, 534, 536, 540, 545,
352 550, 553, 557, 560, 565, 566, 566, 568, 568, 570,
353 577, 595, 620, 634, 639, 641, 643, 647, 657, 671,
354 674, 678, 689, 691, 693, 698, 698, 763, 763, 764,
355 764, 766, 771, 771, 774, 774, 777, 780, 784, 784,
361 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
363 static const char * const yytname[] = { "$","error","$undefined.","INT","BIT",
364 "STRING","BITS","LIST","CODE","DAG","CLASS","DEF","MULTICLASS","DEFM","FIELD",
365 "LET","IN","SHLTOK","SRATOK","SRLTOK","STRCONCATTOK","INTVAL","ID","VARNAME",
366 "STRVAL","CODEFRAGMENT","'<'","'>'","'='","'?'","'{'","'}'","'['","']'","'.'",
367 "'('","')'","','","':'","'-'","';'","ClassID","Type","OptPrefix","OptValue",
368 "IDValue","Value","OptVarName","DagArgListNE","DagArgList","RBitList","BitList",
369 "OptBitList","ValueList","ValueListNE","Declaration","BodyItem","BodyList","Body",
370 "SubClassRef","ClassListNE","ClassList","DeclListNE","TemplateArgList","OptTemplateArgList",
371 "OptID","ObjectName","ClassName","DefName","ObjectBody","@1","ClassInst","@2",
372 "@3","DefInst","MultiClassDef","MultiClassBody","MultiClassName","MultiClassInst",
373 "@4","@5","DefMInst","@6","Object","LETItem","LETList","LETCommand","@7","ObjectList",
378 static const short yyr1[] = { 0,
379 41, 42, 42, 42, 42, 42, 42, 42, 42, 43,
380 43, 44, 44, 45, 46, 46, 46, 46, 46, 46,
381 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
382 47, 47, 48, 48, 49, 49, 50, 50, 50, 50,
383 50, 50, 51, 52, 52, 53, 53, 54, 54, 55,
384 56, 56, 57, 57, 58, 58, 59, 59, 60, 60,
385 61, 61, 62, 62, 63, 64, 64, 65, 65, 66,
386 67, 68, 70, 69, 72, 73, 71, 74, 75, 76,
387 76, 77, 79, 80, 78, 82, 81, 83, 83, 83,
388 83, 84, 85, 85, 87, 86, 83, 83, 88, 88,
392 static const short yyr2[] = { 0,
393 1, 1, 1, 4, 1, 4, 1, 1, 1, 0,
394 1, 0, 2, 1, 1, 1, 1, 1, 1, 3,
395 4, 4, 3, 3, 4, 4, 6, 6, 6, 6,
396 0, 2, 2, 4, 0, 1, 1, 3, 2, 3,
397 5, 4, 1, 0, 3, 0, 1, 1, 3, 4,
398 2, 6, 0, 2, 1, 3, 1, 4, 1, 3,
399 0, 2, 1, 3, 3, 0, 1, 1, 0, 1,
400 1, 1, 0, 3, 0, 0, 6, 3, 1, 1,
401 2, 1, 0, 0, 8, 0, 6, 1, 1, 1,
402 1, 4, 1, 3, 0, 4, 4, 2, 1, 2,
406 static const short yydefact[] = { 0,
407 69, 69, 0, 0, 95, 88, 89, 90, 91, 99,
408 0, 101, 68, 70, 71, 75, 72, 61, 82, 83,
409 86, 0, 0, 98, 100, 66, 0, 73, 78, 66,
410 0, 44, 93, 0, 0, 10, 67, 76, 1, 57,
411 59, 62, 0, 84, 0, 0, 0, 96, 0, 97,
412 11, 0, 63, 0, 61, 0, 0, 53, 55, 74,
413 0, 0, 37, 43, 0, 0, 94, 5, 3, 2,
414 0, 0, 7, 8, 9, 0, 65, 10, 77, 0,
415 0, 0, 0, 16, 14, 17, 18, 19, 46, 46,
416 0, 15, 48, 0, 60, 10, 0, 87, 39, 0,
417 0, 45, 92, 0, 0, 12, 64, 0, 0, 0,
418 0, 0, 0, 47, 0, 14, 35, 0, 0, 0,
419 58, 0, 0, 56, 0, 54, 79, 80, 0, 38,
420 40, 0, 0, 0, 50, 0, 0, 0, 0, 0,
421 20, 23, 31, 36, 0, 0, 0, 24, 49, 44,
422 51, 85, 81, 42, 0, 4, 6, 13, 0, 0,
423 0, 0, 21, 0, 33, 0, 25, 22, 26, 0,
424 41, 0, 0, 0, 0, 32, 31, 0, 27, 28,
425 29, 30, 34, 0, 52, 0, 0, 0
428 static const short yydefgoto[] = { 40,
429 76, 52, 135, 92, 93, 165, 144, 145, 64, 65,
430 47, 113, 114, 53, 126, 96, 60, 41, 42, 28,
431 54, 37, 38, 14, 15, 16, 18, 29, 43, 6,
432 26, 55, 7, 128, 129, 20, 8, 30, 61, 9,
433 31, 10, 33, 34, 11, 22, 12, 186
436 static const short yypact[] = { 129,
437 3, 3, 11, 19,-32768,-32768,-32768,-32768,-32768,-32768,
438 2, 129,-32768,-32768,-32768,-32768,-32768, 29,-32768,-32768,
439 -32768, 24, 129,-32768,-32768, 43, 31,-32768,-32768, 43,
440 40, 50,-32768, -6, -4, 69,-32768,-32768,-32768, 59,
441 -32768, 61, 10,-32768, 31, 81, 78,-32768, 24,-32768,
442 -32768, 15,-32768, 12, 29, 41, 31,-32768,-32768,-32768,
443 84, 68, 8, 83, 87, 41,-32768,-32768,-32768,-32768,
444 111, 120,-32768,-32768,-32768, 126,-32768, 69,-32768, 114,
445 115, 116, 117,-32768, 127,-32768,-32768,-32768, 41, 41,
446 132,-32768, 113, 27,-32768, 60, 144,-32768,-32768, 135,
447 136,-32768, 113, 137, 15, 131,-32768, 41, 41, 41,
448 41, 41, 130, 123, 133,-32768, 41, 81, 81, 140,
449 -32768, 41, 141,-32768, 124,-32768,-32768,-32768, 5,-32768,
450 9, 138, 142, 41,-32768, 67, 73, 79, 85, 45,
451 -32768,-32768, 54, 134, 139, 143, 145,-32768, 113, 50,
452 -32768,-32768,-32768,-32768, 146,-32768,-32768, 113, 41, 41,
453 41, 41,-32768, 147,-32768, 41,-32768,-32768,-32768, 148,
454 -32768, 91, 94, 99, 102,-32768, 54, 41,-32768,-32768,
455 -32768,-32768,-32768, 47,-32768, 168, 172,-32768
458 static const short yypgoto[] = { -50,
459 72,-32768,-32768, 82, -66, 4,-32768,-32768,-32768, -29,
460 30, 89, -55, -44,-32768,-32768,-32768, -19,-32768,-32768,
461 -32768,-32768, 152,-32768, 181,-32768,-32768, 149,-32768,-32768,
462 -32768,-32768, -94, 55,-32768,-32768,-32768,-32768,-32768,-32768,
463 -32768, -7, 150,-32768,-32768,-32768, 162,-32768
470 static const short yytable[] = { 103,
471 94, 75, 127, 24, 25, 1, 2, 3, 4, 48,
472 5, 1, 2, 3, 4, 2, 5, 68, 69, 70,
473 71, 72, 73, 74, 13, 62, 50, 25, 99, 154,
474 49, 23, 19, 107, 127, 152, 39, 95, 77, 58,
475 21, 136, 137, 138, 139, 32, 100, 155, 78, 59,
476 143, 125, 39, 121, 75, 149, 140, 80, 81, 82,
477 83, 84, 85, 122, 86, 87, 27, 158, 36, 88,
478 89, 163, 90, 51, 123, 91, 118, 45, 119, 46,
479 120, 122, 51, 118, 56, 119, 185, 120, 146, 147,
480 124, 164, 172, 173, 174, 175, 118, 57, 119, 177,
481 120, 63, 118, 159, 119, 66, 120, 98, 118, 160,
482 119, 184, 120, 97, 118, 161, 119, 102, 120, 101,
483 118, 162, 119, 118, 120, 119, 179, 120, 118, 180,
484 119, 118, 120, 119, 181, 120, 104, 182, 1, 2,
485 3, 4, 118, 5, 119, 105, 120, 106, 108, 109,
486 110, 111, 112, 116, 2, 130, 131, 132, 134, 122,
487 141, 148, 150, 151, 156, 142, 171, 187, 157, 176,
488 166, 188, 117, 168, 167, 178, 133, 169, 115, 170,
489 183, 44, 17, 153, 35, 0, 0, 0, 0, 0,
490 0, 0, 0, 0, 0, 0, 0, 0, 67, 0,
494 static const short yycheck[] = { 66,
495 56, 52, 97, 11, 12, 10, 11, 12, 13, 16,
496 15, 10, 11, 12, 13, 11, 15, 3, 4, 5,
497 6, 7, 8, 9, 22, 45, 31, 35, 21, 21,
498 37, 30, 22, 78, 129, 31, 22, 57, 27, 30,
499 22, 108, 109, 110, 111, 22, 39, 39, 37, 40,
500 117, 96, 22, 27, 105, 122, 112, 17, 18, 19,
501 20, 21, 22, 37, 24, 25, 38, 134, 26, 29,
502 30, 27, 32, 14, 15, 35, 30, 38, 32, 30,
503 34, 37, 14, 30, 26, 32, 40, 34, 118, 119,
504 31, 38, 159, 160, 161, 162, 30, 37, 32, 166,
505 34, 21, 30, 37, 32, 28, 34, 40, 30, 37,
506 32, 178, 34, 30, 30, 37, 32, 31, 34, 37,
507 30, 37, 32, 30, 34, 32, 36, 34, 30, 36,
508 32, 30, 34, 32, 36, 34, 26, 36, 10, 11,
509 12, 13, 30, 15, 32, 26, 34, 22, 35, 35,
510 35, 35, 26, 22, 11, 21, 21, 21, 28, 37,
511 31, 22, 22, 40, 27, 33, 21, 0, 27, 23,
512 37, 0, 91, 31, 36, 28, 105, 33, 90, 150,
513 177, 30, 2, 129, 23, -1, -1, -1, -1, -1,
514 -1, -1, -1, -1, -1, -1, -1, -1, 49, -1,
517 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
518 #line 3 "/usr/share/bison.simple"
519 /* This file comes from bison-1.28. */
521 /* Skeleton output parser for bison,
522 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
524 This program is free software; you can redistribute it and/or modify
525 it under the terms of the GNU General Public License as published by
526 the Free Software Foundation; either version 2, or (at your option)
529 This program is distributed in the hope that it will be useful,
530 but WITHOUT ANY WARRANTY; without even the implied warranty of
531 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
532 GNU General Public License for more details.
534 You should have received a copy of the GNU General Public License
535 along with this program; if not, write to the Free Software
536 Foundation, Inc., 59 Temple Place - Suite 330,
537 Boston, MA 02111-1307, USA. */
539 /* As a special exception, when this file is copied by Bison into a
540 Bison output file, you may use that output file without restriction.
541 This special exception was added by the Free Software Foundation
542 in version 1.24 of Bison. */
544 /* This is the parser code that is written into each bison parser
545 when the %semantic_parser declaration is not specified in the grammar.
546 It was written by Richard Stallman by simplifying the hairy parser
547 used when %semantic_parser is specified. */
549 #ifndef YYSTACK_USE_ALLOCA
551 #define YYSTACK_USE_ALLOCA
552 #else /* alloca not defined */
554 #define YYSTACK_USE_ALLOCA
555 #define alloca __builtin_alloca
556 #else /* not GNU C. */
557 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
558 #define YYSTACK_USE_ALLOCA
560 #else /* not sparc */
561 /* We think this test detects Watcom and Microsoft C. */
562 /* This used to test MSDOS, but that is a bad idea
563 since that symbol is in the user namespace. */
564 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
565 #if 0 /* No need for malloc.h, which pollutes the namespace;
566 instead, just don't use alloca. */
569 #else /* not MSDOS, or __TURBOC__ */
571 /* I don't know what this was needed for, but it pollutes the namespace.
572 So I turned it off. rms, 2 May 1997. */
573 /* #include <malloc.h> */
575 #define YYSTACK_USE_ALLOCA
576 #else /* not MSDOS, or __TURBOC__, or _AIX */
578 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
579 and on HPUX 10. Eventually we can turn this on. */
580 #define YYSTACK_USE_ALLOCA
581 #define alloca __builtin_alloca
584 #endif /* not _AIX */
585 #endif /* not MSDOS, or __TURBOC__ */
586 #endif /* not sparc */
587 #endif /* not GNU C */
588 #endif /* alloca not defined */
589 #endif /* YYSTACK_USE_ALLOCA not defined */
591 #ifdef YYSTACK_USE_ALLOCA
592 #define YYSTACK_ALLOC alloca
594 #define YYSTACK_ALLOC malloc
597 /* Note: there must be only one dollar sign in this file.
598 It is replaced by the list of actions, each action
599 as one case of the switch. */
601 #define yyerrok (yyerrstatus = 0)
602 #define yyclearin (yychar = YYEMPTY)
605 #define YYACCEPT goto yyacceptlab
606 #define YYABORT goto yyabortlab
607 #define YYERROR goto yyerrlab1
608 /* Like YYERROR except do call yyerror.
609 This remains here temporarily to ease the
610 transition to the new meaning of YYERROR, for GCC.
611 Once GCC version 2 has supplanted version 1, this can go. */
612 #define YYFAIL goto yyerrlab
613 #define YYRECOVERING() (!!yyerrstatus)
614 #define YYBACKUP(token, value) \
616 if (yychar == YYEMPTY && yylen == 1) \
617 { yychar = (token), yylval = (value); \
618 yychar1 = YYTRANSLATE (yychar); \
623 { yyerror ("syntax error: cannot back up"); YYERROR; } \
627 #define YYERRCODE 256
630 #define YYLEX yylex()
636 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
638 #define YYLEX yylex(&yylval, &yylloc)
640 #else /* not YYLSP_NEEDED */
642 #define YYLEX yylex(&yylval, YYLEX_PARAM)
644 #define YYLEX yylex(&yylval)
646 #endif /* not YYLSP_NEEDED */
649 /* If nonreentrant, generate the variables here */
653 int yychar; /* the lookahead symbol */
654 YYSTYPE yylval; /* the semantic value of the */
655 /* lookahead symbol */
658 YYLTYPE yylloc; /* location data for the lookahead */
662 int yynerrs; /* number of parse errors so far */
663 #endif /* not YYPURE */
666 int yydebug; /* nonzero means print parse trace */
667 /* Since this is uninitialized, it does not stop multiple parsers
671 /* YYINITDEPTH indicates the initial size of the parser's stacks */
674 #define YYINITDEPTH 200
677 /* YYMAXDEPTH is the maximum size the stacks can grow to
678 (effective only if the built-in stack extension method is used). */
685 #define YYMAXDEPTH 10000
688 /* Define __yy_memcpy. Note that the size argument
689 should be passed with type unsigned int, because that is what the non-GCC
690 definitions require. With GCC, __builtin_memcpy takes an arg
691 of type size_t, but it can handle unsigned int. */
693 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
694 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
695 #else /* not GNU C or C++ */
698 /* This is the most reliable way to avoid incompatibilities
699 in available built-in functions on various systems. */
701 __yy_memcpy (to, from, count)
706 register char *f = from;
707 register char *t = to;
708 register int i = count;
714 #else /* __cplusplus */
716 /* This is the most reliable way to avoid incompatibilities
717 in available built-in functions on various systems. */
719 __yy_memcpy (char *to, char *from, unsigned int count)
721 register char *t = to;
722 register char *f = from;
723 register int i = count;
732 #line 217 "/usr/share/bison.simple"
734 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
735 into yyparse. The argument should have type void *.
736 It should actually point to an object.
737 Grammar actions can access the variable by casting it
738 to the proper pointer type. */
742 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
743 #define YYPARSE_PARAM_DECL
744 #else /* not __cplusplus */
745 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
746 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
747 #endif /* not __cplusplus */
748 #else /* not YYPARSE_PARAM */
749 #define YYPARSE_PARAM_ARG
750 #define YYPARSE_PARAM_DECL
751 #endif /* not YYPARSE_PARAM */
753 /* Prevent warning if -Wstrict-prototypes. */
756 int yyparse (void *);
763 yyparse(YYPARSE_PARAM_ARG)
766 register int yystate;
768 register short *yyssp;
769 register YYSTYPE *yyvsp;
770 int yyerrstatus; /* number of tokens to shift before error messages enabled */
771 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
773 short yyssa[YYINITDEPTH]; /* the state stack */
774 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
776 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
777 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
780 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
781 YYLTYPE *yyls = yylsa;
784 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
786 #define YYPOPSTACK (yyvsp--, yyssp--)
789 int yystacksize = YYINITDEPTH;
790 int yyfree_stacks = 0;
801 YYSTYPE yyval; /* the variable used to return */
802 /* semantic values from the action */
809 fprintf(stderr, "Starting parse\n");
815 yychar = YYEMPTY; /* Cause a token to be read. */
817 /* Initialize stack pointers.
818 Waste one element of value and location stack
819 so that they stay on the same level as the state stack.
820 The wasted elements are never initialized. */
828 /* Push a new state, which is found in yystate . */
829 /* In all cases, when you get here, the value and location stacks
830 have just been pushed. so pushing a state here evens the stacks. */
835 if (yyssp >= yyss + yystacksize - 1)
837 /* Give user a chance to reallocate the stack */
838 /* Use copies of these so that the &'s don't force the real ones into memory. */
839 YYSTYPE *yyvs1 = yyvs;
842 YYLTYPE *yyls1 = yyls;
845 /* Get the current used size of the three stacks, in elements. */
846 int size = yyssp - yyss + 1;
849 /* Each stack pointer address is followed by the size of
850 the data in use in that stack, in bytes. */
852 /* This used to be a conditional around just the two extra args,
853 but that might be undefined if yyoverflow is a macro. */
854 yyoverflow("parser stack overflow",
855 &yyss1, size * sizeof (*yyssp),
856 &yyvs1, size * sizeof (*yyvsp),
857 &yyls1, size * sizeof (*yylsp),
860 yyoverflow("parser stack overflow",
861 &yyss1, size * sizeof (*yyssp),
862 &yyvs1, size * sizeof (*yyvsp),
866 yyss = yyss1; yyvs = yyvs1;
870 #else /* no yyoverflow */
871 /* Extend the stack our own way. */
872 if (yystacksize >= YYMAXDEPTH)
874 yyerror("parser stack overflow");
886 if (yystacksize > YYMAXDEPTH)
887 yystacksize = YYMAXDEPTH;
888 #ifndef YYSTACK_USE_ALLOCA
891 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
892 __yy_memcpy ((char *)yyss, (char *)yyss1,
893 size * (unsigned int) sizeof (*yyssp));
894 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
895 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
896 size * (unsigned int) sizeof (*yyvsp));
898 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
899 __yy_memcpy ((char *)yyls, (char *)yyls1,
900 size * (unsigned int) sizeof (*yylsp));
902 #endif /* no yyoverflow */
904 yyssp = yyss + size - 1;
905 yyvsp = yyvs + size - 1;
907 yylsp = yyls + size - 1;
912 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
915 if (yyssp >= yyss + yystacksize - 1)
921 fprintf(stderr, "Entering state %d\n", yystate);
927 /* Do appropriate processing given the current state. */
928 /* Read a lookahead token if we need one and don't already have one. */
931 /* First try to decide what to do without reference to lookahead token. */
933 yyn = yypact[yystate];
937 /* Not known => get a lookahead token if don't already have one. */
939 /* yychar is either YYEMPTY or YYEOF
940 or a valid token in external form. */
942 if (yychar == YYEMPTY)
946 fprintf(stderr, "Reading a token: ");
951 /* Convert token to internal form (in yychar1) for indexing tables with */
953 if (yychar <= 0) /* This means end of input. */
956 yychar = YYEOF; /* Don't call YYLEX any more */
960 fprintf(stderr, "Now at end of input.\n");
965 yychar1 = YYTRANSLATE(yychar);
970 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
971 /* Give the individual parser a way to print the precise meaning
972 of a token, for further debugging info. */
974 YYPRINT (stderr, yychar, yylval);
976 fprintf (stderr, ")\n");
982 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
987 /* yyn is what to do for this token type in this state.
988 Negative => reduce, -yyn is rule number.
989 Positive => shift, yyn is new state.
990 New state is final state => don't bother to shift,
992 0, or most negative number => error. */
1007 /* Shift the lookahead token. */
1011 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
1014 /* Discard the token being shifted unless it is eof. */
1015 if (yychar != YYEOF)
1023 /* count tokens shifted since error; after three, turn off error status. */
1024 if (yyerrstatus) yyerrstatus--;
1029 /* Do the default action for the current state. */
1032 yyn = yydefact[yystate];
1036 /* Do a reduction. yyn is the number of a rule to reduce with. */
1040 yyval = yyvsp[1-yylen]; /* implement default value of the action */
1047 fprintf (stderr, "Reducing via rule %d (line %d), ",
1050 /* Print the symbols being reduced, and their result. */
1051 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
1052 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1053 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1061 #line 244 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1063 if (CurDefmPrefix) {
1064 // If CurDefmPrefix is set, we're parsing a defm, which means that this is
1065 // actually the name of a multiclass.
1066 MultiClass *MC = MultiClasses[*yyvsp[0].StrVal];
1068 err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n";
1071 yyval.Rec = &MC->Rec;
1073 yyval.Rec = Records.getClass(*yyvsp[0].StrVal);
1075 if (yyval.Rec == 0) {
1076 err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n";
1079 delete yyvsp[0].StrVal;
1083 #line 266 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1085 yyval.Ty = new StringRecTy();
1089 #line 268 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1091 yyval.Ty = new BitRecTy();
1095 #line 270 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1097 yyval.Ty = new BitsRecTy(yyvsp[-1].IntVal);
1101 #line 272 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1103 yyval.Ty = new IntRecTy();
1107 #line 274 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1109 yyval.Ty = new ListRecTy(yyvsp[-1].Ty);
1113 #line 276 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1115 yyval.Ty = new CodeRecTy();
1119 #line 278 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1121 yyval.Ty = new DagRecTy();
1125 #line 280 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1127 yyval.Ty = new RecordRecTy(yyvsp[0].Rec);
1131 #line 284 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1132 { yyval.IntVal = 0; ;
1135 #line 284 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1136 { yyval.IntVal = 1; ;
1139 #line 286 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1140 { yyval.Initializer = 0; ;
1143 #line 286 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1144 { yyval.Initializer = yyvsp[0].Initializer; ;
1147 #line 288 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1149 if (const RecordVal *RV = (CurRec ? CurRec->getValue(*yyvsp[0].StrVal) : 0)) {
1150 yyval.Initializer = new VarInit(*yyvsp[0].StrVal, RV->getType());
1151 } else if (CurRec && CurRec->isTemplateArg(CurRec->getName()+":"+*yyvsp[0].StrVal)) {
1152 const RecordVal *RV = CurRec->getValue(CurRec->getName()+":"+*yyvsp[0].StrVal);
1153 assert(RV && "Template arg doesn't exist??");
1154 yyval.Initializer = new VarInit(CurRec->getName()+":"+*yyvsp[0].StrVal, RV->getType());
1155 } else if (CurMultiClass &&
1156 CurMultiClass->Rec.isTemplateArg(CurMultiClass->Rec.getName()+"::"+*yyvsp[0].StrVal)) {
1157 std::string Name = CurMultiClass->Rec.getName()+"::"+*yyvsp[0].StrVal;
1158 const RecordVal *RV = CurMultiClass->Rec.getValue(Name);
1159 assert(RV && "Template arg doesn't exist??");
1160 yyval.Initializer = new VarInit(Name, RV->getType());
1161 } else if (Record *D = Records.getDef(*yyvsp[0].StrVal)) {
1162 yyval.Initializer = new DefInit(D);
1164 err() << "Variable not defined: '" << *yyvsp[0].StrVal << "'!\n";
1168 delete yyvsp[0].StrVal;
1172 #line 311 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1174 yyval.Initializer = yyvsp[0].Initializer;
1178 #line 313 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1180 yyval.Initializer = new IntInit(yyvsp[0].IntVal);
1184 #line 315 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1186 yyval.Initializer = new StringInit(*yyvsp[0].StrVal);
1187 delete yyvsp[0].StrVal;
1191 #line 318 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1193 yyval.Initializer = new CodeInit(*yyvsp[0].StrVal);
1194 delete yyvsp[0].StrVal;
1198 #line 321 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1200 yyval.Initializer = new UnsetInit();
1204 #line 323 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1206 BitsInit *Init = new BitsInit(yyvsp[-1].FieldList->size());
1207 for (unsigned i = 0, e = yyvsp[-1].FieldList->size(); i != e; ++i) {
1208 struct Init *Bit = (*yyvsp[-1].FieldList)[i]->convertInitializerTo(new BitRecTy());
1210 err() << "Element #" << i << " (" << *(*yyvsp[-1].FieldList)[i]
1211 << ") is not convertable to a bit!\n";
1214 Init->setBit(yyvsp[-1].FieldList->size()-i-1, Bit);
1216 yyval.Initializer = Init;
1217 delete yyvsp[-1].FieldList;
1221 #line 336 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1223 // This is a CLASS<initvalslist> expression. This is supposed to synthesize
1224 // a new anonymous definition, deriving from CLASS<initvalslist> with no
1226 Record *Class = Records.getClass(*yyvsp[-3].StrVal);
1228 err() << "Expected a class, got '" << *yyvsp[-3].StrVal << "'!\n";
1231 delete yyvsp[-3].StrVal;
1233 static unsigned AnonCounter = 0;
1234 Record *OldRec = CurRec; // Save CurRec.
1236 // Create the new record, set it as CurRec temporarily.
1237 CurRec = new Record("anonymous.val."+utostr(AnonCounter++));
1238 addSubClass(Class, *yyvsp[-1].FieldList); // Add info about the subclass to CurRec.
1239 delete yyvsp[-1].FieldList; // Free up the template args.
1241 CurRec->resolveReferences();
1243 Records.addDef(CurRec);
1245 // The result of the expression is a reference to the new record.
1246 yyval.Initializer = new DefInit(CurRec);
1248 // Restore the old CurRec
1253 #line 364 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1255 yyval.Initializer = yyvsp[-3].Initializer->convertInitializerBitRange(*yyvsp[-1].BitList);
1256 if (yyval.Initializer == 0) {
1257 err() << "Invalid bit range for value '" << *yyvsp[-3].Initializer << "'!\n";
1260 delete yyvsp[-1].BitList;
1264 #line 371 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1266 yyval.Initializer = new ListInit(*yyvsp[-1].FieldList);
1267 delete yyvsp[-1].FieldList;
1271 #line 374 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1273 if (!yyvsp[-2].Initializer->getFieldType(*yyvsp[0].StrVal)) {
1274 err() << "Cannot access field '" << *yyvsp[0].StrVal << "' of value '" << *yyvsp[-2].Initializer << "!\n";
1277 yyval.Initializer = new FieldInit(yyvsp[-2].Initializer, *yyvsp[0].StrVal);
1278 delete yyvsp[0].StrVal;
1282 #line 381 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1284 yyval.Initializer = new DagInit(yyvsp[-2].Initializer, *yyvsp[-1].DagValueList);
1285 delete yyvsp[-1].DagValueList;
1289 #line 384 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1291 std::reverse(yyvsp[-1].BitList->begin(), yyvsp[-1].BitList->end());
1292 yyval.Initializer = yyvsp[-3].Initializer->convertInitListSlice(*yyvsp[-1].BitList);
1293 if (yyval.Initializer == 0) {
1294 err() << "Invalid list slice for value '" << *yyvsp[-3].Initializer << "'!\n";
1297 delete yyvsp[-1].BitList;
1301 #line 392 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1303 yyval.Initializer = (new BinOpInit(BinOpInit::SHL, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1307 #line 394 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1309 yyval.Initializer = (new BinOpInit(BinOpInit::SRA, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1313 #line 396 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1315 yyval.Initializer = (new BinOpInit(BinOpInit::SRL, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1319 #line 398 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1321 yyval.Initializer = (new BinOpInit(BinOpInit::STRCONCAT, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1325 #line 402 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1327 yyval.StrVal = new std::string();
1331 #line 405 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1333 yyval.StrVal = yyvsp[0].StrVal;
1337 #line 409 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1339 yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
1340 yyval.DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal));
1341 delete yyvsp[0].StrVal;
1345 #line 414 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1347 yyvsp[-3].DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal));
1348 delete yyvsp[0].StrVal;
1349 yyval.DagValueList = yyvsp[-3].DagValueList;
1353 #line 420 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1355 yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
1359 #line 423 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1360 { yyval.DagValueList = yyvsp[0].DagValueList; ;
1363 #line 426 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1365 yyval.BitList = new std::vector<unsigned>();
1366 yyval.BitList->push_back(yyvsp[0].IntVal);
1370 #line 429 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1372 if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1373 err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1376 yyval.BitList = new std::vector<unsigned>();
1377 if (yyvsp[-2].IntVal < yyvsp[0].IntVal) {
1378 for (int i = yyvsp[-2].IntVal; i <= yyvsp[0].IntVal; ++i)
1379 yyval.BitList->push_back(i);
1381 for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1382 yyval.BitList->push_back(i);
1387 #line 442 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1389 yyvsp[0].IntVal = -yyvsp[0].IntVal;
1390 if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) {
1391 err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1394 yyval.BitList = new std::vector<unsigned>();
1395 if (yyvsp[-1].IntVal < yyvsp[0].IntVal) {
1396 for (int i = yyvsp[-1].IntVal; i <= yyvsp[0].IntVal; ++i)
1397 yyval.BitList->push_back(i);
1399 for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1400 yyval.BitList->push_back(i);
1405 #line 456 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1407 (yyval.BitList=yyvsp[-2].BitList)->push_back(yyvsp[0].IntVal);
1411 #line 458 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1413 if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1414 err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1417 yyval.BitList = yyvsp[-4].BitList;
1418 if (yyvsp[-2].IntVal < yyvsp[0].IntVal) {
1419 for (int i = yyvsp[-2].IntVal; i <= yyvsp[0].IntVal; ++i)
1420 yyval.BitList->push_back(i);
1422 for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1423 yyval.BitList->push_back(i);
1428 #line 471 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1430 yyvsp[0].IntVal = -yyvsp[0].IntVal;
1431 if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) {
1432 err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1435 yyval.BitList = yyvsp[-3].BitList;
1436 if (yyvsp[-1].IntVal < yyvsp[0].IntVal) {
1437 for (int i = yyvsp[-1].IntVal; i <= yyvsp[0].IntVal; ++i)
1438 yyval.BitList->push_back(i);
1440 for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1441 yyval.BitList->push_back(i);
1446 #line 487 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1447 { yyval.BitList = yyvsp[0].BitList; std::reverse(yyvsp[0].BitList->begin(), yyvsp[0].BitList->end()); ;
1450 #line 489 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1451 { yyval.BitList = 0; ;
1454 #line 489 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1455 { yyval.BitList = yyvsp[-1].BitList; ;
1458 #line 493 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1460 yyval.FieldList = new std::vector<Init*>();
1464 #line 495 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1466 yyval.FieldList = yyvsp[0].FieldList;
1470 #line 499 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1472 yyval.FieldList = new std::vector<Init*>();
1473 yyval.FieldList->push_back(yyvsp[0].Initializer);
1477 #line 502 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1479 (yyval.FieldList = yyvsp[-2].FieldList)->push_back(yyvsp[0].Initializer);
1483 #line 506 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1485 std::string DecName = *yyvsp[-1].StrVal;
1486 if (ParsingTemplateArgs) {
1488 DecName = CurRec->getName() + ":" + DecName;
1490 assert(CurMultiClass);
1493 DecName = CurMultiClass->Rec.getName() + "::" + DecName;
1496 addValue(RecordVal(DecName, yyvsp[-2].Ty, yyvsp[-3].IntVal));
1497 setValue(DecName, 0, yyvsp[0].Initializer);
1498 yyval.StrVal = new std::string(DecName);
1502 #line 523 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1504 delete yyvsp[-1].StrVal;
1508 #line 525 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1510 setValue(*yyvsp[-4].StrVal, yyvsp[-3].BitList, yyvsp[-1].Initializer);
1511 delete yyvsp[-4].StrVal;
1512 delete yyvsp[-3].BitList;
1516 #line 534 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1518 yyval.SubClassRef = new SubClassRefTy(yyvsp[0].Rec, new std::vector<Init*>());
1522 #line 536 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1524 yyval.SubClassRef = new SubClassRefTy(yyvsp[-3].Rec, yyvsp[-1].FieldList);
1528 #line 540 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1530 yyval.SubClassList = new std::vector<SubClassRefTy>();
1531 yyval.SubClassList->push_back(*yyvsp[0].SubClassRef);
1532 delete yyvsp[0].SubClassRef;
1536 #line 545 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1538 (yyval.SubClassList=yyvsp[-2].SubClassList)->push_back(*yyvsp[0].SubClassRef);
1539 delete yyvsp[0].SubClassRef;
1543 #line 550 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1545 yyval.SubClassList = new std::vector<SubClassRefTy>();
1549 #line 553 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1551 yyval.SubClassList = yyvsp[0].SubClassList;
1555 #line 557 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1557 getActiveRec()->addTemplateArg(*yyvsp[0].StrVal);
1558 delete yyvsp[0].StrVal;
1562 #line 560 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1564 getActiveRec()->addTemplateArg(*yyvsp[0].StrVal);
1565 delete yyvsp[0].StrVal;
1569 #line 565 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1573 #line 568 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1574 { yyval.StrVal = yyvsp[0].StrVal; ;
1577 #line 568 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1578 { yyval.StrVal = new std::string(); ;
1581 #line 570 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1583 static unsigned AnonCounter = 0;
1584 if (yyvsp[0].StrVal->empty())
1585 *yyvsp[0].StrVal = "anonymous."+utostr(AnonCounter++);
1586 yyval.StrVal = yyvsp[0].StrVal;
1590 #line 577 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1592 // If a class of this name already exists, it must be a forward ref.
1593 if ((CurRec = Records.getClass(*yyvsp[0].StrVal))) {
1594 // If the body was previously defined, this is an error.
1595 if (!CurRec->getValues().empty() ||
1596 !CurRec->getSuperClasses().empty() ||
1597 !CurRec->getTemplateArgs().empty()) {
1598 err() << "Class '" << CurRec->getName() << "' already defined!\n";
1602 // If this is the first reference to this class, create and add it.
1603 CurRec = new Record(*yyvsp[0].StrVal);
1604 Records.addClass(CurRec);
1606 delete yyvsp[0].StrVal;
1610 #line 595 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1612 CurRec = new Record(*yyvsp[0].StrVal);
1613 delete yyvsp[0].StrVal;
1615 if (!CurMultiClass) {
1616 // Top-level def definition.
1618 // Ensure redefinition doesn't happen.
1619 if (Records.getDef(CurRec->getName())) {
1620 err() << "def '" << CurRec->getName() << "' already defined!\n";
1623 Records.addDef(CurRec);
1625 // Otherwise, a def inside a multiclass, add it to the multiclass.
1626 for (unsigned i = 0, e = CurMultiClass->DefPrototypes.size(); i != e; ++i)
1627 if (CurMultiClass->DefPrototypes[i]->getName() == CurRec->getName()) {
1628 err() << "def '" << CurRec->getName()
1629 << "' already defined in this multiclass!\n";
1632 CurMultiClass->DefPrototypes.push_back(CurRec);
1637 #line 620 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1639 for (unsigned i = 0, e = yyvsp[0].SubClassList->size(); i != e; ++i) {
1640 addSubClass((*yyvsp[0].SubClassList)[i].first, *(*yyvsp[0].SubClassList)[i].second);
1641 // Delete the template arg values for the class
1642 delete (*yyvsp[0].SubClassList)[i].second;
1644 delete yyvsp[0].SubClassList; // Delete the class list...
1646 // Process any variables on the set stack...
1647 for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
1648 for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
1649 setValue(LetStack[i][j].Name,
1650 LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0,
1651 LetStack[i][j].Value);
1655 #line 634 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1662 #line 639 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1664 ParsingTemplateArgs = true;
1668 #line 641 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1670 ParsingTemplateArgs = false;
1674 #line 643 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1676 yyval.Rec = yyvsp[0].Rec;
1680 #line 647 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1682 if (CurMultiClass == 0) // Def's in multiclasses aren't really defs.
1683 yyvsp[0].Rec->resolveReferences();
1685 // If ObjectBody has template arguments, it's an error.
1686 assert(yyvsp[0].Rec->getTemplateArgs().empty() && "How'd this get template args?");
1687 yyval.Rec = yyvsp[0].Rec;
1691 #line 657 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1693 yyval.Rec = yyvsp[0].Rec;
1694 // Copy the template arguments for the multiclass into the def.
1695 const std::vector<std::string> &TArgs = CurMultiClass->Rec.getTemplateArgs();
1697 for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
1698 const RecordVal *RV = CurMultiClass->Rec.getValue(TArgs[i]);
1699 assert(RV && "Template arg doesn't exist?");
1700 yyval.Rec->addValue(*RV);
1705 #line 671 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1707 yyval.RecList = new std::vector<Record*>();
1708 yyval.RecList->push_back(yyvsp[0].Rec);
1712 #line 674 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1714 yyval.RecList->push_back(yyvsp[0].Rec);
1718 #line 678 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1720 MultiClass *&MCE = MultiClasses[*yyvsp[0].StrVal];
1722 err() << "multiclass '" << *yyvsp[0].StrVal << "' already defined!\n";
1725 MCE = CurMultiClass = new MultiClass(*yyvsp[0].StrVal);
1726 delete yyvsp[0].StrVal;
1730 #line 689 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1732 ParsingTemplateArgs = true;
1736 #line 691 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1738 ParsingTemplateArgs = false;
1742 #line 693 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1748 #line 698 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1749 { CurDefmPrefix = yyvsp[0].StrVal; ;
1752 #line 698 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1754 // To instantiate a multiclass, we need to first get the multiclass, then
1755 // instantiate each def contained in the multiclass with the SubClassRef
1756 // template parameters.
1757 MultiClass *MC = MultiClasses[yyvsp[-1].SubClassRef->first->getName()];
1758 assert(MC && "Didn't lookup multiclass correctly?");
1759 std::vector<Init*> &TemplateVals = *yyvsp[-1].SubClassRef->second;
1760 delete yyvsp[-1].SubClassRef;
1762 // Verify that the correct number of template arguments were specified.
1763 const std::vector<std::string> &TArgs = MC->Rec.getTemplateArgs();
1764 if (TArgs.size() < TemplateVals.size()) {
1765 err() << "ERROR: More template args specified than multiclass expects!\n";
1769 // Loop over all the def's in the multiclass, instantiating each one.
1770 for (unsigned i = 0, e = MC->DefPrototypes.size(); i != e; ++i) {
1771 Record *DefProto = MC->DefPrototypes[i];
1773 // Add the suffix to the defm name to get the new name.
1774 assert(CurRec == 0 && "A def is current?");
1775 CurRec = new Record(*yyvsp[-4].StrVal + DefProto->getName());
1777 addSubClass(DefProto, std::vector<Init*>());
1779 // Loop over all of the template arguments, setting them to the specified
1780 // value or leaving them as the default if necessary.
1781 for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
1782 if (i < TemplateVals.size()) { // A value is specified for this temp-arg?
1784 setValue(TArgs[i], 0, TemplateVals[i]);
1787 CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i]));
1790 CurRec->removeValue(TArgs[i]);
1792 } else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) {
1793 err() << "ERROR: Value not specified for template argument #"
1794 << i << " (" << TArgs[i] << ") of multiclassclass '"
1795 << MC->Rec.getName() << "'!\n";
1800 // Ensure redefinition doesn't happen.
1801 if (Records.getDef(CurRec->getName())) {
1802 err() << "def '" << CurRec->getName() << "' already defined, "
1803 << "instantiating defm '" << *yyvsp[-4].StrVal << "' with subdef '"
1804 << DefProto->getName() << "'!\n";
1807 Records.addDef(CurRec);
1809 CurRec->resolveReferences();
1814 delete &TemplateVals;
1815 delete yyvsp[-4].StrVal;
1819 #line 763 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1823 #line 763 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1827 #line 766 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1829 LetStack.back().push_back(LetRecord(*yyvsp[-3].StrVal, yyvsp[-2].BitList, yyvsp[0].Initializer));
1830 delete yyvsp[-3].StrVal; delete yyvsp[-2].BitList;
1834 #line 774 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1835 { LetStack.push_back(std::vector<LetRecord>()); ;
1838 #line 777 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1840 LetStack.pop_back();
1844 #line 780 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1846 LetStack.pop_back();
1850 #line 784 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1854 #line 784 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1858 /* the action file gets copied in in place of this dollarsign */
1859 #line 543 "/usr/share/bison.simple"
1870 short *ssp1 = yyss - 1;
1871 fprintf (stderr, "state stack now");
1872 while (ssp1 != yyssp)
1873 fprintf (stderr, " %d", *++ssp1);
1874 fprintf (stderr, "\n");
1884 yylsp->first_line = yylloc.first_line;
1885 yylsp->first_column = yylloc.first_column;
1886 yylsp->last_line = (yylsp-1)->last_line;
1887 yylsp->last_column = (yylsp-1)->last_column;
1892 yylsp->last_line = (yylsp+yylen-1)->last_line;
1893 yylsp->last_column = (yylsp+yylen-1)->last_column;
1897 /* Now "shift" the result of the reduction.
1898 Determine what state that goes to,
1899 based on the state we popped back to
1900 and the rule number reduced by. */
1904 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1905 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1906 yystate = yytable[yystate];
1908 yystate = yydefgoto[yyn - YYNTBASE];
1912 yyerrlab: /* here on detecting error */
1915 /* If not already recovering from an error, report this error. */
1919 #ifdef YYERROR_VERBOSE
1920 yyn = yypact[yystate];
1922 if (yyn > YYFLAG && yyn < YYLAST)
1929 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1930 for (x = (yyn < 0 ? -yyn : 0);
1931 x < (sizeof(yytname) / sizeof(char *)); x++)
1932 if (yycheck[x + yyn] == x)
1933 size += strlen(yytname[x]) + 15, count++;
1934 msg = (char *) malloc(size + 15);
1937 strcpy(msg, "parse error");
1942 for (x = (yyn < 0 ? -yyn : 0);
1943 x < (sizeof(yytname) / sizeof(char *)); x++)
1944 if (yycheck[x + yyn] == x)
1946 strcat(msg, count == 0 ? ", expecting `" : " or `");
1947 strcat(msg, yytname[x]);
1956 yyerror ("parse error; also virtual memory exceeded");
1959 #endif /* YYERROR_VERBOSE */
1960 yyerror("parse error");
1964 yyerrlab1: /* here on error raised explicitly by an action */
1966 if (yyerrstatus == 3)
1968 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1970 /* return failure if at end of input */
1971 if (yychar == YYEOF)
1976 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1982 /* Else will try to reuse lookahead token
1983 after shifting the error token. */
1985 yyerrstatus = 3; /* Each real token shifted decrements this */
1989 yyerrdefault: /* current state does not do anything special for the error token. */
1992 /* This is wrong; only states that explicitly want error tokens
1993 should shift them. */
1994 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1995 if (yyn) goto yydefault;
1998 yyerrpop: /* pop the current state because it cannot handle the error token */
2000 if (yyssp == yyss) YYABORT;
2010 short *ssp1 = yyss - 1;
2011 fprintf (stderr, "Error: state stack now");
2012 while (ssp1 != yyssp)
2013 fprintf (stderr, " %d", *++ssp1);
2014 fprintf (stderr, "\n");
2020 yyn = yypact[yystate];
2025 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
2044 fprintf(stderr, "Shifting error token, ");
2056 /* YYACCEPT comes here. */
2068 /* YYABORT comes here. */
2079 #line 788 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
2082 int yyerror(const char *ErrorMsg) {
2083 err() << "Error parsing: " << ErrorMsg << "\n";