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