blob: 1f0ff3f02857e0b4a28fef1ac9fb0dc0832bcce6 [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00002/* A Bison parser, made from /Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y
Chris Lattner81779692006-03-30 22:51:12 +00003 by GNU Bison version 1.28 */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004
Chris Lattner81779692006-03-30 22:51:12 +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 Lattner81779692006-03-30 22:51:12 +00008#define yylex Filelex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror Fileerror
Chris Lattner81779692006-03-30 22:51:12 +000010#define yylval Filelval
11#define yychar Filechar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug Filedebug
13#define yynerrs Filenerrs
Chris Lattner81779692006-03-30 22:51:12 +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
Chris Lattner27627382006-09-01 21:14:42 +000023#define MULTICLASS 266
24#define DEFM 267
25#define FIELD 268
26#define LET 269
27#define IN 270
28#define SHLTOK 271
29#define SRATOK 272
30#define SRLTOK 273
31#define STRCONCATTOK 274
32#define INTVAL 275
33#define ID 276
34#define VARNAME 277
35#define STRVAL 278
36#define CODEFRAGMENT 279
Reid Spencer68a24bd2005-08-27 18:50:39 +000037
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +000038#line 14 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +000039
40#include "Record.h"
41#include "llvm/ADT/StringExtras.h"
42#include <algorithm>
43#include <cstdio>
44#define YYERROR_VERBOSE 1
45
46int yyerror(const char *ErrorMsg);
47int yylex();
48
49namespace llvm {
Chris Lattner27627382006-09-01 21:14:42 +000050 struct MultiClass {
51 Record Rec; // Placeholder for template args and Name.
52 std::vector<Record*> DefPrototypes;
53
54 MultiClass(const std::string &Name) : Rec(Name) {}
55 };
Reid Spencer68a24bd2005-08-27 18:50:39 +000056
Chris Lattner27627382006-09-01 21:14:42 +000057
58static std::map<std::string, MultiClass*> MultiClasses;
59
Reid Spencer68a24bd2005-08-27 18:50:39 +000060extern int Filelineno;
Chris Lattner27627382006-09-01 21:14:42 +000061static MultiClass *CurMultiClass = 0; // Set while parsing a multiclass.
62static std::string *CurDefmPrefix = 0; // Set while parsing defm.
Reid Spencer68a24bd2005-08-27 18:50:39 +000063static Record *CurRec = 0;
64static bool ParsingTemplateArgs = false;
65
66typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
67
68struct LetRecord {
69 std::string Name;
70 std::vector<unsigned> Bits;
71 Init *Value;
72 bool HasBits;
73 LetRecord(const std::string &N, std::vector<unsigned> *B, Init *V)
74 : Name(N), Value(V), HasBits(B != 0) {
75 if (HasBits) Bits = *B;
76 }
77};
78
79static std::vector<std::vector<LetRecord> > LetStack;
80
81
82extern std::ostream &err();
83
Chris Lattner27627382006-09-01 21:14:42 +000084/// getActiveRec - If inside a def/class definition, return the def/class.
85/// Otherwise, if within a multidef, return it.
86static Record *getActiveRec() {
87 return CurRec ? CurRec : &CurMultiClass->Rec;
88}
89
Reid Spencer68a24bd2005-08-27 18:50:39 +000090static void addValue(const RecordVal &RV) {
Chris Lattner27627382006-09-01 21:14:42 +000091 Record *TheRec = getActiveRec();
92
93 if (RecordVal *ERV = TheRec->getValue(RV.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +000094 // The value already exists in the class, treat this as a set...
95 if (ERV->setValue(RV.getValue())) {
96 err() << "New definition of '" << RV.getName() << "' of type '"
97 << *RV.getType() << "' is incompatible with previous "
98 << "definition of type '" << *ERV->getType() << "'!\n";
99 exit(1);
100 }
101 } else {
Chris Lattner27627382006-09-01 21:14:42 +0000102 TheRec->addValue(RV);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000103 }
104}
105
106static void addSuperClass(Record *SC) {
107 if (CurRec->isSubClassOf(SC)) {
108 err() << "Already subclass of '" << SC->getName() << "'!\n";
109 exit(1);
110 }
111 CurRec->addSuperClass(SC);
112}
113
114static void setValue(const std::string &ValName,
Chris Lattner81779692006-03-30 22:51:12 +0000115 std::vector<unsigned> *BitList, Init *V) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000116 if (!V) return;
117
Chris Lattnerdc52f172006-10-07 07:15:19 +0000118 Record *TheRec = getActiveRec();
119 RecordVal *RV = TheRec->getValue(ValName);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000120 if (RV == 0) {
121 err() << "Value '" << ValName << "' unknown!\n";
122 exit(1);
123 }
124
125 // Do not allow assignments like 'X = X'. This will just cause infinite loops
126 // in the resolution machinery.
127 if (!BitList)
128 if (VarInit *VI = dynamic_cast<VarInit*>(V))
129 if (VI->getName() == ValName)
130 return;
131
132 // If we are assigning to a subset of the bits in the value... then we must be
133 // assigning to a field of BitsRecTy, which must have a BitsInit
134 // initializer...
135 //
136 if (BitList) {
137 BitsInit *CurVal = dynamic_cast<BitsInit*>(RV->getValue());
138 if (CurVal == 0) {
139 err() << "Value '" << ValName << "' is not a bits type!\n";
140 exit(1);
141 }
142
143 // Convert the incoming value to a bits type of the appropriate size...
144 Init *BI = V->convertInitializerTo(new BitsRecTy(BitList->size()));
145 if (BI == 0) {
146 V->convertInitializerTo(new BitsRecTy(BitList->size()));
147 err() << "Initializer '" << *V << "' not compatible with bit range!\n";
148 exit(1);
149 }
150
151 // We should have a BitsInit type now...
152 assert(dynamic_cast<BitsInit*>(BI) != 0 || &(std::cerr << *BI) == 0);
153 BitsInit *BInit = (BitsInit*)BI;
154
155 BitsInit *NewVal = new BitsInit(CurVal->getNumBits());
156
157 // Loop over bits, assigning values as appropriate...
158 for (unsigned i = 0, e = BitList->size(); i != e; ++i) {
159 unsigned Bit = (*BitList)[i];
160 if (NewVal->getBit(Bit)) {
161 err() << "Cannot set bit #" << Bit << " of value '" << ValName
162 << "' more than once!\n";
163 exit(1);
164 }
165 NewVal->setBit(Bit, BInit->getBit(i));
166 }
167
168 for (unsigned i = 0, e = CurVal->getNumBits(); i != e; ++i)
169 if (NewVal->getBit(i) == 0)
170 NewVal->setBit(i, CurVal->getBit(i));
171
172 V = NewVal;
173 }
174
175 if (RV->setValue(V)) {
176 err() << "Value '" << ValName << "' of type '" << *RV->getType()
177 << "' is incompatible with initializer '" << *V << "'!\n";
178 exit(1);
179 }
180}
181
182// addSubClass - Add SC as a subclass to CurRec, resolving TemplateArgs as SC's
183// template arguments.
184static void addSubClass(Record *SC, const std::vector<Init*> &TemplateArgs) {
185 // Add all of the values in the subclass into the current class...
186 const std::vector<RecordVal> &Vals = SC->getValues();
187 for (unsigned i = 0, e = Vals.size(); i != e; ++i)
188 addValue(Vals[i]);
189
190 const std::vector<std::string> &TArgs = SC->getTemplateArgs();
191
192 // Ensure that an appropriate number of template arguments are specified...
193 if (TArgs.size() < TemplateArgs.size()) {
194 err() << "ERROR: More template args specified than expected!\n";
195 exit(1);
Chris Lattner27627382006-09-01 21:14:42 +0000196 }
197
198 // Loop over all of the template arguments, setting them to the specified
199 // value or leaving them as the default if necessary.
200 for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
201 if (i < TemplateArgs.size()) { // A value is specified for this temp-arg?
202 // Set it now.
203 setValue(TArgs[i], 0, TemplateArgs[i]);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000204
Chris Lattner27627382006-09-01 21:14:42 +0000205 // Resolve it next.
206 CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i]));
207
208
209 // Now remove it.
210 CurRec->removeValue(TArgs[i]);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000211
Chris Lattner27627382006-09-01 21:14:42 +0000212 } else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) {
213 err() << "ERROR: Value not specified for template argument #"
214 << i << " (" << TArgs[i] << ") of subclass '" << SC->getName()
215 << "'!\n";
216 exit(1);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000217 }
218 }
219
220 // Since everything went well, we can now set the "superclass" list for the
221 // current record.
Chris Lattner27627382006-09-01 21:14:42 +0000222 const std::vector<Record*> &SCs = SC->getSuperClasses();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000223 for (unsigned i = 0, e = SCs.size(); i != e; ++i)
224 addSuperClass(SCs[i]);
225 addSuperClass(SC);
226}
227
228} // End llvm namespace
229
230using namespace llvm;
231
232
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +0000233#line 209 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +0000234typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000235 std::string* StrVal;
236 int IntVal;
237 llvm::RecTy* Ty;
238 llvm::Init* Initializer;
239 std::vector<llvm::Init*>* FieldList;
240 std::vector<unsigned>* BitList;
241 llvm::Record* Rec;
Chris Lattner27627382006-09-01 21:14:42 +0000242 std::vector<llvm::Record*>* RecList;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000243 SubClassRefTy* SubClassRef;
244 std::vector<SubClassRefTy>* SubClassList;
245 std::vector<std::pair<llvm::Init*, std::string> >* DagValueList;
246} YYSTYPE;
Chris Lattner81779692006-03-30 22:51:12 +0000247#include <stdio.h>
248
249#ifndef __cplusplus
250#ifndef __STDC__
251#define const
252#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000253#endif
254
255
256
Chris Lattner27627382006-09-01 21:14:42 +0000257#define YYFINAL 188
Chris Lattner81779692006-03-30 22:51:12 +0000258#define YYFLAG -32768
Chris Lattner27627382006-09-01 21:14:42 +0000259#define YYNTBASE 41
Reid Spencer68a24bd2005-08-27 18:50:39 +0000260
Chris Lattner27627382006-09-01 21:14:42 +0000261#define YYTRANSLATE(x) ((unsigned)(x) <= 279 ? yytranslate[x] : 90)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000262
Chris Lattner81779692006-03-30 22:51:12 +0000263static const char yytranslate[] = { 0,
264 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
265 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
266 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner27627382006-09-01 21:14:42 +0000267 2, 2, 2, 2, 2, 2, 2, 2, 2, 35,
268 36, 2, 2, 37, 39, 34, 2, 2, 2, 2,
269 2, 2, 2, 2, 2, 2, 2, 38, 40, 26,
270 28, 27, 29, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner81779692006-03-30 22:51:12 +0000271 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
272 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner27627382006-09-01 21:14:42 +0000273 32, 2, 33, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner81779692006-03-30 22:51:12 +0000274 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
275 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner27627382006-09-01 21:14:42 +0000276 2, 2, 30, 2, 31, 2, 2, 2, 2, 2,
Chris Lattner81779692006-03-30 22:51:12 +0000277 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
278 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
279 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
280 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
281 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
282 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
283 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
284 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
285 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
286 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
287 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
288 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
289 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
290 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
Chris Lattner27627382006-09-01 21:14:42 +0000291 17, 18, 19, 20, 21, 22, 23, 24, 25
Chris Lattner81779692006-03-30 22:51:12 +0000292};
Reid Spencer68a24bd2005-08-27 18:50:39 +0000293
Chris Lattner81779692006-03-30 22:51:12 +0000294#if YYDEBUG != 0
295static const short yyprhs[] = { 0,
296 0, 2, 4, 6, 11, 13, 18, 20, 22, 24,
297 25, 27, 28, 31, 33, 35, 37, 39, 41, 43,
298 47, 52, 57, 61, 65, 70, 75, 82, 89, 96,
Chris Lattnerb8316912006-03-31 21:54:11 +0000299 103, 104, 107, 110, 115, 116, 118, 120, 124, 127,
300 131, 137, 142, 144, 145, 149, 150, 152, 154, 158,
301 163, 166, 173, 174, 177, 179, 183, 185, 190, 192,
302 196, 197, 200, 202, 206, 210, 211, 213, 215, 216,
303 218, 220, 222, 223, 227, 228, 229, 236, 240, 242,
Chris Lattner27627382006-09-01 21:14:42 +0000304 244, 247, 249, 250, 251, 260, 261, 268, 270, 272,
305 274, 276, 281, 283, 287, 288, 293, 298, 301, 303,
306 306
Chris Lattner81779692006-03-30 22:51:12 +0000307};
Reid Spencer68a24bd2005-08-27 18:50:39 +0000308
Chris Lattner27627382006-09-01 21:14:42 +0000309static const short yyrhs[] = { 22,
310 0, 5, 0, 4, 0, 6, 26, 21, 27, 0,
311 3, 0, 7, 26, 42, 27, 0, 8, 0, 9,
312 0, 41, 0, 0, 14, 0, 0, 28, 46, 0,
313 22, 0, 45, 0, 21, 0, 24, 0, 25, 0,
314 29, 0, 30, 53, 31, 0, 22, 26, 54, 27,
315 0, 46, 30, 51, 31, 0, 32, 53, 33, 0,
316 46, 34, 22, 0, 35, 45, 49, 36, 0, 46,
317 32, 51, 33, 0, 17, 35, 46, 37, 46, 36,
318 0, 18, 35, 46, 37, 46, 36, 0, 19, 35,
319 46, 37, 46, 36, 0, 20, 35, 46, 37, 46,
320 36, 0, 0, 38, 23, 0, 46, 47, 0, 48,
321 37, 46, 47, 0, 0, 48, 0, 21, 0, 21,
322 39, 21, 0, 21, 21, 0, 50, 37, 21, 0,
323 50, 37, 21, 39, 21, 0, 50, 37, 21, 21,
324 0, 50, 0, 0, 30, 51, 31, 0, 0, 54,
325 0, 46, 0, 54, 37, 46, 0, 43, 42, 22,
326 44, 0, 55, 40, 0, 15, 22, 52, 28, 46,
327 40, 0, 0, 57, 56, 0, 40, 0, 30, 57,
328 31, 0, 41, 0, 41, 26, 54, 27, 0, 59,
329 0, 60, 37, 59, 0, 0, 38, 60, 0, 55,
330 0, 62, 37, 55, 0, 26, 62, 27, 0, 0,
331 63, 0, 22, 0, 0, 65, 0, 66, 0, 66,
332 0, 0, 61, 70, 58, 0, 0, 0, 10, 67,
333 72, 64, 73, 69, 0, 11, 68, 69, 0, 74,
334 0, 75, 0, 76, 75, 0, 22, 0, 0, 0,
335 12, 77, 79, 64, 80, 30, 76, 31, 0, 0,
336 13, 22, 82, 38, 59, 40, 0, 71, 0, 74,
337 0, 78, 0, 81, 0, 22, 52, 28, 46, 0,
338 84, 0, 85, 37, 84, 0, 0, 15, 87, 85,
339 16, 0, 86, 30, 88, 31, 0, 86, 83, 0,
340 83, 0, 88, 83, 0, 88, 0
Chris Lattner81779692006-03-30 22:51:12 +0000341};
Reid Spencer68a24bd2005-08-27 18:50:39 +0000342
343#endif
344
Chris Lattner81779692006-03-30 22:51:12 +0000345#if YYDEBUG != 0
346static const short yyrline[] = { 0,
Chris Lattnerdc52f172006-10-07 07:15:19 +0000347 245, 267, 269, 271, 273, 275, 277, 279, 281, 285,
348 285, 287, 287, 289, 312, 314, 316, 319, 322, 324,
349 337, 365, 372, 375, 382, 385, 393, 395, 397, 399,
350 403, 406, 410, 415, 421, 424, 427, 430, 443, 457,
351 459, 472, 488, 490, 490, 494, 496, 500, 503, 507,
352 524, 526, 532, 532, 533, 533, 535, 537, 541, 546,
353 551, 554, 558, 561, 566, 567, 567, 569, 569, 571,
354 578, 596, 621, 635, 640, 642, 644, 648, 658, 672,
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +0000355 675, 679, 690, 692, 694, 699, 699, 773, 773, 774,
356 774, 776, 781, 781, 784, 784, 787, 790, 794, 794,
357 796
Chris Lattner81779692006-03-30 22:51:12 +0000358};
359#endif
360
361
362#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
363
364static const char * const yytname[] = { "$","error","$undefined.","INT","BIT",
Chris Lattner27627382006-09-01 21:14:42 +0000365"STRING","BITS","LIST","CODE","DAG","CLASS","DEF","MULTICLASS","DEFM","FIELD",
366"LET","IN","SHLTOK","SRATOK","SRLTOK","STRCONCATTOK","INTVAL","ID","VARNAME",
367"STRVAL","CODEFRAGMENT","'<'","'>'","'='","'?'","'{'","'}'","'['","']'","'.'",
368"'('","')'","','","':'","'-'","';'","ClassID","Type","OptPrefix","OptValue",
369"IDValue","Value","OptVarName","DagArgListNE","DagArgList","RBitList","BitList",
370"OptBitList","ValueList","ValueListNE","Declaration","BodyItem","BodyList","Body",
371"SubClassRef","ClassListNE","ClassList","DeclListNE","TemplateArgList","OptTemplateArgList",
372"OptID","ObjectName","ClassName","DefName","ObjectBody","@1","ClassInst","@2",
373"@3","DefInst","MultiClassDef","MultiClassBody","MultiClassName","MultiClassInst",
374"@4","@5","DefMInst","@6","Object","LETItem","LETList","LETCommand","@7","ObjectList",
375"File", NULL
Chris Lattner81779692006-03-30 22:51:12 +0000376};
377#endif
378
379static const short yyr1[] = { 0,
Chris Lattner27627382006-09-01 21:14:42 +0000380 41, 42, 42, 42, 42, 42, 42, 42, 42, 43,
381 43, 44, 44, 45, 46, 46, 46, 46, 46, 46,
382 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
383 47, 47, 48, 48, 49, 49, 50, 50, 50, 50,
384 50, 50, 51, 52, 52, 53, 53, 54, 54, 55,
385 56, 56, 57, 57, 58, 58, 59, 59, 60, 60,
386 61, 61, 62, 62, 63, 64, 64, 65, 65, 66,
387 67, 68, 70, 69, 72, 73, 71, 74, 75, 76,
388 76, 77, 79, 80, 78, 82, 81, 83, 83, 83,
389 83, 84, 85, 85, 87, 86, 83, 83, 88, 88,
390 89
Chris Lattner81779692006-03-30 22:51:12 +0000391};
392
393static const short yyr2[] = { 0,
394 1, 1, 1, 4, 1, 4, 1, 1, 1, 0,
395 1, 0, 2, 1, 1, 1, 1, 1, 1, 3,
Chris Lattnerb8316912006-03-31 21:54:11 +0000396 4, 4, 3, 3, 4, 4, 6, 6, 6, 6,
397 0, 2, 2, 4, 0, 1, 1, 3, 2, 3,
398 5, 4, 1, 0, 3, 0, 1, 1, 3, 4,
399 2, 6, 0, 2, 1, 3, 1, 4, 1, 3,
400 0, 2, 1, 3, 3, 0, 1, 1, 0, 1,
401 1, 1, 0, 3, 0, 0, 6, 3, 1, 1,
Chris Lattner27627382006-09-01 21:14:42 +0000402 2, 1, 0, 0, 8, 0, 6, 1, 1, 1,
403 1, 4, 1, 3, 0, 4, 4, 2, 1, 2,
404 1
Chris Lattner81779692006-03-30 22:51:12 +0000405};
406
407static const short yydefact[] = { 0,
Chris Lattner27627382006-09-01 21:14:42 +0000408 69, 69, 0, 0, 95, 88, 89, 90, 91, 99,
409 0, 101, 68, 70, 71, 75, 72, 61, 82, 83,
410 86, 0, 0, 98, 100, 66, 0, 73, 78, 66,
411 0, 44, 93, 0, 0, 10, 67, 76, 1, 57,
412 59, 62, 0, 84, 0, 0, 0, 96, 0, 97,
413 11, 0, 63, 0, 61, 0, 0, 53, 55, 74,
414 0, 0, 37, 43, 0, 0, 94, 5, 3, 2,
415 0, 0, 7, 8, 9, 0, 65, 10, 77, 0,
416 0, 0, 0, 16, 14, 17, 18, 19, 46, 46,
417 0, 15, 48, 0, 60, 10, 0, 87, 39, 0,
418 0, 45, 92, 0, 0, 12, 64, 0, 0, 0,
419 0, 0, 0, 47, 0, 14, 35, 0, 0, 0,
420 58, 0, 0, 56, 0, 54, 79, 80, 0, 38,
421 40, 0, 0, 0, 50, 0, 0, 0, 0, 0,
422 20, 23, 31, 36, 0, 0, 0, 24, 49, 44,
423 51, 85, 81, 42, 0, 4, 6, 13, 0, 0,
Chris Lattnerb8316912006-03-31 21:54:11 +0000424 0, 0, 21, 0, 33, 0, 25, 22, 26, 0,
425 41, 0, 0, 0, 0, 32, 31, 0, 27, 28,
426 29, 30, 34, 0, 52, 0, 0, 0
Chris Lattner81779692006-03-30 22:51:12 +0000427};
428
Chris Lattner27627382006-09-01 21:14:42 +0000429static const short yydefgoto[] = { 40,
430 76, 52, 135, 92, 93, 165, 144, 145, 64, 65,
431 47, 113, 114, 53, 126, 96, 60, 41, 42, 28,
432 54, 37, 38, 14, 15, 16, 18, 29, 43, 6,
433 26, 55, 7, 128, 129, 20, 8, 30, 61, 9,
434 31, 10, 33, 34, 11, 22, 12, 186
Chris Lattner81779692006-03-30 22:51:12 +0000435};
436
Chris Lattner27627382006-09-01 21:14:42 +0000437static const short yypact[] = { 129,
438 3, 3, 11, 19,-32768,-32768,-32768,-32768,-32768,-32768,
439 2, 129,-32768,-32768,-32768,-32768,-32768, 29,-32768,-32768,
440-32768, 24, 129,-32768,-32768, 43, 31,-32768,-32768, 43,
441 40, 50,-32768, -6, -4, 69,-32768,-32768,-32768, 59,
442-32768, 61, 10,-32768, 31, 81, 78,-32768, 24,-32768,
443-32768, 15,-32768, 12, 29, 41, 31,-32768,-32768,-32768,
444 84, 68, 8, 83, 87, 41,-32768,-32768,-32768,-32768,
445 111, 120,-32768,-32768,-32768, 126,-32768, 69,-32768, 114,
446 115, 116, 117,-32768, 127,-32768,-32768,-32768, 41, 41,
447 132,-32768, 113, 27,-32768, 60, 144,-32768,-32768, 135,
448 136,-32768, 113, 137, 15, 131,-32768, 41, 41, 41,
449 41, 41, 130, 123, 133,-32768, 41, 81, 81, 140,
450-32768, 41, 141,-32768, 124,-32768,-32768,-32768, 5,-32768,
451 9, 138, 142, 41,-32768, 67, 73, 79, 85, 45,
452-32768,-32768, 54, 134, 139, 143, 145,-32768, 113, 50,
453-32768,-32768,-32768,-32768, 146,-32768,-32768, 113, 41, 41,
454 41, 41,-32768, 147,-32768, 41,-32768,-32768,-32768, 148,
455-32768, 91, 94, 99, 102,-32768, 54, 41,-32768,-32768,
456-32768,-32768,-32768, 47,-32768, 168, 172,-32768
Chris Lattner81779692006-03-30 22:51:12 +0000457};
458
Chris Lattner27627382006-09-01 21:14:42 +0000459static const short yypgoto[] = { -50,
460 72,-32768,-32768, 82, -66, 4,-32768,-32768,-32768, -29,
461 30, 89, -55, -44,-32768,-32768,-32768, -19,-32768,-32768,
462-32768,-32768, 152,-32768, 181,-32768,-32768, 149,-32768,-32768,
463-32768,-32768, -94, 55,-32768,-32768,-32768,-32768,-32768,-32768,
464-32768, -7, 150,-32768,-32768,-32768, 162,-32768
Chris Lattner81779692006-03-30 22:51:12 +0000465};
466
467
Chris Lattner27627382006-09-01 21:14:42 +0000468#define YYLAST 204
Chris Lattner81779692006-03-30 22:51:12 +0000469
470
Chris Lattner27627382006-09-01 21:14:42 +0000471static const short yytable[] = { 103,
472 94, 75, 127, 24, 25, 1, 2, 3, 4, 48,
473 5, 1, 2, 3, 4, 2, 5, 68, 69, 70,
474 71, 72, 73, 74, 13, 62, 50, 25, 99, 154,
475 49, 23, 19, 107, 127, 152, 39, 95, 77, 58,
476 21, 136, 137, 138, 139, 32, 100, 155, 78, 59,
477 143, 125, 39, 121, 75, 149, 140, 80, 81, 82,
478 83, 84, 85, 122, 86, 87, 27, 158, 36, 88,
479 89, 163, 90, 51, 123, 91, 118, 45, 119, 46,
480 120, 122, 51, 118, 56, 119, 185, 120, 146, 147,
481 124, 164, 172, 173, 174, 175, 118, 57, 119, 177,
482 120, 63, 118, 159, 119, 66, 120, 98, 118, 160,
483 119, 184, 120, 97, 118, 161, 119, 102, 120, 101,
484 118, 162, 119, 118, 120, 119, 179, 120, 118, 180,
485 119, 118, 120, 119, 181, 120, 104, 182, 1, 2,
486 3, 4, 118, 5, 119, 105, 120, 106, 108, 109,
487 110, 111, 112, 116, 2, 130, 131, 132, 134, 122,
488 141, 148, 150, 151, 156, 142, 171, 187, 157, 176,
489 166, 188, 117, 168, 167, 178, 133, 169, 115, 170,
490 183, 44, 17, 153, 35, 0, 0, 0, 0, 0,
491 0, 0, 0, 0, 0, 0, 0, 0, 67, 0,
492 0, 0, 0, 79
Chris Lattner81779692006-03-30 22:51:12 +0000493};
494
Chris Lattner27627382006-09-01 21:14:42 +0000495static const short yycheck[] = { 66,
496 56, 52, 97, 11, 12, 10, 11, 12, 13, 16,
497 15, 10, 11, 12, 13, 11, 15, 3, 4, 5,
498 6, 7, 8, 9, 22, 45, 31, 35, 21, 21,
499 37, 30, 22, 78, 129, 31, 22, 57, 27, 30,
500 22, 108, 109, 110, 111, 22, 39, 39, 37, 40,
501 117, 96, 22, 27, 105, 122, 112, 17, 18, 19,
502 20, 21, 22, 37, 24, 25, 38, 134, 26, 29,
503 30, 27, 32, 14, 15, 35, 30, 38, 32, 30,
504 34, 37, 14, 30, 26, 32, 40, 34, 118, 119,
505 31, 38, 159, 160, 161, 162, 30, 37, 32, 166,
506 34, 21, 30, 37, 32, 28, 34, 40, 30, 37,
507 32, 178, 34, 30, 30, 37, 32, 31, 34, 37,
508 30, 37, 32, 30, 34, 32, 36, 34, 30, 36,
509 32, 30, 34, 32, 36, 34, 26, 36, 10, 11,
510 12, 13, 30, 15, 32, 26, 34, 22, 35, 35,
511 35, 35, 26, 22, 11, 21, 21, 21, 28, 37,
512 31, 22, 22, 40, 27, 33, 21, 0, 27, 23,
513 37, 0, 91, 31, 36, 28, 105, 33, 90, 150,
514 177, 30, 2, 129, 23, -1, -1, -1, -1, -1,
515 -1, -1, -1, -1, -1, -1, -1, -1, 49, -1,
516 -1, -1, -1, 55
Chris Lattner81779692006-03-30 22:51:12 +0000517};
518/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
519#line 3 "/usr/share/bison.simple"
520/* This file comes from bison-1.28. */
521
522/* Skeleton output parser for bison,
523 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
524
525 This program is free software; you can redistribute it and/or modify
526 it under the terms of the GNU General Public License as published by
527 the Free Software Foundation; either version 2, or (at your option)
528 any later version.
529
530 This program is distributed in the hope that it will be useful,
531 but WITHOUT ANY WARRANTY; without even the implied warranty of
532 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
533 GNU General Public License for more details.
534
535 You should have received a copy of the GNU General Public License
536 along with this program; if not, write to the Free Software
537 Foundation, Inc., 59 Temple Place - Suite 330,
538 Boston, MA 02111-1307, USA. */
539
540/* As a special exception, when this file is copied by Bison into a
541 Bison output file, you may use that output file without restriction.
542 This special exception was added by the Free Software Foundation
543 in version 1.24 of Bison. */
544
545/* This is the parser code that is written into each bison parser
546 when the %semantic_parser declaration is not specified in the grammar.
547 It was written by Richard Stallman by simplifying the hairy parser
548 used when %semantic_parser is specified. */
549
550#ifndef YYSTACK_USE_ALLOCA
551#ifdef alloca
552#define YYSTACK_USE_ALLOCA
553#else /* alloca not defined */
554#ifdef __GNUC__
555#define YYSTACK_USE_ALLOCA
556#define alloca __builtin_alloca
557#else /* not GNU C. */
558#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
559#define YYSTACK_USE_ALLOCA
560#include <alloca.h>
561#else /* not sparc */
562/* We think this test detects Watcom and Microsoft C. */
563/* This used to test MSDOS, but that is a bad idea
564 since that symbol is in the user namespace. */
565#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
566#if 0 /* No need for malloc.h, which pollutes the namespace;
567 instead, just don't use alloca. */
568#include <malloc.h>
569#endif
570#else /* not MSDOS, or __TURBOC__ */
571#if defined(_AIX)
572/* I don't know what this was needed for, but it pollutes the namespace.
573 So I turned it off. rms, 2 May 1997. */
574/* #include <malloc.h> */
575 #pragma alloca
576#define YYSTACK_USE_ALLOCA
577#else /* not MSDOS, or __TURBOC__, or _AIX */
578#if 0
579#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
580 and on HPUX 10. Eventually we can turn this on. */
581#define YYSTACK_USE_ALLOCA
582#define alloca __builtin_alloca
583#endif /* __hpux */
584#endif
585#endif /* not _AIX */
586#endif /* not MSDOS, or __TURBOC__ */
587#endif /* not sparc */
588#endif /* not GNU C */
589#endif /* alloca not defined */
590#endif /* YYSTACK_USE_ALLOCA not defined */
591
592#ifdef YYSTACK_USE_ALLOCA
593#define YYSTACK_ALLOC alloca
Reid Spencer68a24bd2005-08-27 18:50:39 +0000594#else
Chris Lattner81779692006-03-30 22:51:12 +0000595#define YYSTACK_ALLOC malloc
Reid Spencer68a24bd2005-08-27 18:50:39 +0000596#endif
597
Chris Lattner81779692006-03-30 22:51:12 +0000598/* Note: there must be only one dollar sign in this file.
599 It is replaced by the list of actions, each action
600 as one case of the switch. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000601
602#define yyerrok (yyerrstatus = 0)
603#define yyclearin (yychar = YYEMPTY)
Chris Lattner81779692006-03-30 22:51:12 +0000604#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +0000605#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +0000606#define YYACCEPT goto yyacceptlab
Chris Lattner81779692006-03-30 22:51:12 +0000607#define YYABORT goto yyabortlab
Chris Lattnerba4b1442005-09-08 18:22:57 +0000608#define YYERROR goto yyerrlab1
Chris Lattner81779692006-03-30 22:51:12 +0000609/* Like YYERROR except do call yyerror.
610 This remains here temporarily to ease the
611 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000612 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000613#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +0000614#define YYRECOVERING() (!!yyerrstatus)
Chris Lattner81779692006-03-30 22:51:12 +0000615#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +0000616do \
617 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattner81779692006-03-30 22:51:12 +0000618 { yychar = (token), yylval = (value); \
619 yychar1 = YYTRANSLATE (yychar); \
Reid Spencer68a24bd2005-08-27 18:50:39 +0000620 YYPOPSTACK; \
621 goto yybackup; \
622 } \
623 else \
Chris Lattner81779692006-03-30 22:51:12 +0000624 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencer68a24bd2005-08-27 18:50:39 +0000625while (0)
626
627#define YYTERROR 1
628#define YYERRCODE 256
629
Chris Lattner81779692006-03-30 22:51:12 +0000630#ifndef YYPURE
631#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +0000632#endif
633
Chris Lattner81779692006-03-30 22:51:12 +0000634#ifdef YYPURE
635#ifdef YYLSP_NEEDED
Reid Spencer68a24bd2005-08-27 18:50:39 +0000636#ifdef YYLEX_PARAM
Chris Lattner81779692006-03-30 22:51:12 +0000637#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000638#else
Chris Lattner81779692006-03-30 22:51:12 +0000639#define YYLEX yylex(&yylval, &yylloc)
640#endif
641#else /* not YYLSP_NEEDED */
642#ifdef YYLEX_PARAM
643#define YYLEX yylex(&yylval, YYLEX_PARAM)
644#else
645#define YYLEX yylex(&yylval)
646#endif
647#endif /* not YYLSP_NEEDED */
Chris Lattner8d354e92005-09-30 04:11:27 +0000648#endif
John Criswelld7881242006-01-17 17:01:34 +0000649
Chris Lattner81779692006-03-30 22:51:12 +0000650/* If nonreentrant, generate the variables here */
John Criswelld7881242006-01-17 17:01:34 +0000651
Chris Lattner81779692006-03-30 22:51:12 +0000652#ifndef YYPURE
John Criswelld7881242006-01-17 17:01:34 +0000653
Chris Lattner81779692006-03-30 22:51:12 +0000654int yychar; /* the lookahead symbol */
655YYSTYPE yylval; /* the semantic value of the */
656 /* lookahead symbol */
John Criswelld7881242006-01-17 17:01:34 +0000657
Chris Lattner81779692006-03-30 22:51:12 +0000658#ifdef YYLSP_NEEDED
659YYLTYPE yylloc; /* location data for the lookahead */
660 /* symbol */
Chris Lattner8d354e92005-09-30 04:11:27 +0000661#endif
John Criswelld7881242006-01-17 17:01:34 +0000662
Chris Lattner81779692006-03-30 22:51:12 +0000663int yynerrs; /* number of parse errors so far */
664#endif /* not YYPURE */
John Criswelld7881242006-01-17 17:01:34 +0000665
Chris Lattner81779692006-03-30 22:51:12 +0000666#if YYDEBUG != 0
667int yydebug; /* nonzero means print parse trace */
668/* Since this is uninitialized, it does not stop multiple parsers
669 from coexisting. */
Chris Lattnerba4b1442005-09-08 18:22:57 +0000670#endif
Chris Lattner2b931e82005-09-12 05:30:06 +0000671
Chris Lattner81779692006-03-30 22:51:12 +0000672/* YYINITDEPTH indicates the initial size of the parser's stacks */
Chris Lattner2b931e82005-09-12 05:30:06 +0000673
Reid Spencer68a24bd2005-08-27 18:50:39 +0000674#ifndef YYINITDEPTH
Chris Lattner81779692006-03-30 22:51:12 +0000675#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +0000676#endif
677
Chris Lattner81779692006-03-30 22:51:12 +0000678/* YYMAXDEPTH is the maximum size the stacks can grow to
679 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000680
Chris Lattnerba4b1442005-09-08 18:22:57 +0000681#if YYMAXDEPTH == 0
Chris Lattner81779692006-03-30 22:51:12 +0000682#undef YYMAXDEPTH
Reid Spencer68a24bd2005-08-27 18:50:39 +0000683#endif
684
685#ifndef YYMAXDEPTH
Chris Lattner81779692006-03-30 22:51:12 +0000686#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +0000687#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000688
Chris Lattner81779692006-03-30 22:51:12 +0000689/* Define __yy_memcpy. Note that the size argument
690 should be passed with type unsigned int, because that is what the non-GCC
691 definitions require. With GCC, __builtin_memcpy takes an arg
692 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000693
Chris Lattner81779692006-03-30 22:51:12 +0000694#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
695#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
696#else /* not GNU C or C++ */
697#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +0000698
Chris Lattner81779692006-03-30 22:51:12 +0000699/* This is the most reliable way to avoid incompatibilities
700 in available built-in functions on various systems. */
John Criswelld7881242006-01-17 17:01:34 +0000701static void
Chris Lattner81779692006-03-30 22:51:12 +0000702__yy_memcpy (to, from, count)
703 char *to;
704 char *from;
705 unsigned int count;
706{
707 register char *f = from;
708 register char *t = to;
709 register int i = count;
710
711 while (i-- > 0)
712 *t++ = *f++;
713}
714
715#else /* __cplusplus */
716
717/* This is the most reliable way to avoid incompatibilities
718 in available built-in functions on various systems. */
John Criswelld7881242006-01-17 17:01:34 +0000719static void
Chris Lattner81779692006-03-30 22:51:12 +0000720__yy_memcpy (char *to, char *from, unsigned int count)
721{
722 register char *t = to;
723 register char *f = from;
724 register int i = count;
725
726 while (i-- > 0)
727 *t++ = *f++;
728}
729
Chris Lattner2b931e82005-09-12 05:30:06 +0000730#endif
John Criswelld7881242006-01-17 17:01:34 +0000731#endif
John Criswelld7881242006-01-17 17:01:34 +0000732
Chris Lattner81779692006-03-30 22:51:12 +0000733#line 217 "/usr/share/bison.simple"
John Criswelld7881242006-01-17 17:01:34 +0000734
Chris Lattner81779692006-03-30 22:51:12 +0000735/* The user can define YYPARSE_PARAM as the name of an argument to be passed
736 into yyparse. The argument should have type void *.
737 It should actually point to an object.
738 Grammar actions can access the variable by casting it
739 to the proper pointer type. */
John Criswelld7881242006-01-17 17:01:34 +0000740
741#ifdef YYPARSE_PARAM
Chris Lattner81779692006-03-30 22:51:12 +0000742#ifdef __cplusplus
743#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
744#define YYPARSE_PARAM_DECL
745#else /* not __cplusplus */
746#define YYPARSE_PARAM_ARG YYPARSE_PARAM
747#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
748#endif /* not __cplusplus */
749#else /* not YYPARSE_PARAM */
750#define YYPARSE_PARAM_ARG
751#define YYPARSE_PARAM_DECL
752#endif /* not YYPARSE_PARAM */
753
754/* Prevent warning if -Wstrict-prototypes. */
755#ifdef __GNUC__
756#ifdef YYPARSE_PARAM
757int yyparse (void *);
758#else
John Criswelld7881242006-01-17 17:01:34 +0000759int yyparse (void);
John Criswelld7881242006-01-17 17:01:34 +0000760#endif
Chris Lattner81779692006-03-30 22:51:12 +0000761#endif
John Criswelld7881242006-01-17 17:01:34 +0000762
John Criswelld7881242006-01-17 17:01:34 +0000763int
Chris Lattner81779692006-03-30 22:51:12 +0000764yyparse(YYPARSE_PARAM_ARG)
765 YYPARSE_PARAM_DECL
John Criswelld7881242006-01-17 17:01:34 +0000766{
Reid Spencer68a24bd2005-08-27 18:50:39 +0000767 register int yystate;
768 register int yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000769 register short *yyssp;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000770 register YYSTYPE *yyvsp;
Chris Lattner81779692006-03-30 22:51:12 +0000771 int yyerrstatus; /* number of tokens to shift before error messages enabled */
772 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000773
Chris Lattner81779692006-03-30 22:51:12 +0000774 short yyssa[YYINITDEPTH]; /* the state stack */
775 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000776
Chris Lattner81779692006-03-30 22:51:12 +0000777 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
778 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000779
Chris Lattner81779692006-03-30 22:51:12 +0000780#ifdef YYLSP_NEEDED
781 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
782 YYLTYPE *yyls = yylsa;
783 YYLTYPE *yylsp;
784
785#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
786#else
Reid Spencer68a24bd2005-08-27 18:50:39 +0000787#define YYPOPSTACK (yyvsp--, yyssp--)
Chris Lattner81779692006-03-30 22:51:12 +0000788#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000789
Chris Lattner81779692006-03-30 22:51:12 +0000790 int yystacksize = YYINITDEPTH;
791 int yyfree_stacks = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000792
Chris Lattner81779692006-03-30 22:51:12 +0000793#ifdef YYPURE
794 int yychar;
795 YYSTYPE yylval;
796 int yynerrs;
797#ifdef YYLSP_NEEDED
798 YYLTYPE yylloc;
799#endif
800#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000801
Chris Lattner81779692006-03-30 22:51:12 +0000802 YYSTYPE yyval; /* the variable used to return */
803 /* semantic values from the action */
804 /* routines */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000805
Reid Spencer68a24bd2005-08-27 18:50:39 +0000806 int yylen;
807
Chris Lattner81779692006-03-30 22:51:12 +0000808#if YYDEBUG != 0
809 if (yydebug)
810 fprintf(stderr, "Starting parse\n");
811#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000812
813 yystate = 0;
814 yyerrstatus = 0;
815 yynerrs = 0;
816 yychar = YYEMPTY; /* Cause a token to be read. */
817
818 /* Initialize stack pointers.
819 Waste one element of value and location stack
820 so that they stay on the same level as the state stack.
821 The wasted elements are never initialized. */
822
Chris Lattner81779692006-03-30 22:51:12 +0000823 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000824 yyvsp = yyvs;
Chris Lattner81779692006-03-30 22:51:12 +0000825#ifdef YYLSP_NEEDED
826 yylsp = yyls;
827#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000828
Chris Lattner81779692006-03-30 22:51:12 +0000829/* Push a new state, which is found in yystate . */
830/* In all cases, when you get here, the value and location stacks
831 have just been pushed. so pushing a state here evens the stacks. */
832yynewstate:
Reid Spencer68a24bd2005-08-27 18:50:39 +0000833
Chris Lattner81779692006-03-30 22:51:12 +0000834 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000835
Chris Lattner81779692006-03-30 22:51:12 +0000836 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000837 {
Chris Lattner81779692006-03-30 22:51:12 +0000838 /* Give user a chance to reallocate the stack */
839 /* Use copies of these so that the &'s don't force the real ones into memory. */
840 YYSTYPE *yyvs1 = yyvs;
841 short *yyss1 = yyss;
842#ifdef YYLSP_NEEDED
843 YYLTYPE *yyls1 = yyls;
844#endif
845
Reid Spencer68a24bd2005-08-27 18:50:39 +0000846 /* Get the current used size of the three stacks, in elements. */
Chris Lattner81779692006-03-30 22:51:12 +0000847 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000848
849#ifdef yyoverflow
Chris Lattner81779692006-03-30 22:51:12 +0000850 /* Each stack pointer address is followed by the size of
851 the data in use in that stack, in bytes. */
852#ifdef YYLSP_NEEDED
853 /* This used to be a conditional around just the two extra args,
854 but that might be undefined if yyoverflow is a macro. */
855 yyoverflow("parser stack overflow",
856 &yyss1, size * sizeof (*yyssp),
857 &yyvs1, size * sizeof (*yyvsp),
858 &yyls1, size * sizeof (*yylsp),
859 &yystacksize);
860#else
861 yyoverflow("parser stack overflow",
862 &yyss1, size * sizeof (*yyssp),
863 &yyvs1, size * sizeof (*yyvsp),
864 &yystacksize);
865#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000866
Chris Lattner81779692006-03-30 22:51:12 +0000867 yyss = yyss1; yyvs = yyvs1;
868#ifdef YYLSP_NEEDED
869 yyls = yyls1;
870#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000871#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000872 /* Extend the stack our own way. */
Chris Lattner81779692006-03-30 22:51:12 +0000873 if (yystacksize >= YYMAXDEPTH)
874 {
875 yyerror("parser stack overflow");
876 if (yyfree_stacks)
877 {
878 free (yyss);
879 free (yyvs);
880#ifdef YYLSP_NEEDED
881 free (yyls);
882#endif
883 }
884 return 2;
885 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000886 yystacksize *= 2;
Chris Lattner81779692006-03-30 22:51:12 +0000887 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000888 yystacksize = YYMAXDEPTH;
Chris Lattner81779692006-03-30 22:51:12 +0000889#ifndef YYSTACK_USE_ALLOCA
890 yyfree_stacks = 1;
891#endif
892 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
893 __yy_memcpy ((char *)yyss, (char *)yyss1,
894 size * (unsigned int) sizeof (*yyssp));
895 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
896 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
897 size * (unsigned int) sizeof (*yyvsp));
898#ifdef YYLSP_NEEDED
899 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
900 __yy_memcpy ((char *)yyls, (char *)yyls1,
901 size * (unsigned int) sizeof (*yylsp));
902#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000903#endif /* no yyoverflow */
904
Chris Lattner81779692006-03-30 22:51:12 +0000905 yyssp = yyss + size - 1;
906 yyvsp = yyvs + size - 1;
907#ifdef YYLSP_NEEDED
908 yylsp = yyls + size - 1;
909#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000910
Chris Lattner81779692006-03-30 22:51:12 +0000911#if YYDEBUG != 0
912 if (yydebug)
913 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
914#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000915
Chris Lattner81779692006-03-30 22:51:12 +0000916 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000917 YYABORT;
918 }
919
Chris Lattner81779692006-03-30 22:51:12 +0000920#if YYDEBUG != 0
921 if (yydebug)
922 fprintf(stderr, "Entering state %d\n", yystate);
923#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000924
925 goto yybackup;
Chris Lattner81779692006-03-30 22:51:12 +0000926 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +0000927
928/* Do appropriate processing given the current state. */
929/* Read a lookahead token if we need one and don't already have one. */
930/* yyresume: */
931
932 /* First try to decide what to do without reference to lookahead token. */
933
934 yyn = yypact[yystate];
Chris Lattner81779692006-03-30 22:51:12 +0000935 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000936 goto yydefault;
937
938 /* Not known => get a lookahead token if don't already have one. */
939
Chris Lattner81779692006-03-30 22:51:12 +0000940 /* yychar is either YYEMPTY or YYEOF
941 or a valid token in external form. */
942
Reid Spencer68a24bd2005-08-27 18:50:39 +0000943 if (yychar == YYEMPTY)
944 {
Chris Lattner81779692006-03-30 22:51:12 +0000945#if YYDEBUG != 0
946 if (yydebug)
947 fprintf(stderr, "Reading a token: ");
948#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000949 yychar = YYLEX;
950 }
951
Chris Lattner81779692006-03-30 22:51:12 +0000952 /* Convert token to internal form (in yychar1) for indexing tables with */
953
954 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000955 {
Chris Lattner81779692006-03-30 22:51:12 +0000956 yychar1 = 0;
957 yychar = YYEOF; /* Don't call YYLEX any more */
958
959#if YYDEBUG != 0
960 if (yydebug)
961 fprintf(stderr, "Now at end of input.\n");
962#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000963 }
964 else
965 {
Chris Lattner81779692006-03-30 22:51:12 +0000966 yychar1 = YYTRANSLATE(yychar);
967
968#if YYDEBUG != 0
969 if (yydebug)
970 {
971 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
972 /* Give the individual parser a way to print the precise meaning
973 of a token, for further debugging info. */
974#ifdef YYPRINT
975 YYPRINT (stderr, yychar, yylval);
976#endif
977 fprintf (stderr, ")\n");
978 }
979#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000980 }
981
Chris Lattner81779692006-03-30 22:51:12 +0000982 yyn += yychar1;
983 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000984 goto yydefault;
Chris Lattner81779692006-03-30 22:51:12 +0000985
Reid Spencer68a24bd2005-08-27 18:50:39 +0000986 yyn = yytable[yyn];
Chris Lattner81779692006-03-30 22:51:12 +0000987
988 /* yyn is what to do for this token type in this state.
989 Negative => reduce, -yyn is rule number.
990 Positive => shift, yyn is new state.
991 New state is final state => don't bother to shift,
992 just return success.
993 0, or most negative number => error. */
994
995 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000996 {
Chris Lattner81779692006-03-30 22:51:12 +0000997 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000998 goto yyerrlab;
999 yyn = -yyn;
1000 goto yyreduce;
1001 }
Chris Lattner81779692006-03-30 22:51:12 +00001002 else if (yyn == 0)
1003 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001004
1005 if (yyn == YYFINAL)
1006 YYACCEPT;
1007
1008 /* Shift the lookahead token. */
Chris Lattner81779692006-03-30 22:51:12 +00001009
1010#if YYDEBUG != 0
1011 if (yydebug)
1012 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
1013#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001014
1015 /* Discard the token being shifted unless it is eof. */
1016 if (yychar != YYEOF)
1017 yychar = YYEMPTY;
1018
1019 *++yyvsp = yylval;
Chris Lattner81779692006-03-30 22:51:12 +00001020#ifdef YYLSP_NEEDED
1021 *++yylsp = yylloc;
1022#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001023
Chris Lattner81779692006-03-30 22:51:12 +00001024 /* count tokens shifted since error; after three, turn off error status. */
1025 if (yyerrstatus) yyerrstatus--;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001026
1027 yystate = yyn;
1028 goto yynewstate;
1029
Chris Lattner81779692006-03-30 22:51:12 +00001030/* Do the default action for the current state. */
John Criswelld7881242006-01-17 17:01:34 +00001031yydefault:
Chris Lattner81779692006-03-30 22:51:12 +00001032
Reid Spencer68a24bd2005-08-27 18:50:39 +00001033 yyn = yydefact[yystate];
1034 if (yyn == 0)
1035 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001036
Chris Lattner81779692006-03-30 22:51:12 +00001037/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001038yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00001039 yylen = yyr2[yyn];
Chris Lattner81779692006-03-30 22:51:12 +00001040 if (yylen > 0)
1041 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001042
Chris Lattner81779692006-03-30 22:51:12 +00001043#if YYDEBUG != 0
1044 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001045 {
Chris Lattner81779692006-03-30 22:51:12 +00001046 int i;
1047
1048 fprintf (stderr, "Reducing via rule %d (line %d), ",
1049 yyn, yyrline[yyn]);
1050
1051 /* Print the symbols being reduced, and their result. */
1052 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
1053 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1054 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1055 }
1056#endif
1057
1058
1059 switch (yyn) {
1060
1061case 1:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001062#line 245 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001063{
Chris Lattner27627382006-09-01 21:14:42 +00001064 if (CurDefmPrefix) {
1065 // If CurDefmPrefix is set, we're parsing a defm, which means that this is
1066 // actually the name of a multiclass.
1067 MultiClass *MC = MultiClasses[*yyvsp[0].StrVal];
1068 if (MC == 0) {
1069 err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n";
1070 exit(1);
1071 }
1072 yyval.Rec = &MC->Rec;
1073 } else {
1074 yyval.Rec = Records.getClass(*yyvsp[0].StrVal);
1075 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001076 if (yyval.Rec == 0) {
1077 err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n";
1078 exit(1);
1079 }
1080 delete yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001081 ;
1082 break;}
1083case 2:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001084#line 267 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001085{ // string type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001086 yyval.Ty = new StringRecTy();
Chris Lattner81779692006-03-30 22:51:12 +00001087 ;
1088 break;}
1089case 3:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001090#line 269 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001091{ // bit type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001092 yyval.Ty = new BitRecTy();
Chris Lattner81779692006-03-30 22:51:12 +00001093 ;
1094 break;}
1095case 4:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001096#line 271 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001097{ // bits<x> type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001098 yyval.Ty = new BitsRecTy(yyvsp[-1].IntVal);
Chris Lattner81779692006-03-30 22:51:12 +00001099 ;
1100 break;}
1101case 5:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001102#line 273 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001103{ // int type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001104 yyval.Ty = new IntRecTy();
Chris Lattner81779692006-03-30 22:51:12 +00001105 ;
1106 break;}
1107case 6:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001108#line 275 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001109{ // list<x> type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001110 yyval.Ty = new ListRecTy(yyvsp[-1].Ty);
Chris Lattner81779692006-03-30 22:51:12 +00001111 ;
1112 break;}
1113case 7:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001114#line 277 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001115{ // code type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001116 yyval.Ty = new CodeRecTy();
Chris Lattner81779692006-03-30 22:51:12 +00001117 ;
1118 break;}
1119case 8:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001120#line 279 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001121{ // dag type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001122 yyval.Ty = new DagRecTy();
Chris Lattner81779692006-03-30 22:51:12 +00001123 ;
1124 break;}
1125case 9:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001126#line 281 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001127{ // Record Type
Reid Spencer68a24bd2005-08-27 18:50:39 +00001128 yyval.Ty = new RecordRecTy(yyvsp[0].Rec);
Chris Lattner81779692006-03-30 22:51:12 +00001129 ;
1130 break;}
1131case 10:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001132#line 285 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001133{ yyval.IntVal = 0; ;
1134 break;}
1135case 11:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001136#line 285 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001137{ yyval.IntVal = 1; ;
1138 break;}
1139case 12:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001140#line 287 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001141{ yyval.Initializer = 0; ;
1142 break;}
1143case 13:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001144#line 287 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001145{ yyval.Initializer = yyvsp[0].Initializer; ;
1146 break;}
1147case 14:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001148#line 289 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001149{
1150 if (const RecordVal *RV = (CurRec ? CurRec->getValue(*yyvsp[0].StrVal) : 0)) {
1151 yyval.Initializer = new VarInit(*yyvsp[0].StrVal, RV->getType());
1152 } else if (CurRec && CurRec->isTemplateArg(CurRec->getName()+":"+*yyvsp[0].StrVal)) {
1153 const RecordVal *RV = CurRec->getValue(CurRec->getName()+":"+*yyvsp[0].StrVal);
1154 assert(RV && "Template arg doesn't exist??");
1155 yyval.Initializer = new VarInit(CurRec->getName()+":"+*yyvsp[0].StrVal, RV->getType());
Chris Lattner27627382006-09-01 21:14:42 +00001156 } else if (CurMultiClass &&
1157 CurMultiClass->Rec.isTemplateArg(CurMultiClass->Rec.getName()+"::"+*yyvsp[0].StrVal)) {
1158 std::string Name = CurMultiClass->Rec.getName()+"::"+*yyvsp[0].StrVal;
1159 const RecordVal *RV = CurMultiClass->Rec.getValue(Name);
1160 assert(RV && "Template arg doesn't exist??");
1161 yyval.Initializer = new VarInit(Name, RV->getType());
Chris Lattner81779692006-03-30 22:51:12 +00001162 } else if (Record *D = Records.getDef(*yyvsp[0].StrVal)) {
1163 yyval.Initializer = new DefInit(D);
1164 } else {
1165 err() << "Variable not defined: '" << *yyvsp[0].StrVal << "'!\n";
1166 exit(1);
1167 }
1168
1169 delete yyvsp[0].StrVal;
1170;
1171 break;}
1172case 15:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001173#line 312 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001174{
1175 yyval.Initializer = yyvsp[0].Initializer;
1176 ;
1177 break;}
1178case 16:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001179#line 314 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001180{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001181 yyval.Initializer = new IntInit(yyvsp[0].IntVal);
Chris Lattner81779692006-03-30 22:51:12 +00001182 ;
1183 break;}
1184case 17:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001185#line 316 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001186{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001187 yyval.Initializer = new StringInit(*yyvsp[0].StrVal);
1188 delete yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001189 ;
1190 break;}
1191case 18:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001192#line 319 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001193{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001194 yyval.Initializer = new CodeInit(*yyvsp[0].StrVal);
1195 delete yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001196 ;
1197 break;}
1198case 19:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001199#line 322 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001200{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001201 yyval.Initializer = new UnsetInit();
Chris Lattner81779692006-03-30 22:51:12 +00001202 ;
1203 break;}
1204case 20:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001205#line 324 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001206{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001207 BitsInit *Init = new BitsInit(yyvsp[-1].FieldList->size());
1208 for (unsigned i = 0, e = yyvsp[-1].FieldList->size(); i != e; ++i) {
1209 struct Init *Bit = (*yyvsp[-1].FieldList)[i]->convertInitializerTo(new BitRecTy());
1210 if (Bit == 0) {
Chris Lattnerba4b1442005-09-08 18:22:57 +00001211 err() << "Element #" << i << " (" << *(*yyvsp[-1].FieldList)[i]
1212 << ") is not convertable to a bit!\n";
1213 exit(1);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001214 }
1215 Init->setBit(yyvsp[-1].FieldList->size()-i-1, Bit);
1216 }
1217 yyval.Initializer = Init;
1218 delete yyvsp[-1].FieldList;
Chris Lattner81779692006-03-30 22:51:12 +00001219 ;
1220 break;}
1221case 21:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001222#line 337 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001223{
Chris Lattnerca572be2005-09-08 18:48:47 +00001224 // This is a CLASS<initvalslist> expression. This is supposed to synthesize
1225 // a new anonymous definition, deriving from CLASS<initvalslist> with no
1226 // body.
1227 Record *Class = Records.getClass(*yyvsp[-3].StrVal);
1228 if (!Class) {
1229 err() << "Expected a class, got '" << *yyvsp[-3].StrVal << "'!\n";
1230 exit(1);
1231 }
1232 delete yyvsp[-3].StrVal;
1233
1234 static unsigned AnonCounter = 0;
1235 Record *OldRec = CurRec; // Save CurRec.
1236
1237 // Create the new record, set it as CurRec temporarily.
1238 CurRec = new Record("anonymous.val."+utostr(AnonCounter++));
1239 addSubClass(Class, *yyvsp[-1].FieldList); // Add info about the subclass to CurRec.
1240 delete yyvsp[-1].FieldList; // Free up the template args.
1241
Chris Lattner751eabf2005-09-08 19:47:28 +00001242 CurRec->resolveReferences();
Chris Lattnerca572be2005-09-08 18:48:47 +00001243
1244 Records.addDef(CurRec);
1245
1246 // The result of the expression is a reference to the new record.
1247 yyval.Initializer = new DefInit(CurRec);
1248
1249 // Restore the old CurRec
1250 CurRec = OldRec;
Chris Lattner81779692006-03-30 22:51:12 +00001251 ;
1252 break;}
1253case 22:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001254#line 365 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001255{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001256 yyval.Initializer = yyvsp[-3].Initializer->convertInitializerBitRange(*yyvsp[-1].BitList);
1257 if (yyval.Initializer == 0) {
1258 err() << "Invalid bit range for value '" << *yyvsp[-3].Initializer << "'!\n";
1259 exit(1);
1260 }
1261 delete yyvsp[-1].BitList;
Chris Lattner81779692006-03-30 22:51:12 +00001262 ;
1263 break;}
1264case 23:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001265#line 372 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001266{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001267 yyval.Initializer = new ListInit(*yyvsp[-1].FieldList);
1268 delete yyvsp[-1].FieldList;
Chris Lattner81779692006-03-30 22:51:12 +00001269 ;
1270 break;}
1271case 24:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001272#line 375 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001273{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001274 if (!yyvsp[-2].Initializer->getFieldType(*yyvsp[0].StrVal)) {
1275 err() << "Cannot access field '" << *yyvsp[0].StrVal << "' of value '" << *yyvsp[-2].Initializer << "!\n";
1276 exit(1);
1277 }
1278 yyval.Initializer = new FieldInit(yyvsp[-2].Initializer, *yyvsp[0].StrVal);
1279 delete yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001280 ;
1281 break;}
1282case 25:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001283#line 382 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001284{
1285 yyval.Initializer = new DagInit(yyvsp[-2].Initializer, *yyvsp[-1].DagValueList);
1286 delete yyvsp[-1].DagValueList;
1287 ;
1288 break;}
1289case 26:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001290#line 385 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001291{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001292 std::reverse(yyvsp[-1].BitList->begin(), yyvsp[-1].BitList->end());
1293 yyval.Initializer = yyvsp[-3].Initializer->convertInitListSlice(*yyvsp[-1].BitList);
1294 if (yyval.Initializer == 0) {
1295 err() << "Invalid list slice for value '" << *yyvsp[-3].Initializer << "'!\n";
1296 exit(1);
1297 }
1298 delete yyvsp[-1].BitList;
Chris Lattner81779692006-03-30 22:51:12 +00001299 ;
1300 break;}
1301case 27:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001302#line 393 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001303{
Chris Lattnerb8316912006-03-31 21:54:11 +00001304 yyval.Initializer = (new BinOpInit(BinOpInit::SHL, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
Chris Lattner81779692006-03-30 22:51:12 +00001305 ;
1306 break;}
1307case 28:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001308#line 395 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001309{
Chris Lattnerb8316912006-03-31 21:54:11 +00001310 yyval.Initializer = (new BinOpInit(BinOpInit::SRA, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
Chris Lattner81779692006-03-30 22:51:12 +00001311 ;
1312 break;}
1313case 29:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001314#line 397 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001315{
Chris Lattnerb8316912006-03-31 21:54:11 +00001316 yyval.Initializer = (new BinOpInit(BinOpInit::SRL, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
Chris Lattner81779692006-03-30 22:51:12 +00001317 ;
1318 break;}
1319case 30:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001320#line 399 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattnerb8316912006-03-31 21:54:11 +00001321{
1322 yyval.Initializer = (new BinOpInit(BinOpInit::STRCONCAT, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1323 ;
1324 break;}
1325case 31:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001326#line 403 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001327{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001328 yyval.StrVal = new std::string();
Chris Lattner81779692006-03-30 22:51:12 +00001329 ;
1330 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001331case 32:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001332#line 406 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001333{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001334 yyval.StrVal = yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001335 ;
1336 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001337case 33:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001338#line 410 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001339{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001340 yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
1341 yyval.DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal));
1342 delete yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001343 ;
1344 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001345case 34:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001346#line 415 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001347{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001348 yyvsp[-3].DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal));
1349 delete yyvsp[0].StrVal;
1350 yyval.DagValueList = yyvsp[-3].DagValueList;
Chris Lattner81779692006-03-30 22:51:12 +00001351 ;
1352 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001353case 35:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001354#line 421 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001355{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001356 yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
Chris Lattner81779692006-03-30 22:51:12 +00001357 ;
1358 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001359case 36:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001360#line 424 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001361{ yyval.DagValueList = yyvsp[0].DagValueList; ;
1362 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001363case 37:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001364#line 427 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001365{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001366 yyval.BitList = new std::vector<unsigned>();
1367 yyval.BitList->push_back(yyvsp[0].IntVal);
Chris Lattner81779692006-03-30 22:51:12 +00001368 ;
1369 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001370case 38:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001371#line 430 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001372{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001373 if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1374 err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1375 exit(1);
1376 }
1377 yyval.BitList = new std::vector<unsigned>();
1378 if (yyvsp[-2].IntVal < yyvsp[0].IntVal) {
1379 for (int i = yyvsp[-2].IntVal; i <= yyvsp[0].IntVal; ++i)
1380 yyval.BitList->push_back(i);
1381 } else {
1382 for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1383 yyval.BitList->push_back(i);
1384 }
Chris Lattner81779692006-03-30 22:51:12 +00001385 ;
1386 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001387case 39:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001388#line 443 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001389{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001390 yyvsp[0].IntVal = -yyvsp[0].IntVal;
1391 if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) {
1392 err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1393 exit(1);
1394 }
1395 yyval.BitList = new std::vector<unsigned>();
1396 if (yyvsp[-1].IntVal < yyvsp[0].IntVal) {
1397 for (int i = yyvsp[-1].IntVal; i <= yyvsp[0].IntVal; ++i)
1398 yyval.BitList->push_back(i);
1399 } else {
1400 for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1401 yyval.BitList->push_back(i);
1402 }
Chris Lattner81779692006-03-30 22:51:12 +00001403 ;
1404 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001405case 40:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001406#line 457 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001407{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001408 (yyval.BitList=yyvsp[-2].BitList)->push_back(yyvsp[0].IntVal);
Chris Lattner81779692006-03-30 22:51:12 +00001409 ;
1410 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001411case 41:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001412#line 459 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001413{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001414 if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1415 err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1416 exit(1);
1417 }
1418 yyval.BitList = yyvsp[-4].BitList;
1419 if (yyvsp[-2].IntVal < yyvsp[0].IntVal) {
1420 for (int i = yyvsp[-2].IntVal; i <= yyvsp[0].IntVal; ++i)
1421 yyval.BitList->push_back(i);
1422 } else {
1423 for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1424 yyval.BitList->push_back(i);
1425 }
Chris Lattner81779692006-03-30 22:51:12 +00001426 ;
1427 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001428case 42:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001429#line 472 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001430{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001431 yyvsp[0].IntVal = -yyvsp[0].IntVal;
1432 if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) {
1433 err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n";
1434 exit(1);
1435 }
1436 yyval.BitList = yyvsp[-3].BitList;
1437 if (yyvsp[-1].IntVal < yyvsp[0].IntVal) {
1438 for (int i = yyvsp[-1].IntVal; i <= yyvsp[0].IntVal; ++i)
1439 yyval.BitList->push_back(i);
1440 } else {
1441 for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1442 yyval.BitList->push_back(i);
1443 }
Chris Lattner81779692006-03-30 22:51:12 +00001444 ;
1445 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001446case 43:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001447#line 488 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001448{ yyval.BitList = yyvsp[0].BitList; std::reverse(yyvsp[0].BitList->begin(), yyvsp[0].BitList->end()); ;
1449 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001450case 44:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001451#line 490 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001452{ yyval.BitList = 0; ;
1453 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001454case 45:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001455#line 490 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001456{ yyval.BitList = yyvsp[-1].BitList; ;
1457 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001458case 46:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001459#line 494 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001460{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001461 yyval.FieldList = new std::vector<Init*>();
Chris Lattner81779692006-03-30 22:51:12 +00001462 ;
1463 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001464case 47:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001465#line 496 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001466{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001467 yyval.FieldList = yyvsp[0].FieldList;
Chris Lattner81779692006-03-30 22:51:12 +00001468 ;
1469 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001470case 48:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001471#line 500 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001472{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001473 yyval.FieldList = new std::vector<Init*>();
1474 yyval.FieldList->push_back(yyvsp[0].Initializer);
Chris Lattner81779692006-03-30 22:51:12 +00001475 ;
1476 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001477case 49:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001478#line 503 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001479{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001480 (yyval.FieldList = yyvsp[-2].FieldList)->push_back(yyvsp[0].Initializer);
Chris Lattner81779692006-03-30 22:51:12 +00001481 ;
1482 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001483case 50:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001484#line 507 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001485{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001486 std::string DecName = *yyvsp[-1].StrVal;
Chris Lattner27627382006-09-01 21:14:42 +00001487 if (ParsingTemplateArgs) {
1488 if (CurRec) {
1489 DecName = CurRec->getName() + ":" + DecName;
1490 } else {
1491 assert(CurMultiClass);
1492 }
1493 if (CurMultiClass)
1494 DecName = CurMultiClass->Rec.getName() + "::" + DecName;
1495 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001496
1497 addValue(RecordVal(DecName, yyvsp[-2].Ty, yyvsp[-3].IntVal));
1498 setValue(DecName, 0, yyvsp[0].Initializer);
1499 yyval.StrVal = new std::string(DecName);
Chris Lattner81779692006-03-30 22:51:12 +00001500;
1501 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001502case 51:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001503#line 524 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001504{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001505 delete yyvsp[-1].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001506;
1507 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001508case 52:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001509#line 526 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001510{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001511 setValue(*yyvsp[-4].StrVal, yyvsp[-3].BitList, yyvsp[-1].Initializer);
1512 delete yyvsp[-4].StrVal;
1513 delete yyvsp[-3].BitList;
Chris Lattner81779692006-03-30 22:51:12 +00001514;
1515 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001516case 57:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001517#line 535 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001518{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001519 yyval.SubClassRef = new SubClassRefTy(yyvsp[0].Rec, new std::vector<Init*>());
Chris Lattner81779692006-03-30 22:51:12 +00001520 ;
1521 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001522case 58:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001523#line 537 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001524{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001525 yyval.SubClassRef = new SubClassRefTy(yyvsp[-3].Rec, yyvsp[-1].FieldList);
Chris Lattner81779692006-03-30 22:51:12 +00001526 ;
1527 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001528case 59:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001529#line 541 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001530{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001531 yyval.SubClassList = new std::vector<SubClassRefTy>();
1532 yyval.SubClassList->push_back(*yyvsp[0].SubClassRef);
1533 delete yyvsp[0].SubClassRef;
Chris Lattner81779692006-03-30 22:51:12 +00001534 ;
1535 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001536case 60:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001537#line 546 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001538{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001539 (yyval.SubClassList=yyvsp[-2].SubClassList)->push_back(*yyvsp[0].SubClassRef);
1540 delete yyvsp[0].SubClassRef;
Chris Lattner81779692006-03-30 22:51:12 +00001541 ;
1542 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001543case 61:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001544#line 551 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001545{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001546 yyval.SubClassList = new std::vector<SubClassRefTy>();
Chris Lattner81779692006-03-30 22:51:12 +00001547 ;
1548 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001549case 62:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001550#line 554 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001551{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001552 yyval.SubClassList = yyvsp[0].SubClassList;
Chris Lattner81779692006-03-30 22:51:12 +00001553 ;
1554 break;}
Chris Lattner81779692006-03-30 22:51:12 +00001555case 63:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001556#line 558 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001557{
Chris Lattner27627382006-09-01 21:14:42 +00001558 getActiveRec()->addTemplateArg(*yyvsp[0].StrVal);
Chris Lattnerca572be2005-09-08 18:48:47 +00001559 delete yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001560;
1561 break;}
1562case 64:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001563#line 561 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattnerb8316912006-03-31 21:54:11 +00001564{
Chris Lattner27627382006-09-01 21:14:42 +00001565 getActiveRec()->addTemplateArg(*yyvsp[0].StrVal);
Chris Lattnerb8316912006-03-31 21:54:11 +00001566 delete yyvsp[0].StrVal;
1567;
1568 break;}
1569case 65:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001570#line 566 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001571{;
1572 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001573case 68:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001574#line 569 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001575{ yyval.StrVal = yyvsp[0].StrVal; ;
1576 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001577case 69:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001578#line 569 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001579{ yyval.StrVal = new std::string(); ;
1580 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001581case 70:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001582#line 571 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001583{
Chris Lattner8d354e92005-09-30 04:11:27 +00001584 static unsigned AnonCounter = 0;
1585 if (yyvsp[0].StrVal->empty())
1586 *yyvsp[0].StrVal = "anonymous."+utostr(AnonCounter++);
Chris Lattner946ac932005-09-30 04:53:25 +00001587 yyval.StrVal = yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001588;
1589 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001590case 71:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001591#line 578 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001592{
Chris Lattner946ac932005-09-30 04:53:25 +00001593 // If a class of this name already exists, it must be a forward ref.
Chris Lattner88b7e6e2005-09-30 06:09:50 +00001594 if ((CurRec = Records.getClass(*yyvsp[0].StrVal))) {
Chris Lattner946ac932005-09-30 04:53:25 +00001595 // If the body was previously defined, this is an error.
1596 if (!CurRec->getValues().empty() ||
1597 !CurRec->getSuperClasses().empty() ||
1598 !CurRec->getTemplateArgs().empty()) {
1599 err() << "Class '" << CurRec->getName() << "' already defined!\n";
1600 exit(1);
1601 }
1602 } else {
1603 // If this is the first reference to this class, create and add it.
1604 CurRec = new Record(*yyvsp[0].StrVal);
1605 Records.addClass(CurRec);
Chris Lattner8d354e92005-09-30 04:11:27 +00001606 }
Chris Lattner946ac932005-09-30 04:53:25 +00001607 delete yyvsp[0].StrVal;
Chris Lattner81779692006-03-30 22:51:12 +00001608;
1609 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001610case 72:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001611#line 596 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001612{
Chris Lattner946ac932005-09-30 04:53:25 +00001613 CurRec = new Record(*yyvsp[0].StrVal);
1614 delete yyvsp[0].StrVal;
1615
Chris Lattner27627382006-09-01 21:14:42 +00001616 if (!CurMultiClass) {
1617 // Top-level def definition.
1618
1619 // Ensure redefinition doesn't happen.
1620 if (Records.getDef(CurRec->getName())) {
1621 err() << "def '" << CurRec->getName() << "' already defined!\n";
1622 exit(1);
1623 }
1624 Records.addDef(CurRec);
1625 } else {
1626 // Otherwise, a def inside a multiclass, add it to the multiclass.
1627 for (unsigned i = 0, e = CurMultiClass->DefPrototypes.size(); i != e; ++i)
1628 if (CurMultiClass->DefPrototypes[i]->getName() == CurRec->getName()) {
1629 err() << "def '" << CurRec->getName()
1630 << "' already defined in this multiclass!\n";
1631 exit(1);
1632 }
1633 CurMultiClass->DefPrototypes.push_back(CurRec);
Chris Lattner8d354e92005-09-30 04:11:27 +00001634 }
Chris Lattner81779692006-03-30 22:51:12 +00001635;
1636 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001637case 73:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001638#line 621 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001639{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001640 for (unsigned i = 0, e = yyvsp[0].SubClassList->size(); i != e; ++i) {
Chris Lattnerba4b1442005-09-08 18:22:57 +00001641 addSubClass((*yyvsp[0].SubClassList)[i].first, *(*yyvsp[0].SubClassList)[i].second);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001642 // Delete the template arg values for the class
1643 delete (*yyvsp[0].SubClassList)[i].second;
1644 }
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001645 delete yyvsp[0].SubClassList; // Delete the class list.
Chris Lattner0a284052005-09-30 04:42:56 +00001646
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001647 // Process any variables on the let stack.
Chris Lattnerba4b1442005-09-08 18:22:57 +00001648 for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001649 for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
1650 setValue(LetStack[i][j].Name,
1651 LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0,
1652 LetStack[i][j].Value);
Chris Lattner81779692006-03-30 22:51:12 +00001653 ;
1654 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001655case 74:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001656#line 635 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001657{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001658 yyval.Rec = CurRec;
1659 CurRec = 0;
Chris Lattner81779692006-03-30 22:51:12 +00001660 ;
1661 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001662case 75:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001663#line 640 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001664{
Chris Lattner946ac932005-09-30 04:53:25 +00001665 ParsingTemplateArgs = true;
Chris Lattner81779692006-03-30 22:51:12 +00001666 ;
1667 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001668case 76:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001669#line 642 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001670{
Chris Lattner946ac932005-09-30 04:53:25 +00001671 ParsingTemplateArgs = false;
Chris Lattner81779692006-03-30 22:51:12 +00001672 ;
1673 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001674case 77:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001675#line 644 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001676{
Chris Lattner0a284052005-09-30 04:42:56 +00001677 yyval.Rec = yyvsp[0].Rec;
Chris Lattner81779692006-03-30 22:51:12 +00001678 ;
1679 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001680case 78:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001681#line 648 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001682{
Chris Lattner7717d092006-09-01 21:59:03 +00001683 if (CurMultiClass == 0) // Def's in multiclasses aren't really defs.
1684 yyvsp[0].Rec->resolveReferences();
Reid Spencer68a24bd2005-08-27 18:50:39 +00001685
Chris Lattnerca572be2005-09-08 18:48:47 +00001686 // If ObjectBody has template arguments, it's an error.
Chris Lattner0a284052005-09-30 04:42:56 +00001687 assert(yyvsp[0].Rec->getTemplateArgs().empty() && "How'd this get template args?");
Chris Lattner8d354e92005-09-30 04:11:27 +00001688 yyval.Rec = yyvsp[0].Rec;
Chris Lattner81779692006-03-30 22:51:12 +00001689;
1690 break;}
Chris Lattner27627382006-09-01 21:14:42 +00001691case 79:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001692#line 658 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner27627382006-09-01 21:14:42 +00001693{
1694 yyval.Rec = yyvsp[0].Rec;
1695 // Copy the template arguments for the multiclass into the def.
1696 const std::vector<std::string> &TArgs = CurMultiClass->Rec.getTemplateArgs();
1697
1698 for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
1699 const RecordVal *RV = CurMultiClass->Rec.getValue(TArgs[i]);
1700 assert(RV && "Template arg doesn't exist?");
1701 yyval.Rec->addValue(*RV);
1702 }
1703;
1704 break;}
1705case 80:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001706#line 672 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner27627382006-09-01 21:14:42 +00001707{
1708 yyval.RecList = new std::vector<Record*>();
1709 yyval.RecList->push_back(yyvsp[0].Rec);
1710;
1711 break;}
Chris Lattnerb8316912006-03-31 21:54:11 +00001712case 81:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001713#line 675 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner27627382006-09-01 21:14:42 +00001714{
1715 yyval.RecList->push_back(yyvsp[0].Rec);
1716;
1717 break;}
1718case 82:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001719#line 679 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner27627382006-09-01 21:14:42 +00001720{
1721 MultiClass *&MCE = MultiClasses[*yyvsp[0].StrVal];
1722 if (MCE) {
1723 err() << "multiclass '" << *yyvsp[0].StrVal << "' already defined!\n";
1724 exit(1);
1725 }
1726 MCE = CurMultiClass = new MultiClass(*yyvsp[0].StrVal);
1727 delete yyvsp[0].StrVal;
1728;
1729 break;}
1730case 83:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001731#line 690 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner27627382006-09-01 21:14:42 +00001732{
1733 ParsingTemplateArgs = true;
1734 ;
1735 break;}
1736case 84:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001737#line 692 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner27627382006-09-01 21:14:42 +00001738{
1739 ParsingTemplateArgs = false;
1740 ;
1741 break;}
1742case 85:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001743#line 694 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner27627382006-09-01 21:14:42 +00001744{
1745 CurMultiClass = 0;
1746;
1747 break;}
1748case 86:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001749#line 699 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner27627382006-09-01 21:14:42 +00001750{ CurDefmPrefix = yyvsp[0].StrVal; ;
1751 break;}
1752case 87:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001753#line 699 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner27627382006-09-01 21:14:42 +00001754{
1755 // To instantiate a multiclass, we need to first get the multiclass, then
1756 // instantiate each def contained in the multiclass with the SubClassRef
1757 // template parameters.
1758 MultiClass *MC = MultiClasses[yyvsp[-1].SubClassRef->first->getName()];
1759 assert(MC && "Didn't lookup multiclass correctly?");
1760 std::vector<Init*> &TemplateVals = *yyvsp[-1].SubClassRef->second;
1761 delete yyvsp[-1].SubClassRef;
1762
1763 // Verify that the correct number of template arguments were specified.
1764 const std::vector<std::string> &TArgs = MC->Rec.getTemplateArgs();
1765 if (TArgs.size() < TemplateVals.size()) {
1766 err() << "ERROR: More template args specified than multiclass expects!\n";
1767 exit(1);
1768 }
1769
1770 // Loop over all the def's in the multiclass, instantiating each one.
1771 for (unsigned i = 0, e = MC->DefPrototypes.size(); i != e; ++i) {
1772 Record *DefProto = MC->DefPrototypes[i];
1773
1774 // Add the suffix to the defm name to get the new name.
1775 assert(CurRec == 0 && "A def is current?");
1776 CurRec = new Record(*yyvsp[-4].StrVal + DefProto->getName());
1777
1778 addSubClass(DefProto, std::vector<Init*>());
1779
1780 // Loop over all of the template arguments, setting them to the specified
1781 // value or leaving them as the default if necessary.
1782 for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
1783 if (i < TemplateVals.size()) { // A value is specified for this temp-arg?
1784 // Set it now.
1785 setValue(TArgs[i], 0, TemplateVals[i]);
1786
1787 // Resolve it next.
1788 CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i]));
1789
1790 // Now remove it.
1791 CurRec->removeValue(TArgs[i]);
1792
1793 } else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) {
1794 err() << "ERROR: Value not specified for template argument #"
1795 << i << " (" << TArgs[i] << ") of multiclassclass '"
1796 << MC->Rec.getName() << "'!\n";
1797 exit(1);
1798 }
1799 }
1800
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001801 // If the mdef is inside a 'let' expression, add to each def.
1802 for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
1803 for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
1804 setValue(LetStack[i][j].Name,
1805 LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0,
1806 LetStack[i][j].Value);
1807
1808
Chris Lattner27627382006-09-01 21:14:42 +00001809 // Ensure redefinition doesn't happen.
1810 if (Records.getDef(CurRec->getName())) {
1811 err() << "def '" << CurRec->getName() << "' already defined, "
1812 << "instantiating defm '" << *yyvsp[-4].StrVal << "' with subdef '"
1813 << DefProto->getName() << "'!\n";
1814 exit(1);
1815 }
1816 Records.addDef(CurRec);
Chris Lattner7717d092006-09-01 21:59:03 +00001817
1818 CurRec->resolveReferences();
1819
Chris Lattner27627382006-09-01 21:14:42 +00001820 CurRec = 0;
1821 }
1822
1823 delete &TemplateVals;
1824 delete yyvsp[-4].StrVal;
Chris Lattnercce56af2006-09-01 22:07:27 +00001825 CurDefmPrefix = 0;
Chris Lattner27627382006-09-01 21:14:42 +00001826;
1827 break;}
1828case 88:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001829#line 773 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner27627382006-09-01 21:14:42 +00001830{;
1831 break;}
1832case 89:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001833#line 773 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner27627382006-09-01 21:14:42 +00001834{;
1835 break;}
1836case 92:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001837#line 776 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001838{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001839 LetStack.back().push_back(LetRecord(*yyvsp[-3].StrVal, yyvsp[-2].BitList, yyvsp[0].Initializer));
1840 delete yyvsp[-3].StrVal; delete yyvsp[-2].BitList;
Chris Lattner81779692006-03-30 22:51:12 +00001841;
1842 break;}
Chris Lattner27627382006-09-01 21:14:42 +00001843case 95:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001844#line 784 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001845{ LetStack.push_back(std::vector<LetRecord>()); ;
1846 break;}
Chris Lattner27627382006-09-01 21:14:42 +00001847case 97:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001848#line 787 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001849{
Chris Lattner946ac932005-09-30 04:53:25 +00001850 LetStack.pop_back();
Chris Lattner81779692006-03-30 22:51:12 +00001851 ;
1852 break;}
Chris Lattner27627382006-09-01 21:14:42 +00001853case 98:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001854#line 790 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattnerb8316912006-03-31 21:54:11 +00001855{
1856 LetStack.pop_back();
1857 ;
Chris Lattner81779692006-03-30 22:51:12 +00001858 break;}
Chris Lattner27627382006-09-01 21:14:42 +00001859case 99:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001860#line 794 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001861{;
1862 break;}
Chris Lattner27627382006-09-01 21:14:42 +00001863case 100:
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00001864#line 794 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00001865{;
1866 break;}
1867}
1868 /* the action file gets copied in in place of this dollarsign */
1869#line 543 "/usr/share/bison.simple"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001870
1871 yyvsp -= yylen;
1872 yyssp -= yylen;
Chris Lattner81779692006-03-30 22:51:12 +00001873#ifdef YYLSP_NEEDED
1874 yylsp -= yylen;
1875#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001876
Chris Lattner81779692006-03-30 22:51:12 +00001877#if YYDEBUG != 0
1878 if (yydebug)
1879 {
1880 short *ssp1 = yyss - 1;
1881 fprintf (stderr, "state stack now");
1882 while (ssp1 != yyssp)
1883 fprintf (stderr, " %d", *++ssp1);
1884 fprintf (stderr, "\n");
1885 }
1886#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001887
1888 *++yyvsp = yyval;
1889
Chris Lattner81779692006-03-30 22:51:12 +00001890#ifdef YYLSP_NEEDED
1891 yylsp++;
1892 if (yylen == 0)
1893 {
1894 yylsp->first_line = yylloc.first_line;
1895 yylsp->first_column = yylloc.first_column;
1896 yylsp->last_line = (yylsp-1)->last_line;
1897 yylsp->last_column = (yylsp-1)->last_column;
1898 yylsp->text = 0;
1899 }
1900 else
1901 {
1902 yylsp->last_line = (yylsp+yylen-1)->last_line;
1903 yylsp->last_column = (yylsp+yylen-1)->last_column;
1904 }
1905#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001906
Chris Lattner81779692006-03-30 22:51:12 +00001907 /* Now "shift" the result of the reduction.
1908 Determine what state that goes to,
1909 based on the state we popped back to
1910 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001911
1912 yyn = yyr1[yyn];
1913
Chris Lattner81779692006-03-30 22:51:12 +00001914 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1915 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001916 yystate = yytable[yystate];
1917 else
Chris Lattner81779692006-03-30 22:51:12 +00001918 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00001919
1920 goto yynewstate;
1921
Chris Lattner81779692006-03-30 22:51:12 +00001922yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001923
Chris Lattner81779692006-03-30 22:51:12 +00001924 if (! yyerrstatus)
1925 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001926 {
1927 ++yynerrs;
Chris Lattner81779692006-03-30 22:51:12 +00001928
1929#ifdef YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00001930 yyn = yypact[yystate];
1931
Chris Lattner81779692006-03-30 22:51:12 +00001932 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001933 {
Chris Lattner81779692006-03-30 22:51:12 +00001934 int size = 0;
1935 char *msg;
1936 int x, count;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001937
Chris Lattner81779692006-03-30 22:51:12 +00001938 count = 0;
1939 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1940 for (x = (yyn < 0 ? -yyn : 0);
1941 x < (sizeof(yytname) / sizeof(char *)); x++)
1942 if (yycheck[x + yyn] == x)
1943 size += strlen(yytname[x]) + 15, count++;
1944 msg = (char *) malloc(size + 15);
1945 if (msg != 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001946 {
Chris Lattner81779692006-03-30 22:51:12 +00001947 strcpy(msg, "parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001948
Chris Lattner81779692006-03-30 22:51:12 +00001949 if (count < 5)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001950 {
Chris Lattner81779692006-03-30 22:51:12 +00001951 count = 0;
1952 for (x = (yyn < 0 ? -yyn : 0);
1953 x < (sizeof(yytname) / sizeof(char *)); x++)
1954 if (yycheck[x + yyn] == x)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001955 {
Chris Lattner81779692006-03-30 22:51:12 +00001956 strcat(msg, count == 0 ? ", expecting `" : " or `");
1957 strcat(msg, yytname[x]);
1958 strcat(msg, "'");
1959 count++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001960 }
1961 }
Chris Lattner81779692006-03-30 22:51:12 +00001962 yyerror(msg);
1963 free(msg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001964 }
1965 else
Chris Lattner81779692006-03-30 22:51:12 +00001966 yyerror ("parse error; also virtual memory exceeded");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001967 }
1968 else
1969#endif /* YYERROR_VERBOSE */
Chris Lattner81779692006-03-30 22:51:12 +00001970 yyerror("parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001971 }
1972
Chris Lattner81779692006-03-30 22:51:12 +00001973 goto yyerrlab1;
1974yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001975
1976 if (yyerrstatus == 3)
1977 {
Chris Lattner81779692006-03-30 22:51:12 +00001978 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001979
Chris Lattner81779692006-03-30 22:51:12 +00001980 /* return failure if at end of input */
Chris Lattnerba4b1442005-09-08 18:22:57 +00001981 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001982 YYABORT;
1983
Chris Lattner81779692006-03-30 22:51:12 +00001984#if YYDEBUG != 0
1985 if (yydebug)
1986 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1987#endif
Chris Lattnerba4b1442005-09-08 18:22:57 +00001988
Chris Lattner81779692006-03-30 22:51:12 +00001989 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001990 }
1991
Chris Lattner81779692006-03-30 22:51:12 +00001992 /* Else will try to reuse lookahead token
1993 after shifting the error token. */
1994
1995 yyerrstatus = 3; /* Each real token shifted decrements this */
1996
1997 goto yyerrhandle;
1998
1999yyerrdefault: /* current state does not do anything special for the error token. */
2000
2001#if 0
2002 /* This is wrong; only states that explicitly want error tokens
2003 should shift them. */
2004 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
2005 if (yyn) goto yydefault;
2006#endif
2007
2008yyerrpop: /* pop the current state because it cannot handle the error token */
2009
2010 if (yyssp == yyss) YYABORT;
2011 yyvsp--;
2012 yystate = *--yyssp;
2013#ifdef YYLSP_NEEDED
2014 yylsp--;
2015#endif
2016
2017#if YYDEBUG != 0
2018 if (yydebug)
2019 {
2020 short *ssp1 = yyss - 1;
2021 fprintf (stderr, "Error: state stack now");
2022 while (ssp1 != yyssp)
2023 fprintf (stderr, " %d", *++ssp1);
2024 fprintf (stderr, "\n");
2025 }
2026#endif
2027
2028yyerrhandle:
2029
2030 yyn = yypact[yystate];
2031 if (yyn == YYFLAG)
2032 goto yyerrdefault;
2033
2034 yyn += YYTERROR;
2035 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
2036 goto yyerrdefault;
2037
2038 yyn = yytable[yyn];
2039 if (yyn < 0)
2040 {
2041 if (yyn == YYFLAG)
2042 goto yyerrpop;
2043 yyn = -yyn;
2044 goto yyreduce;
2045 }
2046 else if (yyn == 0)
2047 goto yyerrpop;
2048
Reid Spencer68a24bd2005-08-27 18:50:39 +00002049 if (yyn == YYFINAL)
2050 YYACCEPT;
2051
Chris Lattner81779692006-03-30 22:51:12 +00002052#if YYDEBUG != 0
2053 if (yydebug)
2054 fprintf(stderr, "Shifting error token, ");
2055#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002056
2057 *++yyvsp = yylval;
Chris Lattner81779692006-03-30 22:51:12 +00002058#ifdef YYLSP_NEEDED
2059 *++yylsp = yylloc;
2060#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002061
2062 yystate = yyn;
2063 goto yynewstate;
2064
Chris Lattner81779692006-03-30 22:51:12 +00002065 yyacceptlab:
2066 /* YYACCEPT comes here. */
2067 if (yyfree_stacks)
2068 {
2069 free (yyss);
2070 free (yyvs);
2071#ifdef YYLSP_NEEDED
2072 free (yyls);
Chris Lattner2b931e82005-09-12 05:30:06 +00002073#endif
Chris Lattner81779692006-03-30 22:51:12 +00002074 }
2075 return 0;
John Criswelld7881242006-01-17 17:01:34 +00002076
Chris Lattner81779692006-03-30 22:51:12 +00002077 yyabortlab:
2078 /* YYABORT comes here. */
2079 if (yyfree_stacks)
2080 {
2081 free (yyss);
2082 free (yyvs);
2083#ifdef YYLSP_NEEDED
2084 free (yyls);
John Criswelld7881242006-01-17 17:01:34 +00002085#endif
Chris Lattner81779692006-03-30 22:51:12 +00002086 }
2087 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002088}
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00002089#line 798 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002090
2091
2092int yyerror(const char *ErrorMsg) {
2093 err() << "Error parsing: " << ErrorMsg << "\n";
2094 exit(1);
2095}