2 /* A Bison parser, made from /Users/sabre/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
33 #define CODEFRAGMENT 276
35 #line 14 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
38 #include "llvm/ADT/StringExtras.h"
41 #define YYERROR_VERBOSE 1
43 int yyerror(const char *ErrorMsg);
48 extern int Filelineno;
49 static Record *CurRec = 0;
50 static bool ParsingTemplateArgs = false;
52 typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
56 std::vector<unsigned> Bits;
59 LetRecord(const std::string &N, std::vector<unsigned> *B, Init *V)
60 : Name(N), Value(V), HasBits(B != 0) {
61 if (HasBits) Bits = *B;
65 static std::vector<std::vector<LetRecord> > LetStack;
68 extern std::ostream &err();
70 static void addValue(const RecordVal &RV) {
71 if (RecordVal *ERV = CurRec->getValue(RV.getName())) {
72 // The value already exists in the class, treat this as a set...
73 if (ERV->setValue(RV.getValue())) {
74 err() << "New definition of '" << RV.getName() << "' of type '"
75 << *RV.getType() << "' is incompatible with previous "
76 << "definition of type '" << *ERV->getType() << "'!\n";
84 static void addSuperClass(Record *SC) {
85 if (CurRec->isSubClassOf(SC)) {
86 err() << "Already subclass of '" << SC->getName() << "'!\n";
89 CurRec->addSuperClass(SC);
92 static void setValue(const std::string &ValName,
93 std::vector<unsigned> *BitList, Init *V) {
96 RecordVal *RV = CurRec->getValue(ValName);
98 err() << "Value '" << ValName << "' unknown!\n";
102 // Do not allow assignments like 'X = X'. This will just cause infinite loops
103 // in the resolution machinery.
105 if (VarInit *VI = dynamic_cast<VarInit*>(V))
106 if (VI->getName() == ValName)
109 // If we are assigning to a subset of the bits in the value... then we must be
110 // assigning to a field of BitsRecTy, which must have a BitsInit
114 BitsInit *CurVal = dynamic_cast<BitsInit*>(RV->getValue());
116 err() << "Value '" << ValName << "' is not a bits type!\n";
120 // Convert the incoming value to a bits type of the appropriate size...
121 Init *BI = V->convertInitializerTo(new BitsRecTy(BitList->size()));
123 V->convertInitializerTo(new BitsRecTy(BitList->size()));
124 err() << "Initializer '" << *V << "' not compatible with bit range!\n";
128 // We should have a BitsInit type now...
129 assert(dynamic_cast<BitsInit*>(BI) != 0 || &(std::cerr << *BI) == 0);
130 BitsInit *BInit = (BitsInit*)BI;
132 BitsInit *NewVal = new BitsInit(CurVal->getNumBits());
134 // Loop over bits, assigning values as appropriate...
135 for (unsigned i = 0, e = BitList->size(); i != e; ++i) {
136 unsigned Bit = (*BitList)[i];
137 if (NewVal->getBit(Bit)) {
138 err() << "Cannot set bit #" << Bit << " of value '" << ValName
139 << "' more than once!\n";
142 NewVal->setBit(Bit, BInit->getBit(i));
145 for (unsigned i = 0, e = CurVal->getNumBits(); i != e; ++i)
146 if (NewVal->getBit(i) == 0)
147 NewVal->setBit(i, CurVal->getBit(i));
152 if (RV->setValue(V)) {
153 err() << "Value '" << ValName << "' of type '" << *RV->getType()
154 << "' is incompatible with initializer '" << *V << "'!\n";
159 // addSubClass - Add SC as a subclass to CurRec, resolving TemplateArgs as SC's
160 // template arguments.
161 static void addSubClass(Record *SC, const std::vector<Init*> &TemplateArgs) {
162 // Add all of the values in the subclass into the current class...
163 const std::vector<RecordVal> &Vals = SC->getValues();
164 for (unsigned i = 0, e = Vals.size(); i != e; ++i)
167 const std::vector<std::string> &TArgs = SC->getTemplateArgs();
169 // Ensure that an appropriate number of template arguments are specified...
170 if (TArgs.size() < TemplateArgs.size()) {
171 err() << "ERROR: More template args specified than expected!\n";
173 } else { // This class expects template arguments...
174 // Loop over all of the template arguments, setting them to the specified
175 // value or leaving them as the default if necessary.
176 for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
177 if (i < TemplateArgs.size()) { // A value is specified for this temp-arg?
179 setValue(TArgs[i], 0, TemplateArgs[i]);
182 CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i]));
186 CurRec->removeValue(TArgs[i]);
188 } else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) {
189 err() << "ERROR: Value not specified for template argument #"
190 << i << " (" << TArgs[i] << ") of subclass '" << SC->getName()
197 // Since everything went well, we can now set the "superclass" list for the
199 const std::vector<Record*> &SCs = SC->getSuperClasses();
200 for (unsigned i = 0, e = SCs.size(); i != e; ++i)
201 addSuperClass(SCs[i]);
205 } // End llvm namespace
207 using namespace llvm;
210 #line 189 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
215 llvm::Init* Initializer;
216 std::vector<llvm::Init*>* FieldList;
217 std::vector<unsigned>* BitList;
219 SubClassRefTy* SubClassRef;
220 std::vector<SubClassRefTy>* SubClassList;
221 std::vector<std::pair<llvm::Init*, std::string> >* DagValueList;
234 #define YYFLAG -32768
237 #define YYTRANSLATE(x) ((unsigned)(x) <= 276 ? yytranslate[x] : 78)
239 static const char yytranslate[] = { 0,
240 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
241 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
242 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
243 2, 2, 2, 2, 2, 2, 2, 2, 2, 32,
244 33, 2, 2, 34, 36, 31, 2, 2, 2, 2,
245 2, 2, 2, 2, 2, 2, 2, 35, 37, 23,
246 25, 24, 26, 2, 2, 2, 2, 2, 2, 2,
247 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
248 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
249 29, 2, 30, 2, 2, 2, 2, 2, 2, 2,
250 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
251 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
252 2, 2, 27, 2, 28, 2, 2, 2, 2, 2,
253 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
254 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
255 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
256 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
257 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
258 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
259 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
260 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
261 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
262 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
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, 1, 3, 4, 5, 6,
266 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
267 17, 18, 19, 20, 21, 22
271 static const short yyprhs[] = { 0,
272 0, 2, 4, 6, 11, 13, 18, 20, 22, 24,
273 25, 27, 28, 31, 33, 35, 37, 39, 43, 48,
274 50, 55, 59, 63, 68, 73, 80, 87, 94, 95,
275 98, 101, 106, 107, 109, 111, 115, 118, 122, 128,
276 133, 135, 136, 140, 141, 143, 145, 149, 154, 157,
277 164, 165, 168, 170, 174, 176, 181, 183, 187, 188,
278 191, 193, 197, 201, 202, 204, 206, 207, 209, 211,
279 213, 214, 218, 219, 220, 227, 231, 233, 235, 240,
280 242, 246, 247, 252, 257, 260, 262, 265
283 static const short yyrhs[] = { 19,
284 0, 5, 0, 4, 0, 6, 23, 18, 24, 0,
285 3, 0, 7, 23, 39, 24, 0, 8, 0, 9,
286 0, 38, 0, 0, 12, 0, 0, 25, 42, 0,
287 18, 0, 21, 0, 22, 0, 26, 0, 27, 49,
288 28, 0, 19, 23, 50, 24, 0, 19, 0, 42,
289 27, 47, 28, 0, 29, 49, 30, 0, 42, 31,
290 19, 0, 32, 19, 45, 33, 0, 42, 29, 47,
291 30, 0, 15, 32, 42, 34, 42, 33, 0, 16,
292 32, 42, 34, 42, 33, 0, 17, 32, 42, 34,
293 42, 33, 0, 0, 35, 20, 0, 42, 43, 0,
294 44, 34, 42, 43, 0, 0, 44, 0, 18, 0,
295 18, 36, 18, 0, 18, 18, 0, 46, 34, 18,
296 0, 46, 34, 18, 36, 18, 0, 46, 34, 18,
297 18, 0, 46, 0, 0, 27, 47, 28, 0, 0,
298 50, 0, 42, 0, 50, 34, 42, 0, 40, 39,
299 19, 41, 0, 51, 37, 0, 13, 19, 48, 25,
300 42, 37, 0, 0, 53, 52, 0, 37, 0, 27,
301 53, 28, 0, 38, 0, 38, 23, 50, 24, 0,
302 55, 0, 56, 34, 55, 0, 0, 35, 56, 0,
303 51, 0, 58, 34, 51, 0, 23, 58, 24, 0,
304 0, 59, 0, 19, 0, 0, 61, 0, 62, 0,
305 62, 0, 0, 57, 66, 54, 0, 0, 0, 10,
306 63, 68, 60, 69, 65, 0, 11, 64, 65, 0,
307 67, 0, 70, 0, 19, 48, 25, 42, 0, 72,
308 0, 73, 34, 72, 0, 0, 13, 75, 73, 14,
309 0, 74, 27, 76, 28, 0, 74, 71, 0, 71,
316 static const short yyrline[] = { 0,
317 223, 234, 236, 238, 240, 242, 244, 246, 248, 252,
318 252, 254, 254, 256, 258, 261, 264, 266, 279, 307,
319 322, 329, 332, 339, 347, 355, 361, 367, 375, 378,
320 382, 387, 393, 396, 399, 402, 415, 429, 431, 444,
321 460, 462, 462, 466, 468, 472, 475, 479, 489, 491,
322 497, 497, 498, 498, 500, 502, 506, 511, 516, 519,
323 523, 526, 531, 532, 532, 534, 534, 536, 543, 561,
324 573, 587, 592, 594, 596, 600, 609, 609, 611, 616,
325 616, 619, 619, 622, 625, 629, 629, 631
330 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
332 static const char * const yytname[] = { "$","error","$undefined.","INT","BIT",
333 "STRING","BITS","LIST","CODE","DAG","CLASS","DEF","FIELD","LET","IN","SHLTOK",
334 "SRATOK","SRLTOK","INTVAL","ID","VARNAME","STRVAL","CODEFRAGMENT","'<'","'>'",
335 "'='","'?'","'{'","'}'","'['","']'","'.'","'('","')'","','","':'","'-'","';'",
336 "ClassID","Type","OptPrefix","OptValue","Value","OptVarName","DagArgListNE",
337 "DagArgList","RBitList","BitList","OptBitList","ValueList","ValueListNE","Declaration",
338 "BodyItem","BodyList","Body","SubClassRef","ClassListNE","ClassList","DeclListNE",
339 "TemplateArgList","OptTemplateArgList","OptID","ObjectName","ClassName","DefName",
340 "ObjectBody","@1","ClassInst","@2","@3","DefInst","Object","LETItem","LETList",
341 "LETCommand","@4","ObjectList","File", NULL
345 static const short yyr1[] = { 0,
346 38, 39, 39, 39, 39, 39, 39, 39, 39, 40,
347 40, 41, 41, 42, 42, 42, 42, 42, 42, 42,
348 42, 42, 42, 42, 42, 42, 42, 42, 43, 43,
349 44, 44, 45, 45, 46, 46, 46, 46, 46, 46,
350 47, 48, 48, 49, 49, 50, 50, 51, 52, 52,
351 53, 53, 54, 54, 55, 55, 56, 56, 57, 57,
352 58, 58, 59, 60, 60, 61, 61, 62, 63, 64,
353 66, 65, 68, 69, 67, 70, 71, 71, 72, 73,
354 73, 75, 74, 71, 71, 76, 76, 77
357 static const short yyr2[] = { 0,
358 1, 1, 1, 4, 1, 4, 1, 1, 1, 0,
359 1, 0, 2, 1, 1, 1, 1, 3, 4, 1,
360 4, 3, 3, 4, 4, 6, 6, 6, 0, 2,
361 2, 4, 0, 1, 1, 3, 2, 3, 5, 4,
362 1, 0, 3, 0, 1, 1, 3, 4, 2, 6,
363 0, 2, 1, 3, 1, 4, 1, 3, 0, 2,
364 1, 3, 3, 0, 1, 1, 0, 1, 1, 1,
365 0, 3, 0, 0, 6, 3, 1, 1, 4, 1,
366 3, 0, 4, 4, 2, 1, 2, 1
369 static const short yydefact[] = { 0,
370 67, 67, 82, 77, 78, 86, 0, 88, 66, 68,
371 69, 73, 70, 59, 0, 0, 85, 87, 64, 0,
372 71, 76, 42, 80, 0, 0, 10, 65, 74, 1,
373 55, 57, 60, 0, 0, 0, 83, 0, 84, 11,
374 0, 61, 0, 59, 0, 0, 51, 53, 72, 35,
375 41, 0, 0, 81, 5, 3, 2, 0, 0, 7,
376 8, 9, 0, 63, 10, 75, 0, 0, 0, 14,
377 20, 15, 16, 17, 44, 44, 0, 46, 0, 58,
378 10, 37, 0, 0, 43, 79, 0, 0, 12, 62,
379 0, 0, 0, 0, 0, 45, 0, 33, 0, 0,
380 0, 56, 0, 0, 54, 0, 52, 36, 38, 0,
381 0, 0, 48, 0, 0, 0, 0, 18, 22, 29,
382 34, 0, 0, 0, 23, 47, 42, 49, 40, 0,
383 4, 6, 13, 0, 0, 0, 19, 0, 31, 0,
384 24, 21, 25, 0, 39, 0, 0, 0, 30, 29,
385 0, 26, 27, 28, 32, 0, 50, 0, 0, 0
388 static const short yydefgoto[] = { 31,
389 63, 41, 113, 78, 139, 121, 122, 51, 52, 36,
390 95, 96, 42, 107, 81, 49, 32, 33, 21, 43,
391 28, 29, 10, 11, 12, 14, 22, 34, 4, 19,
392 44, 5, 6, 24, 25, 7, 15, 8, 158
395 static const short yypact[] = { 56,
396 -4, -4,-32768,-32768,-32768,-32768, 1, 56,-32768,-32768,
397 -32768,-32768,-32768, 8, 2, 56,-32768,-32768, 23, 30,
398 -32768,-32768, 50,-32768, -11, -3, 66,-32768,-32768,-32768,
399 62,-32768, 55, 34, 61, 68,-32768, 2,-32768,-32768,
400 49,-32768, -8, 8, 15, 30,-32768,-32768,-32768, -14,
401 82, 67, 15,-32768,-32768,-32768,-32768, 95, 97,-32768,
402 -32768,-32768, 77,-32768, 66,-32768, 89, 90, 91,-32768,
403 101,-32768,-32768,-32768, 15, 15, 106, 73, 39,-32768,
404 7,-32768, 108, 109,-32768, 73, 110, 49, 104,-32768,
405 15, 15, 15, 15, 102, 98, 103, 15, 61, 61,
406 112,-32768, 15, 115,-32768, 99,-32768,-32768, -9, 111,
407 113, 15,-32768, 57, 63, 72, 41,-32768,-32768, 45,
408 105, 107, 114, 116,-32768, 73, 50,-32768,-32768, 120,
409 -32768,-32768, 73, 15, 15, 15,-32768, 121,-32768, 15,
410 -32768,-32768,-32768, 118,-32768, 78, 81, 86,-32768, 45,
411 15,-32768,-32768,-32768,-32768, 33,-32768, 144, 145,-32768
414 static const short yypgoto[] = { -40,
415 59,-32768,-32768, -53, -1,-32768,-32768,-32768, -82, 21,
416 74, -43, -52,-32768,-32768,-32768, 117,-32768,-32768,-32768,
417 -32768,-32768,-32768, 149,-32768,-32768, 122,-32768,-32768,-32768,
418 -32768,-32768, -2, 119,-32768,-32768,-32768, 136,-32768
425 static const short yytable[] = { 86,
426 62, 79, 37, 82, 17, 18, 1, 2, 129, 3,
427 1, 2, 90, 3, 9, 64, 123, 124, 40, 104,
428 23, 83, 38, 18, 39, 65, 130, 16, 106, 67,
429 68, 69, 70, 71, 105, 72, 73, 114, 115, 116,
430 74, 75, 20, 76, 120, 27, 77, 62, 30, 126,
431 117, 55, 56, 57, 58, 59, 60, 61, 133, 99,
432 47, 100, 102, 101, 137, 1, 2, 30, 3, 157,
433 48, 99, 103, 100, 103, 101, 35, 40, 50, 138,
434 146, 147, 148, 99, 45, 100, 150, 101, 46, 99,
435 134, 100, 53, 101, 85, 89, 135, 156, 99, 99,
436 100, 100, 101, 101, 99, 136, 100, 99, 101, 100,
437 152, 101, 99, 153, 100, 84, 101, 87, 154, 88,
438 91, 92, 93, 94, 98, 108, 109, 110, 112, 118,
439 125, 103, 119, 127, 131, 128, 132, 145, 140, 141,
440 149, 142, 151, 159, 160, 143, 111, 144, 155, 97,
441 13, 26, 0, 0, 0, 0, 54, 0, 0, 0,
445 static const short yycheck[] = { 53,
446 41, 45, 14, 18, 7, 8, 10, 11, 18, 13,
447 10, 11, 65, 13, 19, 24, 99, 100, 12, 13,
448 19, 36, 34, 26, 28, 34, 36, 27, 81, 15,
449 16, 17, 18, 19, 28, 21, 22, 91, 92, 93,
450 26, 27, 35, 29, 98, 23, 32, 88, 19, 103,
451 94, 3, 4, 5, 6, 7, 8, 9, 112, 27,
452 27, 29, 24, 31, 24, 10, 11, 19, 13, 37,
453 37, 27, 34, 29, 34, 31, 27, 12, 18, 35,
454 134, 135, 136, 27, 23, 29, 140, 31, 34, 27,
455 34, 29, 25, 31, 28, 19, 34, 151, 27, 27,
456 29, 29, 31, 31, 27, 34, 29, 27, 31, 29,
457 33, 31, 27, 33, 29, 34, 31, 23, 33, 23,
458 32, 32, 32, 23, 19, 18, 18, 18, 25, 28,
459 19, 34, 30, 19, 24, 37, 24, 18, 34, 33,
460 20, 28, 25, 0, 0, 30, 88, 127, 150, 76,
461 2, 16, -1, -1, -1, -1, 38, -1, -1, -1,
462 -1, -1, 46, -1, -1, 44
464 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
465 #line 3 "/usr/share/bison.simple"
466 /* This file comes from bison-1.28. */
468 /* Skeleton output parser for bison,
469 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
471 This program is free software; you can redistribute it and/or modify
472 it under the terms of the GNU General Public License as published by
473 the Free Software Foundation; either version 2, or (at your option)
476 This program is distributed in the hope that it will be useful,
477 but WITHOUT ANY WARRANTY; without even the implied warranty of
478 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
479 GNU General Public License for more details.
481 You should have received a copy of the GNU General Public License
482 along with this program; if not, write to the Free Software
483 Foundation, Inc., 59 Temple Place - Suite 330,
484 Boston, MA 02111-1307, USA. */
486 /* As a special exception, when this file is copied by Bison into a
487 Bison output file, you may use that output file without restriction.
488 This special exception was added by the Free Software Foundation
489 in version 1.24 of Bison. */
491 /* This is the parser code that is written into each bison parser
492 when the %semantic_parser declaration is not specified in the grammar.
493 It was written by Richard Stallman by simplifying the hairy parser
494 used when %semantic_parser is specified. */
496 #ifndef YYSTACK_USE_ALLOCA
498 #define YYSTACK_USE_ALLOCA
499 #else /* alloca not defined */
501 #define YYSTACK_USE_ALLOCA
502 #define alloca __builtin_alloca
503 #else /* not GNU C. */
504 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
505 #define YYSTACK_USE_ALLOCA
507 #else /* not sparc */
508 /* We think this test detects Watcom and Microsoft C. */
509 /* This used to test MSDOS, but that is a bad idea
510 since that symbol is in the user namespace. */
511 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
512 #if 0 /* No need for malloc.h, which pollutes the namespace;
513 instead, just don't use alloca. */
516 #else /* not MSDOS, or __TURBOC__ */
518 /* I don't know what this was needed for, but it pollutes the namespace.
519 So I turned it off. rms, 2 May 1997. */
520 /* #include <malloc.h> */
522 #define YYSTACK_USE_ALLOCA
523 #else /* not MSDOS, or __TURBOC__, or _AIX */
525 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
526 and on HPUX 10. Eventually we can turn this on. */
527 #define YYSTACK_USE_ALLOCA
528 #define alloca __builtin_alloca
531 #endif /* not _AIX */
532 #endif /* not MSDOS, or __TURBOC__ */
533 #endif /* not sparc */
534 #endif /* not GNU C */
535 #endif /* alloca not defined */
536 #endif /* YYSTACK_USE_ALLOCA not defined */
538 #ifdef YYSTACK_USE_ALLOCA
539 #define YYSTACK_ALLOC alloca
541 #define YYSTACK_ALLOC malloc
544 /* Note: there must be only one dollar sign in this file.
545 It is replaced by the list of actions, each action
546 as one case of the switch. */
548 #define yyerrok (yyerrstatus = 0)
549 #define yyclearin (yychar = YYEMPTY)
552 #define YYACCEPT goto yyacceptlab
553 #define YYABORT goto yyabortlab
554 #define YYERROR goto yyerrlab1
555 /* Like YYERROR except do call yyerror.
556 This remains here temporarily to ease the
557 transition to the new meaning of YYERROR, for GCC.
558 Once GCC version 2 has supplanted version 1, this can go. */
559 #define YYFAIL goto yyerrlab
560 #define YYRECOVERING() (!!yyerrstatus)
561 #define YYBACKUP(token, value) \
563 if (yychar == YYEMPTY && yylen == 1) \
564 { yychar = (token), yylval = (value); \
565 yychar1 = YYTRANSLATE (yychar); \
570 { yyerror ("syntax error: cannot back up"); YYERROR; } \
574 #define YYERRCODE 256
577 #define YYLEX yylex()
583 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
585 #define YYLEX yylex(&yylval, &yylloc)
587 #else /* not YYLSP_NEEDED */
589 #define YYLEX yylex(&yylval, YYLEX_PARAM)
591 #define YYLEX yylex(&yylval)
593 #endif /* not YYLSP_NEEDED */
596 /* If nonreentrant, generate the variables here */
600 int yychar; /* the lookahead symbol */
601 YYSTYPE yylval; /* the semantic value of the */
602 /* lookahead symbol */
605 YYLTYPE yylloc; /* location data for the lookahead */
609 int yynerrs; /* number of parse errors so far */
610 #endif /* not YYPURE */
613 int yydebug; /* nonzero means print parse trace */
614 /* Since this is uninitialized, it does not stop multiple parsers
618 /* YYINITDEPTH indicates the initial size of the parser's stacks */
621 #define YYINITDEPTH 200
624 /* YYMAXDEPTH is the maximum size the stacks can grow to
625 (effective only if the built-in stack extension method is used). */
632 #define YYMAXDEPTH 10000
635 /* Define __yy_memcpy. Note that the size argument
636 should be passed with type unsigned int, because that is what the non-GCC
637 definitions require. With GCC, __builtin_memcpy takes an arg
638 of type size_t, but it can handle unsigned int. */
640 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
641 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
642 #else /* not GNU C or C++ */
645 /* This is the most reliable way to avoid incompatibilities
646 in available built-in functions on various systems. */
648 __yy_memcpy (to, from, count)
653 register char *f = from;
654 register char *t = to;
655 register int i = count;
661 #else /* __cplusplus */
663 /* This is the most reliable way to avoid incompatibilities
664 in available built-in functions on various systems. */
666 __yy_memcpy (char *to, char *from, unsigned int count)
668 register char *t = to;
669 register char *f = from;
670 register int i = count;
679 #line 217 "/usr/share/bison.simple"
681 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
682 into yyparse. The argument should have type void *.
683 It should actually point to an object.
684 Grammar actions can access the variable by casting it
685 to the proper pointer type. */
689 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
690 #define YYPARSE_PARAM_DECL
691 #else /* not __cplusplus */
692 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
693 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
694 #endif /* not __cplusplus */
695 #else /* not YYPARSE_PARAM */
696 #define YYPARSE_PARAM_ARG
697 #define YYPARSE_PARAM_DECL
698 #endif /* not YYPARSE_PARAM */
700 /* Prevent warning if -Wstrict-prototypes. */
703 int yyparse (void *);
710 yyparse(YYPARSE_PARAM_ARG)
713 register int yystate;
715 register short *yyssp;
716 register YYSTYPE *yyvsp;
717 int yyerrstatus; /* number of tokens to shift before error messages enabled */
718 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
720 short yyssa[YYINITDEPTH]; /* the state stack */
721 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
723 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
724 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
727 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
728 YYLTYPE *yyls = yylsa;
731 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
733 #define YYPOPSTACK (yyvsp--, yyssp--)
736 int yystacksize = YYINITDEPTH;
737 int yyfree_stacks = 0;
748 YYSTYPE yyval; /* the variable used to return */
749 /* semantic values from the action */
756 fprintf(stderr, "Starting parse\n");
762 yychar = YYEMPTY; /* Cause a token to be read. */
764 /* Initialize stack pointers.
765 Waste one element of value and location stack
766 so that they stay on the same level as the state stack.
767 The wasted elements are never initialized. */
775 /* Push a new state, which is found in yystate . */
776 /* In all cases, when you get here, the value and location stacks
777 have just been pushed. so pushing a state here evens the stacks. */
782 if (yyssp >= yyss + yystacksize - 1)
784 /* Give user a chance to reallocate the stack */
785 /* Use copies of these so that the &'s don't force the real ones into memory. */
786 YYSTYPE *yyvs1 = yyvs;
789 YYLTYPE *yyls1 = yyls;
792 /* Get the current used size of the three stacks, in elements. */
793 int size = yyssp - yyss + 1;
796 /* Each stack pointer address is followed by the size of
797 the data in use in that stack, in bytes. */
799 /* This used to be a conditional around just the two extra args,
800 but that might be undefined if yyoverflow is a macro. */
801 yyoverflow("parser stack overflow",
802 &yyss1, size * sizeof (*yyssp),
803 &yyvs1, size * sizeof (*yyvsp),
804 &yyls1, size * sizeof (*yylsp),
807 yyoverflow("parser stack overflow",
808 &yyss1, size * sizeof (*yyssp),
809 &yyvs1, size * sizeof (*yyvsp),
813 yyss = yyss1; yyvs = yyvs1;
817 #else /* no yyoverflow */
818 /* Extend the stack our own way. */
819 if (yystacksize >= YYMAXDEPTH)
821 yyerror("parser stack overflow");
833 if (yystacksize > YYMAXDEPTH)
834 yystacksize = YYMAXDEPTH;
835 #ifndef YYSTACK_USE_ALLOCA
838 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
839 __yy_memcpy ((char *)yyss, (char *)yyss1,
840 size * (unsigned int) sizeof (*yyssp));
841 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
842 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
843 size * (unsigned int) sizeof (*yyvsp));
845 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
846 __yy_memcpy ((char *)yyls, (char *)yyls1,
847 size * (unsigned int) sizeof (*yylsp));
849 #endif /* no yyoverflow */
851 yyssp = yyss + size - 1;
852 yyvsp = yyvs + size - 1;
854 yylsp = yyls + size - 1;
859 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
862 if (yyssp >= yyss + yystacksize - 1)
868 fprintf(stderr, "Entering state %d\n", yystate);
874 /* Do appropriate processing given the current state. */
875 /* Read a lookahead token if we need one and don't already have one. */
878 /* First try to decide what to do without reference to lookahead token. */
880 yyn = yypact[yystate];
884 /* Not known => get a lookahead token if don't already have one. */
886 /* yychar is either YYEMPTY or YYEOF
887 or a valid token in external form. */
889 if (yychar == YYEMPTY)
893 fprintf(stderr, "Reading a token: ");
898 /* Convert token to internal form (in yychar1) for indexing tables with */
900 if (yychar <= 0) /* This means end of input. */
903 yychar = YYEOF; /* Don't call YYLEX any more */
907 fprintf(stderr, "Now at end of input.\n");
912 yychar1 = YYTRANSLATE(yychar);
917 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
918 /* Give the individual parser a way to print the precise meaning
919 of a token, for further debugging info. */
921 YYPRINT (stderr, yychar, yylval);
923 fprintf (stderr, ")\n");
929 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
934 /* yyn is what to do for this token type in this state.
935 Negative => reduce, -yyn is rule number.
936 Positive => shift, yyn is new state.
937 New state is final state => don't bother to shift,
939 0, or most negative number => error. */
954 /* Shift the lookahead token. */
958 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
961 /* Discard the token being shifted unless it is eof. */
970 /* count tokens shifted since error; after three, turn off error status. */
971 if (yyerrstatus) yyerrstatus--;
976 /* Do the default action for the current state. */
979 yyn = yydefact[yystate];
983 /* Do a reduction. yyn is the number of a rule to reduce with. */
987 yyval = yyvsp[1-yylen]; /* implement default value of the action */
994 fprintf (stderr, "Reducing via rule %d (line %d), ",
997 /* Print the symbols being reduced, and their result. */
998 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
999 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1000 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1008 #line 223 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1010 yyval.Rec = Records.getClass(*yyvsp[0].StrVal);
1011 if (yyval.Rec == 0) {
1012 err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n";
1015 delete yyvsp[0].StrVal;
1019 #line 234 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1021 yyval.Ty = new StringRecTy();
1025 #line 236 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1027 yyval.Ty = new BitRecTy();
1031 #line 238 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1033 yyval.Ty = new BitsRecTy(yyvsp[-1].IntVal);
1037 #line 240 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1039 yyval.Ty = new IntRecTy();
1043 #line 242 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1045 yyval.Ty = new ListRecTy(yyvsp[-1].Ty);
1049 #line 244 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1051 yyval.Ty = new CodeRecTy();
1055 #line 246 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1057 yyval.Ty = new DagRecTy();
1061 #line 248 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1063 yyval.Ty = new RecordRecTy(yyvsp[0].Rec);
1067 #line 252 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1068 { yyval.IntVal = 0; ;
1071 #line 252 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1072 { yyval.IntVal = 1; ;
1075 #line 254 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1076 { yyval.Initializer = 0; ;
1079 #line 254 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1080 { yyval.Initializer = yyvsp[0].Initializer; ;
1083 #line 256 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1085 yyval.Initializer = new IntInit(yyvsp[0].IntVal);
1089 #line 258 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1091 yyval.Initializer = new StringInit(*yyvsp[0].StrVal);
1092 delete yyvsp[0].StrVal;
1096 #line 261 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1098 yyval.Initializer = new CodeInit(*yyvsp[0].StrVal);
1099 delete yyvsp[0].StrVal;
1103 #line 264 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1105 yyval.Initializer = new UnsetInit();
1109 #line 266 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1111 BitsInit *Init = new BitsInit(yyvsp[-1].FieldList->size());
1112 for (unsigned i = 0, e = yyvsp[-1].FieldList->size(); i != e; ++i) {
1113 struct Init *Bit = (*yyvsp[-1].FieldList)[i]->convertInitializerTo(new BitRecTy());
1115 err() << "Element #" << i << " (" << *(*yyvsp[-1].FieldList)[i]
1116 << ") is not convertable to a bit!\n";
1119 Init->setBit(yyvsp[-1].FieldList->size()-i-1, Bit);
1121 yyval.Initializer = Init;
1122 delete yyvsp[-1].FieldList;
1126 #line 279 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1128 // This is a CLASS<initvalslist> expression. This is supposed to synthesize
1129 // a new anonymous definition, deriving from CLASS<initvalslist> with no
1131 Record *Class = Records.getClass(*yyvsp[-3].StrVal);
1133 err() << "Expected a class, got '" << *yyvsp[-3].StrVal << "'!\n";
1136 delete yyvsp[-3].StrVal;
1138 static unsigned AnonCounter = 0;
1139 Record *OldRec = CurRec; // Save CurRec.
1141 // Create the new record, set it as CurRec temporarily.
1142 CurRec = new Record("anonymous.val."+utostr(AnonCounter++));
1143 addSubClass(Class, *yyvsp[-1].FieldList); // Add info about the subclass to CurRec.
1144 delete yyvsp[-1].FieldList; // Free up the template args.
1146 CurRec->resolveReferences();
1148 Records.addDef(CurRec);
1150 // The result of the expression is a reference to the new record.
1151 yyval.Initializer = new DefInit(CurRec);
1153 // Restore the old CurRec
1158 #line 307 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1160 if (const RecordVal *RV = (CurRec ? CurRec->getValue(*yyvsp[0].StrVal) : 0)) {
1161 yyval.Initializer = new VarInit(*yyvsp[0].StrVal, RV->getType());
1162 } else if (CurRec && CurRec->isTemplateArg(CurRec->getName()+":"+*yyvsp[0].StrVal)) {
1163 const RecordVal *RV = CurRec->getValue(CurRec->getName()+":"+*yyvsp[0].StrVal);
1164 assert(RV && "Template arg doesn't exist??");
1165 yyval.Initializer = new VarInit(CurRec->getName()+":"+*yyvsp[0].StrVal, RV->getType());
1166 } else if (Record *D = Records.getDef(*yyvsp[0].StrVal)) {
1167 yyval.Initializer = new DefInit(D);
1169 err() << "Variable not defined: '" << *yyvsp[0].StrVal << "'!\n";
1173 delete yyvsp[0].StrVal;
1177 #line 322 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1179 yyval.Initializer = yyvsp[-3].Initializer->convertInitializerBitRange(*yyvsp[-1].BitList);
1180 if (yyval.Initializer == 0) {
1181 err() << "Invalid bit range for value '" << *yyvsp[-3].Initializer << "'!\n";
1184 delete yyvsp[-1].BitList;
1188 #line 329 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1190 yyval.Initializer = new ListInit(*yyvsp[-1].FieldList);
1191 delete yyvsp[-1].FieldList;
1195 #line 332 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1197 if (!yyvsp[-2].Initializer->getFieldType(*yyvsp[0].StrVal)) {
1198 err() << "Cannot access field '" << *yyvsp[0].StrVal << "' of value '" << *yyvsp[-2].Initializer << "!\n";
1201 yyval.Initializer = new FieldInit(yyvsp[-2].Initializer, *yyvsp[0].StrVal);
1202 delete yyvsp[0].StrVal;
1206 #line 339 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1208 Record *D = Records.getDef(*yyvsp[-2].StrVal);
1210 err() << "Invalid def '" << *yyvsp[-2].StrVal << "'!\n";
1213 yyval.Initializer = new DagInit(D, *yyvsp[-1].DagValueList);
1214 delete yyvsp[-2].StrVal; delete yyvsp[-1].DagValueList;
1218 #line 347 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1220 std::reverse(yyvsp[-1].BitList->begin(), yyvsp[-1].BitList->end());
1221 yyval.Initializer = yyvsp[-3].Initializer->convertInitListSlice(*yyvsp[-1].BitList);
1222 if (yyval.Initializer == 0) {
1223 err() << "Invalid list slice for value '" << *yyvsp[-3].Initializer << "'!\n";
1226 delete yyvsp[-1].BitList;
1230 #line 355 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1232 yyval.Initializer = yyvsp[-3].Initializer->getBinaryOp(Init::SHL, yyvsp[-1].Initializer);
1233 if (yyval.Initializer == 0) {
1234 err() << "Cannot shift values '" << *yyvsp[-3].Initializer << "' and '" << *yyvsp[-1].Initializer << "'!\n";
1240 #line 361 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1242 yyval.Initializer = yyvsp[-3].Initializer->getBinaryOp(Init::SRA, yyvsp[-1].Initializer);
1243 if (yyval.Initializer == 0) {
1244 err() << "Cannot shift values '" << *yyvsp[-3].Initializer << "' and '" << *yyvsp[-1].Initializer << "'!\n";
1250 #line 367 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1252 yyval.Initializer = yyvsp[-3].Initializer->getBinaryOp(Init::SRL, yyvsp[-1].Initializer);
1253 if (yyval.Initializer == 0) {
1254 err() << "Cannot shift values '" << *yyvsp[-3].Initializer << "' and '" << *yyvsp[-1].Initializer << "'!\n";
1260 #line 375 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1262 yyval.StrVal = new std::string();
1266 #line 378 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1268 yyval.StrVal = yyvsp[0].StrVal;
1272 #line 382 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1274 yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
1275 yyval.DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal));
1276 delete yyvsp[0].StrVal;
1280 #line 387 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1282 yyvsp[-3].DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal));
1283 delete yyvsp[0].StrVal;
1284 yyval.DagValueList = yyvsp[-3].DagValueList;
1288 #line 393 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1290 yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
1294 #line 396 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1295 { yyval.DagValueList = yyvsp[0].DagValueList; ;
1298 #line 399 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1300 yyval.BitList = new std::vector<unsigned>();
1301 yyval.BitList->push_back(yyvsp[0].IntVal);
1305 #line 402 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1307 if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1308 err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1311 yyval.BitList = new std::vector<unsigned>();
1312 if (yyvsp[-2].IntVal < yyvsp[0].IntVal) {
1313 for (int i = yyvsp[-2].IntVal; i <= yyvsp[0].IntVal; ++i)
1314 yyval.BitList->push_back(i);
1316 for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1317 yyval.BitList->push_back(i);
1322 #line 415 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1324 yyvsp[0].IntVal = -yyvsp[0].IntVal;
1325 if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) {
1326 err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1329 yyval.BitList = new std::vector<unsigned>();
1330 if (yyvsp[-1].IntVal < yyvsp[0].IntVal) {
1331 for (int i = yyvsp[-1].IntVal; i <= yyvsp[0].IntVal; ++i)
1332 yyval.BitList->push_back(i);
1334 for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1335 yyval.BitList->push_back(i);
1340 #line 429 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1342 (yyval.BitList=yyvsp[-2].BitList)->push_back(yyvsp[0].IntVal);
1346 #line 431 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1348 if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1349 err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1352 yyval.BitList = yyvsp[-4].BitList;
1353 if (yyvsp[-2].IntVal < yyvsp[0].IntVal) {
1354 for (int i = yyvsp[-2].IntVal; i <= yyvsp[0].IntVal; ++i)
1355 yyval.BitList->push_back(i);
1357 for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1358 yyval.BitList->push_back(i);
1363 #line 444 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1365 yyvsp[0].IntVal = -yyvsp[0].IntVal;
1366 if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) {
1367 err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1370 yyval.BitList = yyvsp[-3].BitList;
1371 if (yyvsp[-1].IntVal < yyvsp[0].IntVal) {
1372 for (int i = yyvsp[-1].IntVal; i <= yyvsp[0].IntVal; ++i)
1373 yyval.BitList->push_back(i);
1375 for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1376 yyval.BitList->push_back(i);
1381 #line 460 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1382 { yyval.BitList = yyvsp[0].BitList; std::reverse(yyvsp[0].BitList->begin(), yyvsp[0].BitList->end()); ;
1385 #line 462 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1386 { yyval.BitList = 0; ;
1389 #line 462 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1390 { yyval.BitList = yyvsp[-1].BitList; ;
1393 #line 466 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1395 yyval.FieldList = new std::vector<Init*>();
1399 #line 468 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1401 yyval.FieldList = yyvsp[0].FieldList;
1405 #line 472 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1407 yyval.FieldList = new std::vector<Init*>();
1408 yyval.FieldList->push_back(yyvsp[0].Initializer);
1412 #line 475 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1414 (yyval.FieldList = yyvsp[-2].FieldList)->push_back(yyvsp[0].Initializer);
1418 #line 479 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1420 std::string DecName = *yyvsp[-1].StrVal;
1421 if (ParsingTemplateArgs)
1422 DecName = CurRec->getName() + ":" + DecName;
1424 addValue(RecordVal(DecName, yyvsp[-2].Ty, yyvsp[-3].IntVal));
1425 setValue(DecName, 0, yyvsp[0].Initializer);
1426 yyval.StrVal = new std::string(DecName);
1430 #line 489 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1432 delete yyvsp[-1].StrVal;
1436 #line 491 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1438 setValue(*yyvsp[-4].StrVal, yyvsp[-3].BitList, yyvsp[-1].Initializer);
1439 delete yyvsp[-4].StrVal;
1440 delete yyvsp[-3].BitList;
1444 #line 500 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1446 yyval.SubClassRef = new SubClassRefTy(yyvsp[0].Rec, new std::vector<Init*>());
1450 #line 502 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1452 yyval.SubClassRef = new SubClassRefTy(yyvsp[-3].Rec, yyvsp[-1].FieldList);
1456 #line 506 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1458 yyval.SubClassList = new std::vector<SubClassRefTy>();
1459 yyval.SubClassList->push_back(*yyvsp[0].SubClassRef);
1460 delete yyvsp[0].SubClassRef;
1464 #line 511 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1466 (yyval.SubClassList=yyvsp[-2].SubClassList)->push_back(*yyvsp[0].SubClassRef);
1467 delete yyvsp[0].SubClassRef;
1471 #line 516 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1473 yyval.SubClassList = new std::vector<SubClassRefTy>();
1477 #line 519 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1479 yyval.SubClassList = yyvsp[0].SubClassList;
1483 #line 523 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1485 CurRec->addTemplateArg(*yyvsp[0].StrVal);
1486 delete yyvsp[0].StrVal;
1490 #line 526 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1492 CurRec->addTemplateArg(*yyvsp[0].StrVal);
1493 delete yyvsp[0].StrVal;
1497 #line 531 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1501 #line 534 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1502 { yyval.StrVal = yyvsp[0].StrVal; ;
1505 #line 534 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1506 { yyval.StrVal = new std::string(); ;
1509 #line 536 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1511 static unsigned AnonCounter = 0;
1512 if (yyvsp[0].StrVal->empty())
1513 *yyvsp[0].StrVal = "anonymous."+utostr(AnonCounter++);
1514 yyval.StrVal = yyvsp[0].StrVal;
1518 #line 543 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1520 // If a class of this name already exists, it must be a forward ref.
1521 if ((CurRec = Records.getClass(*yyvsp[0].StrVal))) {
1522 // If the body was previously defined, this is an error.
1523 if (!CurRec->getValues().empty() ||
1524 !CurRec->getSuperClasses().empty() ||
1525 !CurRec->getTemplateArgs().empty()) {
1526 err() << "Class '" << CurRec->getName() << "' already defined!\n";
1530 // If this is the first reference to this class, create and add it.
1531 CurRec = new Record(*yyvsp[0].StrVal);
1532 Records.addClass(CurRec);
1534 delete yyvsp[0].StrVal;
1538 #line 561 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1540 CurRec = new Record(*yyvsp[0].StrVal);
1541 delete yyvsp[0].StrVal;
1543 // Ensure redefinition doesn't happen.
1544 if (Records.getDef(CurRec->getName())) {
1545 err() << "Def '" << CurRec->getName() << "' already defined!\n";
1548 Records.addDef(CurRec);
1552 #line 573 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1554 for (unsigned i = 0, e = yyvsp[0].SubClassList->size(); i != e; ++i) {
1555 addSubClass((*yyvsp[0].SubClassList)[i].first, *(*yyvsp[0].SubClassList)[i].second);
1556 // Delete the template arg values for the class
1557 delete (*yyvsp[0].SubClassList)[i].second;
1559 delete yyvsp[0].SubClassList; // Delete the class list...
1561 // Process any variables on the set stack...
1562 for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
1563 for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
1564 setValue(LetStack[i][j].Name,
1565 LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0,
1566 LetStack[i][j].Value);
1570 #line 587 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1577 #line 592 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1579 ParsingTemplateArgs = true;
1583 #line 594 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1585 ParsingTemplateArgs = false;
1589 #line 596 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1591 yyval.Rec = yyvsp[0].Rec;
1595 #line 600 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1597 yyvsp[0].Rec->resolveReferences();
1599 // If ObjectBody has template arguments, it's an error.
1600 assert(yyvsp[0].Rec->getTemplateArgs().empty() && "How'd this get template args?");
1601 yyval.Rec = yyvsp[0].Rec;
1605 #line 611 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1607 LetStack.back().push_back(LetRecord(*yyvsp[-3].StrVal, yyvsp[-2].BitList, yyvsp[0].Initializer));
1608 delete yyvsp[-3].StrVal; delete yyvsp[-2].BitList;
1612 #line 619 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1613 { LetStack.push_back(std::vector<LetRecord>()); ;
1616 #line 622 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1618 LetStack.pop_back();
1622 #line 625 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1624 LetStack.pop_back();
1628 #line 629 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1632 #line 629 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1636 #line 631 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1640 /* the action file gets copied in in place of this dollarsign */
1641 #line 543 "/usr/share/bison.simple"
1652 short *ssp1 = yyss - 1;
1653 fprintf (stderr, "state stack now");
1654 while (ssp1 != yyssp)
1655 fprintf (stderr, " %d", *++ssp1);
1656 fprintf (stderr, "\n");
1666 yylsp->first_line = yylloc.first_line;
1667 yylsp->first_column = yylloc.first_column;
1668 yylsp->last_line = (yylsp-1)->last_line;
1669 yylsp->last_column = (yylsp-1)->last_column;
1674 yylsp->last_line = (yylsp+yylen-1)->last_line;
1675 yylsp->last_column = (yylsp+yylen-1)->last_column;
1679 /* Now "shift" the result of the reduction.
1680 Determine what state that goes to,
1681 based on the state we popped back to
1682 and the rule number reduced by. */
1686 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1687 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1688 yystate = yytable[yystate];
1690 yystate = yydefgoto[yyn - YYNTBASE];
1694 yyerrlab: /* here on detecting error */
1697 /* If not already recovering from an error, report this error. */
1701 #ifdef YYERROR_VERBOSE
1702 yyn = yypact[yystate];
1704 if (yyn > YYFLAG && yyn < YYLAST)
1711 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1712 for (x = (yyn < 0 ? -yyn : 0);
1713 x < (sizeof(yytname) / sizeof(char *)); x++)
1714 if (yycheck[x + yyn] == x)
1715 size += strlen(yytname[x]) + 15, count++;
1716 msg = (char *) malloc(size + 15);
1719 strcpy(msg, "parse error");
1724 for (x = (yyn < 0 ? -yyn : 0);
1725 x < (sizeof(yytname) / sizeof(char *)); x++)
1726 if (yycheck[x + yyn] == x)
1728 strcat(msg, count == 0 ? ", expecting `" : " or `");
1729 strcat(msg, yytname[x]);
1738 yyerror ("parse error; also virtual memory exceeded");
1741 #endif /* YYERROR_VERBOSE */
1742 yyerror("parse error");
1746 yyerrlab1: /* here on error raised explicitly by an action */
1748 if (yyerrstatus == 3)
1750 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1752 /* return failure if at end of input */
1753 if (yychar == YYEOF)
1758 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1764 /* Else will try to reuse lookahead token
1765 after shifting the error token. */
1767 yyerrstatus = 3; /* Each real token shifted decrements this */
1771 yyerrdefault: /* current state does not do anything special for the error token. */
1774 /* This is wrong; only states that explicitly want error tokens
1775 should shift them. */
1776 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1777 if (yyn) goto yydefault;
1780 yyerrpop: /* pop the current state because it cannot handle the error token */
1782 if (yyssp == yyss) YYABORT;
1792 short *ssp1 = yyss - 1;
1793 fprintf (stderr, "Error: state stack now");
1794 while (ssp1 != yyssp)
1795 fprintf (stderr, " %d", *++ssp1);
1796 fprintf (stderr, "\n");
1802 yyn = yypact[yystate];
1807 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1826 fprintf(stderr, "Shifting error token, ");
1838 /* YYACCEPT comes here. */
1850 /* YYABORT comes here. */
1861 #line 633 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1864 int yyerror(const char *ErrorMsg) {
1865 err() << "Error parsing: " << ErrorMsg << "\n";