Add support for immediates directly in the pattern, this allows itanium to
[oota-llvm.git] / utils / TableGen / FileParser.cpp
1
2 /*  A Bison parser, made from /Users/sabre/llvm/utils/TableGen/FileParser.y
3     by GNU Bison version 1.28  */
4
5 #define YYBISON 1  /* Identify Bison output.  */
6
7 #define yyparse Fileparse
8 #define yylex Filelex
9 #define yyerror Fileerror
10 #define yylval Filelval
11 #define yychar Filechar
12 #define yydebug Filedebug
13 #define yynerrs Filenerrs
14 #define INT     257
15 #define BIT     258
16 #define STRING  259
17 #define BITS    260
18 #define LIST    261
19 #define CODE    262
20 #define DAG     263
21 #define CLASS   264
22 #define DEF     265
23 #define FIELD   266
24 #define LET     267
25 #define IN      268
26 #define SHLTOK  269
27 #define SRATOK  270
28 #define SRLTOK  271
29 #define INTVAL  272
30 #define ID      273
31 #define VARNAME 274
32 #define STRVAL  275
33 #define CODEFRAGMENT    276
34
35 #line 14 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
36
37 #include "Record.h"
38 #include "llvm/ADT/StringExtras.h"
39 #include <algorithm>
40 #include <cstdio>
41 #define YYERROR_VERBOSE 1
42
43 int yyerror(const char *ErrorMsg);
44 int yylex();
45
46 namespace llvm {
47
48 extern int Filelineno;
49 static Record *CurRec = 0;
50 static bool ParsingTemplateArgs = false;
51
52 typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
53
54 struct LetRecord {
55   std::string Name;
56   std::vector<unsigned> Bits;
57   Init *Value;
58   bool HasBits;
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;
62   }
63 };
64
65 static std::vector<std::vector<LetRecord> > LetStack;
66
67
68 extern std::ostream &err();
69
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";
77       exit(1);
78     }
79   } else {
80     CurRec->addValue(RV);
81   }
82 }
83
84 static void addSuperClass(Record *SC) {
85   if (CurRec->isSubClassOf(SC)) {
86     err() << "Already subclass of '" << SC->getName() << "'!\n";
87     exit(1);
88   }
89   CurRec->addSuperClass(SC);
90 }
91
92 static void setValue(const std::string &ValName, 
93                      std::vector<unsigned> *BitList, Init *V) {
94   if (!V) return;
95
96   RecordVal *RV = CurRec->getValue(ValName);
97   if (RV == 0) {
98     err() << "Value '" << ValName << "' unknown!\n";
99     exit(1);
100   }
101
102   // Do not allow assignments like 'X = X'.  This will just cause infinite loops
103   // in the resolution machinery.
104   if (!BitList)
105     if (VarInit *VI = dynamic_cast<VarInit*>(V))
106       if (VI->getName() == ValName)
107         return;
108   
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
111   // initializer...
112   //
113   if (BitList) {
114     BitsInit *CurVal = dynamic_cast<BitsInit*>(RV->getValue());
115     if (CurVal == 0) {
116       err() << "Value '" << ValName << "' is not a bits type!\n";
117       exit(1);
118     }
119
120     // Convert the incoming value to a bits type of the appropriate size...
121     Init *BI = V->convertInitializerTo(new BitsRecTy(BitList->size()));
122     if (BI == 0) {
123       V->convertInitializerTo(new BitsRecTy(BitList->size()));
124       err() << "Initializer '" << *V << "' not compatible with bit range!\n";
125       exit(1);
126     }
127
128     // We should have a BitsInit type now...
129     assert(dynamic_cast<BitsInit*>(BI) != 0 || &(std::cerr << *BI) == 0);
130     BitsInit *BInit = (BitsInit*)BI;
131
132     BitsInit *NewVal = new BitsInit(CurVal->getNumBits());
133
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";
140         exit(1);
141       }
142       NewVal->setBit(Bit, BInit->getBit(i));
143     }
144
145     for (unsigned i = 0, e = CurVal->getNumBits(); i != e; ++i)
146       if (NewVal->getBit(i) == 0)
147         NewVal->setBit(i, CurVal->getBit(i));
148
149     V = NewVal;
150   }
151
152   if (RV->setValue(V)) {
153     err() << "Value '" << ValName << "' of type '" << *RV->getType()
154           << "' is incompatible with initializer '" << *V << "'!\n";
155     exit(1);
156   }
157 }
158
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)
165     addValue(Vals[i]);
166
167   const std::vector<std::string> &TArgs = SC->getTemplateArgs();
168
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";
172     exit(1);
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?
178         // Set it now.
179         setValue(TArgs[i], 0, TemplateArgs[i]);
180
181         // Resolve it next.
182         CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i]));
183                                     
184         
185         // Now remove it.
186         CurRec->removeValue(TArgs[i]);
187
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()
191               << "'!\n";
192         exit(1);
193       }
194     }
195   }
196
197   // Since everything went well, we can now set the "superclass" list for the
198   // current record.
199   const std::vector<Record*> &SCs  = SC->getSuperClasses();
200   for (unsigned i = 0, e = SCs.size(); i != e; ++i)
201     addSuperClass(SCs[i]);
202   addSuperClass(SC);
203 }
204
205 } // End llvm namespace
206
207 using namespace llvm;
208
209
210 #line 189 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
211 typedef union {
212   std::string*                StrVal;
213   int                         IntVal;
214   llvm::RecTy*                Ty;
215   llvm::Init*                 Initializer;
216   std::vector<llvm::Init*>*   FieldList;
217   std::vector<unsigned>*      BitList;
218   llvm::Record*               Rec;
219   SubClassRefTy*              SubClassRef;
220   std::vector<SubClassRefTy>* SubClassList;
221   std::vector<std::pair<llvm::Init*, std::string> >* DagValueList;
222 } YYSTYPE;
223 #include <stdio.h>
224
225 #ifndef __cplusplus
226 #ifndef __STDC__
227 #define const
228 #endif
229 #endif
230
231
232
233 #define YYFINAL         160
234 #define YYFLAG          -32768
235 #define YYNTBASE        38
236
237 #define YYTRANSLATE(x) ((unsigned)(x) <= 276 ? yytranslate[x] : 78)
238
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
268 };
269
270 #if YYDEBUG != 0
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
281 };
282
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,
310      0,    76,    71,     0,    76,     0
311 };
312
313 #endif
314
315 #if YYDEBUG != 0
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
326 };
327 #endif
328
329
330 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
331
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
342 };
343 #endif
344
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
355 };
356
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
367 };
368
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
386 };
387
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
393 };
394
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
412 };
413
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
419 };
420
421
422 #define YYLAST          166
423
424
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,
442      0,     0,    80,     0,     0,    66
443 };
444
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
463 };
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.  */
467
468 /* Skeleton output parser for bison,
469    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
470
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)
474    any later version.
475
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.
480
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.  */
485
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.  */
490
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.  */
495
496 #ifndef YYSTACK_USE_ALLOCA
497 #ifdef alloca
498 #define YYSTACK_USE_ALLOCA
499 #else /* alloca not defined */
500 #ifdef __GNUC__
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
506 #include <alloca.h>
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.  */
514 #include <malloc.h>
515 #endif
516 #else /* not MSDOS, or __TURBOC__ */
517 #if defined(_AIX)
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>  */
521  #pragma alloca
522 #define YYSTACK_USE_ALLOCA
523 #else /* not MSDOS, or __TURBOC__, or _AIX */
524 #if 0
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
529 #endif /* __hpux */
530 #endif
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 */
537
538 #ifdef YYSTACK_USE_ALLOCA
539 #define YYSTACK_ALLOC alloca
540 #else
541 #define YYSTACK_ALLOC malloc
542 #endif
543
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.  */
547
548 #define yyerrok         (yyerrstatus = 0)
549 #define yyclearin       (yychar = YYEMPTY)
550 #define YYEMPTY         -2
551 #define YYEOF           0
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) \
562 do                                                              \
563   if (yychar == YYEMPTY && yylen == 1)                          \
564     { yychar = (token), yylval = (value);                       \
565       yychar1 = YYTRANSLATE (yychar);                           \
566       YYPOPSTACK;                                               \
567       goto yybackup;                                            \
568     }                                                           \
569   else                                                          \
570     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
571 while (0)
572
573 #define YYTERROR        1
574 #define YYERRCODE       256
575
576 #ifndef YYPURE
577 #define YYLEX           yylex()
578 #endif
579
580 #ifdef YYPURE
581 #ifdef YYLSP_NEEDED
582 #ifdef YYLEX_PARAM
583 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
584 #else
585 #define YYLEX           yylex(&yylval, &yylloc)
586 #endif
587 #else /* not YYLSP_NEEDED */
588 #ifdef YYLEX_PARAM
589 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
590 #else
591 #define YYLEX           yylex(&yylval)
592 #endif
593 #endif /* not YYLSP_NEEDED */
594 #endif
595
596 /* If nonreentrant, generate the variables here */
597
598 #ifndef YYPURE
599
600 int     yychar;                 /*  the lookahead symbol                */
601 YYSTYPE yylval;                 /*  the semantic value of the           */
602                                 /*  lookahead symbol                    */
603
604 #ifdef YYLSP_NEEDED
605 YYLTYPE yylloc;                 /*  location data for the lookahead     */
606                                 /*  symbol                              */
607 #endif
608
609 int yynerrs;                    /*  number of parse errors so far       */
610 #endif  /* not YYPURE */
611
612 #if YYDEBUG != 0
613 int yydebug;                    /*  nonzero means print parse trace     */
614 /* Since this is uninitialized, it does not stop multiple parsers
615    from coexisting.  */
616 #endif
617
618 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
619
620 #ifndef YYINITDEPTH
621 #define YYINITDEPTH 200
622 #endif
623
624 /*  YYMAXDEPTH is the maximum size the stacks can grow to
625     (effective only if the built-in stack extension method is used).  */
626
627 #if YYMAXDEPTH == 0
628 #undef YYMAXDEPTH
629 #endif
630
631 #ifndef YYMAXDEPTH
632 #define YYMAXDEPTH 10000
633 #endif
634 \f
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.  */
639
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++ */
643 #ifndef __cplusplus
644
645 /* This is the most reliable way to avoid incompatibilities
646    in available built-in functions on various systems.  */
647 static void
648 __yy_memcpy (to, from, count)
649      char *to;
650      char *from;
651      unsigned int count;
652 {
653   register char *f = from;
654   register char *t = to;
655   register int i = count;
656
657   while (i-- > 0)
658     *t++ = *f++;
659 }
660
661 #else /* __cplusplus */
662
663 /* This is the most reliable way to avoid incompatibilities
664    in available built-in functions on various systems.  */
665 static void
666 __yy_memcpy (char *to, char *from, unsigned int count)
667 {
668   register char *t = to;
669   register char *f = from;
670   register int i = count;
671
672   while (i-- > 0)
673     *t++ = *f++;
674 }
675
676 #endif
677 #endif
678 \f
679 #line 217 "/usr/share/bison.simple"
680
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.  */
686
687 #ifdef YYPARSE_PARAM
688 #ifdef __cplusplus
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 */
699
700 /* Prevent warning if -Wstrict-prototypes.  */
701 #ifdef __GNUC__
702 #ifdef YYPARSE_PARAM
703 int yyparse (void *);
704 #else
705 int yyparse (void);
706 #endif
707 #endif
708
709 int
710 yyparse(YYPARSE_PARAM_ARG)
711      YYPARSE_PARAM_DECL
712 {
713   register int yystate;
714   register int yyn;
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 */
719
720   short yyssa[YYINITDEPTH];     /*  the state stack                     */
721   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
722
723   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
724   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
725
726 #ifdef YYLSP_NEEDED
727   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
728   YYLTYPE *yyls = yylsa;
729   YYLTYPE *yylsp;
730
731 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
732 #else
733 #define YYPOPSTACK   (yyvsp--, yyssp--)
734 #endif
735
736   int yystacksize = YYINITDEPTH;
737   int yyfree_stacks = 0;
738
739 #ifdef YYPURE
740   int yychar;
741   YYSTYPE yylval;
742   int yynerrs;
743 #ifdef YYLSP_NEEDED
744   YYLTYPE yylloc;
745 #endif
746 #endif
747
748   YYSTYPE yyval;                /*  the variable used to return         */
749                                 /*  semantic values from the action     */
750                                 /*  routines                            */
751
752   int yylen;
753
754 #if YYDEBUG != 0
755   if (yydebug)
756     fprintf(stderr, "Starting parse\n");
757 #endif
758
759   yystate = 0;
760   yyerrstatus = 0;
761   yynerrs = 0;
762   yychar = YYEMPTY;             /* Cause a token to be read.  */
763
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.  */
768
769   yyssp = yyss - 1;
770   yyvsp = yyvs;
771 #ifdef YYLSP_NEEDED
772   yylsp = yyls;
773 #endif
774
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.  */
778 yynewstate:
779
780   *++yyssp = yystate;
781
782   if (yyssp >= yyss + yystacksize - 1)
783     {
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;
787       short *yyss1 = yyss;
788 #ifdef YYLSP_NEEDED
789       YYLTYPE *yyls1 = yyls;
790 #endif
791
792       /* Get the current used size of the three stacks, in elements.  */
793       int size = yyssp - yyss + 1;
794
795 #ifdef yyoverflow
796       /* Each stack pointer address is followed by the size of
797          the data in use in that stack, in bytes.  */
798 #ifdef YYLSP_NEEDED
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),
805                  &yystacksize);
806 #else
807       yyoverflow("parser stack overflow",
808                  &yyss1, size * sizeof (*yyssp),
809                  &yyvs1, size * sizeof (*yyvsp),
810                  &yystacksize);
811 #endif
812
813       yyss = yyss1; yyvs = yyvs1;
814 #ifdef YYLSP_NEEDED
815       yyls = yyls1;
816 #endif
817 #else /* no yyoverflow */
818       /* Extend the stack our own way.  */
819       if (yystacksize >= YYMAXDEPTH)
820         {
821           yyerror("parser stack overflow");
822           if (yyfree_stacks)
823             {
824               free (yyss);
825               free (yyvs);
826 #ifdef YYLSP_NEEDED
827               free (yyls);
828 #endif
829             }
830           return 2;
831         }
832       yystacksize *= 2;
833       if (yystacksize > YYMAXDEPTH)
834         yystacksize = YYMAXDEPTH;
835 #ifndef YYSTACK_USE_ALLOCA
836       yyfree_stacks = 1;
837 #endif
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));
844 #ifdef YYLSP_NEEDED
845       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
846       __yy_memcpy ((char *)yyls, (char *)yyls1,
847                    size * (unsigned int) sizeof (*yylsp));
848 #endif
849 #endif /* no yyoverflow */
850
851       yyssp = yyss + size - 1;
852       yyvsp = yyvs + size - 1;
853 #ifdef YYLSP_NEEDED
854       yylsp = yyls + size - 1;
855 #endif
856
857 #if YYDEBUG != 0
858       if (yydebug)
859         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
860 #endif
861
862       if (yyssp >= yyss + yystacksize - 1)
863         YYABORT;
864     }
865
866 #if YYDEBUG != 0
867   if (yydebug)
868     fprintf(stderr, "Entering state %d\n", yystate);
869 #endif
870
871   goto yybackup;
872  yybackup:
873
874 /* Do appropriate processing given the current state.  */
875 /* Read a lookahead token if we need one and don't already have one.  */
876 /* yyresume: */
877
878   /* First try to decide what to do without reference to lookahead token.  */
879
880   yyn = yypact[yystate];
881   if (yyn == YYFLAG)
882     goto yydefault;
883
884   /* Not known => get a lookahead token if don't already have one.  */
885
886   /* yychar is either YYEMPTY or YYEOF
887      or a valid token in external form.  */
888
889   if (yychar == YYEMPTY)
890     {
891 #if YYDEBUG != 0
892       if (yydebug)
893         fprintf(stderr, "Reading a token: ");
894 #endif
895       yychar = YYLEX;
896     }
897
898   /* Convert token to internal form (in yychar1) for indexing tables with */
899
900   if (yychar <= 0)              /* This means end of input. */
901     {
902       yychar1 = 0;
903       yychar = YYEOF;           /* Don't call YYLEX any more */
904
905 #if YYDEBUG != 0
906       if (yydebug)
907         fprintf(stderr, "Now at end of input.\n");
908 #endif
909     }
910   else
911     {
912       yychar1 = YYTRANSLATE(yychar);
913
914 #if YYDEBUG != 0
915       if (yydebug)
916         {
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.  */
920 #ifdef YYPRINT
921           YYPRINT (stderr, yychar, yylval);
922 #endif
923           fprintf (stderr, ")\n");
924         }
925 #endif
926     }
927
928   yyn += yychar1;
929   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
930     goto yydefault;
931
932   yyn = yytable[yyn];
933
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,
938        just return success.
939      0, or most negative number => error.  */
940
941   if (yyn < 0)
942     {
943       if (yyn == YYFLAG)
944         goto yyerrlab;
945       yyn = -yyn;
946       goto yyreduce;
947     }
948   else if (yyn == 0)
949     goto yyerrlab;
950
951   if (yyn == YYFINAL)
952     YYACCEPT;
953
954   /* Shift the lookahead token.  */
955
956 #if YYDEBUG != 0
957   if (yydebug)
958     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
959 #endif
960
961   /* Discard the token being shifted unless it is eof.  */
962   if (yychar != YYEOF)
963     yychar = YYEMPTY;
964
965   *++yyvsp = yylval;
966 #ifdef YYLSP_NEEDED
967   *++yylsp = yylloc;
968 #endif
969
970   /* count tokens shifted since error; after three, turn off error status.  */
971   if (yyerrstatus) yyerrstatus--;
972
973   yystate = yyn;
974   goto yynewstate;
975
976 /* Do the default action for the current state.  */
977 yydefault:
978
979   yyn = yydefact[yystate];
980   if (yyn == 0)
981     goto yyerrlab;
982
983 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
984 yyreduce:
985   yylen = yyr2[yyn];
986   if (yylen > 0)
987     yyval = yyvsp[1-yylen]; /* implement default value of the action */
988
989 #if YYDEBUG != 0
990   if (yydebug)
991     {
992       int i;
993
994       fprintf (stderr, "Reducing via rule %d (line %d), ",
995                yyn, yyrline[yyn]);
996
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]]);
1001     }
1002 #endif
1003
1004
1005   switch (yyn) {
1006
1007 case 1:
1008 #line 223 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1009 {
1010     yyval.Rec = Records.getClass(*yyvsp[0].StrVal);
1011     if (yyval.Rec == 0) {
1012       err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n";
1013       exit(1);
1014     }
1015     delete yyvsp[0].StrVal;
1016   ;
1017     break;}
1018 case 2:
1019 #line 234 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1020 {                       // string type
1021     yyval.Ty = new StringRecTy();
1022   ;
1023     break;}
1024 case 3:
1025 #line 236 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1026 {                           // bit type
1027     yyval.Ty = new BitRecTy();
1028   ;
1029     break;}
1030 case 4:
1031 #line 238 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1032 {           // bits<x> type
1033     yyval.Ty = new BitsRecTy(yyvsp[-1].IntVal);
1034   ;
1035     break;}
1036 case 5:
1037 #line 240 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1038 {                           // int type
1039     yyval.Ty = new IntRecTy();
1040   ;
1041     break;}
1042 case 6:
1043 #line 242 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1044 {          // list<x> type
1045     yyval.Ty = new ListRecTy(yyvsp[-1].Ty);
1046   ;
1047     break;}
1048 case 7:
1049 #line 244 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1050 {                          // code type
1051     yyval.Ty = new CodeRecTy();
1052   ;
1053     break;}
1054 case 8:
1055 #line 246 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1056 {                           // dag type
1057     yyval.Ty = new DagRecTy();
1058   ;
1059     break;}
1060 case 9:
1061 #line 248 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1062 {                       // Record Type
1063     yyval.Ty = new RecordRecTy(yyvsp[0].Rec);
1064   ;
1065     break;}
1066 case 10:
1067 #line 252 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1068 { yyval.IntVal = 0; ;
1069     break;}
1070 case 11:
1071 #line 252 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1072 { yyval.IntVal = 1; ;
1073     break;}
1074 case 12:
1075 #line 254 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1076 { yyval.Initializer = 0; ;
1077     break;}
1078 case 13:
1079 #line 254 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1080 { yyval.Initializer = yyvsp[0].Initializer; ;
1081     break;}
1082 case 14:
1083 #line 256 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1084 {
1085     yyval.Initializer = new IntInit(yyvsp[0].IntVal);
1086   ;
1087     break;}
1088 case 15:
1089 #line 258 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1090 {
1091     yyval.Initializer = new StringInit(*yyvsp[0].StrVal);
1092     delete yyvsp[0].StrVal;
1093   ;
1094     break;}
1095 case 16:
1096 #line 261 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1097 {
1098     yyval.Initializer = new CodeInit(*yyvsp[0].StrVal);
1099     delete yyvsp[0].StrVal;
1100   ;
1101     break;}
1102 case 17:
1103 #line 264 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1104 {
1105     yyval.Initializer = new UnsetInit();
1106   ;
1107     break;}
1108 case 18:
1109 #line 266 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1110 {
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());
1114       if (Bit == 0) {
1115         err() << "Element #" << i << " (" << *(*yyvsp[-1].FieldList)[i]
1116               << ") is not convertable to a bit!\n";
1117         exit(1);
1118       }
1119       Init->setBit(yyvsp[-1].FieldList->size()-i-1, Bit);
1120     }
1121     yyval.Initializer = Init;
1122     delete yyvsp[-1].FieldList;
1123   ;
1124     break;}
1125 case 19:
1126 #line 279 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1127 {
1128     // This is a CLASS<initvalslist> expression.  This is supposed to synthesize
1129     // a new anonymous definition, deriving from CLASS<initvalslist> with no
1130     // body.
1131     Record *Class = Records.getClass(*yyvsp[-3].StrVal);
1132     if (!Class) {
1133       err() << "Expected a class, got '" << *yyvsp[-3].StrVal << "'!\n";
1134       exit(1);
1135     }
1136     delete yyvsp[-3].StrVal;
1137     
1138     static unsigned AnonCounter = 0;
1139     Record *OldRec = CurRec;  // Save CurRec.
1140     
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.
1145     
1146     CurRec->resolveReferences();
1147     
1148     Records.addDef(CurRec);
1149     
1150     // The result of the expression is a reference to the new record.
1151     yyval.Initializer = new DefInit(CurRec);
1152     
1153     // Restore the old CurRec
1154     CurRec = OldRec;
1155   ;
1156     break;}
1157 case 20:
1158 #line 307 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1159 {
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);
1168     } else {
1169       err() << "Variable not defined: '" << *yyvsp[0].StrVal << "'!\n";
1170       exit(1);
1171     }
1172     
1173     delete yyvsp[0].StrVal;
1174   ;
1175     break;}
1176 case 21:
1177 #line 322 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1178 {
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";
1182       exit(1);
1183     }
1184     delete yyvsp[-1].BitList;
1185   ;
1186     break;}
1187 case 22:
1188 #line 329 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1189 {
1190     yyval.Initializer = new ListInit(*yyvsp[-1].FieldList);
1191     delete yyvsp[-1].FieldList;
1192   ;
1193     break;}
1194 case 23:
1195 #line 332 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1196 {
1197     if (!yyvsp[-2].Initializer->getFieldType(*yyvsp[0].StrVal)) {
1198       err() << "Cannot access field '" << *yyvsp[0].StrVal << "' of value '" << *yyvsp[-2].Initializer << "!\n";
1199       exit(1);
1200     }
1201     yyval.Initializer = new FieldInit(yyvsp[-2].Initializer, *yyvsp[0].StrVal);
1202     delete yyvsp[0].StrVal;
1203   ;
1204     break;}
1205 case 24:
1206 #line 339 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1207 {
1208     Record *D = Records.getDef(*yyvsp[-2].StrVal);
1209     if (D == 0) {
1210       err() << "Invalid def '" << *yyvsp[-2].StrVal << "'!\n";
1211       exit(1);
1212     }
1213     yyval.Initializer = new DagInit(D, *yyvsp[-1].DagValueList);
1214     delete yyvsp[-2].StrVal; delete yyvsp[-1].DagValueList;
1215   ;
1216     break;}
1217 case 25:
1218 #line 347 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1219 {
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";
1224       exit(1);
1225     }
1226     delete yyvsp[-1].BitList;
1227   ;
1228     break;}
1229 case 26:
1230 #line 355 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1231 {
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";
1235       exit(1);
1236     }
1237   ;
1238     break;}
1239 case 27:
1240 #line 361 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1241 {
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";
1245       exit(1);
1246     }
1247   ;
1248     break;}
1249 case 28:
1250 #line 367 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1251 {
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";
1255       exit(1);
1256     }
1257   ;
1258     break;}
1259 case 29:
1260 #line 375 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1261 {
1262     yyval.StrVal = new std::string();
1263   ;
1264     break;}
1265 case 30:
1266 #line 378 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1267 {
1268     yyval.StrVal = yyvsp[0].StrVal;
1269   ;
1270     break;}
1271 case 31:
1272 #line 382 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1273 {
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;
1277   ;
1278     break;}
1279 case 32:
1280 #line 387 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1281 {
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;
1285   ;
1286     break;}
1287 case 33:
1288 #line 393 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1289 {
1290     yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
1291   ;
1292     break;}
1293 case 34:
1294 #line 396 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1295 { yyval.DagValueList = yyvsp[0].DagValueList; ;
1296     break;}
1297 case 35:
1298 #line 399 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1299 {
1300     yyval.BitList = new std::vector<unsigned>();
1301     yyval.BitList->push_back(yyvsp[0].IntVal);
1302   ;
1303     break;}
1304 case 36:
1305 #line 402 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1306 {
1307     if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1308       err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1309       exit(1);
1310     }
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);
1315     } else {
1316       for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1317         yyval.BitList->push_back(i);
1318     }
1319   ;
1320     break;}
1321 case 37:
1322 #line 415 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1323 {
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";
1327       exit(1);
1328     }
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);
1333     } else {
1334       for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1335         yyval.BitList->push_back(i);
1336     }
1337   ;
1338     break;}
1339 case 38:
1340 #line 429 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1341 {
1342     (yyval.BitList=yyvsp[-2].BitList)->push_back(yyvsp[0].IntVal);
1343   ;
1344     break;}
1345 case 39:
1346 #line 431 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1347 {
1348     if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1349       err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1350       exit(1);
1351     }
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);
1356     } else {
1357       for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1358         yyval.BitList->push_back(i);
1359     }
1360   ;
1361     break;}
1362 case 40:
1363 #line 444 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1364 {
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";
1368       exit(1);
1369     }
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);
1374     } else {
1375       for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1376         yyval.BitList->push_back(i);
1377     }
1378   ;
1379     break;}
1380 case 41:
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()); ;
1383     break;}
1384 case 42:
1385 #line 462 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1386 { yyval.BitList = 0; ;
1387     break;}
1388 case 43:
1389 #line 462 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1390 { yyval.BitList = yyvsp[-1].BitList; ;
1391     break;}
1392 case 44:
1393 #line 466 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1394 {
1395     yyval.FieldList = new std::vector<Init*>();
1396   ;
1397     break;}
1398 case 45:
1399 #line 468 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1400 {
1401     yyval.FieldList = yyvsp[0].FieldList;
1402   ;
1403     break;}
1404 case 46:
1405 #line 472 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1406 {
1407     yyval.FieldList = new std::vector<Init*>();
1408     yyval.FieldList->push_back(yyvsp[0].Initializer);
1409   ;
1410     break;}
1411 case 47:
1412 #line 475 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1413 {
1414     (yyval.FieldList = yyvsp[-2].FieldList)->push_back(yyvsp[0].Initializer);
1415   ;
1416     break;}
1417 case 48:
1418 #line 479 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1419 {
1420   std::string DecName = *yyvsp[-1].StrVal;
1421   if (ParsingTemplateArgs)
1422     DecName = CurRec->getName() + ":" + DecName;
1423
1424   addValue(RecordVal(DecName, yyvsp[-2].Ty, yyvsp[-3].IntVal));
1425   setValue(DecName, 0, yyvsp[0].Initializer);
1426   yyval.StrVal = new std::string(DecName);
1427 ;
1428     break;}
1429 case 49:
1430 #line 489 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1431 {
1432   delete yyvsp[-1].StrVal;
1433 ;
1434     break;}
1435 case 50:
1436 #line 491 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1437 {
1438   setValue(*yyvsp[-4].StrVal, yyvsp[-3].BitList, yyvsp[-1].Initializer);
1439   delete yyvsp[-4].StrVal;
1440   delete yyvsp[-3].BitList;
1441 ;
1442     break;}
1443 case 55:
1444 #line 500 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1445 {
1446     yyval.SubClassRef = new SubClassRefTy(yyvsp[0].Rec, new std::vector<Init*>());
1447   ;
1448     break;}
1449 case 56:
1450 #line 502 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1451 {
1452     yyval.SubClassRef = new SubClassRefTy(yyvsp[-3].Rec, yyvsp[-1].FieldList);
1453   ;
1454     break;}
1455 case 57:
1456 #line 506 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1457 {
1458     yyval.SubClassList = new std::vector<SubClassRefTy>();
1459     yyval.SubClassList->push_back(*yyvsp[0].SubClassRef);
1460     delete yyvsp[0].SubClassRef;
1461   ;
1462     break;}
1463 case 58:
1464 #line 511 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1465 {
1466     (yyval.SubClassList=yyvsp[-2].SubClassList)->push_back(*yyvsp[0].SubClassRef);
1467     delete yyvsp[0].SubClassRef;
1468   ;
1469     break;}
1470 case 59:
1471 #line 516 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1472 {
1473     yyval.SubClassList = new std::vector<SubClassRefTy>();
1474   ;
1475     break;}
1476 case 60:
1477 #line 519 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1478 {
1479     yyval.SubClassList = yyvsp[0].SubClassList;
1480   ;
1481     break;}
1482 case 61:
1483 #line 523 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1484 {
1485   CurRec->addTemplateArg(*yyvsp[0].StrVal);
1486   delete yyvsp[0].StrVal;
1487 ;
1488     break;}
1489 case 62:
1490 #line 526 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1491 {
1492   CurRec->addTemplateArg(*yyvsp[0].StrVal);
1493   delete yyvsp[0].StrVal;
1494 ;
1495     break;}
1496 case 63:
1497 #line 531 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1498 {;
1499     break;}
1500 case 66:
1501 #line 534 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1502 { yyval.StrVal = yyvsp[0].StrVal; ;
1503     break;}
1504 case 67:
1505 #line 534 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1506 { yyval.StrVal = new std::string(); ;
1507     break;}
1508 case 68:
1509 #line 536 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1510 {
1511   static unsigned AnonCounter = 0;
1512   if (yyvsp[0].StrVal->empty())
1513     *yyvsp[0].StrVal = "anonymous."+utostr(AnonCounter++);
1514   yyval.StrVal = yyvsp[0].StrVal;
1515 ;
1516     break;}
1517 case 69:
1518 #line 543 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1519 {
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";
1527       exit(1);
1528     }
1529   } else {
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);
1533   }
1534   delete yyvsp[0].StrVal;
1535 ;
1536     break;}
1537 case 70:
1538 #line 561 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1539 {
1540   CurRec = new Record(*yyvsp[0].StrVal);
1541   delete yyvsp[0].StrVal;
1542   
1543   // Ensure redefinition doesn't happen.
1544   if (Records.getDef(CurRec->getName())) {
1545     err() << "Def '" << CurRec->getName() << "' already defined!\n";
1546     exit(1);
1547   }
1548   Records.addDef(CurRec);
1549 ;
1550     break;}
1551 case 71:
1552 #line 573 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1553 {
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;
1558            }
1559            delete yyvsp[0].SubClassList;   // Delete the class list...
1560   
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);
1567          ;
1568     break;}
1569 case 72:
1570 #line 587 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1571 {
1572            yyval.Rec = CurRec;
1573            CurRec = 0;
1574          ;
1575     break;}
1576 case 73:
1577 #line 592 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1578 {
1579                 ParsingTemplateArgs = true;
1580             ;
1581     break;}
1582 case 74:
1583 #line 594 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1584 {
1585                 ParsingTemplateArgs = false;
1586             ;
1587     break;}
1588 case 75:
1589 #line 596 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1590 {
1591         yyval.Rec = yyvsp[0].Rec;
1592      ;
1593     break;}
1594 case 76:
1595 #line 600 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1596 {
1597   yyvsp[0].Rec->resolveReferences();
1598
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;
1602 ;
1603     break;}
1604 case 79:
1605 #line 611 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1606 {
1607   LetStack.back().push_back(LetRecord(*yyvsp[-3].StrVal, yyvsp[-2].BitList, yyvsp[0].Initializer));
1608   delete yyvsp[-3].StrVal; delete yyvsp[-2].BitList;
1609 ;
1610     break;}
1611 case 82:
1612 #line 619 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1613 { LetStack.push_back(std::vector<LetRecord>()); ;
1614     break;}
1615 case 84:
1616 #line 622 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1617 {
1618     LetStack.pop_back();
1619   ;
1620     break;}
1621 case 85:
1622 #line 625 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1623 {
1624     LetStack.pop_back();
1625   ;
1626     break;}
1627 case 86:
1628 #line 629 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1629 {;
1630     break;}
1631 case 87:
1632 #line 629 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1633 {;
1634     break;}
1635 case 88:
1636 #line 631 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1637 {;
1638     break;}
1639 }
1640    /* the action file gets copied in in place of this dollarsign */
1641 #line 543 "/usr/share/bison.simple"
1642 \f
1643   yyvsp -= yylen;
1644   yyssp -= yylen;
1645 #ifdef YYLSP_NEEDED
1646   yylsp -= yylen;
1647 #endif
1648
1649 #if YYDEBUG != 0
1650   if (yydebug)
1651     {
1652       short *ssp1 = yyss - 1;
1653       fprintf (stderr, "state stack now");
1654       while (ssp1 != yyssp)
1655         fprintf (stderr, " %d", *++ssp1);
1656       fprintf (stderr, "\n");
1657     }
1658 #endif
1659
1660   *++yyvsp = yyval;
1661
1662 #ifdef YYLSP_NEEDED
1663   yylsp++;
1664   if (yylen == 0)
1665     {
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;
1670       yylsp->text = 0;
1671     }
1672   else
1673     {
1674       yylsp->last_line = (yylsp+yylen-1)->last_line;
1675       yylsp->last_column = (yylsp+yylen-1)->last_column;
1676     }
1677 #endif
1678
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.  */
1683
1684   yyn = yyr1[yyn];
1685
1686   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1687   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1688     yystate = yytable[yystate];
1689   else
1690     yystate = yydefgoto[yyn - YYNTBASE];
1691
1692   goto yynewstate;
1693
1694 yyerrlab:   /* here on detecting error */
1695
1696   if (! yyerrstatus)
1697     /* If not already recovering from an error, report this error.  */
1698     {
1699       ++yynerrs;
1700
1701 #ifdef YYERROR_VERBOSE
1702       yyn = yypact[yystate];
1703
1704       if (yyn > YYFLAG && yyn < YYLAST)
1705         {
1706           int size = 0;
1707           char *msg;
1708           int x, count;
1709
1710           count = 0;
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);
1717           if (msg != 0)
1718             {
1719               strcpy(msg, "parse error");
1720
1721               if (count < 5)
1722                 {
1723                   count = 0;
1724                   for (x = (yyn < 0 ? -yyn : 0);
1725                        x < (sizeof(yytname) / sizeof(char *)); x++)
1726                     if (yycheck[x + yyn] == x)
1727                       {
1728                         strcat(msg, count == 0 ? ", expecting `" : " or `");
1729                         strcat(msg, yytname[x]);
1730                         strcat(msg, "'");
1731                         count++;
1732                       }
1733                 }
1734               yyerror(msg);
1735               free(msg);
1736             }
1737           else
1738             yyerror ("parse error; also virtual memory exceeded");
1739         }
1740       else
1741 #endif /* YYERROR_VERBOSE */
1742         yyerror("parse error");
1743     }
1744
1745   goto yyerrlab1;
1746 yyerrlab1:   /* here on error raised explicitly by an action */
1747
1748   if (yyerrstatus == 3)
1749     {
1750       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
1751
1752       /* return failure if at end of input */
1753       if (yychar == YYEOF)
1754         YYABORT;
1755
1756 #if YYDEBUG != 0
1757       if (yydebug)
1758         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1759 #endif
1760
1761       yychar = YYEMPTY;
1762     }
1763
1764   /* Else will try to reuse lookahead token
1765      after shifting the error token.  */
1766
1767   yyerrstatus = 3;              /* Each real token shifted decrements this */
1768
1769   goto yyerrhandle;
1770
1771 yyerrdefault:  /* current state does not do anything special for the error token. */
1772
1773 #if 0
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;
1778 #endif
1779
1780 yyerrpop:   /* pop the current state because it cannot handle the error token */
1781
1782   if (yyssp == yyss) YYABORT;
1783   yyvsp--;
1784   yystate = *--yyssp;
1785 #ifdef YYLSP_NEEDED
1786   yylsp--;
1787 #endif
1788
1789 #if YYDEBUG != 0
1790   if (yydebug)
1791     {
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");
1797     }
1798 #endif
1799
1800 yyerrhandle:
1801
1802   yyn = yypact[yystate];
1803   if (yyn == YYFLAG)
1804     goto yyerrdefault;
1805
1806   yyn += YYTERROR;
1807   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1808     goto yyerrdefault;
1809
1810   yyn = yytable[yyn];
1811   if (yyn < 0)
1812     {
1813       if (yyn == YYFLAG)
1814         goto yyerrpop;
1815       yyn = -yyn;
1816       goto yyreduce;
1817     }
1818   else if (yyn == 0)
1819     goto yyerrpop;
1820
1821   if (yyn == YYFINAL)
1822     YYACCEPT;
1823
1824 #if YYDEBUG != 0
1825   if (yydebug)
1826     fprintf(stderr, "Shifting error token, ");
1827 #endif
1828
1829   *++yyvsp = yylval;
1830 #ifdef YYLSP_NEEDED
1831   *++yylsp = yylloc;
1832 #endif
1833
1834   yystate = yyn;
1835   goto yynewstate;
1836
1837  yyacceptlab:
1838   /* YYACCEPT comes here.  */
1839   if (yyfree_stacks)
1840     {
1841       free (yyss);
1842       free (yyvs);
1843 #ifdef YYLSP_NEEDED
1844       free (yyls);
1845 #endif
1846     }
1847   return 0;
1848
1849  yyabortlab:
1850   /* YYABORT comes here.  */
1851   if (yyfree_stacks)
1852     {
1853       free (yyss);
1854       free (yyvs);
1855 #ifdef YYLSP_NEEDED
1856       free (yyls);
1857 #endif
1858     }
1859   return 1;
1860 }
1861 #line 633 "/Users/sabre/llvm/utils/TableGen/FileParser.y"
1862
1863
1864 int yyerror(const char *ErrorMsg) {
1865   err() << "Error parsing: " << ErrorMsg << "\n";
1866   exit(1);
1867 }