fix an assertion with multidefs. Def inside of multiclasses don't need to
[oota-llvm.git] / utils / TableGen / FileParser.cpp.cvs
1
2 /*  A Bison parser, made from /Volumes/ProjectsDisk/cvs/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 MULTICLASS      266
24 #define DEFM    267
25 #define FIELD   268
26 #define LET     269
27 #define IN      270
28 #define SHLTOK  271
29 #define SRATOK  272
30 #define SRLTOK  273
31 #define STRCONCATTOK    274
32 #define INTVAL  275
33 #define ID      276
34 #define VARNAME 277
35 #define STRVAL  278
36 #define CODEFRAGMENT    279
37
38 #line 14 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
39
40 #include "Record.h"
41 #include "llvm/ADT/StringExtras.h"
42 #include <algorithm>
43 #include <cstdio>
44 #define YYERROR_VERBOSE 1
45
46 int yyerror(const char *ErrorMsg);
47 int yylex();
48
49 namespace llvm {
50   struct MultiClass {
51     Record Rec;  // Placeholder for template args and Name.
52     std::vector<Record*> DefPrototypes;
53     
54     MultiClass(const std::string &Name) : Rec(Name) {}
55   };
56
57   
58 static std::map<std::string, MultiClass*> MultiClasses;
59   
60 extern int Filelineno;
61 static MultiClass *CurMultiClass = 0;    // Set while parsing a multiclass.
62 static std::string *CurDefmPrefix = 0;   // Set while parsing defm.
63 static Record *CurRec = 0;
64 static bool ParsingTemplateArgs = false;
65
66 typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
67
68 struct LetRecord {
69   std::string Name;
70   std::vector<unsigned> Bits;
71   Init *Value;
72   bool HasBits;
73   LetRecord(const std::string &N, std::vector<unsigned> *B, Init *V)
74     : Name(N), Value(V), HasBits(B != 0) {
75     if (HasBits) Bits = *B;
76   }
77 };
78
79 static std::vector<std::vector<LetRecord> > LetStack;
80
81
82 extern std::ostream &err();
83
84 /// getActiveRec - If inside a def/class definition, return the def/class.
85 /// Otherwise, if within a multidef, return it.
86 static Record *getActiveRec() {
87   return CurRec ? CurRec : &CurMultiClass->Rec;
88 }
89
90 static void addValue(const RecordVal &RV) {
91   Record *TheRec = getActiveRec();
92   
93   if (RecordVal *ERV = TheRec->getValue(RV.getName())) {
94     // The value already exists in the class, treat this as a set...
95     if (ERV->setValue(RV.getValue())) {
96       err() << "New definition of '" << RV.getName() << "' of type '"
97             << *RV.getType() << "' is incompatible with previous "
98             << "definition of type '" << *ERV->getType() << "'!\n";
99       exit(1);
100     }
101   } else {
102     TheRec->addValue(RV);
103   }
104 }
105
106 static void addSuperClass(Record *SC) {
107   if (CurRec->isSubClassOf(SC)) {
108     err() << "Already subclass of '" << SC->getName() << "'!\n";
109     exit(1);
110   }
111   CurRec->addSuperClass(SC);
112 }
113
114 static void setValue(const std::string &ValName, 
115                      std::vector<unsigned> *BitList, Init *V) {
116   if (!V) return;
117
118   RecordVal *RV = CurRec->getValue(ValName);
119   if (RV == 0) {
120     err() << "Value '" << ValName << "' unknown!\n";
121     exit(1);
122   }
123
124   // Do not allow assignments like 'X = X'.  This will just cause infinite loops
125   // in the resolution machinery.
126   if (!BitList)
127     if (VarInit *VI = dynamic_cast<VarInit*>(V))
128       if (VI->getName() == ValName)
129         return;
130   
131   // If we are assigning to a subset of the bits in the value... then we must be
132   // assigning to a field of BitsRecTy, which must have a BitsInit
133   // initializer...
134   //
135   if (BitList) {
136     BitsInit *CurVal = dynamic_cast<BitsInit*>(RV->getValue());
137     if (CurVal == 0) {
138       err() << "Value '" << ValName << "' is not a bits type!\n";
139       exit(1);
140     }
141
142     // Convert the incoming value to a bits type of the appropriate size...
143     Init *BI = V->convertInitializerTo(new BitsRecTy(BitList->size()));
144     if (BI == 0) {
145       V->convertInitializerTo(new BitsRecTy(BitList->size()));
146       err() << "Initializer '" << *V << "' not compatible with bit range!\n";
147       exit(1);
148     }
149
150     // We should have a BitsInit type now...
151     assert(dynamic_cast<BitsInit*>(BI) != 0 || &(std::cerr << *BI) == 0);
152     BitsInit *BInit = (BitsInit*)BI;
153
154     BitsInit *NewVal = new BitsInit(CurVal->getNumBits());
155
156     // Loop over bits, assigning values as appropriate...
157     for (unsigned i = 0, e = BitList->size(); i != e; ++i) {
158       unsigned Bit = (*BitList)[i];
159       if (NewVal->getBit(Bit)) {
160         err() << "Cannot set bit #" << Bit << " of value '" << ValName
161               << "' more than once!\n";
162         exit(1);
163       }
164       NewVal->setBit(Bit, BInit->getBit(i));
165     }
166
167     for (unsigned i = 0, e = CurVal->getNumBits(); i != e; ++i)
168       if (NewVal->getBit(i) == 0)
169         NewVal->setBit(i, CurVal->getBit(i));
170
171     V = NewVal;
172   }
173
174   if (RV->setValue(V)) {
175     err() << "Value '" << ValName << "' of type '" << *RV->getType()
176           << "' is incompatible with initializer '" << *V << "'!\n";
177     exit(1);
178   }
179 }
180
181 // addSubClass - Add SC as a subclass to CurRec, resolving TemplateArgs as SC's
182 // template arguments.
183 static void addSubClass(Record *SC, const std::vector<Init*> &TemplateArgs) {
184   // Add all of the values in the subclass into the current class...
185   const std::vector<RecordVal> &Vals = SC->getValues();
186   for (unsigned i = 0, e = Vals.size(); i != e; ++i)
187     addValue(Vals[i]);
188
189   const std::vector<std::string> &TArgs = SC->getTemplateArgs();
190
191   // Ensure that an appropriate number of template arguments are specified...
192   if (TArgs.size() < TemplateArgs.size()) {
193     err() << "ERROR: More template args specified than expected!\n";
194     exit(1);
195   }
196   
197   // Loop over all of the template arguments, setting them to the specified
198   // value or leaving them as the default if necessary.
199   for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
200     if (i < TemplateArgs.size()) {  // A value is specified for this temp-arg?
201       // Set it now.
202       setValue(TArgs[i], 0, TemplateArgs[i]);
203
204       // Resolve it next.
205       CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i]));
206                                   
207       
208       // Now remove it.
209       CurRec->removeValue(TArgs[i]);
210
211     } else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) {
212       err() << "ERROR: Value not specified for template argument #"
213             << i << " (" << TArgs[i] << ") of subclass '" << SC->getName()
214             << "'!\n";
215       exit(1);
216     }
217   }
218
219   // Since everything went well, we can now set the "superclass" list for the
220   // current record.
221   const std::vector<Record*> &SCs = SC->getSuperClasses();
222   for (unsigned i = 0, e = SCs.size(); i != e; ++i)
223     addSuperClass(SCs[i]);
224   addSuperClass(SC);
225 }
226
227 } // End llvm namespace
228
229 using namespace llvm;
230
231
232 #line 208 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
233 typedef union {
234   std::string*                StrVal;
235   int                         IntVal;
236   llvm::RecTy*                Ty;
237   llvm::Init*                 Initializer;
238   std::vector<llvm::Init*>*   FieldList;
239   std::vector<unsigned>*      BitList;
240   llvm::Record*               Rec;
241   std::vector<llvm::Record*>* RecList;
242   SubClassRefTy*              SubClassRef;
243   std::vector<SubClassRefTy>* SubClassList;
244   std::vector<std::pair<llvm::Init*, std::string> >* DagValueList;
245 } YYSTYPE;
246 #include <stdio.h>
247
248 #ifndef __cplusplus
249 #ifndef __STDC__
250 #define const
251 #endif
252 #endif
253
254
255
256 #define YYFINAL         188
257 #define YYFLAG          -32768
258 #define YYNTBASE        41
259
260 #define YYTRANSLATE(x) ((unsigned)(x) <= 279 ? yytranslate[x] : 90)
261
262 static const char yytranslate[] = {     0,
263      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
264      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
265      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
266      2,     2,     2,     2,     2,     2,     2,     2,     2,    35,
267     36,     2,     2,    37,    39,    34,     2,     2,     2,     2,
268      2,     2,     2,     2,     2,     2,     2,    38,    40,    26,
269     28,    27,    29,     2,     2,     2,     2,     2,     2,     2,
270      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
271      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
272     32,     2,    33,     2,     2,     2,     2,     2,     2,     2,
273      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
274      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
275      2,     2,    30,     2,    31,     2,     2,     2,     2,     2,
276      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
277      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
278      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
279      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
280      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
281      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
282      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
283      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
284      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
285      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
286      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
287      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
288      2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
289      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
290     17,    18,    19,    20,    21,    22,    23,    24,    25
291 };
292
293 #if YYDEBUG != 0
294 static const short yyprhs[] = {     0,
295      0,     2,     4,     6,    11,    13,    18,    20,    22,    24,
296     25,    27,    28,    31,    33,    35,    37,    39,    41,    43,
297     47,    52,    57,    61,    65,    70,    75,    82,    89,    96,
298    103,   104,   107,   110,   115,   116,   118,   120,   124,   127,
299    131,   137,   142,   144,   145,   149,   150,   152,   154,   158,
300    163,   166,   173,   174,   177,   179,   183,   185,   190,   192,
301    196,   197,   200,   202,   206,   210,   211,   213,   215,   216,
302    218,   220,   222,   223,   227,   228,   229,   236,   240,   242,
303    244,   247,   249,   250,   251,   260,   261,   268,   270,   272,
304    274,   276,   281,   283,   287,   288,   293,   298,   301,   303,
305    306
306 };
307
308 static const short yyrhs[] = {    22,
309      0,     5,     0,     4,     0,     6,    26,    21,    27,     0,
310      3,     0,     7,    26,    42,    27,     0,     8,     0,     9,
311      0,    41,     0,     0,    14,     0,     0,    28,    46,     0,
312     22,     0,    45,     0,    21,     0,    24,     0,    25,     0,
313     29,     0,    30,    53,    31,     0,    22,    26,    54,    27,
314      0,    46,    30,    51,    31,     0,    32,    53,    33,     0,
315     46,    34,    22,     0,    35,    45,    49,    36,     0,    46,
316     32,    51,    33,     0,    17,    35,    46,    37,    46,    36,
317      0,    18,    35,    46,    37,    46,    36,     0,    19,    35,
318     46,    37,    46,    36,     0,    20,    35,    46,    37,    46,
319     36,     0,     0,    38,    23,     0,    46,    47,     0,    48,
320     37,    46,    47,     0,     0,    48,     0,    21,     0,    21,
321     39,    21,     0,    21,    21,     0,    50,    37,    21,     0,
322     50,    37,    21,    39,    21,     0,    50,    37,    21,    21,
323      0,    50,     0,     0,    30,    51,    31,     0,     0,    54,
324      0,    46,     0,    54,    37,    46,     0,    43,    42,    22,
325     44,     0,    55,    40,     0,    15,    22,    52,    28,    46,
326     40,     0,     0,    57,    56,     0,    40,     0,    30,    57,
327     31,     0,    41,     0,    41,    26,    54,    27,     0,    59,
328      0,    60,    37,    59,     0,     0,    38,    60,     0,    55,
329      0,    62,    37,    55,     0,    26,    62,    27,     0,     0,
330     63,     0,    22,     0,     0,    65,     0,    66,     0,    66,
331      0,     0,    61,    70,    58,     0,     0,     0,    10,    67,
332     72,    64,    73,    69,     0,    11,    68,    69,     0,    74,
333      0,    75,     0,    76,    75,     0,    22,     0,     0,     0,
334     12,    77,    79,    64,    80,    30,    76,    31,     0,     0,
335     13,    22,    82,    38,    59,    40,     0,    71,     0,    74,
336      0,    78,     0,    81,     0,    22,    52,    28,    46,     0,
337     84,     0,    85,    37,    84,     0,     0,    15,    87,    85,
338     16,     0,    86,    30,    88,    31,     0,    86,    83,     0,
339     83,     0,    88,    83,     0,    88,     0
340 };
341
342 #endif
343
344 #if YYDEBUG != 0
345 static const short yyrline[] = { 0,
346    244,   266,   268,   270,   272,   274,   276,   278,   280,   284,
347    284,   286,   286,   288,   311,   313,   315,   318,   321,   323,
348    336,   364,   371,   374,   381,   384,   392,   394,   396,   398,
349    402,   405,   409,   414,   420,   423,   426,   429,   442,   456,
350    458,   471,   487,   489,   489,   493,   495,   499,   502,   506,
351    523,   525,   531,   531,   532,   532,   534,   536,   540,   545,
352    550,   553,   557,   560,   565,   566,   566,   568,   568,   570,
353    577,   595,   620,   634,   639,   641,   643,   647,   657,   671,
354    674,   678,   689,   691,   693,   698,   698,   763,   763,   764,
355    764,   766,   771,   771,   774,   774,   777,   780,   784,   784,
356    786
357 };
358 #endif
359
360
361 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
362
363 static const char * const yytname[] = {   "$","error","$undefined.","INT","BIT",
364 "STRING","BITS","LIST","CODE","DAG","CLASS","DEF","MULTICLASS","DEFM","FIELD",
365 "LET","IN","SHLTOK","SRATOK","SRLTOK","STRCONCATTOK","INTVAL","ID","VARNAME",
366 "STRVAL","CODEFRAGMENT","'<'","'>'","'='","'?'","'{'","'}'","'['","']'","'.'",
367 "'('","')'","','","':'","'-'","';'","ClassID","Type","OptPrefix","OptValue",
368 "IDValue","Value","OptVarName","DagArgListNE","DagArgList","RBitList","BitList",
369 "OptBitList","ValueList","ValueListNE","Declaration","BodyItem","BodyList","Body",
370 "SubClassRef","ClassListNE","ClassList","DeclListNE","TemplateArgList","OptTemplateArgList",
371 "OptID","ObjectName","ClassName","DefName","ObjectBody","@1","ClassInst","@2",
372 "@3","DefInst","MultiClassDef","MultiClassBody","MultiClassName","MultiClassInst",
373 "@4","@5","DefMInst","@6","Object","LETItem","LETList","LETCommand","@7","ObjectList",
374 "File", NULL
375 };
376 #endif
377
378 static const short yyr1[] = {     0,
379     41,    42,    42,    42,    42,    42,    42,    42,    42,    43,
380     43,    44,    44,    45,    46,    46,    46,    46,    46,    46,
381     46,    46,    46,    46,    46,    46,    46,    46,    46,    46,
382     47,    47,    48,    48,    49,    49,    50,    50,    50,    50,
383     50,    50,    51,    52,    52,    53,    53,    54,    54,    55,
384     56,    56,    57,    57,    58,    58,    59,    59,    60,    60,
385     61,    61,    62,    62,    63,    64,    64,    65,    65,    66,
386     67,    68,    70,    69,    72,    73,    71,    74,    75,    76,
387     76,    77,    79,    80,    78,    82,    81,    83,    83,    83,
388     83,    84,    85,    85,    87,    86,    83,    83,    88,    88,
389     89
390 };
391
392 static const short yyr2[] = {     0,
393      1,     1,     1,     4,     1,     4,     1,     1,     1,     0,
394      1,     0,     2,     1,     1,     1,     1,     1,     1,     3,
395      4,     4,     3,     3,     4,     4,     6,     6,     6,     6,
396      0,     2,     2,     4,     0,     1,     1,     3,     2,     3,
397      5,     4,     1,     0,     3,     0,     1,     1,     3,     4,
398      2,     6,     0,     2,     1,     3,     1,     4,     1,     3,
399      0,     2,     1,     3,     3,     0,     1,     1,     0,     1,
400      1,     1,     0,     3,     0,     0,     6,     3,     1,     1,
401      2,     1,     0,     0,     8,     0,     6,     1,     1,     1,
402      1,     4,     1,     3,     0,     4,     4,     2,     1,     2,
403      1
404 };
405
406 static const short yydefact[] = {     0,
407     69,    69,     0,     0,    95,    88,    89,    90,    91,    99,
408      0,   101,    68,    70,    71,    75,    72,    61,    82,    83,
409     86,     0,     0,    98,   100,    66,     0,    73,    78,    66,
410      0,    44,    93,     0,     0,    10,    67,    76,     1,    57,
411     59,    62,     0,    84,     0,     0,     0,    96,     0,    97,
412     11,     0,    63,     0,    61,     0,     0,    53,    55,    74,
413      0,     0,    37,    43,     0,     0,    94,     5,     3,     2,
414      0,     0,     7,     8,     9,     0,    65,    10,    77,     0,
415      0,     0,     0,    16,    14,    17,    18,    19,    46,    46,
416      0,    15,    48,     0,    60,    10,     0,    87,    39,     0,
417      0,    45,    92,     0,     0,    12,    64,     0,     0,     0,
418      0,     0,     0,    47,     0,    14,    35,     0,     0,     0,
419     58,     0,     0,    56,     0,    54,    79,    80,     0,    38,
420     40,     0,     0,     0,    50,     0,     0,     0,     0,     0,
421     20,    23,    31,    36,     0,     0,     0,    24,    49,    44,
422     51,    85,    81,    42,     0,     4,     6,    13,     0,     0,
423      0,     0,    21,     0,    33,     0,    25,    22,    26,     0,
424     41,     0,     0,     0,     0,    32,    31,     0,    27,    28,
425     29,    30,    34,     0,    52,     0,     0,     0
426 };
427
428 static const short yydefgoto[] = {    40,
429     76,    52,   135,    92,    93,   165,   144,   145,    64,    65,
430     47,   113,   114,    53,   126,    96,    60,    41,    42,    28,
431     54,    37,    38,    14,    15,    16,    18,    29,    43,     6,
432     26,    55,     7,   128,   129,    20,     8,    30,    61,     9,
433     31,    10,    33,    34,    11,    22,    12,   186
434 };
435
436 static const short yypact[] = {   129,
437      3,     3,    11,    19,-32768,-32768,-32768,-32768,-32768,-32768,
438      2,   129,-32768,-32768,-32768,-32768,-32768,    29,-32768,-32768,
439 -32768,    24,   129,-32768,-32768,    43,    31,-32768,-32768,    43,
440     40,    50,-32768,    -6,    -4,    69,-32768,-32768,-32768,    59,
441 -32768,    61,    10,-32768,    31,    81,    78,-32768,    24,-32768,
442 -32768,    15,-32768,    12,    29,    41,    31,-32768,-32768,-32768,
443     84,    68,     8,    83,    87,    41,-32768,-32768,-32768,-32768,
444    111,   120,-32768,-32768,-32768,   126,-32768,    69,-32768,   114,
445    115,   116,   117,-32768,   127,-32768,-32768,-32768,    41,    41,
446    132,-32768,   113,    27,-32768,    60,   144,-32768,-32768,   135,
447    136,-32768,   113,   137,    15,   131,-32768,    41,    41,    41,
448     41,    41,   130,   123,   133,-32768,    41,    81,    81,   140,
449 -32768,    41,   141,-32768,   124,-32768,-32768,-32768,     5,-32768,
450      9,   138,   142,    41,-32768,    67,    73,    79,    85,    45,
451 -32768,-32768,    54,   134,   139,   143,   145,-32768,   113,    50,
452 -32768,-32768,-32768,-32768,   146,-32768,-32768,   113,    41,    41,
453     41,    41,-32768,   147,-32768,    41,-32768,-32768,-32768,   148,
454 -32768,    91,    94,    99,   102,-32768,    54,    41,-32768,-32768,
455 -32768,-32768,-32768,    47,-32768,   168,   172,-32768
456 };
457
458 static const short yypgoto[] = {   -50,
459     72,-32768,-32768,    82,   -66,     4,-32768,-32768,-32768,   -29,
460     30,    89,   -55,   -44,-32768,-32768,-32768,   -19,-32768,-32768,
461 -32768,-32768,   152,-32768,   181,-32768,-32768,   149,-32768,-32768,
462 -32768,-32768,   -94,    55,-32768,-32768,-32768,-32768,-32768,-32768,
463 -32768,    -7,   150,-32768,-32768,-32768,   162,-32768
464 };
465
466
467 #define YYLAST          204
468
469
470 static const short yytable[] = {   103,
471     94,    75,   127,    24,    25,     1,     2,     3,     4,    48,
472      5,     1,     2,     3,     4,     2,     5,    68,    69,    70,
473     71,    72,    73,    74,    13,    62,    50,    25,    99,   154,
474     49,    23,    19,   107,   127,   152,    39,    95,    77,    58,
475     21,   136,   137,   138,   139,    32,   100,   155,    78,    59,
476    143,   125,    39,   121,    75,   149,   140,    80,    81,    82,
477     83,    84,    85,   122,    86,    87,    27,   158,    36,    88,
478     89,   163,    90,    51,   123,    91,   118,    45,   119,    46,
479    120,   122,    51,   118,    56,   119,   185,   120,   146,   147,
480    124,   164,   172,   173,   174,   175,   118,    57,   119,   177,
481    120,    63,   118,   159,   119,    66,   120,    98,   118,   160,
482    119,   184,   120,    97,   118,   161,   119,   102,   120,   101,
483    118,   162,   119,   118,   120,   119,   179,   120,   118,   180,
484    119,   118,   120,   119,   181,   120,   104,   182,     1,     2,
485      3,     4,   118,     5,   119,   105,   120,   106,   108,   109,
486    110,   111,   112,   116,     2,   130,   131,   132,   134,   122,
487    141,   148,   150,   151,   156,   142,   171,   187,   157,   176,
488    166,   188,   117,   168,   167,   178,   133,   169,   115,   170,
489    183,    44,    17,   153,    35,     0,     0,     0,     0,     0,
490      0,     0,     0,     0,     0,     0,     0,     0,    67,     0,
491      0,     0,     0,    79
492 };
493
494 static const short yycheck[] = {    66,
495     56,    52,    97,    11,    12,    10,    11,    12,    13,    16,
496     15,    10,    11,    12,    13,    11,    15,     3,     4,     5,
497      6,     7,     8,     9,    22,    45,    31,    35,    21,    21,
498     37,    30,    22,    78,   129,    31,    22,    57,    27,    30,
499     22,   108,   109,   110,   111,    22,    39,    39,    37,    40,
500    117,    96,    22,    27,   105,   122,   112,    17,    18,    19,
501     20,    21,    22,    37,    24,    25,    38,   134,    26,    29,
502     30,    27,    32,    14,    15,    35,    30,    38,    32,    30,
503     34,    37,    14,    30,    26,    32,    40,    34,   118,   119,
504     31,    38,   159,   160,   161,   162,    30,    37,    32,   166,
505     34,    21,    30,    37,    32,    28,    34,    40,    30,    37,
506     32,   178,    34,    30,    30,    37,    32,    31,    34,    37,
507     30,    37,    32,    30,    34,    32,    36,    34,    30,    36,
508     32,    30,    34,    32,    36,    34,    26,    36,    10,    11,
509     12,    13,    30,    15,    32,    26,    34,    22,    35,    35,
510     35,    35,    26,    22,    11,    21,    21,    21,    28,    37,
511     31,    22,    22,    40,    27,    33,    21,     0,    27,    23,
512     37,     0,    91,    31,    36,    28,   105,    33,    90,   150,
513    177,    30,     2,   129,    23,    -1,    -1,    -1,    -1,    -1,
514     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    49,    -1,
515     -1,    -1,    -1,    55
516 };
517 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
518 #line 3 "/usr/share/bison.simple"
519 /* This file comes from bison-1.28.  */
520
521 /* Skeleton output parser for bison,
522    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
523
524    This program is free software; you can redistribute it and/or modify
525    it under the terms of the GNU General Public License as published by
526    the Free Software Foundation; either version 2, or (at your option)
527    any later version.
528
529    This program is distributed in the hope that it will be useful,
530    but WITHOUT ANY WARRANTY; without even the implied warranty of
531    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
532    GNU General Public License for more details.
533
534    You should have received a copy of the GNU General Public License
535    along with this program; if not, write to the Free Software
536    Foundation, Inc., 59 Temple Place - Suite 330,
537    Boston, MA 02111-1307, USA.  */
538
539 /* As a special exception, when this file is copied by Bison into a
540    Bison output file, you may use that output file without restriction.
541    This special exception was added by the Free Software Foundation
542    in version 1.24 of Bison.  */
543
544 /* This is the parser code that is written into each bison parser
545   when the %semantic_parser declaration is not specified in the grammar.
546   It was written by Richard Stallman by simplifying the hairy parser
547   used when %semantic_parser is specified.  */
548
549 #ifndef YYSTACK_USE_ALLOCA
550 #ifdef alloca
551 #define YYSTACK_USE_ALLOCA
552 #else /* alloca not defined */
553 #ifdef __GNUC__
554 #define YYSTACK_USE_ALLOCA
555 #define alloca __builtin_alloca
556 #else /* not GNU C.  */
557 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
558 #define YYSTACK_USE_ALLOCA
559 #include <alloca.h>
560 #else /* not sparc */
561 /* We think this test detects Watcom and Microsoft C.  */
562 /* This used to test MSDOS, but that is a bad idea
563    since that symbol is in the user namespace.  */
564 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
565 #if 0 /* No need for malloc.h, which pollutes the namespace;
566          instead, just don't use alloca.  */
567 #include <malloc.h>
568 #endif
569 #else /* not MSDOS, or __TURBOC__ */
570 #if defined(_AIX)
571 /* I don't know what this was needed for, but it pollutes the namespace.
572    So I turned it off.   rms, 2 May 1997.  */
573 /* #include <malloc.h>  */
574  #pragma alloca
575 #define YYSTACK_USE_ALLOCA
576 #else /* not MSDOS, or __TURBOC__, or _AIX */
577 #if 0
578 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
579                  and on HPUX 10.  Eventually we can turn this on.  */
580 #define YYSTACK_USE_ALLOCA
581 #define alloca __builtin_alloca
582 #endif /* __hpux */
583 #endif
584 #endif /* not _AIX */
585 #endif /* not MSDOS, or __TURBOC__ */
586 #endif /* not sparc */
587 #endif /* not GNU C */
588 #endif /* alloca not defined */
589 #endif /* YYSTACK_USE_ALLOCA not defined */
590
591 #ifdef YYSTACK_USE_ALLOCA
592 #define YYSTACK_ALLOC alloca
593 #else
594 #define YYSTACK_ALLOC malloc
595 #endif
596
597 /* Note: there must be only one dollar sign in this file.
598    It is replaced by the list of actions, each action
599    as one case of the switch.  */
600
601 #define yyerrok         (yyerrstatus = 0)
602 #define yyclearin       (yychar = YYEMPTY)
603 #define YYEMPTY         -2
604 #define YYEOF           0
605 #define YYACCEPT        goto yyacceptlab
606 #define YYABORT         goto yyabortlab
607 #define YYERROR         goto yyerrlab1
608 /* Like YYERROR except do call yyerror.
609    This remains here temporarily to ease the
610    transition to the new meaning of YYERROR, for GCC.
611    Once GCC version 2 has supplanted version 1, this can go.  */
612 #define YYFAIL          goto yyerrlab
613 #define YYRECOVERING()  (!!yyerrstatus)
614 #define YYBACKUP(token, value) \
615 do                                                              \
616   if (yychar == YYEMPTY && yylen == 1)                          \
617     { yychar = (token), yylval = (value);                       \
618       yychar1 = YYTRANSLATE (yychar);                           \
619       YYPOPSTACK;                                               \
620       goto yybackup;                                            \
621     }                                                           \
622   else                                                          \
623     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
624 while (0)
625
626 #define YYTERROR        1
627 #define YYERRCODE       256
628
629 #ifndef YYPURE
630 #define YYLEX           yylex()
631 #endif
632
633 #ifdef YYPURE
634 #ifdef YYLSP_NEEDED
635 #ifdef YYLEX_PARAM
636 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
637 #else
638 #define YYLEX           yylex(&yylval, &yylloc)
639 #endif
640 #else /* not YYLSP_NEEDED */
641 #ifdef YYLEX_PARAM
642 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
643 #else
644 #define YYLEX           yylex(&yylval)
645 #endif
646 #endif /* not YYLSP_NEEDED */
647 #endif
648
649 /* If nonreentrant, generate the variables here */
650
651 #ifndef YYPURE
652
653 int     yychar;                 /*  the lookahead symbol                */
654 YYSTYPE yylval;                 /*  the semantic value of the           */
655                                 /*  lookahead symbol                    */
656
657 #ifdef YYLSP_NEEDED
658 YYLTYPE yylloc;                 /*  location data for the lookahead     */
659                                 /*  symbol                              */
660 #endif
661
662 int yynerrs;                    /*  number of parse errors so far       */
663 #endif  /* not YYPURE */
664
665 #if YYDEBUG != 0
666 int yydebug;                    /*  nonzero means print parse trace     */
667 /* Since this is uninitialized, it does not stop multiple parsers
668    from coexisting.  */
669 #endif
670
671 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
672
673 #ifndef YYINITDEPTH
674 #define YYINITDEPTH 200
675 #endif
676
677 /*  YYMAXDEPTH is the maximum size the stacks can grow to
678     (effective only if the built-in stack extension method is used).  */
679
680 #if YYMAXDEPTH == 0
681 #undef YYMAXDEPTH
682 #endif
683
684 #ifndef YYMAXDEPTH
685 #define YYMAXDEPTH 10000
686 #endif
687 \f
688 /* Define __yy_memcpy.  Note that the size argument
689    should be passed with type unsigned int, because that is what the non-GCC
690    definitions require.  With GCC, __builtin_memcpy takes an arg
691    of type size_t, but it can handle unsigned int.  */
692
693 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
694 #define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
695 #else                           /* not GNU C or C++ */
696 #ifndef __cplusplus
697
698 /* This is the most reliable way to avoid incompatibilities
699    in available built-in functions on various systems.  */
700 static void
701 __yy_memcpy (to, from, count)
702      char *to;
703      char *from;
704      unsigned int count;
705 {
706   register char *f = from;
707   register char *t = to;
708   register int i = count;
709
710   while (i-- > 0)
711     *t++ = *f++;
712 }
713
714 #else /* __cplusplus */
715
716 /* This is the most reliable way to avoid incompatibilities
717    in available built-in functions on various systems.  */
718 static void
719 __yy_memcpy (char *to, char *from, unsigned int count)
720 {
721   register char *t = to;
722   register char *f = from;
723   register int i = count;
724
725   while (i-- > 0)
726     *t++ = *f++;
727 }
728
729 #endif
730 #endif
731 \f
732 #line 217 "/usr/share/bison.simple"
733
734 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
735    into yyparse.  The argument should have type void *.
736    It should actually point to an object.
737    Grammar actions can access the variable by casting it
738    to the proper pointer type.  */
739
740 #ifdef YYPARSE_PARAM
741 #ifdef __cplusplus
742 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
743 #define YYPARSE_PARAM_DECL
744 #else /* not __cplusplus */
745 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
746 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
747 #endif /* not __cplusplus */
748 #else /* not YYPARSE_PARAM */
749 #define YYPARSE_PARAM_ARG
750 #define YYPARSE_PARAM_DECL
751 #endif /* not YYPARSE_PARAM */
752
753 /* Prevent warning if -Wstrict-prototypes.  */
754 #ifdef __GNUC__
755 #ifdef YYPARSE_PARAM
756 int yyparse (void *);
757 #else
758 int yyparse (void);
759 #endif
760 #endif
761
762 int
763 yyparse(YYPARSE_PARAM_ARG)
764      YYPARSE_PARAM_DECL
765 {
766   register int yystate;
767   register int yyn;
768   register short *yyssp;
769   register YYSTYPE *yyvsp;
770   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
771   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
772
773   short yyssa[YYINITDEPTH];     /*  the state stack                     */
774   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
775
776   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
777   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
778
779 #ifdef YYLSP_NEEDED
780   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
781   YYLTYPE *yyls = yylsa;
782   YYLTYPE *yylsp;
783
784 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
785 #else
786 #define YYPOPSTACK   (yyvsp--, yyssp--)
787 #endif
788
789   int yystacksize = YYINITDEPTH;
790   int yyfree_stacks = 0;
791
792 #ifdef YYPURE
793   int yychar;
794   YYSTYPE yylval;
795   int yynerrs;
796 #ifdef YYLSP_NEEDED
797   YYLTYPE yylloc;
798 #endif
799 #endif
800
801   YYSTYPE yyval;                /*  the variable used to return         */
802                                 /*  semantic values from the action     */
803                                 /*  routines                            */
804
805   int yylen;
806
807 #if YYDEBUG != 0
808   if (yydebug)
809     fprintf(stderr, "Starting parse\n");
810 #endif
811
812   yystate = 0;
813   yyerrstatus = 0;
814   yynerrs = 0;
815   yychar = YYEMPTY;             /* Cause a token to be read.  */
816
817   /* Initialize stack pointers.
818      Waste one element of value and location stack
819      so that they stay on the same level as the state stack.
820      The wasted elements are never initialized.  */
821
822   yyssp = yyss - 1;
823   yyvsp = yyvs;
824 #ifdef YYLSP_NEEDED
825   yylsp = yyls;
826 #endif
827
828 /* Push a new state, which is found in  yystate  .  */
829 /* In all cases, when you get here, the value and location stacks
830    have just been pushed. so pushing a state here evens the stacks.  */
831 yynewstate:
832
833   *++yyssp = yystate;
834
835   if (yyssp >= yyss + yystacksize - 1)
836     {
837       /* Give user a chance to reallocate the stack */
838       /* Use copies of these so that the &'s don't force the real ones into memory. */
839       YYSTYPE *yyvs1 = yyvs;
840       short *yyss1 = yyss;
841 #ifdef YYLSP_NEEDED
842       YYLTYPE *yyls1 = yyls;
843 #endif
844
845       /* Get the current used size of the three stacks, in elements.  */
846       int size = yyssp - yyss + 1;
847
848 #ifdef yyoverflow
849       /* Each stack pointer address is followed by the size of
850          the data in use in that stack, in bytes.  */
851 #ifdef YYLSP_NEEDED
852       /* This used to be a conditional around just the two extra args,
853          but that might be undefined if yyoverflow is a macro.  */
854       yyoverflow("parser stack overflow",
855                  &yyss1, size * sizeof (*yyssp),
856                  &yyvs1, size * sizeof (*yyvsp),
857                  &yyls1, size * sizeof (*yylsp),
858                  &yystacksize);
859 #else
860       yyoverflow("parser stack overflow",
861                  &yyss1, size * sizeof (*yyssp),
862                  &yyvs1, size * sizeof (*yyvsp),
863                  &yystacksize);
864 #endif
865
866       yyss = yyss1; yyvs = yyvs1;
867 #ifdef YYLSP_NEEDED
868       yyls = yyls1;
869 #endif
870 #else /* no yyoverflow */
871       /* Extend the stack our own way.  */
872       if (yystacksize >= YYMAXDEPTH)
873         {
874           yyerror("parser stack overflow");
875           if (yyfree_stacks)
876             {
877               free (yyss);
878               free (yyvs);
879 #ifdef YYLSP_NEEDED
880               free (yyls);
881 #endif
882             }
883           return 2;
884         }
885       yystacksize *= 2;
886       if (yystacksize > YYMAXDEPTH)
887         yystacksize = YYMAXDEPTH;
888 #ifndef YYSTACK_USE_ALLOCA
889       yyfree_stacks = 1;
890 #endif
891       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
892       __yy_memcpy ((char *)yyss, (char *)yyss1,
893                    size * (unsigned int) sizeof (*yyssp));
894       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
895       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
896                    size * (unsigned int) sizeof (*yyvsp));
897 #ifdef YYLSP_NEEDED
898       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
899       __yy_memcpy ((char *)yyls, (char *)yyls1,
900                    size * (unsigned int) sizeof (*yylsp));
901 #endif
902 #endif /* no yyoverflow */
903
904       yyssp = yyss + size - 1;
905       yyvsp = yyvs + size - 1;
906 #ifdef YYLSP_NEEDED
907       yylsp = yyls + size - 1;
908 #endif
909
910 #if YYDEBUG != 0
911       if (yydebug)
912         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
913 #endif
914
915       if (yyssp >= yyss + yystacksize - 1)
916         YYABORT;
917     }
918
919 #if YYDEBUG != 0
920   if (yydebug)
921     fprintf(stderr, "Entering state %d\n", yystate);
922 #endif
923
924   goto yybackup;
925  yybackup:
926
927 /* Do appropriate processing given the current state.  */
928 /* Read a lookahead token if we need one and don't already have one.  */
929 /* yyresume: */
930
931   /* First try to decide what to do without reference to lookahead token.  */
932
933   yyn = yypact[yystate];
934   if (yyn == YYFLAG)
935     goto yydefault;
936
937   /* Not known => get a lookahead token if don't already have one.  */
938
939   /* yychar is either YYEMPTY or YYEOF
940      or a valid token in external form.  */
941
942   if (yychar == YYEMPTY)
943     {
944 #if YYDEBUG != 0
945       if (yydebug)
946         fprintf(stderr, "Reading a token: ");
947 #endif
948       yychar = YYLEX;
949     }
950
951   /* Convert token to internal form (in yychar1) for indexing tables with */
952
953   if (yychar <= 0)              /* This means end of input. */
954     {
955       yychar1 = 0;
956       yychar = YYEOF;           /* Don't call YYLEX any more */
957
958 #if YYDEBUG != 0
959       if (yydebug)
960         fprintf(stderr, "Now at end of input.\n");
961 #endif
962     }
963   else
964     {
965       yychar1 = YYTRANSLATE(yychar);
966
967 #if YYDEBUG != 0
968       if (yydebug)
969         {
970           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
971           /* Give the individual parser a way to print the precise meaning
972              of a token, for further debugging info.  */
973 #ifdef YYPRINT
974           YYPRINT (stderr, yychar, yylval);
975 #endif
976           fprintf (stderr, ")\n");
977         }
978 #endif
979     }
980
981   yyn += yychar1;
982   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
983     goto yydefault;
984
985   yyn = yytable[yyn];
986
987   /* yyn is what to do for this token type in this state.
988      Negative => reduce, -yyn is rule number.
989      Positive => shift, yyn is new state.
990        New state is final state => don't bother to shift,
991        just return success.
992      0, or most negative number => error.  */
993
994   if (yyn < 0)
995     {
996       if (yyn == YYFLAG)
997         goto yyerrlab;
998       yyn = -yyn;
999       goto yyreduce;
1000     }
1001   else if (yyn == 0)
1002     goto yyerrlab;
1003
1004   if (yyn == YYFINAL)
1005     YYACCEPT;
1006
1007   /* Shift the lookahead token.  */
1008
1009 #if YYDEBUG != 0
1010   if (yydebug)
1011     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
1012 #endif
1013
1014   /* Discard the token being shifted unless it is eof.  */
1015   if (yychar != YYEOF)
1016     yychar = YYEMPTY;
1017
1018   *++yyvsp = yylval;
1019 #ifdef YYLSP_NEEDED
1020   *++yylsp = yylloc;
1021 #endif
1022
1023   /* count tokens shifted since error; after three, turn off error status.  */
1024   if (yyerrstatus) yyerrstatus--;
1025
1026   yystate = yyn;
1027   goto yynewstate;
1028
1029 /* Do the default action for the current state.  */
1030 yydefault:
1031
1032   yyn = yydefact[yystate];
1033   if (yyn == 0)
1034     goto yyerrlab;
1035
1036 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
1037 yyreduce:
1038   yylen = yyr2[yyn];
1039   if (yylen > 0)
1040     yyval = yyvsp[1-yylen]; /* implement default value of the action */
1041
1042 #if YYDEBUG != 0
1043   if (yydebug)
1044     {
1045       int i;
1046
1047       fprintf (stderr, "Reducing via rule %d (line %d), ",
1048                yyn, yyrline[yyn]);
1049
1050       /* Print the symbols being reduced, and their result.  */
1051       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
1052         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1053       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1054     }
1055 #endif
1056
1057
1058   switch (yyn) {
1059
1060 case 1:
1061 #line 244 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1062 {
1063     if (CurDefmPrefix) {
1064       // If CurDefmPrefix is set, we're parsing a defm, which means that this is
1065       // actually the name of a multiclass.
1066       MultiClass *MC = MultiClasses[*yyvsp[0].StrVal];
1067       if (MC == 0) {
1068         err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n";
1069         exit(1);
1070       }
1071       yyval.Rec = &MC->Rec;
1072     } else {
1073       yyval.Rec = Records.getClass(*yyvsp[0].StrVal);
1074     }
1075     if (yyval.Rec == 0) {
1076       err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n";
1077       exit(1);
1078     }
1079     delete yyvsp[0].StrVal;
1080   ;
1081     break;}
1082 case 2:
1083 #line 266 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1084 {                       // string type
1085     yyval.Ty = new StringRecTy();
1086   ;
1087     break;}
1088 case 3:
1089 #line 268 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1090 {                           // bit type
1091     yyval.Ty = new BitRecTy();
1092   ;
1093     break;}
1094 case 4:
1095 #line 270 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1096 {           // bits<x> type
1097     yyval.Ty = new BitsRecTy(yyvsp[-1].IntVal);
1098   ;
1099     break;}
1100 case 5:
1101 #line 272 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1102 {                           // int type
1103     yyval.Ty = new IntRecTy();
1104   ;
1105     break;}
1106 case 6:
1107 #line 274 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1108 {          // list<x> type
1109     yyval.Ty = new ListRecTy(yyvsp[-1].Ty);
1110   ;
1111     break;}
1112 case 7:
1113 #line 276 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1114 {                          // code type
1115     yyval.Ty = new CodeRecTy();
1116   ;
1117     break;}
1118 case 8:
1119 #line 278 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1120 {                           // dag type
1121     yyval.Ty = new DagRecTy();
1122   ;
1123     break;}
1124 case 9:
1125 #line 280 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1126 {                       // Record Type
1127     yyval.Ty = new RecordRecTy(yyvsp[0].Rec);
1128   ;
1129     break;}
1130 case 10:
1131 #line 284 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1132 { yyval.IntVal = 0; ;
1133     break;}
1134 case 11:
1135 #line 284 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1136 { yyval.IntVal = 1; ;
1137     break;}
1138 case 12:
1139 #line 286 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1140 { yyval.Initializer = 0; ;
1141     break;}
1142 case 13:
1143 #line 286 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1144 { yyval.Initializer = yyvsp[0].Initializer; ;
1145     break;}
1146 case 14:
1147 #line 288 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1148 {
1149   if (const RecordVal *RV = (CurRec ? CurRec->getValue(*yyvsp[0].StrVal) : 0)) {
1150     yyval.Initializer = new VarInit(*yyvsp[0].StrVal, RV->getType());
1151   } else if (CurRec && CurRec->isTemplateArg(CurRec->getName()+":"+*yyvsp[0].StrVal)) {
1152     const RecordVal *RV = CurRec->getValue(CurRec->getName()+":"+*yyvsp[0].StrVal);
1153     assert(RV && "Template arg doesn't exist??");
1154     yyval.Initializer = new VarInit(CurRec->getName()+":"+*yyvsp[0].StrVal, RV->getType());
1155   } else if (CurMultiClass &&
1156       CurMultiClass->Rec.isTemplateArg(CurMultiClass->Rec.getName()+"::"+*yyvsp[0].StrVal)) {
1157     std::string Name = CurMultiClass->Rec.getName()+"::"+*yyvsp[0].StrVal;
1158     const RecordVal *RV = CurMultiClass->Rec.getValue(Name);
1159     assert(RV && "Template arg doesn't exist??");
1160     yyval.Initializer = new VarInit(Name, RV->getType());
1161   } else if (Record *D = Records.getDef(*yyvsp[0].StrVal)) {
1162     yyval.Initializer = new DefInit(D);
1163   } else {
1164     err() << "Variable not defined: '" << *yyvsp[0].StrVal << "'!\n";
1165     exit(1);
1166   }
1167   
1168   delete yyvsp[0].StrVal;
1169 ;
1170     break;}
1171 case 15:
1172 #line 311 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1173 {
1174     yyval.Initializer = yyvsp[0].Initializer;
1175   ;
1176     break;}
1177 case 16:
1178 #line 313 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1179 {
1180     yyval.Initializer = new IntInit(yyvsp[0].IntVal);
1181   ;
1182     break;}
1183 case 17:
1184 #line 315 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1185 {
1186     yyval.Initializer = new StringInit(*yyvsp[0].StrVal);
1187     delete yyvsp[0].StrVal;
1188   ;
1189     break;}
1190 case 18:
1191 #line 318 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1192 {
1193     yyval.Initializer = new CodeInit(*yyvsp[0].StrVal);
1194     delete yyvsp[0].StrVal;
1195   ;
1196     break;}
1197 case 19:
1198 #line 321 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1199 {
1200     yyval.Initializer = new UnsetInit();
1201   ;
1202     break;}
1203 case 20:
1204 #line 323 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1205 {
1206     BitsInit *Init = new BitsInit(yyvsp[-1].FieldList->size());
1207     for (unsigned i = 0, e = yyvsp[-1].FieldList->size(); i != e; ++i) {
1208       struct Init *Bit = (*yyvsp[-1].FieldList)[i]->convertInitializerTo(new BitRecTy());
1209       if (Bit == 0) {
1210         err() << "Element #" << i << " (" << *(*yyvsp[-1].FieldList)[i]
1211               << ") is not convertable to a bit!\n";
1212         exit(1);
1213       }
1214       Init->setBit(yyvsp[-1].FieldList->size()-i-1, Bit);
1215     }
1216     yyval.Initializer = Init;
1217     delete yyvsp[-1].FieldList;
1218   ;
1219     break;}
1220 case 21:
1221 #line 336 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1222 {
1223     // This is a CLASS<initvalslist> expression.  This is supposed to synthesize
1224     // a new anonymous definition, deriving from CLASS<initvalslist> with no
1225     // body.
1226     Record *Class = Records.getClass(*yyvsp[-3].StrVal);
1227     if (!Class) {
1228       err() << "Expected a class, got '" << *yyvsp[-3].StrVal << "'!\n";
1229       exit(1);
1230     }
1231     delete yyvsp[-3].StrVal;
1232     
1233     static unsigned AnonCounter = 0;
1234     Record *OldRec = CurRec;  // Save CurRec.
1235     
1236     // Create the new record, set it as CurRec temporarily.
1237     CurRec = new Record("anonymous.val."+utostr(AnonCounter++));
1238     addSubClass(Class, *yyvsp[-1].FieldList);    // Add info about the subclass to CurRec.
1239     delete yyvsp[-1].FieldList;  // Free up the template args.
1240     
1241     CurRec->resolveReferences();
1242     
1243     Records.addDef(CurRec);
1244     
1245     // The result of the expression is a reference to the new record.
1246     yyval.Initializer = new DefInit(CurRec);
1247     
1248     // Restore the old CurRec
1249     CurRec = OldRec;
1250   ;
1251     break;}
1252 case 22:
1253 #line 364 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1254 {
1255     yyval.Initializer = yyvsp[-3].Initializer->convertInitializerBitRange(*yyvsp[-1].BitList);
1256     if (yyval.Initializer == 0) {
1257       err() << "Invalid bit range for value '" << *yyvsp[-3].Initializer << "'!\n";
1258       exit(1);
1259     }
1260     delete yyvsp[-1].BitList;
1261   ;
1262     break;}
1263 case 23:
1264 #line 371 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1265 {
1266     yyval.Initializer = new ListInit(*yyvsp[-1].FieldList);
1267     delete yyvsp[-1].FieldList;
1268   ;
1269     break;}
1270 case 24:
1271 #line 374 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1272 {
1273     if (!yyvsp[-2].Initializer->getFieldType(*yyvsp[0].StrVal)) {
1274       err() << "Cannot access field '" << *yyvsp[0].StrVal << "' of value '" << *yyvsp[-2].Initializer << "!\n";
1275       exit(1);
1276     }
1277     yyval.Initializer = new FieldInit(yyvsp[-2].Initializer, *yyvsp[0].StrVal);
1278     delete yyvsp[0].StrVal;
1279   ;
1280     break;}
1281 case 25:
1282 #line 381 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1283 {
1284     yyval.Initializer = new DagInit(yyvsp[-2].Initializer, *yyvsp[-1].DagValueList);
1285     delete yyvsp[-1].DagValueList;
1286   ;
1287     break;}
1288 case 26:
1289 #line 384 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1290 {
1291     std::reverse(yyvsp[-1].BitList->begin(), yyvsp[-1].BitList->end());
1292     yyval.Initializer = yyvsp[-3].Initializer->convertInitListSlice(*yyvsp[-1].BitList);
1293     if (yyval.Initializer == 0) {
1294       err() << "Invalid list slice for value '" << *yyvsp[-3].Initializer << "'!\n";
1295       exit(1);
1296     }
1297     delete yyvsp[-1].BitList;
1298   ;
1299     break;}
1300 case 27:
1301 #line 392 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1302 {
1303     yyval.Initializer = (new BinOpInit(BinOpInit::SHL, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1304   ;
1305     break;}
1306 case 28:
1307 #line 394 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1308 {
1309     yyval.Initializer = (new BinOpInit(BinOpInit::SRA, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1310   ;
1311     break;}
1312 case 29:
1313 #line 396 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1314 {
1315     yyval.Initializer = (new BinOpInit(BinOpInit::SRL, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1316   ;
1317     break;}
1318 case 30:
1319 #line 398 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1320 {
1321     yyval.Initializer = (new BinOpInit(BinOpInit::STRCONCAT, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1322   ;
1323     break;}
1324 case 31:
1325 #line 402 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1326 {
1327     yyval.StrVal = new std::string();
1328   ;
1329     break;}
1330 case 32:
1331 #line 405 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1332 {
1333     yyval.StrVal = yyvsp[0].StrVal;
1334   ;
1335     break;}
1336 case 33:
1337 #line 409 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1338 {
1339     yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
1340     yyval.DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal));
1341     delete yyvsp[0].StrVal;
1342   ;
1343     break;}
1344 case 34:
1345 #line 414 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1346 {
1347     yyvsp[-3].DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal));
1348     delete yyvsp[0].StrVal;
1349     yyval.DagValueList = yyvsp[-3].DagValueList;
1350   ;
1351     break;}
1352 case 35:
1353 #line 420 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1354 {
1355     yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
1356   ;
1357     break;}
1358 case 36:
1359 #line 423 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1360 { yyval.DagValueList = yyvsp[0].DagValueList; ;
1361     break;}
1362 case 37:
1363 #line 426 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1364 {
1365     yyval.BitList = new std::vector<unsigned>();
1366     yyval.BitList->push_back(yyvsp[0].IntVal);
1367   ;
1368     break;}
1369 case 38:
1370 #line 429 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1371 {
1372     if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1373       err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1374       exit(1);
1375     }
1376     yyval.BitList = new std::vector<unsigned>();
1377     if (yyvsp[-2].IntVal < yyvsp[0].IntVal) {
1378       for (int i = yyvsp[-2].IntVal; i <= yyvsp[0].IntVal; ++i)
1379         yyval.BitList->push_back(i);
1380     } else {
1381       for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1382         yyval.BitList->push_back(i);
1383     }
1384   ;
1385     break;}
1386 case 39:
1387 #line 442 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1388 {
1389     yyvsp[0].IntVal = -yyvsp[0].IntVal;
1390     if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) {
1391       err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1392       exit(1);
1393     }
1394     yyval.BitList = new std::vector<unsigned>();
1395     if (yyvsp[-1].IntVal < yyvsp[0].IntVal) {
1396       for (int i = yyvsp[-1].IntVal; i <= yyvsp[0].IntVal; ++i)
1397         yyval.BitList->push_back(i);
1398     } else {
1399       for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1400         yyval.BitList->push_back(i);
1401     }
1402   ;
1403     break;}
1404 case 40:
1405 #line 456 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1406 {
1407     (yyval.BitList=yyvsp[-2].BitList)->push_back(yyvsp[0].IntVal);
1408   ;
1409     break;}
1410 case 41:
1411 #line 458 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1412 {
1413     if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1414       err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1415       exit(1);
1416     }
1417     yyval.BitList = yyvsp[-4].BitList;
1418     if (yyvsp[-2].IntVal < yyvsp[0].IntVal) {
1419       for (int i = yyvsp[-2].IntVal; i <= yyvsp[0].IntVal; ++i)
1420         yyval.BitList->push_back(i);
1421     } else {
1422       for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1423         yyval.BitList->push_back(i);
1424     }
1425   ;
1426     break;}
1427 case 42:
1428 #line 471 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1429 {
1430     yyvsp[0].IntVal = -yyvsp[0].IntVal;
1431     if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) {
1432       err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1433       exit(1);
1434     }
1435     yyval.BitList = yyvsp[-3].BitList;
1436     if (yyvsp[-1].IntVal < yyvsp[0].IntVal) {
1437       for (int i = yyvsp[-1].IntVal; i <= yyvsp[0].IntVal; ++i)
1438         yyval.BitList->push_back(i);
1439     } else {
1440       for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1441         yyval.BitList->push_back(i);
1442     }
1443   ;
1444     break;}
1445 case 43:
1446 #line 487 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1447 { yyval.BitList = yyvsp[0].BitList; std::reverse(yyvsp[0].BitList->begin(), yyvsp[0].BitList->end()); ;
1448     break;}
1449 case 44:
1450 #line 489 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1451 { yyval.BitList = 0; ;
1452     break;}
1453 case 45:
1454 #line 489 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1455 { yyval.BitList = yyvsp[-1].BitList; ;
1456     break;}
1457 case 46:
1458 #line 493 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1459 {
1460     yyval.FieldList = new std::vector<Init*>();
1461   ;
1462     break;}
1463 case 47:
1464 #line 495 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1465 {
1466     yyval.FieldList = yyvsp[0].FieldList;
1467   ;
1468     break;}
1469 case 48:
1470 #line 499 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1471 {
1472     yyval.FieldList = new std::vector<Init*>();
1473     yyval.FieldList->push_back(yyvsp[0].Initializer);
1474   ;
1475     break;}
1476 case 49:
1477 #line 502 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1478 {
1479     (yyval.FieldList = yyvsp[-2].FieldList)->push_back(yyvsp[0].Initializer);
1480   ;
1481     break;}
1482 case 50:
1483 #line 506 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1484 {
1485   std::string DecName = *yyvsp[-1].StrVal;
1486   if (ParsingTemplateArgs) {
1487     if (CurRec) {
1488       DecName = CurRec->getName() + ":" + DecName;
1489     } else {
1490       assert(CurMultiClass);
1491     }
1492     if (CurMultiClass)
1493       DecName = CurMultiClass->Rec.getName() + "::" + DecName;
1494   }
1495
1496   addValue(RecordVal(DecName, yyvsp[-2].Ty, yyvsp[-3].IntVal));
1497   setValue(DecName, 0, yyvsp[0].Initializer);
1498   yyval.StrVal = new std::string(DecName);
1499 ;
1500     break;}
1501 case 51:
1502 #line 523 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1503 {
1504   delete yyvsp[-1].StrVal;
1505 ;
1506     break;}
1507 case 52:
1508 #line 525 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1509 {
1510   setValue(*yyvsp[-4].StrVal, yyvsp[-3].BitList, yyvsp[-1].Initializer);
1511   delete yyvsp[-4].StrVal;
1512   delete yyvsp[-3].BitList;
1513 ;
1514     break;}
1515 case 57:
1516 #line 534 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1517 {
1518     yyval.SubClassRef = new SubClassRefTy(yyvsp[0].Rec, new std::vector<Init*>());
1519   ;
1520     break;}
1521 case 58:
1522 #line 536 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1523 {
1524     yyval.SubClassRef = new SubClassRefTy(yyvsp[-3].Rec, yyvsp[-1].FieldList);
1525   ;
1526     break;}
1527 case 59:
1528 #line 540 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1529 {
1530     yyval.SubClassList = new std::vector<SubClassRefTy>();
1531     yyval.SubClassList->push_back(*yyvsp[0].SubClassRef);
1532     delete yyvsp[0].SubClassRef;
1533   ;
1534     break;}
1535 case 60:
1536 #line 545 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1537 {
1538     (yyval.SubClassList=yyvsp[-2].SubClassList)->push_back(*yyvsp[0].SubClassRef);
1539     delete yyvsp[0].SubClassRef;
1540   ;
1541     break;}
1542 case 61:
1543 #line 550 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1544 {
1545     yyval.SubClassList = new std::vector<SubClassRefTy>();
1546   ;
1547     break;}
1548 case 62:
1549 #line 553 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1550 {
1551     yyval.SubClassList = yyvsp[0].SubClassList;
1552   ;
1553     break;}
1554 case 63:
1555 #line 557 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1556 {
1557   getActiveRec()->addTemplateArg(*yyvsp[0].StrVal);
1558   delete yyvsp[0].StrVal;
1559 ;
1560     break;}
1561 case 64:
1562 #line 560 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1563 {
1564   getActiveRec()->addTemplateArg(*yyvsp[0].StrVal);
1565   delete yyvsp[0].StrVal;
1566 ;
1567     break;}
1568 case 65:
1569 #line 565 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1570 {;
1571     break;}
1572 case 68:
1573 #line 568 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1574 { yyval.StrVal = yyvsp[0].StrVal; ;
1575     break;}
1576 case 69:
1577 #line 568 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1578 { yyval.StrVal = new std::string(); ;
1579     break;}
1580 case 70:
1581 #line 570 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1582 {
1583   static unsigned AnonCounter = 0;
1584   if (yyvsp[0].StrVal->empty())
1585     *yyvsp[0].StrVal = "anonymous."+utostr(AnonCounter++);
1586   yyval.StrVal = yyvsp[0].StrVal;
1587 ;
1588     break;}
1589 case 71:
1590 #line 577 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1591 {
1592   // If a class of this name already exists, it must be a forward ref.
1593   if ((CurRec = Records.getClass(*yyvsp[0].StrVal))) {
1594     // If the body was previously defined, this is an error.
1595     if (!CurRec->getValues().empty() ||
1596         !CurRec->getSuperClasses().empty() ||
1597         !CurRec->getTemplateArgs().empty()) {
1598       err() << "Class '" << CurRec->getName() << "' already defined!\n";
1599       exit(1);
1600     }
1601   } else {
1602     // If this is the first reference to this class, create and add it.
1603     CurRec = new Record(*yyvsp[0].StrVal);
1604     Records.addClass(CurRec);
1605   }
1606   delete yyvsp[0].StrVal;
1607 ;
1608     break;}
1609 case 72:
1610 #line 595 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1611 {
1612   CurRec = new Record(*yyvsp[0].StrVal);
1613   delete yyvsp[0].StrVal;
1614   
1615   if (!CurMultiClass) {
1616     // Top-level def definition.
1617     
1618     // Ensure redefinition doesn't happen.
1619     if (Records.getDef(CurRec->getName())) {
1620       err() << "def '" << CurRec->getName() << "' already defined!\n";
1621       exit(1);
1622     }
1623     Records.addDef(CurRec);
1624   } else {
1625     // Otherwise, a def inside a multiclass, add it to the multiclass.
1626     for (unsigned i = 0, e = CurMultiClass->DefPrototypes.size(); i != e; ++i)
1627       if (CurMultiClass->DefPrototypes[i]->getName() == CurRec->getName()) {
1628         err() << "def '" << CurRec->getName()
1629               << "' already defined in this multiclass!\n";
1630         exit(1);
1631       }
1632     CurMultiClass->DefPrototypes.push_back(CurRec);
1633   }
1634 ;
1635     break;}
1636 case 73:
1637 #line 620 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1638 {
1639            for (unsigned i = 0, e = yyvsp[0].SubClassList->size(); i != e; ++i) {
1640              addSubClass((*yyvsp[0].SubClassList)[i].first, *(*yyvsp[0].SubClassList)[i].second);
1641              // Delete the template arg values for the class
1642              delete (*yyvsp[0].SubClassList)[i].second;
1643            }
1644            delete yyvsp[0].SubClassList;   // Delete the class list...
1645   
1646            // Process any variables on the set stack...
1647            for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
1648              for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
1649                setValue(LetStack[i][j].Name,
1650                         LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0,
1651                         LetStack[i][j].Value);
1652          ;
1653     break;}
1654 case 74:
1655 #line 634 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1656 {
1657            yyval.Rec = CurRec;
1658            CurRec = 0;
1659          ;
1660     break;}
1661 case 75:
1662 #line 639 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1663 {
1664                 ParsingTemplateArgs = true;
1665             ;
1666     break;}
1667 case 76:
1668 #line 641 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1669 {
1670                 ParsingTemplateArgs = false;
1671             ;
1672     break;}
1673 case 77:
1674 #line 643 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1675 {
1676         yyval.Rec = yyvsp[0].Rec;
1677      ;
1678     break;}
1679 case 78:
1680 #line 647 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1681 {
1682   if (CurMultiClass == 0)  // Def's in multiclasses aren't really defs.
1683     yyvsp[0].Rec->resolveReferences();
1684
1685   // If ObjectBody has template arguments, it's an error.
1686   assert(yyvsp[0].Rec->getTemplateArgs().empty() && "How'd this get template args?");
1687   yyval.Rec = yyvsp[0].Rec;
1688 ;
1689     break;}
1690 case 79:
1691 #line 657 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1692 {
1693   yyval.Rec = yyvsp[0].Rec;
1694   // Copy the template arguments for the multiclass into the def.
1695   const std::vector<std::string> &TArgs = CurMultiClass->Rec.getTemplateArgs();
1696   
1697   for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
1698     const RecordVal *RV = CurMultiClass->Rec.getValue(TArgs[i]);
1699     assert(RV && "Template arg doesn't exist?");
1700     yyval.Rec->addValue(*RV);
1701   }
1702 ;
1703     break;}
1704 case 80:
1705 #line 671 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1706 {
1707   yyval.RecList = new std::vector<Record*>();
1708   yyval.RecList->push_back(yyvsp[0].Rec);
1709 ;
1710     break;}
1711 case 81:
1712 #line 674 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1713 {
1714   yyval.RecList->push_back(yyvsp[0].Rec);  
1715 ;
1716     break;}
1717 case 82:
1718 #line 678 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1719 {
1720   MultiClass *&MCE = MultiClasses[*yyvsp[0].StrVal];
1721   if (MCE) {
1722     err() << "multiclass '" << *yyvsp[0].StrVal << "' already defined!\n";
1723     exit(1);
1724   }
1725   MCE = CurMultiClass = new MultiClass(*yyvsp[0].StrVal);
1726   delete yyvsp[0].StrVal;
1727 ;
1728     break;}
1729 case 83:
1730 #line 689 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1731 {
1732                                              ParsingTemplateArgs = true;
1733                                            ;
1734     break;}
1735 case 84:
1736 #line 691 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1737 {
1738                                              ParsingTemplateArgs = false;
1739                                            ;
1740     break;}
1741 case 85:
1742 #line 693 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1743 {
1744   CurMultiClass = 0;
1745 ;
1746     break;}
1747 case 86:
1748 #line 698 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1749 { CurDefmPrefix = yyvsp[0].StrVal; ;
1750     break;}
1751 case 87:
1752 #line 698 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1753 {
1754   // To instantiate a multiclass, we need to first get the multiclass, then
1755   // instantiate each def contained in the multiclass with the SubClassRef
1756   // template parameters.
1757   MultiClass *MC = MultiClasses[yyvsp[-1].SubClassRef->first->getName()];
1758   assert(MC && "Didn't lookup multiclass correctly?");
1759   std::vector<Init*> &TemplateVals = *yyvsp[-1].SubClassRef->second;
1760   delete yyvsp[-1].SubClassRef;
1761   
1762   // Verify that the correct number of template arguments were specified.
1763   const std::vector<std::string> &TArgs = MC->Rec.getTemplateArgs();
1764   if (TArgs.size() < TemplateVals.size()) {
1765     err() << "ERROR: More template args specified than multiclass expects!\n";
1766     exit(1);
1767   }
1768   
1769   // Loop over all the def's in the multiclass, instantiating each one.
1770   for (unsigned i = 0, e = MC->DefPrototypes.size(); i != e; ++i) {
1771     Record *DefProto = MC->DefPrototypes[i];
1772     
1773     // Add the suffix to the defm name to get the new name.
1774     assert(CurRec == 0 && "A def is current?");
1775     CurRec = new Record(*yyvsp[-4].StrVal + DefProto->getName());
1776     
1777     addSubClass(DefProto, std::vector<Init*>());
1778     
1779     // Loop over all of the template arguments, setting them to the specified
1780     // value or leaving them as the default if necessary.
1781     for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
1782       if (i < TemplateVals.size()) { // A value is specified for this temp-arg?
1783         // Set it now.
1784         setValue(TArgs[i], 0, TemplateVals[i]);
1785         
1786         // Resolve it next.
1787         CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i]));
1788         
1789         // Now remove it.
1790         CurRec->removeValue(TArgs[i]);
1791         
1792       } else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) {
1793         err() << "ERROR: Value not specified for template argument #"
1794         << i << " (" << TArgs[i] << ") of multiclassclass '"
1795         << MC->Rec.getName() << "'!\n";
1796         exit(1);
1797       }
1798     }
1799     
1800     // Ensure redefinition doesn't happen.
1801     if (Records.getDef(CurRec->getName())) {
1802       err() << "def '" << CurRec->getName() << "' already defined, "
1803             << "instantiating defm '" << *yyvsp[-4].StrVal << "' with subdef '"
1804             << DefProto->getName() << "'!\n";
1805       exit(1);
1806     }
1807     Records.addDef(CurRec);
1808     
1809     CurRec->resolveReferences();
1810
1811     CurRec = 0;
1812   }
1813   
1814   delete &TemplateVals;
1815   delete yyvsp[-4].StrVal;
1816 ;
1817     break;}
1818 case 88:
1819 #line 763 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1820 {;
1821     break;}
1822 case 89:
1823 #line 763 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1824 {;
1825     break;}
1826 case 92:
1827 #line 766 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1828 {
1829   LetStack.back().push_back(LetRecord(*yyvsp[-3].StrVal, yyvsp[-2].BitList, yyvsp[0].Initializer));
1830   delete yyvsp[-3].StrVal; delete yyvsp[-2].BitList;
1831 ;
1832     break;}
1833 case 95:
1834 #line 774 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1835 { LetStack.push_back(std::vector<LetRecord>()); ;
1836     break;}
1837 case 97:
1838 #line 777 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1839 {
1840     LetStack.pop_back();
1841   ;
1842     break;}
1843 case 98:
1844 #line 780 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1845 {
1846     LetStack.pop_back();
1847   ;
1848     break;}
1849 case 99:
1850 #line 784 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1851 {;
1852     break;}
1853 case 100:
1854 #line 784 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1855 {;
1856     break;}
1857 }
1858    /* the action file gets copied in in place of this dollarsign */
1859 #line 543 "/usr/share/bison.simple"
1860 \f
1861   yyvsp -= yylen;
1862   yyssp -= yylen;
1863 #ifdef YYLSP_NEEDED
1864   yylsp -= yylen;
1865 #endif
1866
1867 #if YYDEBUG != 0
1868   if (yydebug)
1869     {
1870       short *ssp1 = yyss - 1;
1871       fprintf (stderr, "state stack now");
1872       while (ssp1 != yyssp)
1873         fprintf (stderr, " %d", *++ssp1);
1874       fprintf (stderr, "\n");
1875     }
1876 #endif
1877
1878   *++yyvsp = yyval;
1879
1880 #ifdef YYLSP_NEEDED
1881   yylsp++;
1882   if (yylen == 0)
1883     {
1884       yylsp->first_line = yylloc.first_line;
1885       yylsp->first_column = yylloc.first_column;
1886       yylsp->last_line = (yylsp-1)->last_line;
1887       yylsp->last_column = (yylsp-1)->last_column;
1888       yylsp->text = 0;
1889     }
1890   else
1891     {
1892       yylsp->last_line = (yylsp+yylen-1)->last_line;
1893       yylsp->last_column = (yylsp+yylen-1)->last_column;
1894     }
1895 #endif
1896
1897   /* Now "shift" the result of the reduction.
1898      Determine what state that goes to,
1899      based on the state we popped back to
1900      and the rule number reduced by.  */
1901
1902   yyn = yyr1[yyn];
1903
1904   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1905   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1906     yystate = yytable[yystate];
1907   else
1908     yystate = yydefgoto[yyn - YYNTBASE];
1909
1910   goto yynewstate;
1911
1912 yyerrlab:   /* here on detecting error */
1913
1914   if (! yyerrstatus)
1915     /* If not already recovering from an error, report this error.  */
1916     {
1917       ++yynerrs;
1918
1919 #ifdef YYERROR_VERBOSE
1920       yyn = yypact[yystate];
1921
1922       if (yyn > YYFLAG && yyn < YYLAST)
1923         {
1924           int size = 0;
1925           char *msg;
1926           int x, count;
1927
1928           count = 0;
1929           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
1930           for (x = (yyn < 0 ? -yyn : 0);
1931                x < (sizeof(yytname) / sizeof(char *)); x++)
1932             if (yycheck[x + yyn] == x)
1933               size += strlen(yytname[x]) + 15, count++;
1934           msg = (char *) malloc(size + 15);
1935           if (msg != 0)
1936             {
1937               strcpy(msg, "parse error");
1938
1939               if (count < 5)
1940                 {
1941                   count = 0;
1942                   for (x = (yyn < 0 ? -yyn : 0);
1943                        x < (sizeof(yytname) / sizeof(char *)); x++)
1944                     if (yycheck[x + yyn] == x)
1945                       {
1946                         strcat(msg, count == 0 ? ", expecting `" : " or `");
1947                         strcat(msg, yytname[x]);
1948                         strcat(msg, "'");
1949                         count++;
1950                       }
1951                 }
1952               yyerror(msg);
1953               free(msg);
1954             }
1955           else
1956             yyerror ("parse error; also virtual memory exceeded");
1957         }
1958       else
1959 #endif /* YYERROR_VERBOSE */
1960         yyerror("parse error");
1961     }
1962
1963   goto yyerrlab1;
1964 yyerrlab1:   /* here on error raised explicitly by an action */
1965
1966   if (yyerrstatus == 3)
1967     {
1968       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
1969
1970       /* return failure if at end of input */
1971       if (yychar == YYEOF)
1972         YYABORT;
1973
1974 #if YYDEBUG != 0
1975       if (yydebug)
1976         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1977 #endif
1978
1979       yychar = YYEMPTY;
1980     }
1981
1982   /* Else will try to reuse lookahead token
1983      after shifting the error token.  */
1984
1985   yyerrstatus = 3;              /* Each real token shifted decrements this */
1986
1987   goto yyerrhandle;
1988
1989 yyerrdefault:  /* current state does not do anything special for the error token. */
1990
1991 #if 0
1992   /* This is wrong; only states that explicitly want error tokens
1993      should shift them.  */
1994   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
1995   if (yyn) goto yydefault;
1996 #endif
1997
1998 yyerrpop:   /* pop the current state because it cannot handle the error token */
1999
2000   if (yyssp == yyss) YYABORT;
2001   yyvsp--;
2002   yystate = *--yyssp;
2003 #ifdef YYLSP_NEEDED
2004   yylsp--;
2005 #endif
2006
2007 #if YYDEBUG != 0
2008   if (yydebug)
2009     {
2010       short *ssp1 = yyss - 1;
2011       fprintf (stderr, "Error: state stack now");
2012       while (ssp1 != yyssp)
2013         fprintf (stderr, " %d", *++ssp1);
2014       fprintf (stderr, "\n");
2015     }
2016 #endif
2017
2018 yyerrhandle:
2019
2020   yyn = yypact[yystate];
2021   if (yyn == YYFLAG)
2022     goto yyerrdefault;
2023
2024   yyn += YYTERROR;
2025   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
2026     goto yyerrdefault;
2027
2028   yyn = yytable[yyn];
2029   if (yyn < 0)
2030     {
2031       if (yyn == YYFLAG)
2032         goto yyerrpop;
2033       yyn = -yyn;
2034       goto yyreduce;
2035     }
2036   else if (yyn == 0)
2037     goto yyerrpop;
2038
2039   if (yyn == YYFINAL)
2040     YYACCEPT;
2041
2042 #if YYDEBUG != 0
2043   if (yydebug)
2044     fprintf(stderr, "Shifting error token, ");
2045 #endif
2046
2047   *++yyvsp = yylval;
2048 #ifdef YYLSP_NEEDED
2049   *++yylsp = yylloc;
2050 #endif
2051
2052   yystate = yyn;
2053   goto yynewstate;
2054
2055  yyacceptlab:
2056   /* YYACCEPT comes here.  */
2057   if (yyfree_stacks)
2058     {
2059       free (yyss);
2060       free (yyvs);
2061 #ifdef YYLSP_NEEDED
2062       free (yyls);
2063 #endif
2064     }
2065   return 0;
2066
2067  yyabortlab:
2068   /* YYABORT comes here.  */
2069   if (yyfree_stacks)
2070     {
2071       free (yyss);
2072       free (yyvs);
2073 #ifdef YYLSP_NEEDED
2074       free (yyls);
2075 #endif
2076     }
2077   return 1;
2078 }
2079 #line 788 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
2080
2081
2082 int yyerror(const char *ErrorMsg) {
2083   err() << "Error parsing: " << ErrorMsg << "\n";
2084   exit(1);
2085 }