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
32 #define STRCONCATTOK 275
37 #define CODEFRAGMENT 280
39 #line 14 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
42 #include "llvm/ADT/StringExtras.h"
43 #include "llvm/Support/Streams.h"
46 #define YYERROR_VERBOSE 1
48 int yyerror(const char *ErrorMsg);
53 Record Rec; // Placeholder for template args and Name.
54 std::vector<Record*> DefPrototypes;
56 MultiClass(const std::string &Name) : Rec(Name) {}
60 static std::map<std::string, MultiClass*> MultiClasses;
62 extern int Filelineno;
63 static MultiClass *CurMultiClass = 0; // Set while parsing a multiclass.
64 static std::string *CurDefmPrefix = 0; // Set while parsing defm.
65 static Record *CurRec = 0;
66 static bool ParsingTemplateArgs = false;
68 typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
72 std::vector<unsigned> Bits;
75 LetRecord(const std::string &N, std::vector<unsigned> *B, Init *V)
76 : Name(N), Value(V), HasBits(B != 0) {
77 if (HasBits) Bits = *B;
81 static std::vector<std::vector<LetRecord> > LetStack;
84 extern std::ostream &err();
86 /// getActiveRec - If inside a def/class definition, return the def/class.
87 /// Otherwise, if within a multidef, return it.
88 static Record *getActiveRec() {
89 return CurRec ? CurRec : &CurMultiClass->Rec;
92 static void addValue(const RecordVal &RV) {
93 Record *TheRec = getActiveRec();
95 if (RecordVal *ERV = TheRec->getValue(RV.getName())) {
96 // The value already exists in the class, treat this as a set...
97 if (ERV->setValue(RV.getValue())) {
98 err() << "New definition of '" << RV.getName() << "' of type '"
99 << *RV.getType() << "' is incompatible with previous "
100 << "definition of type '" << *ERV->getType() << "'!\n";
104 TheRec->addValue(RV);
108 static void addSuperClass(Record *SC) {
109 if (CurRec->isSubClassOf(SC)) {
110 err() << "Already subclass of '" << SC->getName() << "'!\n";
113 CurRec->addSuperClass(SC);
116 static void setValue(const std::string &ValName,
117 std::vector<unsigned> *BitList, Init *V) {
120 Record *TheRec = getActiveRec();
121 RecordVal *RV = TheRec->getValue(ValName);
123 err() << "Value '" << ValName << "' unknown!\n";
127 // Do not allow assignments like 'X = X'. This will just cause infinite loops
128 // in the resolution machinery.
130 if (VarInit *VI = dynamic_cast<VarInit*>(V))
131 if (VI->getName() == ValName)
134 // If we are assigning to a subset of the bits in the value... then we must be
135 // assigning to a field of BitsRecTy, which must have a BitsInit
139 BitsInit *CurVal = dynamic_cast<BitsInit*>(RV->getValue());
141 err() << "Value '" << ValName << "' is not a bits type!\n";
145 // Convert the incoming value to a bits type of the appropriate size...
146 Init *BI = V->convertInitializerTo(new BitsRecTy(BitList->size()));
148 V->convertInitializerTo(new BitsRecTy(BitList->size()));
149 err() << "Initializer '" << *V << "' not compatible with bit range!\n";
153 // We should have a BitsInit type now...
154 assert(dynamic_cast<BitsInit*>(BI) != 0 || (cerr << *BI).stream() == 0);
155 BitsInit *BInit = (BitsInit*)BI;
157 BitsInit *NewVal = new BitsInit(CurVal->getNumBits());
159 // Loop over bits, assigning values as appropriate...
160 for (unsigned i = 0, e = BitList->size(); i != e; ++i) {
161 unsigned Bit = (*BitList)[i];
162 if (NewVal->getBit(Bit)) {
163 err() << "Cannot set bit #" << Bit << " of value '" << ValName
164 << "' more than once!\n";
167 NewVal->setBit(Bit, BInit->getBit(i));
170 for (unsigned i = 0, e = CurVal->getNumBits(); i != e; ++i)
171 if (NewVal->getBit(i) == 0)
172 NewVal->setBit(i, CurVal->getBit(i));
177 if (RV->setValue(V)) {
178 err() << "Value '" << ValName << "' of type '" << *RV->getType()
179 << "' is incompatible with initializer '" << *V << "'!\n";
184 // addSubClass - Add SC as a subclass to CurRec, resolving TemplateArgs as SC's
185 // template arguments.
186 static void addSubClass(Record *SC, const std::vector<Init*> &TemplateArgs) {
187 // Add all of the values in the subclass into the current class...
188 const std::vector<RecordVal> &Vals = SC->getValues();
189 for (unsigned i = 0, e = Vals.size(); i != e; ++i)
192 const std::vector<std::string> &TArgs = SC->getTemplateArgs();
194 // Ensure that an appropriate number of template arguments are specified...
195 if (TArgs.size() < TemplateArgs.size()) {
196 err() << "ERROR: More template args specified than expected!\n";
200 // Loop over all of the template arguments, setting them to the specified
201 // value or leaving them as the default if necessary.
202 for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
203 if (i < TemplateArgs.size()) { // A value is specified for this temp-arg?
205 setValue(TArgs[i], 0, TemplateArgs[i]);
208 CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i]));
212 CurRec->removeValue(TArgs[i]);
214 } else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) {
215 err() << "ERROR: Value not specified for template argument #"
216 << i << " (" << TArgs[i] << ") of subclass '" << SC->getName()
222 // Since everything went well, we can now set the "superclass" list for the
224 const std::vector<Record*> &SCs = SC->getSuperClasses();
225 for (unsigned i = 0, e = SCs.size(); i != e; ++i)
226 addSuperClass(SCs[i]);
230 } // End llvm namespace
232 using namespace llvm;
235 #line 210 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
240 llvm::Init* Initializer;
241 std::vector<llvm::Init*>* FieldList;
242 std::vector<unsigned>* BitList;
244 std::vector<llvm::Record*>* RecList;
245 SubClassRefTy* SubClassRef;
246 std::vector<SubClassRefTy>* SubClassList;
247 std::vector<std::pair<llvm::Init*, std::string> >* DagValueList;
260 #define YYFLAG -32768
263 #define YYTRANSLATE(x) ((unsigned)(x) <= 280 ? yytranslate[x] : 91)
265 static const char yytranslate[] = { 0,
266 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
267 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
268 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
269 2, 2, 2, 2, 2, 2, 2, 2, 2, 36,
270 37, 2, 2, 38, 40, 35, 2, 2, 2, 2,
271 2, 2, 2, 2, 2, 2, 2, 39, 41, 27,
272 29, 28, 30, 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 33, 2, 34, 2, 2, 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, 31, 2, 32, 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, 2, 2, 2, 2, 2,
289 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
290 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
291 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
292 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
293 17, 18, 19, 20, 21, 22, 23, 24, 25, 26
297 static const short yyprhs[] = { 0,
298 0, 2, 4, 6, 11, 13, 18, 20, 22, 24,
299 25, 27, 28, 31, 33, 35, 37, 39, 41, 43,
300 47, 52, 57, 61, 65, 70, 75, 82, 89, 96,
301 103, 110, 111, 114, 117, 122, 123, 125, 127, 131,
302 134, 138, 144, 149, 151, 152, 156, 157, 159, 161,
303 165, 170, 173, 180, 181, 184, 186, 190, 192, 197,
304 199, 203, 204, 207, 209, 213, 217, 218, 220, 222,
305 223, 225, 227, 229, 230, 234, 235, 236, 243, 247,
306 249, 251, 254, 256, 257, 258, 267, 268, 275, 277,
307 279, 281, 283, 288, 290, 294, 295, 300, 305, 308,
311 static const short yyrhs[] = { 23,
312 0, 5, 0, 4, 0, 6, 27, 22, 28, 0,
313 3, 0, 7, 27, 43, 28, 0, 8, 0, 9,
314 0, 42, 0, 0, 14, 0, 0, 29, 47, 0,
315 23, 0, 46, 0, 22, 0, 25, 0, 26, 0,
316 30, 0, 31, 54, 32, 0, 23, 27, 55, 28,
317 0, 47, 31, 52, 32, 0, 33, 54, 34, 0,
318 47, 35, 23, 0, 36, 46, 50, 37, 0, 47,
319 33, 52, 34, 0, 17, 36, 47, 38, 47, 37,
320 0, 18, 36, 47, 38, 47, 37, 0, 19, 36,
321 47, 38, 47, 37, 0, 20, 36, 47, 38, 47,
322 37, 0, 21, 36, 47, 38, 47, 37, 0, 0,
323 39, 24, 0, 47, 48, 0, 49, 38, 47, 48,
324 0, 0, 49, 0, 22, 0, 22, 40, 22, 0,
325 22, 22, 0, 51, 38, 22, 0, 51, 38, 22,
326 40, 22, 0, 51, 38, 22, 22, 0, 51, 0,
327 0, 31, 52, 32, 0, 0, 55, 0, 47, 0,
328 55, 38, 47, 0, 44, 43, 23, 45, 0, 56,
329 41, 0, 15, 23, 53, 29, 47, 41, 0, 0,
330 58, 57, 0, 41, 0, 31, 58, 32, 0, 42,
331 0, 42, 27, 55, 28, 0, 60, 0, 61, 38,
332 60, 0, 0, 39, 61, 0, 56, 0, 63, 38,
333 56, 0, 27, 63, 28, 0, 0, 64, 0, 23,
334 0, 0, 66, 0, 67, 0, 67, 0, 0, 62,
335 71, 59, 0, 0, 0, 10, 68, 73, 65, 74,
336 70, 0, 11, 69, 70, 0, 75, 0, 76, 0,
337 77, 76, 0, 23, 0, 0, 0, 12, 78, 80,
338 65, 81, 31, 77, 32, 0, 0, 13, 23, 83,
339 39, 60, 41, 0, 72, 0, 75, 0, 79, 0,
340 82, 0, 23, 53, 29, 47, 0, 85, 0, 86,
341 38, 85, 0, 0, 15, 88, 86, 16, 0, 87,
342 31, 89, 32, 0, 87, 84, 0, 84, 0, 89,
349 static const short yyrline[] = { 0,
350 246, 268, 270, 272, 274, 276, 278, 280, 282, 286,
351 286, 288, 288, 290, 313, 315, 317, 320, 323, 325,
352 338, 366, 373, 376, 383, 386, 394, 396, 398, 400,
353 402, 406, 409, 413, 418, 424, 427, 430, 433, 446,
354 460, 462, 475, 491, 493, 493, 497, 499, 503, 506,
355 510, 527, 529, 535, 535, 536, 536, 538, 540, 544,
356 549, 554, 557, 561, 564, 569, 570, 570, 572, 572,
357 574, 581, 599, 624, 638, 643, 645, 647, 651, 661,
358 675, 678, 682, 693, 695, 697, 702, 702, 776, 776,
359 777, 777, 779, 784, 784, 787, 787, 790, 793, 797,
365 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
367 static const char * const yytname[] = { "$","error","$undefined.","INT","BIT",
368 "STRING","BITS","LIST","CODE","DAG","CLASS","DEF","MULTICLASS","DEFM","FIELD",
369 "LET","IN","CONCATTOK","SHLTOK","SRATOK","SRLTOK","STRCONCATTOK","INTVAL","ID",
370 "VARNAME","STRVAL","CODEFRAGMENT","'<'","'>'","'='","'?'","'{'","'}'","'['",
371 "']'","'.'","'('","')'","','","':'","'-'","';'","ClassID","Type","OptPrefix",
372 "OptValue","IDValue","Value","OptVarName","DagArgListNE","DagArgList","RBitList",
373 "BitList","OptBitList","ValueList","ValueListNE","Declaration","BodyItem","BodyList",
374 "Body","SubClassRef","ClassListNE","ClassList","DeclListNE","TemplateArgList",
375 "OptTemplateArgList","OptID","ObjectName","ClassName","DefName","ObjectBody",
376 "@1","ClassInst","@2","@3","DefInst","MultiClassDef","MultiClassBody","MultiClassName",
377 "MultiClassInst","@4","@5","DefMInst","@6","Object","LETItem","LETList","LETCommand",
378 "@7","ObjectList","File", NULL
382 static const short yyr1[] = { 0,
383 42, 43, 43, 43, 43, 43, 43, 43, 43, 44,
384 44, 45, 45, 46, 47, 47, 47, 47, 47, 47,
385 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
386 47, 48, 48, 49, 49, 50, 50, 51, 51, 51,
387 51, 51, 51, 52, 53, 53, 54, 54, 55, 55,
388 56, 57, 57, 58, 58, 59, 59, 60, 60, 61,
389 61, 62, 62, 63, 63, 64, 65, 65, 66, 66,
390 67, 68, 69, 71, 70, 73, 74, 72, 75, 76,
391 77, 77, 78, 80, 81, 79, 83, 82, 84, 84,
392 84, 84, 85, 86, 86, 88, 87, 84, 84, 89,
396 static const short yyr2[] = { 0,
397 1, 1, 1, 4, 1, 4, 1, 1, 1, 0,
398 1, 0, 2, 1, 1, 1, 1, 1, 1, 3,
399 4, 4, 3, 3, 4, 4, 6, 6, 6, 6,
400 6, 0, 2, 2, 4, 0, 1, 1, 3, 2,
401 3, 5, 4, 1, 0, 3, 0, 1, 1, 3,
402 4, 2, 6, 0, 2, 1, 3, 1, 4, 1,
403 3, 0, 2, 1, 3, 3, 0, 1, 1, 0,
404 1, 1, 1, 0, 3, 0, 0, 6, 3, 1,
405 1, 2, 1, 0, 0, 8, 0, 6, 1, 1,
406 1, 1, 4, 1, 3, 0, 4, 4, 2, 1,
410 static const short yydefact[] = { 0,
411 70, 70, 0, 0, 96, 89, 90, 91, 92, 100,
412 0, 102, 69, 71, 72, 76, 73, 62, 83, 84,
413 87, 0, 0, 99, 101, 67, 0, 74, 79, 67,
414 0, 45, 94, 0, 0, 10, 68, 77, 1, 58,
415 60, 63, 0, 85, 0, 0, 0, 97, 0, 98,
416 11, 0, 64, 0, 62, 0, 0, 54, 56, 75,
417 0, 0, 38, 44, 0, 0, 95, 5, 3, 2,
418 0, 0, 7, 8, 9, 0, 66, 10, 78, 0,
419 0, 0, 0, 0, 16, 14, 17, 18, 19, 47,
420 47, 0, 15, 49, 0, 61, 10, 0, 88, 40,
421 0, 0, 46, 93, 0, 0, 12, 65, 0, 0,
422 0, 0, 0, 0, 0, 48, 0, 14, 36, 0,
423 0, 0, 59, 0, 0, 57, 0, 55, 80, 81,
424 0, 39, 41, 0, 0, 0, 51, 0, 0, 0,
425 0, 0, 0, 20, 23, 32, 37, 0, 0, 0,
426 24, 50, 45, 52, 86, 82, 43, 0, 4, 6,
427 13, 0, 0, 0, 0, 0, 21, 0, 34, 0,
428 25, 22, 26, 0, 42, 0, 0, 0, 0, 0,
429 33, 32, 0, 27, 28, 29, 30, 31, 35, 0,
433 static const short yydefgoto[] = { 40,
434 76, 52, 137, 93, 94, 169, 147, 148, 64, 65,
435 47, 115, 116, 53, 128, 97, 60, 41, 42, 28,
436 54, 37, 38, 14, 15, 16, 18, 29, 43, 6,
437 26, 55, 7, 130, 131, 20, 8, 30, 61, 9,
438 31, 10, 33, 34, 11, 22, 12, 192
441 static const short yypact[] = { 147,
442 -17, -17, 8, 12,-32768,-32768,-32768,-32768,-32768,-32768,
443 3, 147,-32768,-32768,-32768,-32768,-32768, -13,-32768,-32768,
444 -32768, 17, 147,-32768,-32768, 21, 58,-32768,-32768, 21,
445 45, 55,-32768, -5, -3, 77,-32768,-32768,-32768, 68,
446 -32768, 64, -4,-32768, 58, 84, 81,-32768, 17,-32768,
447 -32768, 16,-32768, 13, -13, 43, 58,-32768,-32768,-32768,
448 88, 74, 10, 83, 93, 43,-32768,-32768,-32768,-32768,
449 100, 104,-32768,-32768,-32768, 110,-32768, 77,-32768, 117,
450 125, 127, 128, 129,-32768, 139,-32768,-32768,-32768, 43,
451 43, 132,-32768, 59, 14,-32768, 40, 156,-32768,-32768,
452 146, 148,-32768, 59, 149, 16, 140,-32768, 43, 43,
453 43, 43, 43, 43, 141, 134, 142,-32768, 43, 84,
454 84, 151,-32768, 43, 152,-32768, 136,-32768,-32768,-32768,
455 6,-32768, 35, 150, 153, 43,-32768, 70, 76, 85,
456 91, 97, 39,-32768,-32768, 54, 144, 143, 154, 145,
457 -32768, 59, 55,-32768,-32768,-32768,-32768, 161,-32768,-32768,
458 59, 43, 43, 43, 43, 43,-32768, 160,-32768, 43,
459 -32768,-32768,-32768, 158,-32768, 103, 106, 111, 114, 119,
460 -32768, 54, 43,-32768,-32768,-32768,-32768,-32768,-32768, 47,
461 -32768, 185, 188,-32768
464 static const short yypgoto[] = { -50,
465 86,-32768,-32768, 98, -66, 7,-32768,-32768,-32768, -8,
466 38, 102, -55, -48,-32768,-32768,-32768, 26,-32768,-32768,
467 -32768,-32768, 164,-32768, 193,-32768,-32768, 155,-32768,-32768,
468 -32768,-32768, -95, 65,-32768,-32768,-32768,-32768,-32768,-32768,
469 -32768, -7, 157,-32768,-32768,-32768, 174,-32768
476 static const short yytable[] = { 104,
477 95, 75, 129, 24, 25, 13, 1, 2, 3, 4,
478 48, 5, 1, 2, 3, 4, 2, 5, 68, 69,
479 70, 71, 72, 73, 74, 27, 58, 25, 50, 108,
480 19, 100, 49, 23, 21, 129, 59, 155, 39, 32,
481 77, 123, 138, 139, 140, 141, 142, 36, 127, 101,
482 78, 124, 146, 51, 125, 75, 157, 152, 143, 80,
483 81, 82, 83, 84, 85, 86, 167, 87, 88, 161,
484 62, 126, 89, 90, 158, 91, 124, 120, 92, 121,
485 39, 122, 96, 45, 120, 46, 121, 191, 122, 120,
486 51, 121, 168, 122, 56, 176, 177, 178, 179, 180,
487 120, 57, 121, 182, 122, 63, 120, 162, 121, 66,
488 122, 149, 150, 163, 99, 120, 190, 121, 98, 122,
489 102, 120, 164, 121, 103, 122, 105, 120, 165, 121,
490 106, 122, 107, 120, 166, 121, 120, 122, 121, 184,
491 122, 120, 185, 121, 120, 122, 121, 186, 122, 120,
492 187, 121, 109, 122, 118, 188, 1, 2, 3, 4,
493 110, 5, 111, 112, 113, 114, 2, 132, 136, 133,
494 134, 124, 144, 151, 153, 145, 154, 159, 173, 171,
495 160, 170, 175, 181, 193, 172, 183, 194, 189, 119,
496 174, 135, 117, 44, 17, 156, 35, 0, 0, 0,
497 0, 0, 0, 0, 0, 67, 0, 0, 0, 79
500 static const short yycheck[] = { 66,
501 56, 52, 98, 11, 12, 23, 10, 11, 12, 13,
502 16, 15, 10, 11, 12, 13, 11, 15, 3, 4,
503 5, 6, 7, 8, 9, 39, 31, 35, 32, 78,
504 23, 22, 38, 31, 23, 131, 41, 32, 23, 23,
505 28, 28, 109, 110, 111, 112, 113, 27, 97, 40,
506 38, 38, 119, 14, 15, 106, 22, 124, 114, 17,
507 18, 19, 20, 21, 22, 23, 28, 25, 26, 136,
508 45, 32, 30, 31, 40, 33, 38, 31, 36, 33,
509 23, 35, 57, 39, 31, 31, 33, 41, 35, 31,
510 14, 33, 39, 35, 27, 162, 163, 164, 165, 166,
511 31, 38, 33, 170, 35, 22, 31, 38, 33, 29,
512 35, 120, 121, 38, 41, 31, 183, 33, 31, 35,
513 38, 31, 38, 33, 32, 35, 27, 31, 38, 33,
514 27, 35, 23, 31, 38, 33, 31, 35, 33, 37,
515 35, 31, 37, 33, 31, 35, 33, 37, 35, 31,
516 37, 33, 36, 35, 23, 37, 10, 11, 12, 13,
517 36, 15, 36, 36, 36, 27, 11, 22, 29, 22,
518 22, 38, 32, 23, 23, 34, 41, 28, 34, 37,
519 28, 38, 22, 24, 0, 32, 29, 0, 182, 92,
520 153, 106, 91, 30, 2, 131, 23, -1, -1, -1,
521 -1, -1, -1, -1, -1, 49, -1, -1, -1, 55
523 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
524 #line 3 "/usr/share/bison.simple"
525 /* This file comes from bison-1.28. */
527 /* Skeleton output parser for bison,
528 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
530 This program is free software; you can redistribute it and/or modify
531 it under the terms of the GNU General Public License as published by
532 the Free Software Foundation; either version 2, or (at your option)
535 This program is distributed in the hope that it will be useful,
536 but WITHOUT ANY WARRANTY; without even the implied warranty of
537 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
538 GNU General Public License for more details.
540 You should have received a copy of the GNU General Public License
541 along with this program; if not, write to the Free Software
542 Foundation, Inc., 59 Temple Place - Suite 330,
543 Boston, MA 02111-1307, USA. */
545 /* As a special exception, when this file is copied by Bison into a
546 Bison output file, you may use that output file without restriction.
547 This special exception was added by the Free Software Foundation
548 in version 1.24 of Bison. */
550 /* This is the parser code that is written into each bison parser
551 when the %semantic_parser declaration is not specified in the grammar.
552 It was written by Richard Stallman by simplifying the hairy parser
553 used when %semantic_parser is specified. */
555 #ifndef YYSTACK_USE_ALLOCA
557 #define YYSTACK_USE_ALLOCA
558 #else /* alloca not defined */
560 #define YYSTACK_USE_ALLOCA
561 #define alloca __builtin_alloca
562 #else /* not GNU C. */
563 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
564 #define YYSTACK_USE_ALLOCA
566 #else /* not sparc */
567 /* We think this test detects Watcom and Microsoft C. */
568 /* This used to test MSDOS, but that is a bad idea
569 since that symbol is in the user namespace. */
570 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
571 #if 0 /* No need for malloc.h, which pollutes the namespace;
572 instead, just don't use alloca. */
575 #else /* not MSDOS, or __TURBOC__ */
577 /* I don't know what this was needed for, but it pollutes the namespace.
578 So I turned it off. rms, 2 May 1997. */
579 /* #include <malloc.h> */
581 #define YYSTACK_USE_ALLOCA
582 #else /* not MSDOS, or __TURBOC__, or _AIX */
584 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
585 and on HPUX 10. Eventually we can turn this on. */
586 #define YYSTACK_USE_ALLOCA
587 #define alloca __builtin_alloca
590 #endif /* not _AIX */
591 #endif /* not MSDOS, or __TURBOC__ */
592 #endif /* not sparc */
593 #endif /* not GNU C */
594 #endif /* alloca not defined */
595 #endif /* YYSTACK_USE_ALLOCA not defined */
597 #ifdef YYSTACK_USE_ALLOCA
598 #define YYSTACK_ALLOC alloca
600 #define YYSTACK_ALLOC malloc
603 /* Note: there must be only one dollar sign in this file.
604 It is replaced by the list of actions, each action
605 as one case of the switch. */
607 #define yyerrok (yyerrstatus = 0)
608 #define yyclearin (yychar = YYEMPTY)
611 #define YYACCEPT goto yyacceptlab
612 #define YYABORT goto yyabortlab
613 #define YYERROR goto yyerrlab1
614 /* Like YYERROR except do call yyerror.
615 This remains here temporarily to ease the
616 transition to the new meaning of YYERROR, for GCC.
617 Once GCC version 2 has supplanted version 1, this can go. */
618 #define YYFAIL goto yyerrlab
619 #define YYRECOVERING() (!!yyerrstatus)
620 #define YYBACKUP(token, value) \
622 if (yychar == YYEMPTY && yylen == 1) \
623 { yychar = (token), yylval = (value); \
624 yychar1 = YYTRANSLATE (yychar); \
629 { yyerror ("syntax error: cannot back up"); YYERROR; } \
633 #define YYERRCODE 256
636 #define YYLEX yylex()
642 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
644 #define YYLEX yylex(&yylval, &yylloc)
646 #else /* not YYLSP_NEEDED */
648 #define YYLEX yylex(&yylval, YYLEX_PARAM)
650 #define YYLEX yylex(&yylval)
652 #endif /* not YYLSP_NEEDED */
655 /* If nonreentrant, generate the variables here */
659 int yychar; /* the lookahead symbol */
660 YYSTYPE yylval; /* the semantic value of the */
661 /* lookahead symbol */
664 YYLTYPE yylloc; /* location data for the lookahead */
668 int yynerrs; /* number of parse errors so far */
669 #endif /* not YYPURE */
672 int yydebug; /* nonzero means print parse trace */
673 /* Since this is uninitialized, it does not stop multiple parsers
677 /* YYINITDEPTH indicates the initial size of the parser's stacks */
680 #define YYINITDEPTH 200
683 /* YYMAXDEPTH is the maximum size the stacks can grow to
684 (effective only if the built-in stack extension method is used). */
691 #define YYMAXDEPTH 10000
694 /* Define __yy_memcpy. Note that the size argument
695 should be passed with type unsigned int, because that is what the non-GCC
696 definitions require. With GCC, __builtin_memcpy takes an arg
697 of type size_t, but it can handle unsigned int. */
699 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
700 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
701 #else /* not GNU C or C++ */
704 /* This is the most reliable way to avoid incompatibilities
705 in available built-in functions on various systems. */
707 __yy_memcpy (to, from, count)
712 register char *f = from;
713 register char *t = to;
714 register int i = count;
720 #else /* __cplusplus */
722 /* This is the most reliable way to avoid incompatibilities
723 in available built-in functions on various systems. */
725 __yy_memcpy (char *to, char *from, unsigned int count)
727 register char *t = to;
728 register char *f = from;
729 register int i = count;
738 #line 217 "/usr/share/bison.simple"
740 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
741 into yyparse. The argument should have type void *.
742 It should actually point to an object.
743 Grammar actions can access the variable by casting it
744 to the proper pointer type. */
748 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
749 #define YYPARSE_PARAM_DECL
750 #else /* not __cplusplus */
751 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
752 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
753 #endif /* not __cplusplus */
754 #else /* not YYPARSE_PARAM */
755 #define YYPARSE_PARAM_ARG
756 #define YYPARSE_PARAM_DECL
757 #endif /* not YYPARSE_PARAM */
759 /* Prevent warning if -Wstrict-prototypes. */
762 int yyparse (void *);
769 yyparse(YYPARSE_PARAM_ARG)
772 register int yystate;
774 register short *yyssp;
775 register YYSTYPE *yyvsp;
776 int yyerrstatus; /* number of tokens to shift before error messages enabled */
777 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
779 short yyssa[YYINITDEPTH]; /* the state stack */
780 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
782 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
783 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
786 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
787 YYLTYPE *yyls = yylsa;
790 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
792 #define YYPOPSTACK (yyvsp--, yyssp--)
795 int yystacksize = YYINITDEPTH;
796 int yyfree_stacks = 0;
807 YYSTYPE yyval; /* the variable used to return */
808 /* semantic values from the action */
815 fprintf(stderr, "Starting parse\n");
821 yychar = YYEMPTY; /* Cause a token to be read. */
823 /* Initialize stack pointers.
824 Waste one element of value and location stack
825 so that they stay on the same level as the state stack.
826 The wasted elements are never initialized. */
834 /* Push a new state, which is found in yystate . */
835 /* In all cases, when you get here, the value and location stacks
836 have just been pushed. so pushing a state here evens the stacks. */
841 if (yyssp >= yyss + yystacksize - 1)
843 /* Give user a chance to reallocate the stack */
844 /* Use copies of these so that the &'s don't force the real ones into memory. */
845 YYSTYPE *yyvs1 = yyvs;
848 YYLTYPE *yyls1 = yyls;
851 /* Get the current used size of the three stacks, in elements. */
852 int size = yyssp - yyss + 1;
855 /* Each stack pointer address is followed by the size of
856 the data in use in that stack, in bytes. */
858 /* This used to be a conditional around just the two extra args,
859 but that might be undefined if yyoverflow is a macro. */
860 yyoverflow("parser stack overflow",
861 &yyss1, size * sizeof (*yyssp),
862 &yyvs1, size * sizeof (*yyvsp),
863 &yyls1, size * sizeof (*yylsp),
866 yyoverflow("parser stack overflow",
867 &yyss1, size * sizeof (*yyssp),
868 &yyvs1, size * sizeof (*yyvsp),
872 yyss = yyss1; yyvs = yyvs1;
876 #else /* no yyoverflow */
877 /* Extend the stack our own way. */
878 if (yystacksize >= YYMAXDEPTH)
880 yyerror("parser stack overflow");
892 if (yystacksize > YYMAXDEPTH)
893 yystacksize = YYMAXDEPTH;
894 #ifndef YYSTACK_USE_ALLOCA
897 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
898 __yy_memcpy ((char *)yyss, (char *)yyss1,
899 size * (unsigned int) sizeof (*yyssp));
900 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
901 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
902 size * (unsigned int) sizeof (*yyvsp));
904 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
905 __yy_memcpy ((char *)yyls, (char *)yyls1,
906 size * (unsigned int) sizeof (*yylsp));
908 #endif /* no yyoverflow */
910 yyssp = yyss + size - 1;
911 yyvsp = yyvs + size - 1;
913 yylsp = yyls + size - 1;
918 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
921 if (yyssp >= yyss + yystacksize - 1)
927 fprintf(stderr, "Entering state %d\n", yystate);
933 /* Do appropriate processing given the current state. */
934 /* Read a lookahead token if we need one and don't already have one. */
937 /* First try to decide what to do without reference to lookahead token. */
939 yyn = yypact[yystate];
943 /* Not known => get a lookahead token if don't already have one. */
945 /* yychar is either YYEMPTY or YYEOF
946 or a valid token in external form. */
948 if (yychar == YYEMPTY)
952 fprintf(stderr, "Reading a token: ");
957 /* Convert token to internal form (in yychar1) for indexing tables with */
959 if (yychar <= 0) /* This means end of input. */
962 yychar = YYEOF; /* Don't call YYLEX any more */
966 fprintf(stderr, "Now at end of input.\n");
971 yychar1 = YYTRANSLATE(yychar);
976 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
977 /* Give the individual parser a way to print the precise meaning
978 of a token, for further debugging info. */
980 YYPRINT (stderr, yychar, yylval);
982 fprintf (stderr, ")\n");
988 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
993 /* yyn is what to do for this token type in this state.
994 Negative => reduce, -yyn is rule number.
995 Positive => shift, yyn is new state.
996 New state is final state => don't bother to shift,
998 0, or most negative number => error. */
1013 /* Shift the lookahead token. */
1017 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
1020 /* Discard the token being shifted unless it is eof. */
1021 if (yychar != YYEOF)
1029 /* count tokens shifted since error; after three, turn off error status. */
1030 if (yyerrstatus) yyerrstatus--;
1035 /* Do the default action for the current state. */
1038 yyn = yydefact[yystate];
1042 /* Do a reduction. yyn is the number of a rule to reduce with. */
1046 yyval = yyvsp[1-yylen]; /* implement default value of the action */
1053 fprintf (stderr, "Reducing via rule %d (line %d), ",
1056 /* Print the symbols being reduced, and their result. */
1057 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
1058 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1059 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1067 #line 246 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1069 if (CurDefmPrefix) {
1070 // If CurDefmPrefix is set, we're parsing a defm, which means that this is
1071 // actually the name of a multiclass.
1072 MultiClass *MC = MultiClasses[*yyvsp[0].StrVal];
1074 err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n";
1077 yyval.Rec = &MC->Rec;
1079 yyval.Rec = Records.getClass(*yyvsp[0].StrVal);
1081 if (yyval.Rec == 0) {
1082 err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n";
1085 delete yyvsp[0].StrVal;
1089 #line 268 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1091 yyval.Ty = new StringRecTy();
1095 #line 270 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1097 yyval.Ty = new BitRecTy();
1101 #line 272 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1103 yyval.Ty = new BitsRecTy(yyvsp[-1].IntVal);
1107 #line 274 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1109 yyval.Ty = new IntRecTy();
1113 #line 276 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1115 yyval.Ty = new ListRecTy(yyvsp[-1].Ty);
1119 #line 278 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1121 yyval.Ty = new CodeRecTy();
1125 #line 280 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1127 yyval.Ty = new DagRecTy();
1131 #line 282 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1133 yyval.Ty = new RecordRecTy(yyvsp[0].Rec);
1137 #line 286 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1138 { yyval.IntVal = 0; ;
1141 #line 286 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1142 { yyval.IntVal = 1; ;
1145 #line 288 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1146 { yyval.Initializer = 0; ;
1149 #line 288 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1150 { yyval.Initializer = yyvsp[0].Initializer; ;
1153 #line 290 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1155 if (const RecordVal *RV = (CurRec ? CurRec->getValue(*yyvsp[0].StrVal) : 0)) {
1156 yyval.Initializer = new VarInit(*yyvsp[0].StrVal, RV->getType());
1157 } else if (CurRec && CurRec->isTemplateArg(CurRec->getName()+":"+*yyvsp[0].StrVal)) {
1158 const RecordVal *RV = CurRec->getValue(CurRec->getName()+":"+*yyvsp[0].StrVal);
1159 assert(RV && "Template arg doesn't exist??");
1160 yyval.Initializer = new VarInit(CurRec->getName()+":"+*yyvsp[0].StrVal, RV->getType());
1161 } else if (CurMultiClass &&
1162 CurMultiClass->Rec.isTemplateArg(CurMultiClass->Rec.getName()+"::"+*yyvsp[0].StrVal)) {
1163 std::string Name = CurMultiClass->Rec.getName()+"::"+*yyvsp[0].StrVal;
1164 const RecordVal *RV = CurMultiClass->Rec.getValue(Name);
1165 assert(RV && "Template arg doesn't exist??");
1166 yyval.Initializer = new VarInit(Name, RV->getType());
1167 } else if (Record *D = Records.getDef(*yyvsp[0].StrVal)) {
1168 yyval.Initializer = new DefInit(D);
1170 err() << "Variable not defined: '" << *yyvsp[0].StrVal << "'!\n";
1174 delete yyvsp[0].StrVal;
1178 #line 313 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1180 yyval.Initializer = yyvsp[0].Initializer;
1184 #line 315 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1186 yyval.Initializer = new IntInit(yyvsp[0].IntVal);
1190 #line 317 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1192 yyval.Initializer = new StringInit(*yyvsp[0].StrVal);
1193 delete yyvsp[0].StrVal;
1197 #line 320 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1199 yyval.Initializer = new CodeInit(*yyvsp[0].StrVal);
1200 delete yyvsp[0].StrVal;
1204 #line 323 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1206 yyval.Initializer = new UnsetInit();
1210 #line 325 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1212 BitsInit *Init = new BitsInit(yyvsp[-1].FieldList->size());
1213 for (unsigned i = 0, e = yyvsp[-1].FieldList->size(); i != e; ++i) {
1214 struct Init *Bit = (*yyvsp[-1].FieldList)[i]->convertInitializerTo(new BitRecTy());
1216 err() << "Element #" << i << " (" << *(*yyvsp[-1].FieldList)[i]
1217 << ") is not convertable to a bit!\n";
1220 Init->setBit(yyvsp[-1].FieldList->size()-i-1, Bit);
1222 yyval.Initializer = Init;
1223 delete yyvsp[-1].FieldList;
1227 #line 338 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1229 // This is a CLASS<initvalslist> expression. This is supposed to synthesize
1230 // a new anonymous definition, deriving from CLASS<initvalslist> with no
1232 Record *Class = Records.getClass(*yyvsp[-3].StrVal);
1234 err() << "Expected a class, got '" << *yyvsp[-3].StrVal << "'!\n";
1237 delete yyvsp[-3].StrVal;
1239 static unsigned AnonCounter = 0;
1240 Record *OldRec = CurRec; // Save CurRec.
1242 // Create the new record, set it as CurRec temporarily.
1243 CurRec = new Record("anonymous.val."+utostr(AnonCounter++));
1244 addSubClass(Class, *yyvsp[-1].FieldList); // Add info about the subclass to CurRec.
1245 delete yyvsp[-1].FieldList; // Free up the template args.
1247 CurRec->resolveReferences();
1249 Records.addDef(CurRec);
1251 // The result of the expression is a reference to the new record.
1252 yyval.Initializer = new DefInit(CurRec);
1254 // Restore the old CurRec
1259 #line 366 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1261 yyval.Initializer = yyvsp[-3].Initializer->convertInitializerBitRange(*yyvsp[-1].BitList);
1262 if (yyval.Initializer == 0) {
1263 err() << "Invalid bit range for value '" << *yyvsp[-3].Initializer << "'!\n";
1266 delete yyvsp[-1].BitList;
1270 #line 373 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1272 yyval.Initializer = new ListInit(*yyvsp[-1].FieldList);
1273 delete yyvsp[-1].FieldList;
1277 #line 376 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1279 if (!yyvsp[-2].Initializer->getFieldType(*yyvsp[0].StrVal)) {
1280 err() << "Cannot access field '" << *yyvsp[0].StrVal << "' of value '" << *yyvsp[-2].Initializer << "!\n";
1283 yyval.Initializer = new FieldInit(yyvsp[-2].Initializer, *yyvsp[0].StrVal);
1284 delete yyvsp[0].StrVal;
1288 #line 383 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1290 yyval.Initializer = new DagInit(yyvsp[-2].Initializer, *yyvsp[-1].DagValueList);
1291 delete yyvsp[-1].DagValueList;
1295 #line 386 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1297 std::reverse(yyvsp[-1].BitList->begin(), yyvsp[-1].BitList->end());
1298 yyval.Initializer = yyvsp[-3].Initializer->convertInitListSlice(*yyvsp[-1].BitList);
1299 if (yyval.Initializer == 0) {
1300 err() << "Invalid list slice for value '" << *yyvsp[-3].Initializer << "'!\n";
1303 delete yyvsp[-1].BitList;
1307 #line 394 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1309 yyval.Initializer = (new BinOpInit(BinOpInit::CONCAT, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1313 #line 396 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1315 yyval.Initializer = (new BinOpInit(BinOpInit::SHL, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1319 #line 398 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1321 yyval.Initializer = (new BinOpInit(BinOpInit::SRA, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1325 #line 400 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1327 yyval.Initializer = (new BinOpInit(BinOpInit::SRL, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1331 #line 402 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1333 yyval.Initializer = (new BinOpInit(BinOpInit::STRCONCAT, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1337 #line 406 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1339 yyval.StrVal = new std::string();
1343 #line 409 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1345 yyval.StrVal = yyvsp[0].StrVal;
1349 #line 413 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1351 yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
1352 yyval.DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal));
1353 delete yyvsp[0].StrVal;
1357 #line 418 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1359 yyvsp[-3].DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal));
1360 delete yyvsp[0].StrVal;
1361 yyval.DagValueList = yyvsp[-3].DagValueList;
1365 #line 424 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1367 yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
1371 #line 427 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1372 { yyval.DagValueList = yyvsp[0].DagValueList; ;
1375 #line 430 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1377 yyval.BitList = new std::vector<unsigned>();
1378 yyval.BitList->push_back(yyvsp[0].IntVal);
1382 #line 433 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1384 if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1385 err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1388 yyval.BitList = new std::vector<unsigned>();
1389 if (yyvsp[-2].IntVal < yyvsp[0].IntVal) {
1390 for (int i = yyvsp[-2].IntVal; i <= yyvsp[0].IntVal; ++i)
1391 yyval.BitList->push_back(i);
1393 for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1394 yyval.BitList->push_back(i);
1399 #line 446 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1401 yyvsp[0].IntVal = -yyvsp[0].IntVal;
1402 if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) {
1403 err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1406 yyval.BitList = new std::vector<unsigned>();
1407 if (yyvsp[-1].IntVal < yyvsp[0].IntVal) {
1408 for (int i = yyvsp[-1].IntVal; i <= yyvsp[0].IntVal; ++i)
1409 yyval.BitList->push_back(i);
1411 for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1412 yyval.BitList->push_back(i);
1417 #line 460 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1419 (yyval.BitList=yyvsp[-2].BitList)->push_back(yyvsp[0].IntVal);
1423 #line 462 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1425 if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1426 err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1429 yyval.BitList = yyvsp[-4].BitList;
1430 if (yyvsp[-2].IntVal < yyvsp[0].IntVal) {
1431 for (int i = yyvsp[-2].IntVal; i <= yyvsp[0].IntVal; ++i)
1432 yyval.BitList->push_back(i);
1434 for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1435 yyval.BitList->push_back(i);
1440 #line 475 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1442 yyvsp[0].IntVal = -yyvsp[0].IntVal;
1443 if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) {
1444 err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1447 yyval.BitList = yyvsp[-3].BitList;
1448 if (yyvsp[-1].IntVal < yyvsp[0].IntVal) {
1449 for (int i = yyvsp[-1].IntVal; i <= yyvsp[0].IntVal; ++i)
1450 yyval.BitList->push_back(i);
1452 for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1453 yyval.BitList->push_back(i);
1458 #line 491 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1459 { yyval.BitList = yyvsp[0].BitList; std::reverse(yyvsp[0].BitList->begin(), yyvsp[0].BitList->end()); ;
1462 #line 493 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1463 { yyval.BitList = 0; ;
1466 #line 493 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1467 { yyval.BitList = yyvsp[-1].BitList; ;
1470 #line 497 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1472 yyval.FieldList = new std::vector<Init*>();
1476 #line 499 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1478 yyval.FieldList = yyvsp[0].FieldList;
1482 #line 503 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1484 yyval.FieldList = new std::vector<Init*>();
1485 yyval.FieldList->push_back(yyvsp[0].Initializer);
1489 #line 506 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1491 (yyval.FieldList = yyvsp[-2].FieldList)->push_back(yyvsp[0].Initializer);
1495 #line 510 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1497 std::string DecName = *yyvsp[-1].StrVal;
1498 if (ParsingTemplateArgs) {
1500 DecName = CurRec->getName() + ":" + DecName;
1502 assert(CurMultiClass);
1505 DecName = CurMultiClass->Rec.getName() + "::" + DecName;
1508 addValue(RecordVal(DecName, yyvsp[-2].Ty, yyvsp[-3].IntVal));
1509 setValue(DecName, 0, yyvsp[0].Initializer);
1510 yyval.StrVal = new std::string(DecName);
1514 #line 527 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1516 delete yyvsp[-1].StrVal;
1520 #line 529 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1522 setValue(*yyvsp[-4].StrVal, yyvsp[-3].BitList, yyvsp[-1].Initializer);
1523 delete yyvsp[-4].StrVal;
1524 delete yyvsp[-3].BitList;
1528 #line 538 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1530 yyval.SubClassRef = new SubClassRefTy(yyvsp[0].Rec, new std::vector<Init*>());
1534 #line 540 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1536 yyval.SubClassRef = new SubClassRefTy(yyvsp[-3].Rec, yyvsp[-1].FieldList);
1540 #line 544 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1542 yyval.SubClassList = new std::vector<SubClassRefTy>();
1543 yyval.SubClassList->push_back(*yyvsp[0].SubClassRef);
1544 delete yyvsp[0].SubClassRef;
1548 #line 549 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1550 (yyval.SubClassList=yyvsp[-2].SubClassList)->push_back(*yyvsp[0].SubClassRef);
1551 delete yyvsp[0].SubClassRef;
1555 #line 554 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1557 yyval.SubClassList = new std::vector<SubClassRefTy>();
1561 #line 557 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1563 yyval.SubClassList = yyvsp[0].SubClassList;
1567 #line 561 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1569 getActiveRec()->addTemplateArg(*yyvsp[0].StrVal);
1570 delete yyvsp[0].StrVal;
1574 #line 564 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1576 getActiveRec()->addTemplateArg(*yyvsp[0].StrVal);
1577 delete yyvsp[0].StrVal;
1581 #line 569 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1585 #line 572 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1586 { yyval.StrVal = yyvsp[0].StrVal; ;
1589 #line 572 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1590 { yyval.StrVal = new std::string(); ;
1593 #line 574 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1595 static unsigned AnonCounter = 0;
1596 if (yyvsp[0].StrVal->empty())
1597 *yyvsp[0].StrVal = "anonymous."+utostr(AnonCounter++);
1598 yyval.StrVal = yyvsp[0].StrVal;
1602 #line 581 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1604 // If a class of this name already exists, it must be a forward ref.
1605 if ((CurRec = Records.getClass(*yyvsp[0].StrVal))) {
1606 // If the body was previously defined, this is an error.
1607 if (!CurRec->getValues().empty() ||
1608 !CurRec->getSuperClasses().empty() ||
1609 !CurRec->getTemplateArgs().empty()) {
1610 err() << "Class '" << CurRec->getName() << "' already defined!\n";
1614 // If this is the first reference to this class, create and add it.
1615 CurRec = new Record(*yyvsp[0].StrVal);
1616 Records.addClass(CurRec);
1618 delete yyvsp[0].StrVal;
1622 #line 599 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1624 CurRec = new Record(*yyvsp[0].StrVal);
1625 delete yyvsp[0].StrVal;
1627 if (!CurMultiClass) {
1628 // Top-level def definition.
1630 // Ensure redefinition doesn't happen.
1631 if (Records.getDef(CurRec->getName())) {
1632 err() << "def '" << CurRec->getName() << "' already defined!\n";
1635 Records.addDef(CurRec);
1637 // Otherwise, a def inside a multiclass, add it to the multiclass.
1638 for (unsigned i = 0, e = CurMultiClass->DefPrototypes.size(); i != e; ++i)
1639 if (CurMultiClass->DefPrototypes[i]->getName() == CurRec->getName()) {
1640 err() << "def '" << CurRec->getName()
1641 << "' already defined in this multiclass!\n";
1644 CurMultiClass->DefPrototypes.push_back(CurRec);
1649 #line 624 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1651 for (unsigned i = 0, e = yyvsp[0].SubClassList->size(); i != e; ++i) {
1652 addSubClass((*yyvsp[0].SubClassList)[i].first, *(*yyvsp[0].SubClassList)[i].second);
1653 // Delete the template arg values for the class
1654 delete (*yyvsp[0].SubClassList)[i].second;
1656 delete yyvsp[0].SubClassList; // Delete the class list.
1658 // Process any variables on the let stack.
1659 for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
1660 for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
1661 setValue(LetStack[i][j].Name,
1662 LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0,
1663 LetStack[i][j].Value);
1667 #line 638 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1674 #line 643 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1676 ParsingTemplateArgs = true;
1680 #line 645 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1682 ParsingTemplateArgs = false;
1686 #line 647 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1688 yyval.Rec = yyvsp[0].Rec;
1692 #line 651 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1694 if (CurMultiClass == 0) // Def's in multiclasses aren't really defs.
1695 yyvsp[0].Rec->resolveReferences();
1697 // If ObjectBody has template arguments, it's an error.
1698 assert(yyvsp[0].Rec->getTemplateArgs().empty() && "How'd this get template args?");
1699 yyval.Rec = yyvsp[0].Rec;
1703 #line 661 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1705 yyval.Rec = yyvsp[0].Rec;
1706 // Copy the template arguments for the multiclass into the def.
1707 const std::vector<std::string> &TArgs = CurMultiClass->Rec.getTemplateArgs();
1709 for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
1710 const RecordVal *RV = CurMultiClass->Rec.getValue(TArgs[i]);
1711 assert(RV && "Template arg doesn't exist?");
1712 yyval.Rec->addValue(*RV);
1717 #line 675 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1719 yyval.RecList = new std::vector<Record*>();
1720 yyval.RecList->push_back(yyvsp[0].Rec);
1724 #line 678 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1726 yyval.RecList->push_back(yyvsp[0].Rec);
1730 #line 682 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1732 MultiClass *&MCE = MultiClasses[*yyvsp[0].StrVal];
1734 err() << "multiclass '" << *yyvsp[0].StrVal << "' already defined!\n";
1737 MCE = CurMultiClass = new MultiClass(*yyvsp[0].StrVal);
1738 delete yyvsp[0].StrVal;
1742 #line 693 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1744 ParsingTemplateArgs = true;
1748 #line 695 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1750 ParsingTemplateArgs = false;
1754 #line 697 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1760 #line 702 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1761 { CurDefmPrefix = yyvsp[0].StrVal; ;
1764 #line 702 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1766 // To instantiate a multiclass, we need to first get the multiclass, then
1767 // instantiate each def contained in the multiclass with the SubClassRef
1768 // template parameters.
1769 MultiClass *MC = MultiClasses[yyvsp[-1].SubClassRef->first->getName()];
1770 assert(MC && "Didn't lookup multiclass correctly?");
1771 std::vector<Init*> &TemplateVals = *yyvsp[-1].SubClassRef->second;
1772 delete yyvsp[-1].SubClassRef;
1774 // Verify that the correct number of template arguments were specified.
1775 const std::vector<std::string> &TArgs = MC->Rec.getTemplateArgs();
1776 if (TArgs.size() < TemplateVals.size()) {
1777 err() << "ERROR: More template args specified than multiclass expects!\n";
1781 // Loop over all the def's in the multiclass, instantiating each one.
1782 for (unsigned i = 0, e = MC->DefPrototypes.size(); i != e; ++i) {
1783 Record *DefProto = MC->DefPrototypes[i];
1785 // Add the suffix to the defm name to get the new name.
1786 assert(CurRec == 0 && "A def is current?");
1787 CurRec = new Record(*yyvsp[-4].StrVal + DefProto->getName());
1789 addSubClass(DefProto, std::vector<Init*>());
1791 // Loop over all of the template arguments, setting them to the specified
1792 // value or leaving them as the default if necessary.
1793 for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
1794 if (i < TemplateVals.size()) { // A value is specified for this temp-arg?
1796 setValue(TArgs[i], 0, TemplateVals[i]);
1799 CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i]));
1802 CurRec->removeValue(TArgs[i]);
1804 } else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) {
1805 err() << "ERROR: Value not specified for template argument #"
1806 << i << " (" << TArgs[i] << ") of multiclassclass '"
1807 << MC->Rec.getName() << "'!\n";
1812 // If the mdef is inside a 'let' expression, add to each def.
1813 for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
1814 for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
1815 setValue(LetStack[i][j].Name,
1816 LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0,
1817 LetStack[i][j].Value);
1820 // Ensure redefinition doesn't happen.
1821 if (Records.getDef(CurRec->getName())) {
1822 err() << "def '" << CurRec->getName() << "' already defined, "
1823 << "instantiating defm '" << *yyvsp[-4].StrVal << "' with subdef '"
1824 << DefProto->getName() << "'!\n";
1827 Records.addDef(CurRec);
1829 CurRec->resolveReferences();
1834 delete &TemplateVals;
1835 delete yyvsp[-4].StrVal;
1840 #line 776 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1844 #line 776 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1848 #line 779 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1850 LetStack.back().push_back(LetRecord(*yyvsp[-3].StrVal, yyvsp[-2].BitList, yyvsp[0].Initializer));
1851 delete yyvsp[-3].StrVal; delete yyvsp[-2].BitList;
1855 #line 787 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1856 { LetStack.push_back(std::vector<LetRecord>()); ;
1859 #line 790 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1861 LetStack.pop_back();
1865 #line 793 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1867 LetStack.pop_back();
1871 #line 797 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1875 #line 797 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1879 /* the action file gets copied in in place of this dollarsign */
1880 #line 543 "/usr/share/bison.simple"
1891 short *ssp1 = yyss - 1;
1892 fprintf (stderr, "state stack now");
1893 while (ssp1 != yyssp)
1894 fprintf (stderr, " %d", *++ssp1);
1895 fprintf (stderr, "\n");
1905 yylsp->first_line = yylloc.first_line;
1906 yylsp->first_column = yylloc.first_column;
1907 yylsp->last_line = (yylsp-1)->last_line;
1908 yylsp->last_column = (yylsp-1)->last_column;
1913 yylsp->last_line = (yylsp+yylen-1)->last_line;
1914 yylsp->last_column = (yylsp+yylen-1)->last_column;
1918 /* Now "shift" the result of the reduction.
1919 Determine what state that goes to,
1920 based on the state we popped back to
1921 and the rule number reduced by. */
1925 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1926 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1927 yystate = yytable[yystate];
1929 yystate = yydefgoto[yyn - YYNTBASE];
1933 yyerrlab: /* here on detecting error */
1936 /* If not already recovering from an error, report this error. */
1940 #ifdef YYERROR_VERBOSE
1941 yyn = yypact[yystate];
1943 if (yyn > YYFLAG && yyn < YYLAST)
1950 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1951 for (x = (yyn < 0 ? -yyn : 0);
1952 x < (sizeof(yytname) / sizeof(char *)); x++)
1953 if (yycheck[x + yyn] == x)
1954 size += strlen(yytname[x]) + 15, count++;
1955 msg = (char *) malloc(size + 15);
1958 strcpy(msg, "parse error");
1963 for (x = (yyn < 0 ? -yyn : 0);
1964 x < (sizeof(yytname) / sizeof(char *)); x++)
1965 if (yycheck[x + yyn] == x)
1967 strcat(msg, count == 0 ? ", expecting `" : " or `");
1968 strcat(msg, yytname[x]);
1977 yyerror ("parse error; also virtual memory exceeded");
1980 #endif /* YYERROR_VERBOSE */
1981 yyerror("parse error");
1985 yyerrlab1: /* here on error raised explicitly by an action */
1987 if (yyerrstatus == 3)
1989 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1991 /* return failure if at end of input */
1992 if (yychar == YYEOF)
1997 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
2003 /* Else will try to reuse lookahead token
2004 after shifting the error token. */
2006 yyerrstatus = 3; /* Each real token shifted decrements this */
2010 yyerrdefault: /* current state does not do anything special for the error token. */
2013 /* This is wrong; only states that explicitly want error tokens
2014 should shift them. */
2015 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
2016 if (yyn) goto yydefault;
2019 yyerrpop: /* pop the current state because it cannot handle the error token */
2021 if (yyssp == yyss) YYABORT;
2031 short *ssp1 = yyss - 1;
2032 fprintf (stderr, "Error: state stack now");
2033 while (ssp1 != yyssp)
2034 fprintf (stderr, " %d", *++ssp1);
2035 fprintf (stderr, "\n");
2041 yyn = yypact[yystate];
2046 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
2065 fprintf(stderr, "Shifting error token, ");
2077 /* YYACCEPT comes here. */
2089 /* YYABORT comes here. */
2100 #line 801 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
2103 int yyerror(const char *ErrorMsg) {
2104 err() << "Error parsing: " << ErrorMsg << "\n";