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