2 /* A Bison parser, made from /Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
7 #define yyparse Fileparse
9 #define yyerror Fileerror
10 #define yylval Filelval
11 #define yychar Filechar
12 #define yydebug Filedebug
13 #define yynerrs Filenerrs
23 #define MULTICLASS 266
31 #define STRCONCATTOK 274
36 #define CODEFRAGMENT 279
38 #line 14 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
41 #include "llvm/ADT/StringExtras.h"
44 #define YYERROR_VERBOSE 1
46 int yyerror(const char *ErrorMsg);
51 Record Rec; // Placeholder for template args and Name.
52 std::vector<Record*> DefPrototypes;
54 MultiClass(const std::string &Name) : Rec(Name) {}
58 static std::map<std::string, MultiClass*> MultiClasses;
60 extern int Filelineno;
61 static MultiClass *CurMultiClass = 0; // Set while parsing a multiclass.
62 static std::string *CurDefmPrefix = 0; // Set while parsing defm.
63 static Record *CurRec = 0;
64 static bool ParsingTemplateArgs = false;
66 typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
70 std::vector<unsigned> Bits;
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;
79 static std::vector<std::vector<LetRecord> > LetStack;
82 extern std::ostream &err();
84 /// getActiveRec - If inside a def/class definition, return the def/class.
85 /// Otherwise, if within a multidef, return it.
86 static Record *getActiveRec() {
87 return CurRec ? CurRec : &CurMultiClass->Rec;
90 static void addValue(const RecordVal &RV) {
91 Record *TheRec = getActiveRec();
93 if (RecordVal *ERV = TheRec->getValue(RV.getName())) {
94 // The value already exists in the class, treat this as a set...
95 if (ERV->setValue(RV.getValue())) {
96 err() << "New definition of '" << RV.getName() << "' of type '"
97 << *RV.getType() << "' is incompatible with previous "
98 << "definition of type '" << *ERV->getType() << "'!\n";
102 TheRec->addValue(RV);
106 static void addSuperClass(Record *SC) {
107 if (CurRec->isSubClassOf(SC)) {
108 err() << "Already subclass of '" << SC->getName() << "'!\n";
111 CurRec->addSuperClass(SC);
114 static void setValue(const std::string &ValName,
115 std::vector<unsigned> *BitList, Init *V) {
118 Record *TheRec = getActiveRec();
119 RecordVal *RV = TheRec->getValue(ValName);
121 err() << "Value '" << ValName << "' unknown!\n";
125 // Do not allow assignments like 'X = X'. This will just cause infinite loops
126 // in the resolution machinery.
128 if (VarInit *VI = dynamic_cast<VarInit*>(V))
129 if (VI->getName() == ValName)
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
137 BitsInit *CurVal = dynamic_cast<BitsInit*>(RV->getValue());
139 err() << "Value '" << ValName << "' is not a bits type!\n";
143 // Convert the incoming value to a bits type of the appropriate size...
144 Init *BI = V->convertInitializerTo(new BitsRecTy(BitList->size()));
146 V->convertInitializerTo(new BitsRecTy(BitList->size()));
147 err() << "Initializer '" << *V << "' not compatible with bit range!\n";
151 // We should have a BitsInit type now...
152 assert(dynamic_cast<BitsInit*>(BI) != 0 || &(std::cerr << *BI) == 0);
153 BitsInit *BInit = (BitsInit*)BI;
155 BitsInit *NewVal = new BitsInit(CurVal->getNumBits());
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";
165 NewVal->setBit(Bit, BInit->getBit(i));
168 for (unsigned i = 0, e = CurVal->getNumBits(); i != e; ++i)
169 if (NewVal->getBit(i) == 0)
170 NewVal->setBit(i, CurVal->getBit(i));
175 if (RV->setValue(V)) {
176 err() << "Value '" << ValName << "' of type '" << *RV->getType()
177 << "' is incompatible with initializer '" << *V << "'!\n";
182 // addSubClass - Add SC as a subclass to CurRec, resolving TemplateArgs as SC's
183 // template arguments.
184 static void addSubClass(Record *SC, const std::vector<Init*> &TemplateArgs) {
185 // Add all of the values in the subclass into the current class...
186 const std::vector<RecordVal> &Vals = SC->getValues();
187 for (unsigned i = 0, e = Vals.size(); i != e; ++i)
190 const std::vector<std::string> &TArgs = SC->getTemplateArgs();
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";
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?
203 setValue(TArgs[i], 0, TemplateArgs[i]);
206 CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i]));
210 CurRec->removeValue(TArgs[i]);
212 } else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) {
213 err() << "ERROR: Value not specified for template argument #"
214 << i << " (" << TArgs[i] << ") of subclass '" << SC->getName()
220 // Since everything went well, we can now set the "superclass" list for the
222 const std::vector<Record*> &SCs = SC->getSuperClasses();
223 for (unsigned i = 0, e = SCs.size(); i != e; ++i)
224 addSuperClass(SCs[i]);
228 } // End llvm namespace
230 using namespace llvm;
233 #line 209 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
238 llvm::Init* Initializer;
239 std::vector<llvm::Init*>* FieldList;
240 std::vector<unsigned>* BitList;
242 std::vector<llvm::Record*>* RecList;
243 SubClassRefTy* SubClassRef;
244 std::vector<SubClassRefTy>* SubClassList;
245 std::vector<std::pair<llvm::Init*, std::string> >* DagValueList;
258 #define YYFLAG -32768
261 #define YYTRANSLATE(x) ((unsigned)(x) <= 279 ? yytranslate[x] : 90)
263 static const char yytranslate[] = { 0,
264 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
265 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
266 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
267 2, 2, 2, 2, 2, 2, 2, 2, 2, 35,
268 36, 2, 2, 37, 39, 34, 2, 2, 2, 2,
269 2, 2, 2, 2, 2, 2, 2, 38, 40, 26,
270 28, 27, 29, 2, 2, 2, 2, 2, 2, 2,
271 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
272 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
273 32, 2, 33, 2, 2, 2, 2, 2, 2, 2,
274 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
275 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
276 2, 2, 30, 2, 31, 2, 2, 2, 2, 2,
277 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
278 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
279 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
280 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
281 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
282 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
283 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
284 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
285 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
286 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
287 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
288 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
289 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
290 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
291 17, 18, 19, 20, 21, 22, 23, 24, 25
295 static const short yyprhs[] = { 0,
296 0, 2, 4, 6, 11, 13, 18, 20, 22, 24,
297 25, 27, 28, 31, 33, 35, 37, 39, 41, 43,
298 47, 52, 57, 61, 65, 70, 75, 82, 89, 96,
299 103, 104, 107, 110, 115, 116, 118, 120, 124, 127,
300 131, 137, 142, 144, 145, 149, 150, 152, 154, 158,
301 163, 166, 173, 174, 177, 179, 183, 185, 190, 192,
302 196, 197, 200, 202, 206, 210, 211, 213, 215, 216,
303 218, 220, 222, 223, 227, 228, 229, 236, 240, 242,
304 244, 247, 249, 250, 251, 260, 261, 268, 270, 272,
305 274, 276, 281, 283, 287, 288, 293, 298, 301, 303,
309 static const short yyrhs[] = { 22,
310 0, 5, 0, 4, 0, 6, 26, 21, 27, 0,
311 3, 0, 7, 26, 42, 27, 0, 8, 0, 9,
312 0, 41, 0, 0, 14, 0, 0, 28, 46, 0,
313 22, 0, 45, 0, 21, 0, 24, 0, 25, 0,
314 29, 0, 30, 53, 31, 0, 22, 26, 54, 27,
315 0, 46, 30, 51, 31, 0, 32, 53, 33, 0,
316 46, 34, 22, 0, 35, 45, 49, 36, 0, 46,
317 32, 51, 33, 0, 17, 35, 46, 37, 46, 36,
318 0, 18, 35, 46, 37, 46, 36, 0, 19, 35,
319 46, 37, 46, 36, 0, 20, 35, 46, 37, 46,
320 36, 0, 0, 38, 23, 0, 46, 47, 0, 48,
321 37, 46, 47, 0, 0, 48, 0, 21, 0, 21,
322 39, 21, 0, 21, 21, 0, 50, 37, 21, 0,
323 50, 37, 21, 39, 21, 0, 50, 37, 21, 21,
324 0, 50, 0, 0, 30, 51, 31, 0, 0, 54,
325 0, 46, 0, 54, 37, 46, 0, 43, 42, 22,
326 44, 0, 55, 40, 0, 15, 22, 52, 28, 46,
327 40, 0, 0, 57, 56, 0, 40, 0, 30, 57,
328 31, 0, 41, 0, 41, 26, 54, 27, 0, 59,
329 0, 60, 37, 59, 0, 0, 38, 60, 0, 55,
330 0, 62, 37, 55, 0, 26, 62, 27, 0, 0,
331 63, 0, 22, 0, 0, 65, 0, 66, 0, 66,
332 0, 0, 61, 70, 58, 0, 0, 0, 10, 67,
333 72, 64, 73, 69, 0, 11, 68, 69, 0, 74,
334 0, 75, 0, 76, 75, 0, 22, 0, 0, 0,
335 12, 77, 79, 64, 80, 30, 76, 31, 0, 0,
336 13, 22, 82, 38, 59, 40, 0, 71, 0, 74,
337 0, 78, 0, 81, 0, 22, 52, 28, 46, 0,
338 84, 0, 85, 37, 84, 0, 0, 15, 87, 85,
339 16, 0, 86, 30, 88, 31, 0, 86, 83, 0,
340 83, 0, 88, 83, 0, 88, 0
346 static const short yyrline[] = { 0,
347 245, 267, 269, 271, 273, 275, 277, 279, 281, 285,
348 285, 287, 287, 289, 312, 314, 316, 319, 322, 324,
349 337, 365, 372, 375, 382, 385, 393, 395, 397, 399,
350 403, 406, 410, 415, 421, 424, 427, 430, 443, 457,
351 459, 472, 488, 490, 490, 494, 496, 500, 503, 507,
352 524, 526, 532, 532, 533, 533, 535, 537, 541, 546,
353 551, 554, 558, 561, 566, 567, 567, 569, 569, 571,
354 578, 596, 621, 635, 640, 642, 644, 648, 658, 672,
355 675, 679, 690, 692, 694, 699, 699, 773, 773, 774,
356 774, 776, 781, 781, 784, 784, 787, 790, 794, 794,
362 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
364 static const char * const yytname[] = { "$","error","$undefined.","INT","BIT",
365 "STRING","BITS","LIST","CODE","DAG","CLASS","DEF","MULTICLASS","DEFM","FIELD",
366 "LET","IN","SHLTOK","SRATOK","SRLTOK","STRCONCATTOK","INTVAL","ID","VARNAME",
367 "STRVAL","CODEFRAGMENT","'<'","'>'","'='","'?'","'{'","'}'","'['","']'","'.'",
368 "'('","')'","','","':'","'-'","';'","ClassID","Type","OptPrefix","OptValue",
369 "IDValue","Value","OptVarName","DagArgListNE","DagArgList","RBitList","BitList",
370 "OptBitList","ValueList","ValueListNE","Declaration","BodyItem","BodyList","Body",
371 "SubClassRef","ClassListNE","ClassList","DeclListNE","TemplateArgList","OptTemplateArgList",
372 "OptID","ObjectName","ClassName","DefName","ObjectBody","@1","ClassInst","@2",
373 "@3","DefInst","MultiClassDef","MultiClassBody","MultiClassName","MultiClassInst",
374 "@4","@5","DefMInst","@6","Object","LETItem","LETList","LETCommand","@7","ObjectList",
379 static const short yyr1[] = { 0,
380 41, 42, 42, 42, 42, 42, 42, 42, 42, 43,
381 43, 44, 44, 45, 46, 46, 46, 46, 46, 46,
382 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
383 47, 47, 48, 48, 49, 49, 50, 50, 50, 50,
384 50, 50, 51, 52, 52, 53, 53, 54, 54, 55,
385 56, 56, 57, 57, 58, 58, 59, 59, 60, 60,
386 61, 61, 62, 62, 63, 64, 64, 65, 65, 66,
387 67, 68, 70, 69, 72, 73, 71, 74, 75, 76,
388 76, 77, 79, 80, 78, 82, 81, 83, 83, 83,
389 83, 84, 85, 85, 87, 86, 83, 83, 88, 88,
393 static const short yyr2[] = { 0,
394 1, 1, 1, 4, 1, 4, 1, 1, 1, 0,
395 1, 0, 2, 1, 1, 1, 1, 1, 1, 3,
396 4, 4, 3, 3, 4, 4, 6, 6, 6, 6,
397 0, 2, 2, 4, 0, 1, 1, 3, 2, 3,
398 5, 4, 1, 0, 3, 0, 1, 1, 3, 4,
399 2, 6, 0, 2, 1, 3, 1, 4, 1, 3,
400 0, 2, 1, 3, 3, 0, 1, 1, 0, 1,
401 1, 1, 0, 3, 0, 0, 6, 3, 1, 1,
402 2, 1, 0, 0, 8, 0, 6, 1, 1, 1,
403 1, 4, 1, 3, 0, 4, 4, 2, 1, 2,
407 static const short yydefact[] = { 0,
408 69, 69, 0, 0, 95, 88, 89, 90, 91, 99,
409 0, 101, 68, 70, 71, 75, 72, 61, 82, 83,
410 86, 0, 0, 98, 100, 66, 0, 73, 78, 66,
411 0, 44, 93, 0, 0, 10, 67, 76, 1, 57,
412 59, 62, 0, 84, 0, 0, 0, 96, 0, 97,
413 11, 0, 63, 0, 61, 0, 0, 53, 55, 74,
414 0, 0, 37, 43, 0, 0, 94, 5, 3, 2,
415 0, 0, 7, 8, 9, 0, 65, 10, 77, 0,
416 0, 0, 0, 16, 14, 17, 18, 19, 46, 46,
417 0, 15, 48, 0, 60, 10, 0, 87, 39, 0,
418 0, 45, 92, 0, 0, 12, 64, 0, 0, 0,
419 0, 0, 0, 47, 0, 14, 35, 0, 0, 0,
420 58, 0, 0, 56, 0, 54, 79, 80, 0, 38,
421 40, 0, 0, 0, 50, 0, 0, 0, 0, 0,
422 20, 23, 31, 36, 0, 0, 0, 24, 49, 44,
423 51, 85, 81, 42, 0, 4, 6, 13, 0, 0,
424 0, 0, 21, 0, 33, 0, 25, 22, 26, 0,
425 41, 0, 0, 0, 0, 32, 31, 0, 27, 28,
426 29, 30, 34, 0, 52, 0, 0, 0
429 static const short yydefgoto[] = { 40,
430 76, 52, 135, 92, 93, 165, 144, 145, 64, 65,
431 47, 113, 114, 53, 126, 96, 60, 41, 42, 28,
432 54, 37, 38, 14, 15, 16, 18, 29, 43, 6,
433 26, 55, 7, 128, 129, 20, 8, 30, 61, 9,
434 31, 10, 33, 34, 11, 22, 12, 186
437 static const short yypact[] = { 129,
438 3, 3, 11, 19,-32768,-32768,-32768,-32768,-32768,-32768,
439 2, 129,-32768,-32768,-32768,-32768,-32768, 29,-32768,-32768,
440 -32768, 24, 129,-32768,-32768, 43, 31,-32768,-32768, 43,
441 40, 50,-32768, -6, -4, 69,-32768,-32768,-32768, 59,
442 -32768, 61, 10,-32768, 31, 81, 78,-32768, 24,-32768,
443 -32768, 15,-32768, 12, 29, 41, 31,-32768,-32768,-32768,
444 84, 68, 8, 83, 87, 41,-32768,-32768,-32768,-32768,
445 111, 120,-32768,-32768,-32768, 126,-32768, 69,-32768, 114,
446 115, 116, 117,-32768, 127,-32768,-32768,-32768, 41, 41,
447 132,-32768, 113, 27,-32768, 60, 144,-32768,-32768, 135,
448 136,-32768, 113, 137, 15, 131,-32768, 41, 41, 41,
449 41, 41, 130, 123, 133,-32768, 41, 81, 81, 140,
450 -32768, 41, 141,-32768, 124,-32768,-32768,-32768, 5,-32768,
451 9, 138, 142, 41,-32768, 67, 73, 79, 85, 45,
452 -32768,-32768, 54, 134, 139, 143, 145,-32768, 113, 50,
453 -32768,-32768,-32768,-32768, 146,-32768,-32768, 113, 41, 41,
454 41, 41,-32768, 147,-32768, 41,-32768,-32768,-32768, 148,
455 -32768, 91, 94, 99, 102,-32768, 54, 41,-32768,-32768,
456 -32768,-32768,-32768, 47,-32768, 168, 172,-32768
459 static const short yypgoto[] = { -50,
460 72,-32768,-32768, 82, -66, 4,-32768,-32768,-32768, -29,
461 30, 89, -55, -44,-32768,-32768,-32768, -19,-32768,-32768,
462 -32768,-32768, 152,-32768, 181,-32768,-32768, 149,-32768,-32768,
463 -32768,-32768, -94, 55,-32768,-32768,-32768,-32768,-32768,-32768,
464 -32768, -7, 150,-32768,-32768,-32768, 162,-32768
471 static const short yytable[] = { 103,
472 94, 75, 127, 24, 25, 1, 2, 3, 4, 48,
473 5, 1, 2, 3, 4, 2, 5, 68, 69, 70,
474 71, 72, 73, 74, 13, 62, 50, 25, 99, 154,
475 49, 23, 19, 107, 127, 152, 39, 95, 77, 58,
476 21, 136, 137, 138, 139, 32, 100, 155, 78, 59,
477 143, 125, 39, 121, 75, 149, 140, 80, 81, 82,
478 83, 84, 85, 122, 86, 87, 27, 158, 36, 88,
479 89, 163, 90, 51, 123, 91, 118, 45, 119, 46,
480 120, 122, 51, 118, 56, 119, 185, 120, 146, 147,
481 124, 164, 172, 173, 174, 175, 118, 57, 119, 177,
482 120, 63, 118, 159, 119, 66, 120, 98, 118, 160,
483 119, 184, 120, 97, 118, 161, 119, 102, 120, 101,
484 118, 162, 119, 118, 120, 119, 179, 120, 118, 180,
485 119, 118, 120, 119, 181, 120, 104, 182, 1, 2,
486 3, 4, 118, 5, 119, 105, 120, 106, 108, 109,
487 110, 111, 112, 116, 2, 130, 131, 132, 134, 122,
488 141, 148, 150, 151, 156, 142, 171, 187, 157, 176,
489 166, 188, 117, 168, 167, 178, 133, 169, 115, 170,
490 183, 44, 17, 153, 35, 0, 0, 0, 0, 0,
491 0, 0, 0, 0, 0, 0, 0, 0, 67, 0,
495 static const short yycheck[] = { 66,
496 56, 52, 97, 11, 12, 10, 11, 12, 13, 16,
497 15, 10, 11, 12, 13, 11, 15, 3, 4, 5,
498 6, 7, 8, 9, 22, 45, 31, 35, 21, 21,
499 37, 30, 22, 78, 129, 31, 22, 57, 27, 30,
500 22, 108, 109, 110, 111, 22, 39, 39, 37, 40,
501 117, 96, 22, 27, 105, 122, 112, 17, 18, 19,
502 20, 21, 22, 37, 24, 25, 38, 134, 26, 29,
503 30, 27, 32, 14, 15, 35, 30, 38, 32, 30,
504 34, 37, 14, 30, 26, 32, 40, 34, 118, 119,
505 31, 38, 159, 160, 161, 162, 30, 37, 32, 166,
506 34, 21, 30, 37, 32, 28, 34, 40, 30, 37,
507 32, 178, 34, 30, 30, 37, 32, 31, 34, 37,
508 30, 37, 32, 30, 34, 32, 36, 34, 30, 36,
509 32, 30, 34, 32, 36, 34, 26, 36, 10, 11,
510 12, 13, 30, 15, 32, 26, 34, 22, 35, 35,
511 35, 35, 26, 22, 11, 21, 21, 21, 28, 37,
512 31, 22, 22, 40, 27, 33, 21, 0, 27, 23,
513 37, 0, 91, 31, 36, 28, 105, 33, 90, 150,
514 177, 30, 2, 129, 23, -1, -1, -1, -1, -1,
515 -1, -1, -1, -1, -1, -1, -1, -1, 49, -1,
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. */
522 /* Skeleton output parser for bison,
523 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
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)
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.
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. */
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. */
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. */
550 #ifndef YYSTACK_USE_ALLOCA
552 #define YYSTACK_USE_ALLOCA
553 #else /* alloca not defined */
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
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. */
570 #else /* not MSDOS, or __TURBOC__ */
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> */
576 #define YYSTACK_USE_ALLOCA
577 #else /* not MSDOS, or __TURBOC__, or _AIX */
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
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 */
592 #ifdef YYSTACK_USE_ALLOCA
593 #define YYSTACK_ALLOC alloca
595 #define YYSTACK_ALLOC malloc
598 /* Note: there must be only one dollar sign in this file.
599 It is replaced by the list of actions, each action
600 as one case of the switch. */
602 #define yyerrok (yyerrstatus = 0)
603 #define yyclearin (yychar = YYEMPTY)
606 #define YYACCEPT goto yyacceptlab
607 #define YYABORT goto yyabortlab
608 #define YYERROR goto yyerrlab1
609 /* Like YYERROR except do call yyerror.
610 This remains here temporarily to ease the
611 transition to the new meaning of YYERROR, for GCC.
612 Once GCC version 2 has supplanted version 1, this can go. */
613 #define YYFAIL goto yyerrlab
614 #define YYRECOVERING() (!!yyerrstatus)
615 #define YYBACKUP(token, value) \
617 if (yychar == YYEMPTY && yylen == 1) \
618 { yychar = (token), yylval = (value); \
619 yychar1 = YYTRANSLATE (yychar); \
624 { yyerror ("syntax error: cannot back up"); YYERROR; } \
628 #define YYERRCODE 256
631 #define YYLEX yylex()
637 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
639 #define YYLEX yylex(&yylval, &yylloc)
641 #else /* not YYLSP_NEEDED */
643 #define YYLEX yylex(&yylval, YYLEX_PARAM)
645 #define YYLEX yylex(&yylval)
647 #endif /* not YYLSP_NEEDED */
650 /* If nonreentrant, generate the variables here */
654 int yychar; /* the lookahead symbol */
655 YYSTYPE yylval; /* the semantic value of the */
656 /* lookahead symbol */
659 YYLTYPE yylloc; /* location data for the lookahead */
663 int yynerrs; /* number of parse errors so far */
664 #endif /* not YYPURE */
667 int yydebug; /* nonzero means print parse trace */
668 /* Since this is uninitialized, it does not stop multiple parsers
672 /* YYINITDEPTH indicates the initial size of the parser's stacks */
675 #define YYINITDEPTH 200
678 /* YYMAXDEPTH is the maximum size the stacks can grow to
679 (effective only if the built-in stack extension method is used). */
686 #define YYMAXDEPTH 10000
689 /* Define __yy_memcpy. Note that the size argument
690 should be passed with type unsigned int, because that is what the non-GCC
691 definitions require. With GCC, __builtin_memcpy takes an arg
692 of type size_t, but it can handle unsigned int. */
694 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
695 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
696 #else /* not GNU C or C++ */
699 /* This is the most reliable way to avoid incompatibilities
700 in available built-in functions on various systems. */
702 __yy_memcpy (to, from, count)
707 register char *f = from;
708 register char *t = to;
709 register int i = count;
715 #else /* __cplusplus */
717 /* This is the most reliable way to avoid incompatibilities
718 in available built-in functions on various systems. */
720 __yy_memcpy (char *to, char *from, unsigned int count)
722 register char *t = to;
723 register char *f = from;
724 register int i = count;
733 #line 217 "/usr/share/bison.simple"
735 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
736 into yyparse. The argument should have type void *.
737 It should actually point to an object.
738 Grammar actions can access the variable by casting it
739 to the proper pointer type. */
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 */
754 /* Prevent warning if -Wstrict-prototypes. */
757 int yyparse (void *);
764 yyparse(YYPARSE_PARAM_ARG)
767 register int yystate;
769 register short *yyssp;
770 register YYSTYPE *yyvsp;
771 int yyerrstatus; /* number of tokens to shift before error messages enabled */
772 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
774 short yyssa[YYINITDEPTH]; /* the state stack */
775 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
777 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
778 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
781 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
782 YYLTYPE *yyls = yylsa;
785 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
787 #define YYPOPSTACK (yyvsp--, yyssp--)
790 int yystacksize = YYINITDEPTH;
791 int yyfree_stacks = 0;
802 YYSTYPE yyval; /* the variable used to return */
803 /* semantic values from the action */
810 fprintf(stderr, "Starting parse\n");
816 yychar = YYEMPTY; /* Cause a token to be read. */
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. */
829 /* Push a new state, which is found in yystate . */
830 /* In all cases, when you get here, the value and location stacks
831 have just been pushed. so pushing a state here evens the stacks. */
836 if (yyssp >= yyss + yystacksize - 1)
838 /* Give user a chance to reallocate the stack */
839 /* Use copies of these so that the &'s don't force the real ones into memory. */
840 YYSTYPE *yyvs1 = yyvs;
843 YYLTYPE *yyls1 = yyls;
846 /* Get the current used size of the three stacks, in elements. */
847 int size = yyssp - yyss + 1;
850 /* Each stack pointer address is followed by the size of
851 the data in use in that stack, in bytes. */
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),
861 yyoverflow("parser stack overflow",
862 &yyss1, size * sizeof (*yyssp),
863 &yyvs1, size * sizeof (*yyvsp),
867 yyss = yyss1; yyvs = yyvs1;
871 #else /* no yyoverflow */
872 /* Extend the stack our own way. */
873 if (yystacksize >= YYMAXDEPTH)
875 yyerror("parser stack overflow");
887 if (yystacksize > YYMAXDEPTH)
888 yystacksize = YYMAXDEPTH;
889 #ifndef YYSTACK_USE_ALLOCA
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));
899 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
900 __yy_memcpy ((char *)yyls, (char *)yyls1,
901 size * (unsigned int) sizeof (*yylsp));
903 #endif /* no yyoverflow */
905 yyssp = yyss + size - 1;
906 yyvsp = yyvs + size - 1;
908 yylsp = yyls + size - 1;
913 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
916 if (yyssp >= yyss + yystacksize - 1)
922 fprintf(stderr, "Entering state %d\n", yystate);
928 /* Do appropriate processing given the current state. */
929 /* Read a lookahead token if we need one and don't already have one. */
932 /* First try to decide what to do without reference to lookahead token. */
934 yyn = yypact[yystate];
938 /* Not known => get a lookahead token if don't already have one. */
940 /* yychar is either YYEMPTY or YYEOF
941 or a valid token in external form. */
943 if (yychar == YYEMPTY)
947 fprintf(stderr, "Reading a token: ");
952 /* Convert token to internal form (in yychar1) for indexing tables with */
954 if (yychar <= 0) /* This means end of input. */
957 yychar = YYEOF; /* Don't call YYLEX any more */
961 fprintf(stderr, "Now at end of input.\n");
966 yychar1 = YYTRANSLATE(yychar);
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. */
975 YYPRINT (stderr, yychar, yylval);
977 fprintf (stderr, ")\n");
983 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
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,
993 0, or most negative number => error. */
1008 /* Shift the lookahead token. */
1012 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
1015 /* Discard the token being shifted unless it is eof. */
1016 if (yychar != YYEOF)
1024 /* count tokens shifted since error; after three, turn off error status. */
1025 if (yyerrstatus) yyerrstatus--;
1030 /* Do the default action for the current state. */
1033 yyn = yydefact[yystate];
1037 /* Do a reduction. yyn is the number of a rule to reduce with. */
1041 yyval = yyvsp[1-yylen]; /* implement default value of the action */
1048 fprintf (stderr, "Reducing via rule %d (line %d), ",
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]]);
1062 #line 245 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1064 if (CurDefmPrefix) {
1065 // If CurDefmPrefix is set, we're parsing a defm, which means that this is
1066 // actually the name of a multiclass.
1067 MultiClass *MC = MultiClasses[*yyvsp[0].StrVal];
1069 err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n";
1072 yyval.Rec = &MC->Rec;
1074 yyval.Rec = Records.getClass(*yyvsp[0].StrVal);
1076 if (yyval.Rec == 0) {
1077 err() << "Couldn't find class '" << *yyvsp[0].StrVal << "'!\n";
1080 delete yyvsp[0].StrVal;
1084 #line 267 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1086 yyval.Ty = new StringRecTy();
1090 #line 269 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1092 yyval.Ty = new BitRecTy();
1096 #line 271 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1098 yyval.Ty = new BitsRecTy(yyvsp[-1].IntVal);
1102 #line 273 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1104 yyval.Ty = new IntRecTy();
1108 #line 275 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1110 yyval.Ty = new ListRecTy(yyvsp[-1].Ty);
1114 #line 277 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1116 yyval.Ty = new CodeRecTy();
1120 #line 279 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1122 yyval.Ty = new DagRecTy();
1126 #line 281 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1128 yyval.Ty = new RecordRecTy(yyvsp[0].Rec);
1132 #line 285 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1133 { yyval.IntVal = 0; ;
1136 #line 285 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1137 { yyval.IntVal = 1; ;
1140 #line 287 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1141 { yyval.Initializer = 0; ;
1144 #line 287 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1145 { yyval.Initializer = yyvsp[0].Initializer; ;
1148 #line 289 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1150 if (const RecordVal *RV = (CurRec ? CurRec->getValue(*yyvsp[0].StrVal) : 0)) {
1151 yyval.Initializer = new VarInit(*yyvsp[0].StrVal, RV->getType());
1152 } else if (CurRec && CurRec->isTemplateArg(CurRec->getName()+":"+*yyvsp[0].StrVal)) {
1153 const RecordVal *RV = CurRec->getValue(CurRec->getName()+":"+*yyvsp[0].StrVal);
1154 assert(RV && "Template arg doesn't exist??");
1155 yyval.Initializer = new VarInit(CurRec->getName()+":"+*yyvsp[0].StrVal, RV->getType());
1156 } else if (CurMultiClass &&
1157 CurMultiClass->Rec.isTemplateArg(CurMultiClass->Rec.getName()+"::"+*yyvsp[0].StrVal)) {
1158 std::string Name = CurMultiClass->Rec.getName()+"::"+*yyvsp[0].StrVal;
1159 const RecordVal *RV = CurMultiClass->Rec.getValue(Name);
1160 assert(RV && "Template arg doesn't exist??");
1161 yyval.Initializer = new VarInit(Name, RV->getType());
1162 } else if (Record *D = Records.getDef(*yyvsp[0].StrVal)) {
1163 yyval.Initializer = new DefInit(D);
1165 err() << "Variable not defined: '" << *yyvsp[0].StrVal << "'!\n";
1169 delete yyvsp[0].StrVal;
1173 #line 312 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1175 yyval.Initializer = yyvsp[0].Initializer;
1179 #line 314 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1181 yyval.Initializer = new IntInit(yyvsp[0].IntVal);
1185 #line 316 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1187 yyval.Initializer = new StringInit(*yyvsp[0].StrVal);
1188 delete yyvsp[0].StrVal;
1192 #line 319 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1194 yyval.Initializer = new CodeInit(*yyvsp[0].StrVal);
1195 delete yyvsp[0].StrVal;
1199 #line 322 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1201 yyval.Initializer = new UnsetInit();
1205 #line 324 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1207 BitsInit *Init = new BitsInit(yyvsp[-1].FieldList->size());
1208 for (unsigned i = 0, e = yyvsp[-1].FieldList->size(); i != e; ++i) {
1209 struct Init *Bit = (*yyvsp[-1].FieldList)[i]->convertInitializerTo(new BitRecTy());
1211 err() << "Element #" << i << " (" << *(*yyvsp[-1].FieldList)[i]
1212 << ") is not convertable to a bit!\n";
1215 Init->setBit(yyvsp[-1].FieldList->size()-i-1, Bit);
1217 yyval.Initializer = Init;
1218 delete yyvsp[-1].FieldList;
1222 #line 337 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1224 // This is a CLASS<initvalslist> expression. This is supposed to synthesize
1225 // a new anonymous definition, deriving from CLASS<initvalslist> with no
1227 Record *Class = Records.getClass(*yyvsp[-3].StrVal);
1229 err() << "Expected a class, got '" << *yyvsp[-3].StrVal << "'!\n";
1232 delete yyvsp[-3].StrVal;
1234 static unsigned AnonCounter = 0;
1235 Record *OldRec = CurRec; // Save CurRec.
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.
1242 CurRec->resolveReferences();
1244 Records.addDef(CurRec);
1246 // The result of the expression is a reference to the new record.
1247 yyval.Initializer = new DefInit(CurRec);
1249 // Restore the old CurRec
1254 #line 365 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1256 yyval.Initializer = yyvsp[-3].Initializer->convertInitializerBitRange(*yyvsp[-1].BitList);
1257 if (yyval.Initializer == 0) {
1258 err() << "Invalid bit range for value '" << *yyvsp[-3].Initializer << "'!\n";
1261 delete yyvsp[-1].BitList;
1265 #line 372 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1267 yyval.Initializer = new ListInit(*yyvsp[-1].FieldList);
1268 delete yyvsp[-1].FieldList;
1272 #line 375 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1274 if (!yyvsp[-2].Initializer->getFieldType(*yyvsp[0].StrVal)) {
1275 err() << "Cannot access field '" << *yyvsp[0].StrVal << "' of value '" << *yyvsp[-2].Initializer << "!\n";
1278 yyval.Initializer = new FieldInit(yyvsp[-2].Initializer, *yyvsp[0].StrVal);
1279 delete yyvsp[0].StrVal;
1283 #line 382 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1285 yyval.Initializer = new DagInit(yyvsp[-2].Initializer, *yyvsp[-1].DagValueList);
1286 delete yyvsp[-1].DagValueList;
1290 #line 385 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1292 std::reverse(yyvsp[-1].BitList->begin(), yyvsp[-1].BitList->end());
1293 yyval.Initializer = yyvsp[-3].Initializer->convertInitListSlice(*yyvsp[-1].BitList);
1294 if (yyval.Initializer == 0) {
1295 err() << "Invalid list slice for value '" << *yyvsp[-3].Initializer << "'!\n";
1298 delete yyvsp[-1].BitList;
1302 #line 393 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1304 yyval.Initializer = (new BinOpInit(BinOpInit::SHL, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1308 #line 395 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1310 yyval.Initializer = (new BinOpInit(BinOpInit::SRA, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1314 #line 397 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1316 yyval.Initializer = (new BinOpInit(BinOpInit::SRL, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1320 #line 399 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1322 yyval.Initializer = (new BinOpInit(BinOpInit::STRCONCAT, yyvsp[-3].Initializer, yyvsp[-1].Initializer))->Fold();
1326 #line 403 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1328 yyval.StrVal = new std::string();
1332 #line 406 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1334 yyval.StrVal = yyvsp[0].StrVal;
1338 #line 410 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1340 yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
1341 yyval.DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal));
1342 delete yyvsp[0].StrVal;
1346 #line 415 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1348 yyvsp[-3].DagValueList->push_back(std::make_pair(yyvsp[-1].Initializer, *yyvsp[0].StrVal));
1349 delete yyvsp[0].StrVal;
1350 yyval.DagValueList = yyvsp[-3].DagValueList;
1354 #line 421 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1356 yyval.DagValueList = new std::vector<std::pair<Init*, std::string> >();
1360 #line 424 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1361 { yyval.DagValueList = yyvsp[0].DagValueList; ;
1364 #line 427 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1366 yyval.BitList = new std::vector<unsigned>();
1367 yyval.BitList->push_back(yyvsp[0].IntVal);
1371 #line 430 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1373 if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1374 err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
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);
1382 for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1383 yyval.BitList->push_back(i);
1388 #line 443 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1390 yyvsp[0].IntVal = -yyvsp[0].IntVal;
1391 if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) {
1392 err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n";
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);
1400 for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1401 yyval.BitList->push_back(i);
1406 #line 457 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1408 (yyval.BitList=yyvsp[-2].BitList)->push_back(yyvsp[0].IntVal);
1412 #line 459 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1414 if (yyvsp[-2].IntVal < 0 || yyvsp[0].IntVal < 0) {
1415 err() << "Invalid range: " << yyvsp[-2].IntVal << "-" << yyvsp[0].IntVal << "!\n";
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);
1423 for (int i = yyvsp[-2].IntVal; i >= yyvsp[0].IntVal; --i)
1424 yyval.BitList->push_back(i);
1429 #line 472 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1431 yyvsp[0].IntVal = -yyvsp[0].IntVal;
1432 if (yyvsp[-1].IntVal < 0 || yyvsp[0].IntVal < 0) {
1433 err() << "Invalid range: " << yyvsp[-1].IntVal << "-" << yyvsp[0].IntVal << "!\n";
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);
1441 for (int i = yyvsp[-1].IntVal; i >= yyvsp[0].IntVal; --i)
1442 yyval.BitList->push_back(i);
1447 #line 488 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1448 { yyval.BitList = yyvsp[0].BitList; std::reverse(yyvsp[0].BitList->begin(), yyvsp[0].BitList->end()); ;
1451 #line 490 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1452 { yyval.BitList = 0; ;
1455 #line 490 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1456 { yyval.BitList = yyvsp[-1].BitList; ;
1459 #line 494 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1461 yyval.FieldList = new std::vector<Init*>();
1465 #line 496 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1467 yyval.FieldList = yyvsp[0].FieldList;
1471 #line 500 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1473 yyval.FieldList = new std::vector<Init*>();
1474 yyval.FieldList->push_back(yyvsp[0].Initializer);
1478 #line 503 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1480 (yyval.FieldList = yyvsp[-2].FieldList)->push_back(yyvsp[0].Initializer);
1484 #line 507 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1486 std::string DecName = *yyvsp[-1].StrVal;
1487 if (ParsingTemplateArgs) {
1489 DecName = CurRec->getName() + ":" + DecName;
1491 assert(CurMultiClass);
1494 DecName = CurMultiClass->Rec.getName() + "::" + DecName;
1497 addValue(RecordVal(DecName, yyvsp[-2].Ty, yyvsp[-3].IntVal));
1498 setValue(DecName, 0, yyvsp[0].Initializer);
1499 yyval.StrVal = new std::string(DecName);
1503 #line 524 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1505 delete yyvsp[-1].StrVal;
1509 #line 526 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1511 setValue(*yyvsp[-4].StrVal, yyvsp[-3].BitList, yyvsp[-1].Initializer);
1512 delete yyvsp[-4].StrVal;
1513 delete yyvsp[-3].BitList;
1517 #line 535 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1519 yyval.SubClassRef = new SubClassRefTy(yyvsp[0].Rec, new std::vector<Init*>());
1523 #line 537 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1525 yyval.SubClassRef = new SubClassRefTy(yyvsp[-3].Rec, yyvsp[-1].FieldList);
1529 #line 541 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1531 yyval.SubClassList = new std::vector<SubClassRefTy>();
1532 yyval.SubClassList->push_back(*yyvsp[0].SubClassRef);
1533 delete yyvsp[0].SubClassRef;
1537 #line 546 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1539 (yyval.SubClassList=yyvsp[-2].SubClassList)->push_back(*yyvsp[0].SubClassRef);
1540 delete yyvsp[0].SubClassRef;
1544 #line 551 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1546 yyval.SubClassList = new std::vector<SubClassRefTy>();
1550 #line 554 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1552 yyval.SubClassList = yyvsp[0].SubClassList;
1556 #line 558 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1558 getActiveRec()->addTemplateArg(*yyvsp[0].StrVal);
1559 delete yyvsp[0].StrVal;
1563 #line 561 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1565 getActiveRec()->addTemplateArg(*yyvsp[0].StrVal);
1566 delete yyvsp[0].StrVal;
1570 #line 566 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1574 #line 569 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1575 { yyval.StrVal = yyvsp[0].StrVal; ;
1578 #line 569 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1579 { yyval.StrVal = new std::string(); ;
1582 #line 571 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1584 static unsigned AnonCounter = 0;
1585 if (yyvsp[0].StrVal->empty())
1586 *yyvsp[0].StrVal = "anonymous."+utostr(AnonCounter++);
1587 yyval.StrVal = yyvsp[0].StrVal;
1591 #line 578 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1593 // If a class of this name already exists, it must be a forward ref.
1594 if ((CurRec = Records.getClass(*yyvsp[0].StrVal))) {
1595 // If the body was previously defined, this is an error.
1596 if (!CurRec->getValues().empty() ||
1597 !CurRec->getSuperClasses().empty() ||
1598 !CurRec->getTemplateArgs().empty()) {
1599 err() << "Class '" << CurRec->getName() << "' already defined!\n";
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);
1607 delete yyvsp[0].StrVal;
1611 #line 596 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1613 CurRec = new Record(*yyvsp[0].StrVal);
1614 delete yyvsp[0].StrVal;
1616 if (!CurMultiClass) {
1617 // Top-level def definition.
1619 // Ensure redefinition doesn't happen.
1620 if (Records.getDef(CurRec->getName())) {
1621 err() << "def '" << CurRec->getName() << "' already defined!\n";
1624 Records.addDef(CurRec);
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";
1633 CurMultiClass->DefPrototypes.push_back(CurRec);
1638 #line 621 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1640 for (unsigned i = 0, e = yyvsp[0].SubClassList->size(); i != e; ++i) {
1641 addSubClass((*yyvsp[0].SubClassList)[i].first, *(*yyvsp[0].SubClassList)[i].second);
1642 // Delete the template arg values for the class
1643 delete (*yyvsp[0].SubClassList)[i].second;
1645 delete yyvsp[0].SubClassList; // Delete the class list.
1647 // Process any variables on the let stack.
1648 for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
1649 for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
1650 setValue(LetStack[i][j].Name,
1651 LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0,
1652 LetStack[i][j].Value);
1656 #line 635 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1663 #line 640 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1665 ParsingTemplateArgs = true;
1669 #line 642 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1671 ParsingTemplateArgs = false;
1675 #line 644 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1677 yyval.Rec = yyvsp[0].Rec;
1681 #line 648 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1683 if (CurMultiClass == 0) // Def's in multiclasses aren't really defs.
1684 yyvsp[0].Rec->resolveReferences();
1686 // If ObjectBody has template arguments, it's an error.
1687 assert(yyvsp[0].Rec->getTemplateArgs().empty() && "How'd this get template args?");
1688 yyval.Rec = yyvsp[0].Rec;
1692 #line 658 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
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();
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);
1706 #line 672 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1708 yyval.RecList = new std::vector<Record*>();
1709 yyval.RecList->push_back(yyvsp[0].Rec);
1713 #line 675 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1715 yyval.RecList->push_back(yyvsp[0].Rec);
1719 #line 679 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1721 MultiClass *&MCE = MultiClasses[*yyvsp[0].StrVal];
1723 err() << "multiclass '" << *yyvsp[0].StrVal << "' already defined!\n";
1726 MCE = CurMultiClass = new MultiClass(*yyvsp[0].StrVal);
1727 delete yyvsp[0].StrVal;
1731 #line 690 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1733 ParsingTemplateArgs = true;
1737 #line 692 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1739 ParsingTemplateArgs = false;
1743 #line 694 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1749 #line 699 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1750 { CurDefmPrefix = yyvsp[0].StrVal; ;
1753 #line 699 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
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;
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";
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];
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());
1778 addSubClass(DefProto, std::vector<Init*>());
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?
1785 setValue(TArgs[i], 0, TemplateVals[i]);
1788 CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i]));
1791 CurRec->removeValue(TArgs[i]);
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";
1801 // If the mdef is inside a 'let' expression, add to each def.
1802 for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
1803 for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
1804 setValue(LetStack[i][j].Name,
1805 LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0,
1806 LetStack[i][j].Value);
1809 // Ensure redefinition doesn't happen.
1810 if (Records.getDef(CurRec->getName())) {
1811 err() << "def '" << CurRec->getName() << "' already defined, "
1812 << "instantiating defm '" << *yyvsp[-4].StrVal << "' with subdef '"
1813 << DefProto->getName() << "'!\n";
1816 Records.addDef(CurRec);
1818 CurRec->resolveReferences();
1823 delete &TemplateVals;
1824 delete yyvsp[-4].StrVal;
1829 #line 773 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1833 #line 773 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1837 #line 776 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1839 LetStack.back().push_back(LetRecord(*yyvsp[-3].StrVal, yyvsp[-2].BitList, yyvsp[0].Initializer));
1840 delete yyvsp[-3].StrVal; delete yyvsp[-2].BitList;
1844 #line 784 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1845 { LetStack.push_back(std::vector<LetRecord>()); ;
1848 #line 787 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1850 LetStack.pop_back();
1854 #line 790 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1856 LetStack.pop_back();
1860 #line 794 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1864 #line 794 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
1868 /* the action file gets copied in in place of this dollarsign */
1869 #line 543 "/usr/share/bison.simple"
1880 short *ssp1 = yyss - 1;
1881 fprintf (stderr, "state stack now");
1882 while (ssp1 != yyssp)
1883 fprintf (stderr, " %d", *++ssp1);
1884 fprintf (stderr, "\n");
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;
1902 yylsp->last_line = (yylsp+yylen-1)->last_line;
1903 yylsp->last_column = (yylsp+yylen-1)->last_column;
1907 /* Now "shift" the result of the reduction.
1908 Determine what state that goes to,
1909 based on the state we popped back to
1910 and the rule number reduced by. */
1914 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1915 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1916 yystate = yytable[yystate];
1918 yystate = yydefgoto[yyn - YYNTBASE];
1922 yyerrlab: /* here on detecting error */
1925 /* If not already recovering from an error, report this error. */
1929 #ifdef YYERROR_VERBOSE
1930 yyn = yypact[yystate];
1932 if (yyn > YYFLAG && yyn < YYLAST)
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);
1947 strcpy(msg, "parse error");
1952 for (x = (yyn < 0 ? -yyn : 0);
1953 x < (sizeof(yytname) / sizeof(char *)); x++)
1954 if (yycheck[x + yyn] == x)
1956 strcat(msg, count == 0 ? ", expecting `" : " or `");
1957 strcat(msg, yytname[x]);
1966 yyerror ("parse error; also virtual memory exceeded");
1969 #endif /* YYERROR_VERBOSE */
1970 yyerror("parse error");
1974 yyerrlab1: /* here on error raised explicitly by an action */
1976 if (yyerrstatus == 3)
1978 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1980 /* return failure if at end of input */
1981 if (yychar == YYEOF)
1986 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1992 /* Else will try to reuse lookahead token
1993 after shifting the error token. */
1995 yyerrstatus = 3; /* Each real token shifted decrements this */
1999 yyerrdefault: /* current state does not do anything special for the error token. */
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;
2008 yyerrpop: /* pop the current state because it cannot handle the error token */
2010 if (yyssp == yyss) YYABORT;
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");
2030 yyn = yypact[yystate];
2035 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
2054 fprintf(stderr, "Shifting error token, ");
2066 /* YYACCEPT comes here. */
2078 /* YYABORT comes here. */
2089 #line 798 "/Volumes/ProjectsDisk/cvs/llvm/utils/TableGen/FileParser.y"
2092 int yyerror(const char *ErrorMsg) {
2093 err() << "Error parsing: " << ErrorMsg << "\n";