blob: a49846ffa0b77bb06b4369185673df563d1c29e6 [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Chris Lattner10814822007-09-17 17:40:48 +00002/* A Bison parser, made from /Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y
3 by GNU Bison version 1.28 */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004
Chris Lattner10814822007-09-17 17:40:48 +00005#define YYBISON 1 /* Identify Bison output. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00006
Reid Spencer68a24bd2005-08-27 18:50:39 +00007#define yyparse Fileparse
Chris Lattner10814822007-09-17 17:40:48 +00008#define yylex Filelex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror Fileerror
Chris Lattner10814822007-09-17 17:40:48 +000010#define yylval Filelval
11#define yychar Filechar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug Filedebug
13#define yynerrs Filenerrs
Chris Lattner10814822007-09-17 17:40:48 +000014#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
Reid Spencer68a24bd2005-08-27 18:50:39 +000038
Chris Lattner10814822007-09-17 17:40:48 +000039#line 14 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +000040
41#include "Record.h"
42#include "llvm/ADT/StringExtras.h"
Bill Wendlingf5da1332006-12-07 22:21:48 +000043#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +000044#include <algorithm>
45#include <cstdio>
46#define YYERROR_VERBOSE 1
47
48int yyerror(const char *ErrorMsg);
49int yylex();
50
51namespace llvm {
Chris Lattner27627382006-09-01 21:14:42 +000052 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 };
Reid Spencer68a24bd2005-08-27 18:50:39 +000058
Chris Lattner27627382006-09-01 21:14:42 +000059
60static std::map<std::string, MultiClass*> MultiClasses;
61
Reid Spencer68a24bd2005-08-27 18:50:39 +000062extern int Filelineno;
Chris Lattner27627382006-09-01 21:14:42 +000063static MultiClass *CurMultiClass = 0; // Set while parsing a multiclass.
64static std::string *CurDefmPrefix = 0; // Set while parsing defm.
Reid Spencer68a24bd2005-08-27 18:50:39 +000065static Record *CurRec = 0;
66static bool ParsingTemplateArgs = false;
67
68typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
69
70struct 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
81static std::vector<std::vector<LetRecord> > LetStack;
82
83
84extern std::ostream &err();
85
Chris Lattner27627382006-09-01 21:14:42 +000086/// getActiveRec - If inside a def/class definition, return the def/class.
87/// Otherwise, if within a multidef, return it.
88static Record *getActiveRec() {
89 return CurRec ? CurRec : &CurMultiClass->Rec;
90}
91
Reid Spencer68a24bd2005-08-27 18:50:39 +000092static void addValue(const RecordVal &RV) {
Chris Lattner27627382006-09-01 21:14:42 +000093 Record *TheRec = getActiveRec();
94
95 if (RecordVal *ERV = TheRec->getValue(RV.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +000096 // 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 {
Chris Lattner27627382006-09-01 21:14:42 +0000104 TheRec->addValue(RV);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000105 }
106}
107
108static 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
116static void setValue(const std::string &ValName,
Chris Lattner81779692006-03-30 22:51:12 +0000117 std::vector<unsigned> *BitList, Init *V) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000118 if (!V) return;
119
Chris Lattnerdc52f172006-10-07 07:15:19 +0000120 Record *TheRec = getActiveRec();
121 RecordVal *RV = TheRec->getValue(ValName);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000122 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...
Bill Wendlingf5da1332006-12-07 22:21:48 +0000154 assert(dynamic_cast<BitsInit*>(BI) != 0 || (cerr << *BI).stream() == 0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000155 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.
186static 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);
Chris Lattner27627382006-09-01 21:14:42 +0000198 }
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]);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000206
Chris Lattner27627382006-09-01 21:14:42 +0000207 // Resolve it next.
208 CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i]));
209
210
211 // Now remove it.
212 CurRec->removeValue(TArgs[i]);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000213
Chris Lattner27627382006-09-01 21:14:42 +0000214 } 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);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000219 }
220 }
221
222 // Since everything went well, we can now set the "superclass" list for the
223 // current record.
Chris Lattner27627382006-09-01 21:14:42 +0000224 const std::vector<Record*> &SCs = SC->getSuperClasses();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000225 for (unsigned i = 0, e = SCs.size(); i != e; ++i)
226 addSuperClass(SCs[i]);
227 addSuperClass(SC);
228}
229
230} // End llvm namespace
231
232using namespace llvm;
233
234
Chris Lattner10814822007-09-17 17:40:48 +0000235#line 210 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
236typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000237 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;
Chris Lattner27627382006-09-01 21:14:42 +0000244 std::vector<llvm::Record*>* RecList;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000245 SubClassRefTy* SubClassRef;
246 std::vector<SubClassRefTy>* SubClassList;
247 std::vector<std::pair<llvm::Init*, std::string> >* DagValueList;
Chris Lattner10814822007-09-17 17:40:48 +0000248} YYSTYPE;
249#include <stdio.h>
250
251#ifndef __cplusplus
252#ifndef __STDC__
253#define const
254#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000255#endif
256
257
258
Chris Lattner10814822007-09-17 17:40:48 +0000259#define YYFINAL 194
260#define YYFLAG -32768
261#define YYNTBASE 42
Reid Spencer68a24bd2005-08-27 18:50:39 +0000262
Chris Lattner10814822007-09-17 17:40:48 +0000263#define YYTRANSLATE(x) ((unsigned)(x) <= 280 ? yytranslate[x] : 91)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000264
Chris Lattner10814822007-09-17 17:40:48 +0000265static 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};
Reid Spencer68a24bd2005-08-27 18:50:39 +0000295
Chris Lattner10814822007-09-17 17:40:48 +0000296#if YYDEBUG != 0
297static 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
311static 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
Reid Spencer68a24bd2005-08-27 18:50:39 +0000346#endif
347
Chris Lattner10814822007-09-17 17:40:48 +0000348#if YYDEBUG != 0
349static 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
367static 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
382static 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
396static 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
410static 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
433static 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
441static 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
464static 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
476static 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
500static 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
Reid Spencer68a24bd2005-08-27 18:50:39 +0000599#else
Chris Lattner10814822007-09-17 17:40:48 +0000600#define YYSTACK_ALLOC malloc
Reid Spencer68a24bd2005-08-27 18:50:39 +0000601#endif
602
Chris Lattner10814822007-09-17 17:40:48 +0000603/* 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. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000606
607#define yyerrok (yyerrstatus = 0)
608#define yyclearin (yychar = YYEMPTY)
Chris Lattner10814822007-09-17 17:40:48 +0000609#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +0000610#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +0000611#define YYACCEPT goto yyacceptlab
Chris Lattner10814822007-09-17 17:40:48 +0000612#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.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000617 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000618#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +0000619#define YYRECOVERING() (!!yyerrstatus)
Chris Lattner10814822007-09-17 17:40:48 +0000620#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +0000621do \
622 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattner10814822007-09-17 17:40:48 +0000623 { yychar = (token), yylval = (value); \
624 yychar1 = YYTRANSLATE (yychar); \
625 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +0000626 goto yybackup; \
627 } \
628 else \
Chris Lattner10814822007-09-17 17:40:48 +0000629 { yyerror ("syntax error: cannot back up"); YYERROR; } \
630while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000631
632#define YYTERROR 1
633#define YYERRCODE 256
634
Chris Lattner10814822007-09-17 17:40:48 +0000635#ifndef YYPURE
636#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +0000637#endif
638
Chris Lattner10814822007-09-17 17:40:48 +0000639#ifdef YYPURE
640#ifdef YYLSP_NEEDED
Reid Spencer68a24bd2005-08-27 18:50:39 +0000641#ifdef YYLEX_PARAM
Chris Lattner10814822007-09-17 17:40:48 +0000642#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000643#else
Chris Lattner10814822007-09-17 17:40:48 +0000644#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 */
Chris Lattner81779692006-03-30 22:51:12 +0000653#endif
Bill Wendlingf5da1332006-12-07 22:21:48 +0000654
Chris Lattner10814822007-09-17 17:40:48 +0000655/* If nonreentrant, generate the variables here */
Bill Wendlingf5da1332006-12-07 22:21:48 +0000656
Chris Lattner10814822007-09-17 17:40:48 +0000657#ifndef YYPURE
Bill Wendlingf5da1332006-12-07 22:21:48 +0000658
Chris Lattner10814822007-09-17 17:40:48 +0000659int yychar; /* the lookahead symbol */
660YYSTYPE yylval; /* the semantic value of the */
661 /* lookahead symbol */
Bill Wendlingf5da1332006-12-07 22:21:48 +0000662
Chris Lattner10814822007-09-17 17:40:48 +0000663#ifdef YYLSP_NEEDED
664YYLTYPE yylloc; /* location data for the lookahead */
665 /* symbol */
Chris Lattner81779692006-03-30 22:51:12 +0000666#endif
Bill Wendlingf5da1332006-12-07 22:21:48 +0000667
Chris Lattner10814822007-09-17 17:40:48 +0000668int yynerrs; /* number of parse errors so far */
669#endif /* not YYPURE */
Bill Wendlingf5da1332006-12-07 22:21:48 +0000670
Chris Lattner10814822007-09-17 17:40:48 +0000671#if YYDEBUG != 0
672int yydebug; /* nonzero means print parse trace */
673/* Since this is uninitialized, it does not stop multiple parsers
674 from coexisting. */
Chris Lattner8d354e92005-09-30 04:11:27 +0000675#endif
John Criswelld7881242006-01-17 17:01:34 +0000676
Chris Lattner10814822007-09-17 17:40:48 +0000677/* YYINITDEPTH indicates the initial size of the parser's stacks */
John Criswelld7881242006-01-17 17:01:34 +0000678
Reid Spencer68a24bd2005-08-27 18:50:39 +0000679#ifndef YYINITDEPTH
Chris Lattner10814822007-09-17 17:40:48 +0000680#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +0000681#endif
682
Chris Lattner10814822007-09-17 17:40:48 +0000683/* YYMAXDEPTH is the maximum size the stacks can grow to
684 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000685
Chris Lattner10814822007-09-17 17:40:48 +0000686#if YYMAXDEPTH == 0
687#undef YYMAXDEPTH
688#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000689
690#ifndef YYMAXDEPTH
Chris Lattner10814822007-09-17 17:40:48 +0000691#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +0000692#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000693
Chris Lattner10814822007-09-17 17:40:48 +0000694/* 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. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000698
Chris Lattner10814822007-09-17 17:40:48 +0000699#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
Reid Spencer68a24bd2005-08-27 18:50:39 +0000703
Chris Lattner10814822007-09-17 17:40:48 +0000704/* This is the most reliable way to avoid incompatibilities
705 in available built-in functions on various systems. */
Bill Wendlingf5da1332006-12-07 22:21:48 +0000706static void
Chris Lattner10814822007-09-17 17:40:48 +0000707__yy_memcpy (to, from, count)
708 char *to;
709 char *from;
710 unsigned int count;
Bill Wendlingf5da1332006-12-07 22:21:48 +0000711{
Chris Lattner10814822007-09-17 17:40:48 +0000712 register char *f = from;
713 register char *t = to;
714 register int i = count;
Bill Wendlingf5da1332006-12-07 22:21:48 +0000715
Chris Lattner10814822007-09-17 17:40:48 +0000716 while (i-- > 0)
717 *t++ = *f++;
Bill Wendlingf5da1332006-12-07 22:21:48 +0000718}
Bill Wendlingf5da1332006-12-07 22:21:48 +0000719
Chris Lattner10814822007-09-17 17:40:48 +0000720#else /* __cplusplus */
721
722/* This is the most reliable way to avoid incompatibilities
723 in available built-in functions on various systems. */
724static 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
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. */
Bill Wendlingf5da1332006-12-07 22:21:48 +0000745
746#ifdef YYPARSE_PARAM
Chris Lattner10814822007-09-17 17:40:48 +0000747#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
762int yyparse (void *);
Bill Wendlingf5da1332006-12-07 22:21:48 +0000763#else
John Criswelld7881242006-01-17 17:01:34 +0000764int yyparse (void);
Chris Lattner81779692006-03-30 22:51:12 +0000765#endif
766#endif
Chris Lattner10814822007-09-17 17:40:48 +0000767
768int
769yyparse(YYPARSE_PARAM_ARG)
770 YYPARSE_PARAM_DECL
Bill Wendlingf5da1332006-12-07 22:21:48 +0000771{
Chris Lattner10814822007-09-17 17:40:48 +0000772 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--)
Chris Lattner81779692006-03-30 22:51:12 +0000793#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000794
Chris Lattner10814822007-09-17 17:40:48 +0000795 int yystacksize = YYINITDEPTH;
796 int yyfree_stacks = 0;
Bill Wendlingf5da1332006-12-07 22:21:48 +0000797
Chris Lattner10814822007-09-17 17:40:48 +0000798#ifdef YYPURE
799 int yychar;
800 YYSTYPE yylval;
801 int yynerrs;
802#ifdef YYLSP_NEEDED
803 YYLTYPE yylloc;
804#endif
805#endif
Bill Wendlingf5da1332006-12-07 22:21:48 +0000806
Chris Lattner10814822007-09-17 17:40:48 +0000807 YYSTYPE yyval; /* the variable used to return */
808 /* semantic values from the action */
809 /* routines */
Bill Wendlingf5da1332006-12-07 22:21:48 +0000810
Chris Lattner10814822007-09-17 17:40:48 +0000811 int yylen;
Bill Wendlingf5da1332006-12-07 22:21:48 +0000812
Chris Lattner10814822007-09-17 17:40:48 +0000813#if YYDEBUG != 0
814 if (yydebug)
815 fprintf(stderr, "Starting parse\n");
816#endif
Bill Wendlingf5da1332006-12-07 22:21:48 +0000817
Reid Spencer68a24bd2005-08-27 18:50:39 +0000818 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
Chris Lattner10814822007-09-17 17:40:48 +0000828 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000829 yyvsp = yyvs;
Chris Lattner10814822007-09-17 17:40:48 +0000830#ifdef YYLSP_NEEDED
831 yylsp = yyls;
832#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000833
Chris Lattner10814822007-09-17 17:40:48 +0000834/* 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. */
837yynewstate:
Reid Spencer68a24bd2005-08-27 18:50:39 +0000838
Chris Lattner10814822007-09-17 17:40:48 +0000839 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000840
Chris Lattner10814822007-09-17 17:40:48 +0000841 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000842 {
Chris Lattner10814822007-09-17 17:40:48 +0000843 /* 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
Reid Spencer68a24bd2005-08-27 18:50:39 +0000851 /* Get the current used size of the three stacks, in elements. */
Chris Lattner10814822007-09-17 17:40:48 +0000852 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000853
854#ifdef yyoverflow
Chris Lattner10814822007-09-17 17:40:48 +0000855 /* 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
Reid Spencer68a24bd2005-08-27 18:50:39 +0000871
Chris Lattner10814822007-09-17 17:40:48 +0000872 yyss = yyss1; yyvs = yyvs1;
873#ifdef YYLSP_NEEDED
874 yyls = yyls1;
875#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000876#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000877 /* Extend the stack our own way. */
Chris Lattner10814822007-09-17 17:40:48 +0000878 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 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000891 yystacksize *= 2;
Chris Lattner10814822007-09-17 17:40:48 +0000892 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000893 yystacksize = YYMAXDEPTH;
Chris Lattner10814822007-09-17 17:40:48 +0000894#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
Reid Spencer68a24bd2005-08-27 18:50:39 +0000908#endif /* no yyoverflow */
909
Chris Lattner10814822007-09-17 17:40:48 +0000910 yyssp = yyss + size - 1;
911 yyvsp = yyvs + size - 1;
912#ifdef YYLSP_NEEDED
913 yylsp = yyls + size - 1;
914#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000915
Chris Lattner10814822007-09-17 17:40:48 +0000916#if YYDEBUG != 0
917 if (yydebug)
918 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
919#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000920
Chris Lattner10814822007-09-17 17:40:48 +0000921 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000922 YYABORT;
923 }
924
Chris Lattner10814822007-09-17 17:40:48 +0000925#if YYDEBUG != 0
926 if (yydebug)
927 fprintf(stderr, "Entering state %d\n", yystate);
928#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000929
930 goto yybackup;
Chris Lattner10814822007-09-17 17:40:48 +0000931 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +0000932
Chris Lattner10814822007-09-17 17:40:48 +0000933/* Do appropriate processing given the current state. */
934/* Read a lookahead token if we need one and don't already have one. */
935/* yyresume: */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000936
Chris Lattner10814822007-09-17 17:40:48 +0000937 /* First try to decide what to do without reference to lookahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000938
939 yyn = yypact[yystate];
Chris Lattner10814822007-09-17 17:40:48 +0000940 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000941 goto yydefault;
942
Chris Lattner10814822007-09-17 17:40:48 +0000943 /* Not known => get a lookahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000944
Chris Lattner10814822007-09-17 17:40:48 +0000945 /* yychar is either YYEMPTY or YYEOF
946 or a valid token in external form. */
947
Reid Spencer68a24bd2005-08-27 18:50:39 +0000948 if (yychar == YYEMPTY)
949 {
Chris Lattner10814822007-09-17 17:40:48 +0000950#if YYDEBUG != 0
951 if (yydebug)
952 fprintf(stderr, "Reading a token: ");
953#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000954 yychar = YYLEX;
955 }
956
Chris Lattner10814822007-09-17 17:40:48 +0000957 /* Convert token to internal form (in yychar1) for indexing tables with */
958
959 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000960 {
Chris Lattner10814822007-09-17 17:40:48 +0000961 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
Reid Spencer68a24bd2005-08-27 18:50:39 +0000968 }
969 else
970 {
Chris Lattner10814822007-09-17 17:40:48 +0000971 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
Reid Spencer68a24bd2005-08-27 18:50:39 +0000985 }
986
Chris Lattner10814822007-09-17 17:40:48 +0000987 yyn += yychar1;
988 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000989 goto yydefault;
Chris Lattner10814822007-09-17 17:40:48 +0000990
Reid Spencer68a24bd2005-08-27 18:50:39 +0000991 yyn = yytable[yyn];
Chris Lattner10814822007-09-17 17:40:48 +0000992
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)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001001 {
Chris Lattner10814822007-09-17 17:40:48 +00001002 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001003 goto yyerrlab;
1004 yyn = -yyn;
1005 goto yyreduce;
1006 }
Chris Lattner10814822007-09-17 17:40:48 +00001007 else if (yyn == 0)
1008 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001009
1010 if (yyn == YYFINAL)
1011 YYACCEPT;
1012
Chris Lattner10814822007-09-17 17:40:48 +00001013 /* Shift the lookahead token. */
Chris Lattner81779692006-03-30 22:51:12 +00001014
Chris Lattner10814822007-09-17 17:40:48 +00001015#if YYDEBUG != 0
1016 if (yydebug)
1017 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
1018#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001019
Chris Lattner10814822007-09-17 17:40:48 +00001020 /* Discard the token being shifted unless it is eof. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001021 if (yychar != YYEOF)
1022 yychar = YYEMPTY;
1023
Bill Wendlingf5da1332006-12-07 22:21:48 +00001024 *++yyvsp = yylval;
Chris Lattner10814822007-09-17 17:40:48 +00001025#ifdef YYLSP_NEEDED
1026 *++yylsp = yylloc;
1027#endif
Bill Wendlingf5da1332006-12-07 22:21:48 +00001028
Chris Lattner10814822007-09-17 17:40:48 +00001029 /* count tokens shifted since error; after three, turn off error status. */
1030 if (yyerrstatus) yyerrstatus--;
1031
1032 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001033 goto yynewstate;
1034
Chris Lattner10814822007-09-17 17:40:48 +00001035/* Do the default action for the current state. */
Bill Wendlingf5da1332006-12-07 22:21:48 +00001036yydefault:
Chris Lattner10814822007-09-17 17:40:48 +00001037
Reid Spencer68a24bd2005-08-27 18:50:39 +00001038 yyn = yydefact[yystate];
1039 if (yyn == 0)
1040 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001041
Chris Lattner10814822007-09-17 17:40:48 +00001042/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001043yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00001044 yylen = yyr2[yyn];
Chris Lattner10814822007-09-17 17:40:48 +00001045 if (yylen > 0)
1046 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001047
Chris Lattner10814822007-09-17 17:40:48 +00001048#if YYDEBUG != 0
1049 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001050 {
Chris Lattner10814822007-09-17 17:40:48 +00001051 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
1066case 1:
1067#line 246 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1068{
Chris Lattner27627382006-09-01 21:14:42 +00001069 if (CurDefmPrefix) {
1070 // If CurDefmPrefix is set, we're parsing a defm, which means that this is
1071 // actually the name of a multiclass.
Chris Lattner10814822007-09-17 17:40:48 +00001072 MultiClass *MC = MultiClasses[*yyvsp[0].StrVal];
Chris Lattner27627382006-09-01 21:14:42 +00001073 if (MC == 0) {
Chris Lattner10814822007-09-17 17:40:48 +00001074 err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n";
Chris Lattner27627382006-09-01 21:14:42 +00001075 exit(1);
1076 }
Chris Lattner10814822007-09-17 17:40:48 +00001077 yyval.Rec = &MC->Rec;
Chris Lattner27627382006-09-01 21:14:42 +00001078 } else {
Chris Lattner10814822007-09-17 17:40:48 +00001079 yyval.Rec = Records.getClass(*yyvsp[0].StrVal);
Chris Lattner27627382006-09-01 21:14:42 +00001080 }
Chris Lattner10814822007-09-17 17:40:48 +00001081 if (yyval.Rec == 0) {
1082 err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n";
Reid Spencer68a24bd2005-08-27 18:50:39 +00001083 exit(1);
1084 }
Chris Lattner10814822007-09-17 17:40:48 +00001085 delete yyvsp[0].StrVal;
1086 ;
1087 break;}
1088case 2:
1089#line 268 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1090{ // string type
1091 yyval.Ty = new StringRecTy();
1092 ;
1093 break;}
1094case 3:
1095#line 270 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1096{ // bit type
1097 yyval.Ty = new BitRecTy();
1098 ;
1099 break;}
1100case 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;}
1106case 5:
1107#line 274 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1108{ // int type
1109 yyval.Ty = new IntRecTy();
1110 ;
1111 break;}
1112case 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;}
1118case 7:
1119#line 278 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1120{ // code type
1121 yyval.Ty = new CodeRecTy();
1122 ;
1123 break;}
1124case 8:
1125#line 280 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1126{ // dag type
1127 yyval.Ty = new DagRecTy();
1128 ;
1129 break;}
1130case 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;}
1136case 10:
1137#line 286 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1138{ yyval.IntVal = 0; ;
1139 break;}
1140case 11:
1141#line 286 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1142{ yyval.IntVal = 1; ;
1143 break;}
1144case 12:
1145#line 288 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1146{ yyval.Initializer = 0; ;
1147 break;}
1148case 13:
1149#line 288 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1150{ yyval.Initializer = yyvsp[0].Initializer; ;
1151 break;}
1152case 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);
Chris Lattner81779692006-03-30 22:51:12 +00001159 assert(RV && "Template arg doesn't exist??");
Chris Lattner10814822007-09-17 17:40:48 +00001160 yyval.Initializer = new VarInit(CurRec->getName()+":"+*yyvsp[0].StrVal, RV->getType());
Chris Lattner27627382006-09-01 21:14:42 +00001161 } else if (CurMultiClass &&
Chris Lattner10814822007-09-17 17:40:48 +00001162 CurMultiClass->Rec.isTemplateArg(CurMultiClass->Rec.getName()+"::"+*yyvsp[0].StrVal)) {
1163 std::string Name = CurMultiClass->Rec.getName()+"::"+*yyvsp[0].StrVal;
Chris Lattner27627382006-09-01 21:14:42 +00001164 const RecordVal *RV = CurMultiClass->Rec.getValue(Name);
1165 assert(RV && "Template arg doesn't exist??");
Chris Lattner10814822007-09-17 17:40:48 +00001166 yyval.Initializer = new VarInit(Name, RV->getType());
1167 } else if (Record *D = Records.getDef(*yyvsp[0].StrVal)) {
1168 yyval.Initializer = new DefInit(D);
Chris Lattner81779692006-03-30 22:51:12 +00001169 } else {
Chris Lattner10814822007-09-17 17:40:48 +00001170 err() << "Variable not defined: '" << *yyvsp[0].StrVal << "'!\n";
Chris Lattner81779692006-03-30 22:51:12 +00001171 exit(1);
1172 }
1173
Chris Lattner10814822007-09-17 17:40:48 +00001174 delete yyvsp[0].StrVal;
1175;
1176 break;}
1177case 15:
1178#line 313 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1179{
1180 yyval.Initializer = yyvsp[0].Initializer;
1181 ;
1182 break;}
1183case 16:
1184#line 315 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1185{
1186 yyval.Initializer = new IntInit(yyvsp[0].IntVal);
1187 ;
1188 break;}
1189case 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;}
1196case 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;}
1203case 19:
1204#line 323 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1205{
1206 yyval.Initializer = new UnsetInit();
1207 ;
1208 break;}
1209case 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());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001215 if (Bit == 0) {
Chris Lattner10814822007-09-17 17:40:48 +00001216 err() << "Element #" << i << " (" << *(*yyvsp[-1].FieldList)[i]
Chris Lattnerba4b1442005-09-08 18:22:57 +00001217 << ") is not convertable to a bit!\n";
1218 exit(1);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001219 }
Chris Lattner10814822007-09-17 17:40:48 +00001220 Init->setBit(yyvsp[-1].FieldList->size()-i-1, Bit);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001221 }
Chris Lattner10814822007-09-17 17:40:48 +00001222 yyval.Initializer = Init;
1223 delete yyvsp[-1].FieldList;
1224 ;
1225 break;}
1226case 21:
1227#line 338 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1228{
Chris Lattnerca572be2005-09-08 18:48:47 +00001229 // This is a CLASS<initvalslist> expression. This is supposed to synthesize
1230 // a new anonymous definition, deriving from CLASS<initvalslist> with no
1231 // body.
Chris Lattner10814822007-09-17 17:40:48 +00001232 Record *Class = Records.getClass(*yyvsp[-3].StrVal);
Chris Lattnerca572be2005-09-08 18:48:47 +00001233 if (!Class) {
Chris Lattner10814822007-09-17 17:40:48 +00001234 err() << "Expected a class, got '" << *yyvsp[-3].StrVal << "'!\n";
Chris Lattnerca572be2005-09-08 18:48:47 +00001235 exit(1);
1236 }
Chris Lattner10814822007-09-17 17:40:48 +00001237 delete yyvsp[-3].StrVal;
Chris Lattnerca572be2005-09-08 18:48:47 +00001238
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++));
Chris Lattner10814822007-09-17 17:40:48 +00001244 addSubClass(Class, *yyvsp[-1].FieldList); // Add info about the subclass to CurRec.
1245 delete yyvsp[-1].FieldList; // Free up the template args.
Chris Lattnerca572be2005-09-08 18:48:47 +00001246
Chris Lattner751eabf2005-09-08 19:47:28 +00001247 CurRec->resolveReferences();
Chris Lattnerca572be2005-09-08 18:48:47 +00001248
1249 Records.addDef(CurRec);
1250
1251 // The result of the expression is a reference to the new record.
Chris Lattner10814822007-09-17 17:40:48 +00001252 yyval.Initializer = new DefInit(CurRec);
Chris Lattnerca572be2005-09-08 18:48:47 +00001253
1254 // Restore the old CurRec
1255 CurRec = OldRec;
Chris Lattner10814822007-09-17 17:40:48 +00001256 ;
1257 break;}
1258case 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";
Reid Spencer68a24bd2005-08-27 18:50:39 +00001264 exit(1);
1265 }
Chris Lattner10814822007-09-17 17:40:48 +00001266 delete yyvsp[-1].BitList;
1267 ;
1268 break;}
1269case 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;}
1276case 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";
Reid Spencer68a24bd2005-08-27 18:50:39 +00001281 exit(1);
1282 }
Chris Lattner10814822007-09-17 17:40:48 +00001283 yyval.Initializer = new FieldInit(yyvsp[-2].Initializer, *yyvsp[0].StrVal);
1284 delete yyvsp[0].StrVal;
1285 ;
1286 break;}
1287case 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;}
1294case 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";
Reid Spencer68a24bd2005-08-27 18:50:39 +00001301 exit(1);
1302 }
Chris Lattner10814822007-09-17 17:40:48 +00001303 delete yyvsp[-1].BitList;
1304 ;
1305 break;}
1306case 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;}
1312case 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;}
1318case 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;}
1324case 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;}
1330case 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;}
1336case 32:
1337#line 406 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1338{
1339 yyval.StrVal = new std::string();
1340 ;
1341 break;}
1342case 33:
1343#line 409 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1344{
1345 yyval.StrVal = yyvsp[0].StrVal;
1346 ;
1347 break;}
1348case 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;}
1356case 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;}
1364case 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;}
1370case 37:
1371#line 427 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1372{ yyval.DagValueList = yyvsp[0].DagValueList; ;
1373 break;}
1374case 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;}
1381case 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";
Reid Spencer68a24bd2005-08-27 18:50:39 +00001386 exit(1);
1387 }
Chris Lattner10814822007-09-17 17:40:48 +00001388 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);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001392 } else {
Chris Lattner10814822007-09-17 17:40:48 +00001393 for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1394 yyval.BitList->push_back(i);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001395 }
Chris Lattner10814822007-09-17 17:40:48 +00001396 ;
1397 break;}
1398case 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";
Reid Spencer68a24bd2005-08-27 18:50:39 +00001404 exit(1);
1405 }
Chris Lattner10814822007-09-17 17:40:48 +00001406 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);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001410 } else {
Chris Lattner10814822007-09-17 17:40:48 +00001411 for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1412 yyval.BitList->push_back(i);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001413 }
Chris Lattner10814822007-09-17 17:40:48 +00001414 ;
1415 break;}
1416case 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;}
1422case 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";
Reid Spencer68a24bd2005-08-27 18:50:39 +00001427 exit(1);
1428 }
Chris Lattner10814822007-09-17 17:40:48 +00001429 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);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001433 } else {
Chris Lattner10814822007-09-17 17:40:48 +00001434 for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1435 yyval.BitList->push_back(i);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001436 }
Chris Lattner10814822007-09-17 17:40:48 +00001437 ;
1438 break;}
1439case 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";
Reid Spencer68a24bd2005-08-27 18:50:39 +00001445 exit(1);
1446 }
Chris Lattner10814822007-09-17 17:40:48 +00001447 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);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001451 } else {
Chris Lattner10814822007-09-17 17:40:48 +00001452 for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1453 yyval.BitList->push_back(i);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001454 }
Chris Lattner10814822007-09-17 17:40:48 +00001455 ;
1456 break;}
1457case 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;}
1461case 45:
1462#line 493 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1463{ yyval.BitList = 0; ;
1464 break;}
1465case 46:
1466#line 493 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1467{ yyval.BitList = yyvsp[-1].BitList; ;
1468 break;}
1469case 47:
1470#line 497 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1471{
1472 yyval.FieldList = new std::vector<Init*>();
1473 ;
1474 break;}
1475case 48:
1476#line 499 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1477{
1478 yyval.FieldList = yyvsp[0].FieldList;
1479 ;
1480 break;}
1481case 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;}
1488case 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;}
1494case 51:
1495#line 510 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1496{
1497 std::string DecName = *yyvsp[-1].StrVal;
Chris Lattner27627382006-09-01 21:14:42 +00001498 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 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001507
Chris Lattner10814822007-09-17 17:40:48 +00001508 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;}
1513case 52:
1514#line 527 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1515{
1516 delete yyvsp[-1].StrVal;
1517;
1518 break;}
1519case 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;}
1527case 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;}
1533case 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;}
1539case 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;}
1547case 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;}
1554case 62:
1555#line 554 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1556{
1557 yyval.SubClassList = new std::vector<SubClassRefTy>();
1558 ;
1559 break;}
1560case 63:
1561#line 557 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1562{
1563 yyval.SubClassList = yyvsp[0].SubClassList;
1564 ;
1565 break;}
1566case 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;}
1573case 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;}
1580case 66:
1581#line 569 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1582{;
1583 break;}
1584case 69:
1585#line 572 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1586{ yyval.StrVal = yyvsp[0].StrVal; ;
1587 break;}
1588case 70:
1589#line 572 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1590{ yyval.StrVal = new std::string(); ;
1591 break;}
1592case 71:
1593#line 574 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1594{
Chris Lattner8d354e92005-09-30 04:11:27 +00001595 static unsigned AnonCounter = 0;
Chris Lattner10814822007-09-17 17:40:48 +00001596 if (yyvsp[0].StrVal->empty())
1597 *yyvsp[0].StrVal = "anonymous."+utostr(AnonCounter++);
1598 yyval.StrVal = yyvsp[0].StrVal;
1599;
1600 break;}
1601case 72:
1602#line 581 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1603{
Chris Lattner946ac932005-09-30 04:53:25 +00001604 // If a class of this name already exists, it must be a forward ref.
Chris Lattner10814822007-09-17 17:40:48 +00001605 if ((CurRec = Records.getClass(*yyvsp[0].StrVal))) {
Chris Lattner946ac932005-09-30 04:53:25 +00001606 // 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.
Chris Lattner10814822007-09-17 17:40:48 +00001615 CurRec = new Record(*yyvsp[0].StrVal);
Chris Lattner946ac932005-09-30 04:53:25 +00001616 Records.addClass(CurRec);
Chris Lattner8d354e92005-09-30 04:11:27 +00001617 }
Chris Lattner10814822007-09-17 17:40:48 +00001618 delete yyvsp[0].StrVal;
1619;
1620 break;}
1621case 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;
Chris Lattner946ac932005-09-30 04:53:25 +00001626
Chris Lattner27627382006-09-01 21:14:42 +00001627 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);
Chris Lattner8d354e92005-09-30 04:11:27 +00001645 }
Chris Lattner10814822007-09-17 17:40:48 +00001646;
1647 break;}
1648case 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);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001653 // Delete the template arg values for the class
Chris Lattner10814822007-09-17 17:40:48 +00001654 delete (*yyvsp[0].SubClassList)[i].second;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001655 }
Chris Lattner10814822007-09-17 17:40:48 +00001656 delete yyvsp[0].SubClassList; // Delete the class list.
Chris Lattner0a284052005-09-30 04:42:56 +00001657
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001658 // Process any variables on the let stack.
Chris Lattnerba4b1442005-09-08 18:22:57 +00001659 for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001660 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);
Chris Lattner10814822007-09-17 17:40:48 +00001664 ;
1665 break;}
1666case 75:
1667#line 638 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1668{
1669 yyval.Rec = CurRec;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001670 CurRec = 0;
Chris Lattner10814822007-09-17 17:40:48 +00001671 ;
1672 break;}
1673case 76:
1674#line 643 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1675{
Chris Lattner946ac932005-09-30 04:53:25 +00001676 ParsingTemplateArgs = true;
Chris Lattner10814822007-09-17 17:40:48 +00001677 ;
1678 break;}
1679case 77:
1680#line 645 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1681{
Chris Lattner946ac932005-09-30 04:53:25 +00001682 ParsingTemplateArgs = false;
Chris Lattner10814822007-09-17 17:40:48 +00001683 ;
1684 break;}
1685case 78:
1686#line 647 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1687{
1688 yyval.Rec = yyvsp[0].Rec;
1689 ;
1690 break;}
1691case 79:
1692#line 651 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1693{
Chris Lattner7717d092006-09-01 21:59:03 +00001694 if (CurMultiClass == 0) // Def's in multiclasses aren't really defs.
Chris Lattner10814822007-09-17 17:40:48 +00001695 yyvsp[0].Rec->resolveReferences();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001696
Chris Lattnerca572be2005-09-08 18:48:47 +00001697 // If ObjectBody has template arguments, it's an error.
Chris Lattner10814822007-09-17 17:40:48 +00001698 assert(yyvsp[0].Rec->getTemplateArgs().empty() && "How'd this get template args?");
1699 yyval.Rec = yyvsp[0].Rec;
1700;
1701 break;}
1702case 80:
1703#line 661 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1704{
1705 yyval.Rec = yyvsp[0].Rec;
Chris Lattner27627382006-09-01 21:14:42 +00001706 // 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?");
Chris Lattner10814822007-09-17 17:40:48 +00001712 yyval.Rec->addValue(*RV);
Chris Lattner27627382006-09-01 21:14:42 +00001713 }
Chris Lattner10814822007-09-17 17:40:48 +00001714;
1715 break;}
1716case 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;}
1723case 82:
1724#line 678 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1725{
1726 yyval.RecList->push_back(yyvsp[0].Rec);
1727;
1728 break;}
1729case 83:
1730#line 682 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1731{
1732 MultiClass *&MCE = MultiClasses[*yyvsp[0].StrVal];
Chris Lattner27627382006-09-01 21:14:42 +00001733 if (MCE) {
Chris Lattner10814822007-09-17 17:40:48 +00001734 err() << "multiclass '" << *yyvsp[0].StrVal << "' already defined!\n";
Chris Lattner27627382006-09-01 21:14:42 +00001735 exit(1);
1736 }
Chris Lattner10814822007-09-17 17:40:48 +00001737 MCE = CurMultiClass = new MultiClass(*yyvsp[0].StrVal);
1738 delete yyvsp[0].StrVal;
1739;
1740 break;}
1741case 84:
1742#line 693 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1743{
Chris Lattner27627382006-09-01 21:14:42 +00001744 ParsingTemplateArgs = true;
Chris Lattner10814822007-09-17 17:40:48 +00001745 ;
1746 break;}
1747case 85:
1748#line 695 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1749{
Chris Lattner27627382006-09-01 21:14:42 +00001750 ParsingTemplateArgs = false;
Chris Lattner10814822007-09-17 17:40:48 +00001751 ;
1752 break;}
1753case 86:
1754#line 697 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1755{
Chris Lattner27627382006-09-01 21:14:42 +00001756 CurMultiClass = 0;
Chris Lattner10814822007-09-17 17:40:48 +00001757;
1758 break;}
1759case 87:
1760#line 702 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1761{ CurDefmPrefix = yyvsp[0].StrVal; ;
1762 break;}
1763case 88:
1764#line 702 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1765{
Chris Lattner27627382006-09-01 21:14:42 +00001766 // 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.
Chris Lattner10814822007-09-17 17:40:48 +00001769 MultiClass *MC = MultiClasses[yyvsp[-1].SubClassRef->first->getName()];
Chris Lattner27627382006-09-01 21:14:42 +00001770 assert(MC && "Didn't lookup multiclass correctly?");
Chris Lattner10814822007-09-17 17:40:48 +00001771 std::vector<Init*> &TemplateVals = *yyvsp[-1].SubClassRef->second;
1772 delete yyvsp[-1].SubClassRef;
Chris Lattner27627382006-09-01 21:14:42 +00001773
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?");
Chris Lattner10814822007-09-17 17:40:48 +00001787 CurRec = new Record(*yyvsp[-4].StrVal + DefProto->getName());
Chris Lattner27627382006-09-01 21:14:42 +00001788
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
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001812 // 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
Chris Lattner27627382006-09-01 21:14:42 +00001820 // Ensure redefinition doesn't happen.
1821 if (Records.getDef(CurRec->getName())) {
1822 err() << "def '" << CurRec->getName() << "' already defined, "
Chris Lattner10814822007-09-17 17:40:48 +00001823 << "instantiating defm '" << *yyvsp[-4].StrVal << "' with subdef '"
Chris Lattner27627382006-09-01 21:14:42 +00001824 << DefProto->getName() << "'!\n";
1825 exit(1);
1826 }
1827 Records.addDef(CurRec);
Chris Lattner7717d092006-09-01 21:59:03 +00001828
1829 CurRec->resolveReferences();
1830
Chris Lattner27627382006-09-01 21:14:42 +00001831 CurRec = 0;
1832 }
1833
1834 delete &TemplateVals;
Chris Lattner10814822007-09-17 17:40:48 +00001835 delete yyvsp[-4].StrVal;
Chris Lattnercce56af2006-09-01 22:07:27 +00001836 CurDefmPrefix = 0;
Chris Lattner10814822007-09-17 17:40:48 +00001837;
1838 break;}
1839case 89:
1840#line 776 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1841{;
1842 break;}
1843case 90:
1844#line 776 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1845{;
1846 break;}
1847case 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;}
1854case 96:
1855#line 787 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1856{ LetStack.push_back(std::vector<LetRecord>()); ;
1857 break;}
1858case 98:
1859#line 790 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1860{
Bill Wendlingf5da1332006-12-07 22:21:48 +00001861 LetStack.pop_back();
Chris Lattner10814822007-09-17 17:40:48 +00001862 ;
1863 break;}
1864case 99:
1865#line 793 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1866{
Bill Wendlingf5da1332006-12-07 22:21:48 +00001867 LetStack.pop_back();
Chris Lattner10814822007-09-17 17:40:48 +00001868 ;
1869 break;}
1870case 100:
1871#line 797 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1872{;
1873 break;}
1874case 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
1882 yyvsp -= yylen;
1883 yyssp -= yylen;
1884#ifdef YYLSP_NEEDED
1885 yylsp -= yylen;
1886#endif
Bill Wendlingf5da1332006-12-07 22:21:48 +00001887
Chris Lattner10814822007-09-17 17:40:48 +00001888#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");
Chris Lattner81779692006-03-30 22:51:12 +00001896 }
Chris Lattner10814822007-09-17 17:40:48 +00001897#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001898
1899 *++yyvsp = yyval;
1900
Chris Lattner10814822007-09-17 17:40:48 +00001901#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
Reid Spencer68a24bd2005-08-27 18:50:39 +00001917
Chris Lattner10814822007-09-17 17:40:48 +00001918 /* 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. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001922
1923 yyn = yyr1[yyn];
1924
Chris Lattner10814822007-09-17 17:40:48 +00001925 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1926 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001927 yystate = yytable[yystate];
1928 else
Chris Lattner10814822007-09-17 17:40:48 +00001929 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00001930
1931 goto yynewstate;
1932
Chris Lattner10814822007-09-17 17:40:48 +00001933yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001934
Chris Lattner10814822007-09-17 17:40:48 +00001935 if (! yyerrstatus)
1936 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001937 {
1938 ++yynerrs;
Chris Lattner81779692006-03-30 22:51:12 +00001939
Chris Lattner10814822007-09-17 17:40:48 +00001940#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");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001982 }
1983
Chris Lattner10814822007-09-17 17:40:48 +00001984 goto yyerrlab1;
1985yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001986
1987 if (yyerrstatus == 3)
1988 {
Chris Lattner10814822007-09-17 17:40:48 +00001989 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001990
Chris Lattner10814822007-09-17 17:40:48 +00001991 /* return failure if at end of input */
1992 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001993 YYABORT;
1994
Chris Lattner10814822007-09-17 17:40:48 +00001995#if YYDEBUG != 0
1996 if (yydebug)
1997 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1998#endif
Chris Lattnerba4b1442005-09-08 18:22:57 +00001999
Chris Lattner10814822007-09-17 17:40:48 +00002000 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002001 }
2002
Chris Lattner10814822007-09-17 17:40:48 +00002003 /* 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
2010yyerrdefault: /* 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
2019yyerrpop: /* 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
2039yyerrhandle:
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
Reid Spencer68a24bd2005-08-27 18:50:39 +00002060 if (yyn == YYFINAL)
2061 YYACCEPT;
2062
Chris Lattner10814822007-09-17 17:40:48 +00002063#if YYDEBUG != 0
2064 if (yydebug)
2065 fprintf(stderr, "Shifting error token, ");
2066#endif
2067
Reid Spencer68a24bd2005-08-27 18:50:39 +00002068 *++yyvsp = yylval;
Chris Lattner10814822007-09-17 17:40:48 +00002069#ifdef YYLSP_NEEDED
2070 *++yylsp = yylloc;
2071#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002072
2073 yystate = yyn;
2074 goto yynewstate;
2075
Chris Lattner10814822007-09-17 17:40:48 +00002076 yyacceptlab:
2077 /* YYACCEPT comes here. */
2078 if (yyfree_stacks)
Bill Wendlingf5da1332006-12-07 22:21:48 +00002079 {
Chris Lattner10814822007-09-17 17:40:48 +00002080 free (yyss);
2081 free (yyvs);
2082#ifdef YYLSP_NEEDED
2083 free (yyls);
2084#endif
Chris Lattner81779692006-03-30 22:51:12 +00002085 }
Chris Lattner10814822007-09-17 17:40:48 +00002086 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);
Bill Wendlingf5da1332006-12-07 22:21:48 +00002096#endif
Chris Lattner10814822007-09-17 17:40:48 +00002097 }
2098 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002099}
Chris Lattner10814822007-09-17 17:40:48 +00002100#line 801 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002101
2102
2103int yyerror(const char *ErrorMsg) {
2104 err() << "Error parsing: " << ErrorMsg << "\n";
2105 exit(1);
2106}