blob: 6cfc3dde27a6a899be97c335f0e38a84914457f8 [file] [log] [blame]
Bill Wendlingf5da1332006-12-07 22:21:48 +00001/* A Bison parser, made by GNU Bison 2.3. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Bill Wendlingf5da1332006-12-07 22:21:48 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
Reid Spencer68a24bd2005-08-27 18:50:39 +00004
Bill Wendlingf5da1332006-12-07 22:21:48 +00005 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
Reid Spencer68a24bd2005-08-27 18:50:39 +00007
Bill Wendlingf5da1332006-12-07 22:21:48 +00008 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22
23/* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
32
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
35
36/* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
38
39/* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
45
46/* Identify Bison output. */
47#define YYBISON 1
48
49/* Bison version. */
50#define YYBISON_VERSION "2.3"
51
52/* Skeleton name. */
53#define YYSKELETON_NAME "yacc.c"
54
55/* Pure parsers. */
56#define YYPURE 0
57
58/* Using locations. */
59#define YYLSP_NEEDED 0
60
61/* Substitute the variable and function names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000062#define yyparse Fileparse
Bill Wendlingf5da1332006-12-07 22:21:48 +000063#define yylex Filelex
Reid Spencer68a24bd2005-08-27 18:50:39 +000064#define yyerror Fileerror
Bill Wendlingf5da1332006-12-07 22:21:48 +000065#define yylval Filelval
66#define yychar Filechar
Reid Spencer68a24bd2005-08-27 18:50:39 +000067#define yydebug Filedebug
68#define yynerrs Filenerrs
69
Bill Wendlingf5da1332006-12-07 22:21:48 +000070
71/* Tokens. */
72#ifndef YYTOKENTYPE
73# define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
77 INT = 258,
78 BIT = 259,
79 STRING = 260,
80 BITS = 261,
81 LIST = 262,
82 CODE = 263,
83 DAG = 264,
84 CLASS = 265,
85 DEF = 266,
86 MULTICLASS = 267,
87 DEFM = 268,
88 FIELD = 269,
89 LET = 270,
90 IN = 271,
91 SHLTOK = 272,
92 SRATOK = 273,
93 SRLTOK = 274,
94 STRCONCATTOK = 275,
95 INTVAL = 276,
96 ID = 277,
97 VARNAME = 278,
98 STRVAL = 279,
99 CODEFRAGMENT = 280
100 };
101#endif
102/* Tokens. */
103#define INT 258
104#define BIT 259
105#define STRING 260
106#define BITS 261
107#define LIST 262
108#define CODE 263
109#define DAG 264
110#define CLASS 265
111#define DEF 266
112#define MULTICLASS 267
113#define DEFM 268
114#define FIELD 269
115#define LET 270
116#define IN 271
117#define SHLTOK 272
118#define SRATOK 273
119#define SRLTOK 274
120#define STRCONCATTOK 275
121#define INTVAL 276
122#define ID 277
123#define VARNAME 278
124#define STRVAL 279
125#define CODEFRAGMENT 280
126
127
128
129
130/* Copy the first part of user declarations. */
131#line 14 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000132
133#include "Record.h"
134#include "llvm/ADT/StringExtras.h"
Bill Wendlingf5da1332006-12-07 22:21:48 +0000135#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000136#include <algorithm>
137#include <cstdio>
138#define YYERROR_VERBOSE 1
139
140int yyerror(const char *ErrorMsg);
141int yylex();
142
143namespace llvm {
Chris Lattner27627382006-09-01 21:14:42 +0000144 struct MultiClass {
145 Record Rec; // Placeholder for template args and Name.
146 std::vector<Record*> DefPrototypes;
147
148 MultiClass(const std::string &Name) : Rec(Name) {}
149 };
Reid Spencer68a24bd2005-08-27 18:50:39 +0000150
Chris Lattner27627382006-09-01 21:14:42 +0000151
152static std::map<std::string, MultiClass*> MultiClasses;
153
Reid Spencer68a24bd2005-08-27 18:50:39 +0000154extern int Filelineno;
Chris Lattner27627382006-09-01 21:14:42 +0000155static MultiClass *CurMultiClass = 0; // Set while parsing a multiclass.
156static std::string *CurDefmPrefix = 0; // Set while parsing defm.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000157static Record *CurRec = 0;
158static bool ParsingTemplateArgs = false;
159
160typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
161
162struct LetRecord {
163 std::string Name;
164 std::vector<unsigned> Bits;
165 Init *Value;
166 bool HasBits;
167 LetRecord(const std::string &N, std::vector<unsigned> *B, Init *V)
168 : Name(N), Value(V), HasBits(B != 0) {
169 if (HasBits) Bits = *B;
170 }
171};
172
173static std::vector<std::vector<LetRecord> > LetStack;
174
175
176extern std::ostream &err();
177
Chris Lattner27627382006-09-01 21:14:42 +0000178/// getActiveRec - If inside a def/class definition, return the def/class.
179/// Otherwise, if within a multidef, return it.
180static Record *getActiveRec() {
181 return CurRec ? CurRec : &CurMultiClass->Rec;
182}
183
Reid Spencer68a24bd2005-08-27 18:50:39 +0000184static void addValue(const RecordVal &RV) {
Chris Lattner27627382006-09-01 21:14:42 +0000185 Record *TheRec = getActiveRec();
186
187 if (RecordVal *ERV = TheRec->getValue(RV.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000188 // The value already exists in the class, treat this as a set...
189 if (ERV->setValue(RV.getValue())) {
190 err() << "New definition of '" << RV.getName() << "' of type '"
191 << *RV.getType() << "' is incompatible with previous "
192 << "definition of type '" << *ERV->getType() << "'!\n";
193 exit(1);
194 }
195 } else {
Chris Lattner27627382006-09-01 21:14:42 +0000196 TheRec->addValue(RV);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000197 }
198}
199
200static void addSuperClass(Record *SC) {
201 if (CurRec->isSubClassOf(SC)) {
202 err() << "Already subclass of '" << SC->getName() << "'!\n";
203 exit(1);
204 }
205 CurRec->addSuperClass(SC);
206}
207
208static void setValue(const std::string &ValName,
Chris Lattner81779692006-03-30 22:51:12 +0000209 std::vector<unsigned> *BitList, Init *V) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000210 if (!V) return;
211
Chris Lattnerdc52f172006-10-07 07:15:19 +0000212 Record *TheRec = getActiveRec();
213 RecordVal *RV = TheRec->getValue(ValName);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000214 if (RV == 0) {
215 err() << "Value '" << ValName << "' unknown!\n";
216 exit(1);
217 }
218
219 // Do not allow assignments like 'X = X'. This will just cause infinite loops
220 // in the resolution machinery.
221 if (!BitList)
222 if (VarInit *VI = dynamic_cast<VarInit*>(V))
223 if (VI->getName() == ValName)
224 return;
225
226 // If we are assigning to a subset of the bits in the value... then we must be
227 // assigning to a field of BitsRecTy, which must have a BitsInit
228 // initializer...
229 //
230 if (BitList) {
231 BitsInit *CurVal = dynamic_cast<BitsInit*>(RV->getValue());
232 if (CurVal == 0) {
233 err() << "Value '" << ValName << "' is not a bits type!\n";
234 exit(1);
235 }
236
237 // Convert the incoming value to a bits type of the appropriate size...
238 Init *BI = V->convertInitializerTo(new BitsRecTy(BitList->size()));
239 if (BI == 0) {
240 V->convertInitializerTo(new BitsRecTy(BitList->size()));
241 err() << "Initializer '" << *V << "' not compatible with bit range!\n";
242 exit(1);
243 }
244
245 // We should have a BitsInit type now...
Bill Wendlingf5da1332006-12-07 22:21:48 +0000246 assert(dynamic_cast<BitsInit*>(BI) != 0 || (cerr << *BI).stream() == 0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000247 BitsInit *BInit = (BitsInit*)BI;
248
249 BitsInit *NewVal = new BitsInit(CurVal->getNumBits());
250
251 // Loop over bits, assigning values as appropriate...
252 for (unsigned i = 0, e = BitList->size(); i != e; ++i) {
253 unsigned Bit = (*BitList)[i];
254 if (NewVal->getBit(Bit)) {
255 err() << "Cannot set bit #" << Bit << " of value '" << ValName
256 << "' more than once!\n";
257 exit(1);
258 }
259 NewVal->setBit(Bit, BInit->getBit(i));
260 }
261
262 for (unsigned i = 0, e = CurVal->getNumBits(); i != e; ++i)
263 if (NewVal->getBit(i) == 0)
264 NewVal->setBit(i, CurVal->getBit(i));
265
266 V = NewVal;
267 }
268
269 if (RV->setValue(V)) {
270 err() << "Value '" << ValName << "' of type '" << *RV->getType()
271 << "' is incompatible with initializer '" << *V << "'!\n";
272 exit(1);
273 }
274}
275
276// addSubClass - Add SC as a subclass to CurRec, resolving TemplateArgs as SC's
277// template arguments.
278static void addSubClass(Record *SC, const std::vector<Init*> &TemplateArgs) {
279 // Add all of the values in the subclass into the current class...
280 const std::vector<RecordVal> &Vals = SC->getValues();
281 for (unsigned i = 0, e = Vals.size(); i != e; ++i)
282 addValue(Vals[i]);
283
284 const std::vector<std::string> &TArgs = SC->getTemplateArgs();
285
286 // Ensure that an appropriate number of template arguments are specified...
287 if (TArgs.size() < TemplateArgs.size()) {
288 err() << "ERROR: More template args specified than expected!\n";
289 exit(1);
Chris Lattner27627382006-09-01 21:14:42 +0000290 }
291
292 // Loop over all of the template arguments, setting them to the specified
293 // value or leaving them as the default if necessary.
294 for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
295 if (i < TemplateArgs.size()) { // A value is specified for this temp-arg?
296 // Set it now.
297 setValue(TArgs[i], 0, TemplateArgs[i]);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000298
Chris Lattner27627382006-09-01 21:14:42 +0000299 // Resolve it next.
300 CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i]));
301
302
303 // Now remove it.
304 CurRec->removeValue(TArgs[i]);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000305
Chris Lattner27627382006-09-01 21:14:42 +0000306 } else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) {
307 err() << "ERROR: Value not specified for template argument #"
308 << i << " (" << TArgs[i] << ") of subclass '" << SC->getName()
309 << "'!\n";
310 exit(1);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000311 }
312 }
313
314 // Since everything went well, we can now set the "superclass" list for the
315 // current record.
Chris Lattner27627382006-09-01 21:14:42 +0000316 const std::vector<Record*> &SCs = SC->getSuperClasses();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000317 for (unsigned i = 0, e = SCs.size(); i != e; ++i)
318 addSuperClass(SCs[i]);
319 addSuperClass(SC);
320}
321
322} // End llvm namespace
323
324using namespace llvm;
325
326
Bill Wendlingf5da1332006-12-07 22:21:48 +0000327
328/* Enabling traces. */
329#ifndef YYDEBUG
330# define YYDEBUG 0
331#endif
332
333/* Enabling verbose error messages. */
334#ifdef YYERROR_VERBOSE
335# undef YYERROR_VERBOSE
336# define YYERROR_VERBOSE 1
337#else
338# define YYERROR_VERBOSE 0
339#endif
340
341/* Enabling the token table. */
342#ifndef YYTOKEN_TABLE
343# define YYTOKEN_TABLE 0
344#endif
345
346#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
347typedef union YYSTYPE
348#line 210 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
349{
Reid Spencer68a24bd2005-08-27 18:50:39 +0000350 std::string* StrVal;
351 int IntVal;
352 llvm::RecTy* Ty;
353 llvm::Init* Initializer;
354 std::vector<llvm::Init*>* FieldList;
355 std::vector<unsigned>* BitList;
356 llvm::Record* Rec;
Chris Lattner27627382006-09-01 21:14:42 +0000357 std::vector<llvm::Record*>* RecList;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000358 SubClassRefTy* SubClassRef;
359 std::vector<SubClassRefTy>* SubClassList;
360 std::vector<std::pair<llvm::Init*, std::string> >* DagValueList;
Bill Wendlingf5da1332006-12-07 22:21:48 +0000361}
362/* Line 193 of yacc.c. */
363#line 364 "FileParser.tab.c"
364 YYSTYPE;
365# define yystype YYSTYPE /* obsolescent; will be withdrawn */
366# define YYSTYPE_IS_DECLARED 1
367# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +0000368#endif
369
370
371
Bill Wendlingf5da1332006-12-07 22:21:48 +0000372/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +0000373
374
Bill Wendlingf5da1332006-12-07 22:21:48 +0000375/* Line 216 of yacc.c. */
376#line 377 "FileParser.tab.c"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000377
Bill Wendlingf5da1332006-12-07 22:21:48 +0000378#ifdef short
379# undef short
Reid Spencer68a24bd2005-08-27 18:50:39 +0000380#endif
381
Bill Wendlingf5da1332006-12-07 22:21:48 +0000382#ifdef YYTYPE_UINT8
383typedef YYTYPE_UINT8 yytype_uint8;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000384#else
Bill Wendlingf5da1332006-12-07 22:21:48 +0000385typedef unsigned char yytype_uint8;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000386#endif
387
Bill Wendlingf5da1332006-12-07 22:21:48 +0000388#ifdef YYTYPE_INT8
389typedef YYTYPE_INT8 yytype_int8;
390#elif (defined __STDC__ || defined __C99__FUNC__ \
391 || defined __cplusplus || defined _MSC_VER)
392typedef signed char yytype_int8;
393#else
394typedef short int yytype_int8;
395#endif
396
397#ifdef YYTYPE_UINT16
398typedef YYTYPE_UINT16 yytype_uint16;
399#else
400typedef unsigned short int yytype_uint16;
401#endif
402
403#ifdef YYTYPE_INT16
404typedef YYTYPE_INT16 yytype_int16;
405#else
406typedef short int yytype_int16;
407#endif
408
409#ifndef YYSIZE_T
410# ifdef __SIZE_TYPE__
411# define YYSIZE_T __SIZE_TYPE__
412# elif defined size_t
413# define YYSIZE_T size_t
414# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
415 || defined __cplusplus || defined _MSC_VER)
416# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
417# define YYSIZE_T size_t
418# else
419# define YYSIZE_T unsigned int
420# endif
421#endif
422
423#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
424
425#ifndef YY_
426# if YYENABLE_NLS
427# if ENABLE_NLS
428# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
429# define YY_(msgid) dgettext ("bison-runtime", msgid)
430# endif
431# endif
432# ifndef YY_
433# define YY_(msgid) msgid
434# endif
435#endif
436
437/* Suppress unused-variable warnings by "using" E. */
438#if ! defined lint || defined __GNUC__
439# define YYUSE(e) ((void) (e))
440#else
441# define YYUSE(e) /* empty */
442#endif
443
444/* Identity function, used to suppress warnings about constant conditions. */
445#ifndef lint
446# define YYID(n) (n)
447#else
448#if (defined __STDC__ || defined __C99__FUNC__ \
449 || defined __cplusplus || defined _MSC_VER)
450static int
451YYID (int i)
452#else
453static int
454YYID (i)
455 int i;
456#endif
457{
458 return i;
459}
460#endif
461
462#if ! defined yyoverflow || YYERROR_VERBOSE
463
464/* The parser invokes alloca or malloc; define the necessary symbols. */
465
466# ifdef YYSTACK_USE_ALLOCA
467# if YYSTACK_USE_ALLOCA
468# ifdef __GNUC__
469# define YYSTACK_ALLOC __builtin_alloca
470# elif defined __BUILTIN_VA_ARG_INCR
471# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
472# elif defined _AIX
473# define YYSTACK_ALLOC __alloca
474# elif defined _MSC_VER
475# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
476# define alloca _alloca
477# else
478# define YYSTACK_ALLOC alloca
479# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
480 || defined __cplusplus || defined _MSC_VER)
481# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
482# ifndef _STDLIB_H
483# define _STDLIB_H 1
484# endif
485# endif
486# endif
487# endif
488# endif
489
490# ifdef YYSTACK_ALLOC
491 /* Pacify GCC's `empty if-body' warning. */
492# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
493# ifndef YYSTACK_ALLOC_MAXIMUM
494 /* The OS might guarantee only one guard page at the bottom of the stack,
495 and a page size can be as small as 4096 bytes. So we cannot safely
496 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
497 to allow for a few compiler-allocated temporary stack slots. */
498# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
499# endif
500# else
501# define YYSTACK_ALLOC YYMALLOC
502# define YYSTACK_FREE YYFREE
503# ifndef YYSTACK_ALLOC_MAXIMUM
504# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
505# endif
506# if (defined __cplusplus && ! defined _STDLIB_H \
507 && ! ((defined YYMALLOC || defined malloc) \
508 && (defined YYFREE || defined free)))
509# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
510# ifndef _STDLIB_H
511# define _STDLIB_H 1
512# endif
513# endif
514# ifndef YYMALLOC
515# define YYMALLOC malloc
516# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
517 || defined __cplusplus || defined _MSC_VER)
518void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
519# endif
520# endif
521# ifndef YYFREE
522# define YYFREE free
523# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
524 || defined __cplusplus || defined _MSC_VER)
525void free (void *); /* INFRINGES ON USER NAME SPACE */
526# endif
527# endif
528# endif
529#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
530
531
532#if (! defined yyoverflow \
533 && (! defined __cplusplus \
534 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
535
536/* A type that is properly aligned for any stack member. */
537union yyalloc
538{
539 yytype_int16 yyss;
540 YYSTYPE yyvs;
541 };
542
543/* The size of the maximum gap between one aligned stack and the next. */
544# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
545
546/* The size of an array large to enough to hold all stacks, each with
547 N elements. */
548# define YYSTACK_BYTES(N) \
549 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
550 + YYSTACK_GAP_MAXIMUM)
551
552/* Copy COUNT objects from FROM to TO. The source and destination do
553 not overlap. */
554# ifndef YYCOPY
555# if defined __GNUC__ && 1 < __GNUC__
556# define YYCOPY(To, From, Count) \
557 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
558# else
559# define YYCOPY(To, From, Count) \
560 do \
561 { \
562 YYSIZE_T yyi; \
563 for (yyi = 0; yyi < (Count); yyi++) \
564 (To)[yyi] = (From)[yyi]; \
565 } \
566 while (YYID (0))
567# endif
568# endif
569
570/* Relocate STACK from its old location to the new one. The
571 local variables YYSIZE and YYSTACKSIZE give the old and new number of
572 elements in the stack, and YYPTR gives the new location of the
573 stack. Advance YYPTR to a properly aligned location for the next
574 stack. */
575# define YYSTACK_RELOCATE(Stack) \
576 do \
577 { \
578 YYSIZE_T yynewbytes; \
579 YYCOPY (&yyptr->Stack, Stack, yysize); \
580 Stack = &yyptr->Stack; \
581 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
582 yyptr += yynewbytes / sizeof (*yyptr); \
583 } \
584 while (YYID (0))
585
586#endif
587
588/* YYFINAL -- State number of the termination state. */
589#define YYFINAL 27
590/* YYLAST -- Last index in YYTABLE. */
591#define YYLAST 204
592
593/* YYNTOKENS -- Number of terminals. */
594#define YYNTOKENS 41
595/* YYNNTS -- Number of nonterminals. */
596#define YYNNTS 50
597/* YYNRULES -- Number of rules. */
598#define YYNRULES 102
599/* YYNRULES -- Number of states. */
600#define YYNSTATES 188
601
602/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
603#define YYUNDEFTOK 2
604#define YYMAXUTOK 280
605
606#define YYTRANSLATE(YYX) \
607 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
608
609/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
610static const yytype_uint8 yytranslate[] =
611{
612 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
613 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
614 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
615 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
616 35, 36, 2, 2, 37, 39, 34, 2, 2, 2,
617 2, 2, 2, 2, 2, 2, 2, 2, 38, 40,
618 26, 28, 27, 29, 2, 2, 2, 2, 2, 2,
619 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
620 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
621 2, 32, 2, 33, 2, 2, 2, 2, 2, 2,
622 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
623 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
624 2, 2, 2, 30, 2, 31, 2, 2, 2, 2,
625 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
626 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
627 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
628 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
629 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
630 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
631 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
632 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
633 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
634 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
635 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
636 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
637 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
638 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
639 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
640 25
641};
642
643#if YYDEBUG
644/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
645 YYRHS. */
646static const yytype_uint16 yyprhs[] =
647{
648 0, 0, 3, 5, 7, 9, 14, 16, 21, 23,
649 25, 27, 28, 30, 31, 34, 36, 38, 40, 42,
650 44, 46, 50, 55, 60, 64, 68, 73, 78, 85,
651 92, 99, 106, 107, 110, 113, 118, 119, 121, 123,
652 127, 130, 134, 140, 145, 147, 148, 152, 153, 155,
653 157, 161, 166, 169, 176, 177, 180, 182, 186, 188,
654 193, 195, 199, 200, 203, 205, 209, 213, 214, 216,
655 218, 219, 221, 223, 225, 226, 230, 231, 232, 239,
656 243, 245, 247, 250, 252, 253, 254, 263, 264, 271,
657 273, 275, 277, 279, 284, 286, 290, 291, 296, 301,
658 304, 306, 309
659};
660
661/* YYRHS -- A `-1'-separated list of the rules' RHS. */
662static const yytype_int8 yyrhs[] =
663{
664 90, 0, -1, 22, -1, 5, -1, 4, -1, 6,
665 26, 21, 27, -1, 3, -1, 7, 26, 43, 27,
666 -1, 8, -1, 9, -1, 42, -1, -1, 14, -1,
667 -1, 28, 47, -1, 22, -1, 46, -1, 21, -1,
668 24, -1, 25, -1, 29, -1, 30, 54, 31, -1,
669 22, 26, 55, 27, -1, 47, 30, 52, 31, -1,
670 32, 54, 33, -1, 47, 34, 22, -1, 35, 46,
671 50, 36, -1, 47, 32, 52, 33, -1, 17, 35,
672 47, 37, 47, 36, -1, 18, 35, 47, 37, 47,
673 36, -1, 19, 35, 47, 37, 47, 36, -1, 20,
674 35, 47, 37, 47, 36, -1, -1, 38, 23, -1,
675 47, 48, -1, 49, 37, 47, 48, -1, -1, 49,
676 -1, 21, -1, 21, 39, 21, -1, 21, 21, -1,
677 51, 37, 21, -1, 51, 37, 21, 39, 21, -1,
678 51, 37, 21, 21, -1, 51, -1, -1, 30, 52,
679 31, -1, -1, 55, -1, 47, -1, 55, 37, 47,
680 -1, 44, 43, 22, 45, -1, 56, 40, -1, 15,
681 22, 53, 28, 47, 40, -1, -1, 58, 57, -1,
682 40, -1, 30, 58, 31, -1, 42, -1, 42, 26,
683 55, 27, -1, 60, -1, 61, 37, 60, -1, -1,
684 38, 61, -1, 56, -1, 63, 37, 56, -1, 26,
685 63, 27, -1, -1, 64, -1, 22, -1, -1, 66,
686 -1, 67, -1, 67, -1, -1, 62, 71, 59, -1,
687 -1, -1, 10, 68, 73, 65, 74, 70, -1, 11,
688 69, 70, -1, 75, -1, 76, -1, 77, 76, -1,
689 22, -1, -1, -1, 12, 78, 80, 65, 81, 30,
690 77, 31, -1, -1, 13, 22, 83, 38, 60, 40,
691 -1, 72, -1, 75, -1, 79, -1, 82, -1, 22,
692 53, 28, 47, -1, 85, -1, 86, 37, 85, -1,
693 -1, 15, 88, 86, 16, -1, 87, 30, 89, 31,
694 -1, 87, 84, -1, 84, -1, 89, 84, -1, 89,
695 -1
696};
697
698/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
699static const yytype_uint16 yyrline[] =
700{
701 0, 246, 246, 268, 270, 272, 274, 276, 278, 280,
702 282, 286, 286, 288, 288, 290, 313, 315, 317, 320,
703 323, 325, 338, 366, 373, 376, 383, 386, 394, 396,
704 398, 400, 404, 407, 411, 416, 422, 425, 428, 431,
705 444, 458, 460, 473, 489, 491, 491, 495, 497, 501,
706 504, 508, 525, 527, 533, 533, 534, 534, 536, 538,
707 542, 547, 552, 555, 559, 562, 567, 568, 568, 570,
708 570, 572, 579, 597, 622, 622, 641, 643, 641, 649,
709 659, 673, 676, 680, 691, 693, 691, 700, 700, 774,
710 774, 775, 775, 777, 782, 782, 785, 785, 788, 791,
711 795, 795, 797
712};
713#endif
714
715#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
716/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
717 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
718static const char *const yytname[] =
719{
720 "$end", "error", "$undefined", "INT", "BIT", "STRING", "BITS", "LIST",
721 "CODE", "DAG", "CLASS", "DEF", "MULTICLASS", "DEFM", "FIELD", "LET",
722 "IN", "SHLTOK", "SRATOK", "SRLTOK", "STRCONCATTOK", "INTVAL", "ID",
723 "VARNAME", "STRVAL", "CODEFRAGMENT", "'<'", "'>'", "'='", "'?'", "'{'",
724 "'}'", "'['", "']'", "'.'", "'('", "')'", "','", "':'", "'-'", "';'",
725 "$accept", "ClassID", "Type", "OptPrefix", "OptValue", "IDValue",
726 "Value", "OptVarName", "DagArgListNE", "DagArgList", "RBitList",
727 "BitList", "OptBitList", "ValueList", "ValueListNE", "Declaration",
728 "BodyItem", "BodyList", "Body", "SubClassRef", "ClassListNE",
729 "ClassList", "DeclListNE", "TemplateArgList", "OptTemplateArgList",
730 "OptID", "ObjectName", "ClassName", "DefName", "ObjectBody", "@1",
731 "ClassInst", "@2", "@3", "DefInst", "MultiClassDef", "MultiClassBody",
732 "MultiClassName", "MultiClassInst", "@4", "@5", "DefMInst", "@6",
733 "Object", "LETItem", "LETList", "LETCommand", "@7", "ObjectList", "File", 0
734};
735#endif
736
737# ifdef YYPRINT
738/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
739 token YYLEX-NUM. */
740static const yytype_uint16 yytoknum[] =
741{
742 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
743 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
744 275, 276, 277, 278, 279, 280, 60, 62, 61, 63,
745 123, 125, 91, 93, 46, 40, 41, 44, 58, 45,
746 59
747};
748# endif
749
750/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
751static const yytype_uint8 yyr1[] =
752{
753 0, 41, 42, 43, 43, 43, 43, 43, 43, 43,
754 43, 44, 44, 45, 45, 46, 47, 47, 47, 47,
755 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
756 47, 47, 48, 48, 49, 49, 50, 50, 51, 51,
757 51, 51, 51, 51, 52, 53, 53, 54, 54, 55,
758 55, 56, 57, 57, 58, 58, 59, 59, 60, 60,
759 61, 61, 62, 62, 63, 63, 64, 65, 65, 66,
760 66, 67, 68, 69, 71, 70, 73, 74, 72, 75,
761 76, 77, 77, 78, 80, 81, 79, 83, 82, 84,
762 84, 84, 84, 85, 86, 86, 88, 87, 84, 84,
763 89, 89, 90
764};
765
766/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
767static const yytype_uint8 yyr2[] =
768{
769 0, 2, 1, 1, 1, 4, 1, 4, 1, 1,
770 1, 0, 1, 0, 2, 1, 1, 1, 1, 1,
771 1, 3, 4, 4, 3, 3, 4, 4, 6, 6,
772 6, 6, 0, 2, 2, 4, 0, 1, 1, 3,
773 2, 3, 5, 4, 1, 0, 3, 0, 1, 1,
774 3, 4, 2, 6, 0, 2, 1, 3, 1, 4,
775 1, 3, 0, 2, 1, 3, 3, 0, 1, 1,
776 0, 1, 1, 1, 0, 3, 0, 0, 6, 3,
777 1, 1, 2, 1, 0, 0, 8, 0, 6, 1,
778 1, 1, 1, 4, 1, 3, 0, 4, 4, 2,
779 1, 2, 1
780};
781
782/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
783 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
784 means the default is an error. */
785static const yytype_uint8 yydefact[] =
786{
787 0, 70, 70, 0, 0, 96, 89, 90, 91, 92,
788 100, 0, 102, 0, 69, 71, 72, 76, 73, 62,
789 83, 84, 87, 0, 0, 99, 101, 1, 67, 0,
790 74, 79, 67, 0, 45, 94, 0, 0, 11, 68,
791 77, 2, 58, 60, 63, 0, 85, 0, 0, 0,
792 97, 0, 98, 12, 0, 64, 0, 62, 0, 0,
793 54, 56, 75, 0, 0, 38, 44, 0, 0, 95,
794 6, 4, 3, 0, 0, 8, 9, 10, 0, 66,
795 11, 78, 0, 0, 0, 0, 17, 15, 18, 19,
796 20, 47, 47, 0, 16, 49, 0, 61, 11, 0,
797 88, 40, 0, 0, 46, 93, 0, 0, 13, 65,
798 0, 0, 0, 0, 0, 0, 48, 0, 15, 36,
799 0, 0, 0, 59, 0, 0, 57, 0, 55, 80,
800 81, 0, 39, 41, 0, 0, 0, 51, 0, 0,
801 0, 0, 0, 21, 24, 32, 37, 0, 0, 0,
802 25, 50, 45, 52, 86, 82, 43, 0, 5, 7,
803 14, 0, 0, 0, 0, 22, 0, 34, 0, 26,
804 23, 27, 0, 42, 0, 0, 0, 0, 33, 32,
805 0, 28, 29, 30, 31, 35, 0, 53
806};
807
808/* YYDEFGOTO[NTERM-NUM]. */
809static const yytype_int16 yydefgoto[] =
810{
811 -1, 42, 78, 54, 137, 94, 95, 167, 146, 147,
812 66, 67, 49, 115, 116, 55, 128, 98, 62, 43,
813 44, 30, 56, 39, 40, 15, 16, 17, 19, 31,
814 45, 6, 28, 57, 7, 130, 131, 21, 8, 32,
815 63, 9, 33, 10, 35, 36, 11, 23, 12, 13
816};
817
818/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
819 STATE-NUM. */
820#define YYPACT_NINF -97
821static const yytype_int16 yypact[] =
822{
823 129, 3, 3, 11, 19, -97, -97, -97, -97, -97,
824 -97, 2, 129, 48, -97, -97, -97, -97, -97, 29,
825 -97, -97, -97, 31, 129, -97, -97, -97, 43, 56,
826 -97, -97, 43, 42, 53, -97, -6, -4, 71, -97,
827 -97, -97, 72, -97, 65, 9, -97, 56, 87, 78,
828 -97, 31, -97, -97, 15, -97, 13, 29, 41, 56,
829 -97, -97, -97, 84, 80, 7, 81, 106, 41, -97,
830 -97, -97, -97, 120, 122, -97, -97, -97, 127, -97,
831 71, -97, 115, 116, 117, 118, -97, 128, -97, -97,
832 -97, 41, 41, 133, -97, 113, 27, -97, 60, 145,
833 -97, -97, 136, 137, -97, 113, 138, 15, 132, -97,
834 41, 41, 41, 41, 41, 130, 125, 131, -97, 41,
835 87, 87, 141, -97, 41, 143, -97, 126, -97, -97,
836 -97, 5, -97, 8, 140, 142, 41, -97, 67, 73,
837 79, 85, 45, -97, -97, 54, 134, 139, 146, 135,
838 -97, 113, 53, -97, -97, -97, -97, 149, -97, -97,
839 113, 41, 41, 41, 41, -97, 150, -97, 41, -97,
840 -97, -97, 144, -97, 91, 94, 99, 102, -97, 54,
841 41, -97, -97, -97, -97, -97, 47, -97
842};
843
844/* YYPGOTO[NTERM-NUM]. */
845static const yytype_int16 yypgoto[] =
846{
847 -97, -52, 69, -97, -97, 86, -68, -5, -97, -97,
848 -97, -31, 26, 88, -57, -46, -97, -97, -97, -21,
849 -97, -97, -97, -97, 151, -97, 179, -97, -97, 147,
850 -97, -97, -97, -97, -96, 51, -97, -97, -97, -97,
851 -97, -97, -97, -7, 148, -97, -97, -97, 160, -97
852};
853
854/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
855 positive, shift that token. If negative, reduce the rule which
856 number is the opposite. If zero, do what YYDEFACT says.
857 If YYTABLE_NINF, syntax error. */
858#define YYTABLE_NINF -1
859static const yytype_uint8 yytable[] =
860{
861 105, 96, 77, 129, 25, 26, 1, 2, 3, 4,
862 50, 5, 1, 2, 3, 4, 2, 5, 70, 71,
863 72, 73, 74, 75, 76, 14, 64, 52, 101, 156,
864 26, 51, 24, 20, 109, 129, 154, 41, 97, 60,
865 79, 22, 138, 139, 140, 141, 102, 157, 27, 61,
866 80, 145, 127, 34, 123, 77, 151, 142, 82, 83,
867 84, 85, 86, 87, 124, 88, 89, 29, 160, 38,
868 90, 91, 165, 92, 53, 125, 93, 120, 41, 121,
869 47, 122, 124, 48, 120, 53, 121, 187, 122, 148,
870 149, 126, 166, 174, 175, 176, 177, 120, 58, 121,
871 179, 122, 59, 120, 161, 121, 68, 122, 65, 120,
872 162, 121, 186, 122, 99, 120, 163, 121, 103, 122,
873 100, 120, 164, 121, 120, 122, 121, 181, 122, 120,
874 182, 121, 120, 122, 121, 183, 122, 104, 184, 1,
875 2, 3, 4, 120, 5, 121, 106, 122, 107, 108,
876 110, 111, 112, 113, 114, 118, 2, 132, 133, 134,
877 136, 143, 124, 150, 144, 152, 153, 158, 171, 159,
878 173, 168, 180, 178, 185, 169, 135, 170, 172, 119,
879 117, 18, 155, 46, 37, 0, 0, 0, 0, 0,
880 0, 0, 0, 0, 0, 0, 0, 0, 0, 69,
881 0, 0, 0, 0, 81
882};
883
884static const yytype_int16 yycheck[] =
885{
886 68, 58, 54, 99, 11, 12, 10, 11, 12, 13,
887 16, 15, 10, 11, 12, 13, 11, 15, 3, 4,
888 5, 6, 7, 8, 9, 22, 47, 31, 21, 21,
889 37, 37, 30, 22, 80, 131, 31, 22, 59, 30,
890 27, 22, 110, 111, 112, 113, 39, 39, 0, 40,
891 37, 119, 98, 22, 27, 107, 124, 114, 17, 18,
892 19, 20, 21, 22, 37, 24, 25, 38, 136, 26,
893 29, 30, 27, 32, 14, 15, 35, 30, 22, 32,
894 38, 34, 37, 30, 30, 14, 32, 40, 34, 120,
895 121, 31, 38, 161, 162, 163, 164, 30, 26, 32,
896 168, 34, 37, 30, 37, 32, 28, 34, 21, 30,
897 37, 32, 180, 34, 30, 30, 37, 32, 37, 34,
898 40, 30, 37, 32, 30, 34, 32, 36, 34, 30,
899 36, 32, 30, 34, 32, 36, 34, 31, 36, 10,
900 11, 12, 13, 30, 15, 32, 26, 34, 26, 22,
901 35, 35, 35, 35, 26, 22, 11, 21, 21, 21,
902 28, 31, 37, 22, 33, 22, 40, 27, 33, 27,
903 21, 37, 28, 23, 179, 36, 107, 31, 152, 93,
904 92, 2, 131, 32, 24, -1, -1, -1, -1, -1,
905 -1, -1, -1, -1, -1, -1, -1, -1, -1, 51,
906 -1, -1, -1, -1, 57
907};
908
909/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
910 symbol of state STATE-NUM. */
911static const yytype_uint8 yystos[] =
912{
913 0, 10, 11, 12, 13, 15, 72, 75, 79, 82,
914 84, 87, 89, 90, 22, 66, 67, 68, 67, 69,
915 22, 78, 22, 88, 30, 84, 84, 0, 73, 38,
916 62, 70, 80, 83, 22, 85, 86, 89, 26, 64,
917 65, 22, 42, 60, 61, 71, 65, 38, 30, 53,
918 16, 37, 31, 14, 44, 56, 63, 74, 26, 37,
919 30, 40, 59, 81, 60, 21, 51, 52, 28, 85,
920 3, 4, 5, 6, 7, 8, 9, 42, 43, 27,
921 37, 70, 17, 18, 19, 20, 21, 22, 24, 25,
922 29, 30, 32, 35, 46, 47, 55, 60, 58, 30,
923 40, 21, 39, 37, 31, 47, 26, 26, 22, 56,
924 35, 35, 35, 35, 26, 54, 55, 54, 22, 46,
925 30, 32, 34, 27, 37, 15, 31, 56, 57, 75,
926 76, 77, 21, 21, 21, 43, 28, 45, 47, 47,
927 47, 47, 55, 31, 33, 47, 49, 50, 52, 52,
928 22, 47, 22, 40, 31, 76, 21, 39, 27, 27,
929 47, 37, 37, 37, 37, 27, 38, 48, 37, 36,
930 31, 33, 53, 21, 47, 47, 47, 47, 23, 47,
931 28, 36, 36, 36, 36, 48, 47, 40
932};
Reid Spencer68a24bd2005-08-27 18:50:39 +0000933
934#define yyerrok (yyerrstatus = 0)
935#define yyclearin (yychar = YYEMPTY)
Bill Wendlingf5da1332006-12-07 22:21:48 +0000936#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000937#define YYEOF 0
Bill Wendlingf5da1332006-12-07 22:21:48 +0000938
Reid Spencer68a24bd2005-08-27 18:50:39 +0000939#define YYACCEPT goto yyacceptlab
Bill Wendlingf5da1332006-12-07 22:21:48 +0000940#define YYABORT goto yyabortlab
941#define YYERROR goto yyerrorlab
942
943
944/* Like YYERROR except do call yyerror. This remains here temporarily
945 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000946 Once GCC version 2 has supplanted version 1, this can go. */
Bill Wendlingf5da1332006-12-07 22:21:48 +0000947
Reid Spencer68a24bd2005-08-27 18:50:39 +0000948#define YYFAIL goto yyerrlab
Bill Wendlingf5da1332006-12-07 22:21:48 +0000949
Reid Spencer68a24bd2005-08-27 18:50:39 +0000950#define YYRECOVERING() (!!yyerrstatus)
Bill Wendlingf5da1332006-12-07 22:21:48 +0000951
952#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +0000953do \
954 if (yychar == YYEMPTY && yylen == 1) \
Bill Wendlingf5da1332006-12-07 22:21:48 +0000955 { \
956 yychar = (Token); \
957 yylval = (Value); \
958 yytoken = YYTRANSLATE (yychar); \
959 YYPOPSTACK (1); \
Reid Spencer68a24bd2005-08-27 18:50:39 +0000960 goto yybackup; \
961 } \
962 else \
Bill Wendlingf5da1332006-12-07 22:21:48 +0000963 { \
964 yyerror (YY_("syntax error: cannot back up")); \
965 YYERROR; \
966 } \
967while (YYID (0))
968
Reid Spencer68a24bd2005-08-27 18:50:39 +0000969
970#define YYTERROR 1
971#define YYERRCODE 256
972
Bill Wendlingf5da1332006-12-07 22:21:48 +0000973
974/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
975 If N is 0, then set CURRENT to the empty location which ends
976 the previous symbol: RHS[0] (always defined). */
977
978#define YYRHSLOC(Rhs, K) ((Rhs)[K])
979#ifndef YYLLOC_DEFAULT
980# define YYLLOC_DEFAULT(Current, Rhs, N) \
981 do \
982 if (YYID (N)) \
983 { \
984 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
985 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
986 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
987 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
988 } \
989 else \
990 { \
991 (Current).first_line = (Current).last_line = \
992 YYRHSLOC (Rhs, 0).last_line; \
993 (Current).first_column = (Current).last_column = \
994 YYRHSLOC (Rhs, 0).last_column; \
995 } \
996 while (YYID (0))
Reid Spencer68a24bd2005-08-27 18:50:39 +0000997#endif
998
Bill Wendlingf5da1332006-12-07 22:21:48 +0000999
1000/* YY_LOCATION_PRINT -- Print the location on the stream.
1001 This macro was not mandated originally: define only if we know
1002 we won't break user code: when these are the locations we know. */
1003
1004#ifndef YY_LOCATION_PRINT
1005# if YYLTYPE_IS_TRIVIAL
1006# define YY_LOCATION_PRINT(File, Loc) \
1007 fprintf (File, "%d.%d-%d.%d", \
1008 (Loc).first_line, (Loc).first_column, \
1009 (Loc).last_line, (Loc).last_column)
1010# else
1011# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1012# endif
1013#endif
1014
1015
1016/* YYLEX -- calling `yylex' with the right arguments. */
1017
Reid Spencer68a24bd2005-08-27 18:50:39 +00001018#ifdef YYLEX_PARAM
Bill Wendlingf5da1332006-12-07 22:21:48 +00001019# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001020#else
Bill Wendlingf5da1332006-12-07 22:21:48 +00001021# define YYLEX yylex ()
Chris Lattner81779692006-03-30 22:51:12 +00001022#endif
Bill Wendlingf5da1332006-12-07 22:21:48 +00001023
1024/* Enable debugging if requested. */
1025#if YYDEBUG
1026
1027# ifndef YYFPRINTF
1028# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1029# define YYFPRINTF fprintf
1030# endif
1031
1032# define YYDPRINTF(Args) \
1033do { \
1034 if (yydebug) \
1035 YYFPRINTF Args; \
1036} while (YYID (0))
1037
1038# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1039do { \
1040 if (yydebug) \
1041 { \
1042 YYFPRINTF (stderr, "%s ", Title); \
1043 yy_symbol_print (stderr, \
1044 Type, Value); \
1045 YYFPRINTF (stderr, "\n"); \
1046 } \
1047} while (YYID (0))
1048
1049
1050/*--------------------------------.
1051| Print this symbol on YYOUTPUT. |
1052`--------------------------------*/
1053
1054/*ARGSUSED*/
1055#if (defined __STDC__ || defined __C99__FUNC__ \
1056 || defined __cplusplus || defined _MSC_VER)
1057static void
1058yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Chris Lattner81779692006-03-30 22:51:12 +00001059#else
Bill Wendlingf5da1332006-12-07 22:21:48 +00001060static void
1061yy_symbol_value_print (yyoutput, yytype, yyvaluep)
1062 FILE *yyoutput;
1063 int yytype;
1064 YYSTYPE const * const yyvaluep;
Chris Lattner81779692006-03-30 22:51:12 +00001065#endif
Bill Wendlingf5da1332006-12-07 22:21:48 +00001066{
1067 if (!yyvaluep)
1068 return;
1069# ifdef YYPRINT
1070 if (yytype < YYNTOKENS)
1071 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1072# else
1073 YYUSE (yyoutput);
1074# endif
1075 switch (yytype)
1076 {
1077 default:
1078 break;
1079 }
1080}
1081
1082
1083/*--------------------------------.
1084| Print this symbol on YYOUTPUT. |
1085`--------------------------------*/
1086
1087#if (defined __STDC__ || defined __C99__FUNC__ \
1088 || defined __cplusplus || defined _MSC_VER)
1089static void
1090yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1091#else
1092static void
1093yy_symbol_print (yyoutput, yytype, yyvaluep)
1094 FILE *yyoutput;
1095 int yytype;
1096 YYSTYPE const * const yyvaluep;
Chris Lattner8d354e92005-09-30 04:11:27 +00001097#endif
Bill Wendlingf5da1332006-12-07 22:21:48 +00001098{
1099 if (yytype < YYNTOKENS)
1100 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1101 else
1102 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
John Criswelld7881242006-01-17 17:01:34 +00001103
Bill Wendlingf5da1332006-12-07 22:21:48 +00001104 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
1105 YYFPRINTF (yyoutput, ")");
1106}
John Criswelld7881242006-01-17 17:01:34 +00001107
Bill Wendlingf5da1332006-12-07 22:21:48 +00001108/*------------------------------------------------------------------.
1109| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1110| TOP (included). |
1111`------------------------------------------------------------------*/
John Criswelld7881242006-01-17 17:01:34 +00001112
Bill Wendlingf5da1332006-12-07 22:21:48 +00001113#if (defined __STDC__ || defined __C99__FUNC__ \
1114 || defined __cplusplus || defined _MSC_VER)
1115static void
1116yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
1117#else
1118static void
1119yy_stack_print (bottom, top)
1120 yytype_int16 *bottom;
1121 yytype_int16 *top;
Chris Lattner8d354e92005-09-30 04:11:27 +00001122#endif
Bill Wendlingf5da1332006-12-07 22:21:48 +00001123{
1124 YYFPRINTF (stderr, "Stack now");
1125 for (; bottom <= top; ++bottom)
1126 YYFPRINTF (stderr, " %d", *bottom);
1127 YYFPRINTF (stderr, "\n");
1128}
John Criswelld7881242006-01-17 17:01:34 +00001129
Bill Wendlingf5da1332006-12-07 22:21:48 +00001130# define YY_STACK_PRINT(Bottom, Top) \
1131do { \
1132 if (yydebug) \
1133 yy_stack_print ((Bottom), (Top)); \
1134} while (YYID (0))
John Criswelld7881242006-01-17 17:01:34 +00001135
Bill Wendlingf5da1332006-12-07 22:21:48 +00001136
1137/*------------------------------------------------.
1138| Report that the YYRULE is going to be reduced. |
1139`------------------------------------------------*/
1140
1141#if (defined __STDC__ || defined __C99__FUNC__ \
1142 || defined __cplusplus || defined _MSC_VER)
1143static void
1144yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
1145#else
1146static void
1147yy_reduce_print (yyvsp, yyrule)
1148 YYSTYPE *yyvsp;
1149 int yyrule;
Chris Lattnerba4b1442005-09-08 18:22:57 +00001150#endif
Bill Wendlingf5da1332006-12-07 22:21:48 +00001151{
1152 int yynrhs = yyr2[yyrule];
1153 int yyi;
1154 unsigned long int yylno = yyrline[yyrule];
1155 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1156 yyrule - 1, yylno);
1157 /* The symbols being reduced. */
1158 for (yyi = 0; yyi < yynrhs; yyi++)
1159 {
1160 fprintf (stderr, " $%d = ", yyi + 1);
1161 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1162 &(yyvsp[(yyi + 1) - (yynrhs)])
1163 );
1164 fprintf (stderr, "\n");
1165 }
1166}
Chris Lattner2b931e82005-09-12 05:30:06 +00001167
Bill Wendlingf5da1332006-12-07 22:21:48 +00001168# define YY_REDUCE_PRINT(Rule) \
1169do { \
1170 if (yydebug) \
1171 yy_reduce_print (yyvsp, Rule); \
1172} while (YYID (0))
Chris Lattner2b931e82005-09-12 05:30:06 +00001173
Bill Wendlingf5da1332006-12-07 22:21:48 +00001174/* Nonzero means print parse trace. It is left uninitialized so that
1175 multiple parsers can coexist. */
1176int yydebug;
1177#else /* !YYDEBUG */
1178# define YYDPRINTF(Args)
1179# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1180# define YY_STACK_PRINT(Bottom, Top)
1181# define YY_REDUCE_PRINT(Rule)
1182#endif /* !YYDEBUG */
1183
1184
1185/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001186#ifndef YYINITDEPTH
Bill Wendlingf5da1332006-12-07 22:21:48 +00001187# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00001188#endif
1189
Bill Wendlingf5da1332006-12-07 22:21:48 +00001190/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1191 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00001192
Bill Wendlingf5da1332006-12-07 22:21:48 +00001193 Do not make this value too large; the results are undefined if
1194 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1195 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001196
1197#ifndef YYMAXDEPTH
Bill Wendlingf5da1332006-12-07 22:21:48 +00001198# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00001199#endif
Bill Wendlingf5da1332006-12-07 22:21:48 +00001200
Reid Spencer68a24bd2005-08-27 18:50:39 +00001201
1202
Bill Wendlingf5da1332006-12-07 22:21:48 +00001203#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00001204
Bill Wendlingf5da1332006-12-07 22:21:48 +00001205# ifndef yystrlen
1206# if defined __GLIBC__ && defined _STRING_H
1207# define yystrlen strlen
1208# else
1209/* Return the length of YYSTR. */
1210#if (defined __STDC__ || defined __C99__FUNC__ \
1211 || defined __cplusplus || defined _MSC_VER)
1212static YYSIZE_T
1213yystrlen (const char *yystr)
Chris Lattner81779692006-03-30 22:51:12 +00001214#else
Bill Wendlingf5da1332006-12-07 22:21:48 +00001215static YYSIZE_T
1216yystrlen (yystr)
1217 const char *yystr;
1218#endif
1219{
1220 YYSIZE_T yylen;
1221 for (yylen = 0; yystr[yylen]; yylen++)
1222 continue;
1223 return yylen;
1224}
1225# endif
1226# endif
1227
1228# ifndef yystpcpy
1229# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1230# define yystpcpy stpcpy
1231# else
1232/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1233 YYDEST. */
1234#if (defined __STDC__ || defined __C99__FUNC__ \
1235 || defined __cplusplus || defined _MSC_VER)
1236static char *
1237yystpcpy (char *yydest, const char *yysrc)
1238#else
1239static char *
1240yystpcpy (yydest, yysrc)
1241 char *yydest;
1242 const char *yysrc;
1243#endif
1244{
1245 char *yyd = yydest;
1246 const char *yys = yysrc;
1247
1248 while ((*yyd++ = *yys++) != '\0')
1249 continue;
1250
1251 return yyd - 1;
1252}
1253# endif
1254# endif
1255
1256# ifndef yytnamerr
1257/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1258 quotes and backslashes, so that it's suitable for yyerror. The
1259 heuristic is that double-quoting is unnecessary unless the string
1260 contains an apostrophe, a comma, or backslash (other than
1261 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1262 null, do not copy; instead, return the length of what the result
1263 would have been. */
1264static YYSIZE_T
1265yytnamerr (char *yyres, const char *yystr)
1266{
1267 if (*yystr == '"')
1268 {
1269 YYSIZE_T yyn = 0;
1270 char const *yyp = yystr;
1271
1272 for (;;)
1273 switch (*++yyp)
1274 {
1275 case '\'':
1276 case ',':
1277 goto do_not_strip_quotes;
1278
1279 case '\\':
1280 if (*++yyp != '\\')
1281 goto do_not_strip_quotes;
1282 /* Fall through. */
1283 default:
1284 if (yyres)
1285 yyres[yyn] = *yyp;
1286 yyn++;
1287 break;
1288
1289 case '"':
1290 if (yyres)
1291 yyres[yyn] = '\0';
1292 return yyn;
1293 }
1294 do_not_strip_quotes: ;
1295 }
1296
1297 if (! yyres)
1298 return yystrlen (yystr);
1299
1300 return yystpcpy (yyres, yystr) - yyres;
1301}
1302# endif
1303
1304/* Copy into YYRESULT an error message about the unexpected token
1305 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1306 including the terminating null byte. If YYRESULT is null, do not
1307 copy anything; just return the number of bytes that would be
1308 copied. As a special case, return 0 if an ordinary "syntax error"
1309 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1310 size calculation. */
1311static YYSIZE_T
1312yysyntax_error (char *yyresult, int yystate, int yychar)
1313{
1314 int yyn = yypact[yystate];
1315
1316 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1317 return 0;
1318 else
1319 {
1320 int yytype = YYTRANSLATE (yychar);
1321 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1322 YYSIZE_T yysize = yysize0;
1323 YYSIZE_T yysize1;
1324 int yysize_overflow = 0;
1325 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1326 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1327 int yyx;
1328
1329# if 0
1330 /* This is so xgettext sees the translatable formats that are
1331 constructed on the fly. */
1332 YY_("syntax error, unexpected %s");
1333 YY_("syntax error, unexpected %s, expecting %s");
1334 YY_("syntax error, unexpected %s, expecting %s or %s");
1335 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1336 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1337# endif
1338 char *yyfmt;
1339 char const *yyf;
1340 static char const yyunexpected[] = "syntax error, unexpected %s";
1341 static char const yyexpecting[] = ", expecting %s";
1342 static char const yyor[] = " or %s";
1343 char yyformat[sizeof yyunexpected
1344 + sizeof yyexpecting - 1
1345 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1346 * (sizeof yyor - 1))];
1347 char const *yyprefix = yyexpecting;
1348
1349 /* Start YYX at -YYN if negative to avoid negative indexes in
1350 YYCHECK. */
1351 int yyxbegin = yyn < 0 ? -yyn : 0;
1352
1353 /* Stay within bounds of both yycheck and yytname. */
1354 int yychecklim = YYLAST - yyn + 1;
1355 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1356 int yycount = 1;
1357
1358 yyarg[0] = yytname[yytype];
1359 yyfmt = yystpcpy (yyformat, yyunexpected);
1360
1361 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1362 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1363 {
1364 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1365 {
1366 yycount = 1;
1367 yysize = yysize0;
1368 yyformat[sizeof yyunexpected - 1] = '\0';
1369 break;
1370 }
1371 yyarg[yycount++] = yytname[yyx];
1372 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1373 yysize_overflow |= (yysize1 < yysize);
1374 yysize = yysize1;
1375 yyfmt = yystpcpy (yyfmt, yyprefix);
1376 yyprefix = yyor;
1377 }
1378
1379 yyf = YY_(yyformat);
1380 yysize1 = yysize + yystrlen (yyf);
1381 yysize_overflow |= (yysize1 < yysize);
1382 yysize = yysize1;
1383
1384 if (yysize_overflow)
1385 return YYSIZE_MAXIMUM;
1386
1387 if (yyresult)
1388 {
1389 /* Avoid sprintf, as that infringes on the user's name space.
1390 Don't have undefined behavior even if the translation
1391 produced a string with the wrong number of "%s"s. */
1392 char *yyp = yyresult;
1393 int yyi = 0;
1394 while ((*yyp = *yyf) != '\0')
1395 {
1396 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1397 {
1398 yyp += yytnamerr (yyp, yyarg[yyi++]);
1399 yyf += 2;
1400 }
1401 else
1402 {
1403 yyp++;
1404 yyf++;
1405 }
1406 }
1407 }
1408 return yysize;
1409 }
1410}
1411#endif /* YYERROR_VERBOSE */
1412
1413
1414/*-----------------------------------------------.
1415| Release the memory associated to this symbol. |
1416`-----------------------------------------------*/
1417
1418/*ARGSUSED*/
1419#if (defined __STDC__ || defined __C99__FUNC__ \
1420 || defined __cplusplus || defined _MSC_VER)
1421static void
1422yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1423#else
1424static void
1425yydestruct (yymsg, yytype, yyvaluep)
1426 const char *yymsg;
1427 int yytype;
1428 YYSTYPE *yyvaluep;
1429#endif
1430{
1431 YYUSE (yyvaluep);
1432
1433 if (!yymsg)
1434 yymsg = "Deleting";
1435 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1436
1437 switch (yytype)
1438 {
1439
1440 default:
1441 break;
1442 }
1443}
1444
1445
1446/* Prevent warnings from -Wmissing-prototypes. */
1447
1448#ifdef YYPARSE_PARAM
1449#if defined __STDC__ || defined __cplusplus
1450int yyparse (void *YYPARSE_PARAM);
1451#else
1452int yyparse ();
1453#endif
1454#else /* ! YYPARSE_PARAM */
1455#if defined __STDC__ || defined __cplusplus
John Criswelld7881242006-01-17 17:01:34 +00001456int yyparse (void);
Chris Lattner81779692006-03-30 22:51:12 +00001457#else
Bill Wendlingf5da1332006-12-07 22:21:48 +00001458int yyparse ();
Chris Lattner81779692006-03-30 22:51:12 +00001459#endif
Bill Wendlingf5da1332006-12-07 22:21:48 +00001460#endif /* ! YYPARSE_PARAM */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001461
Reid Spencer68a24bd2005-08-27 18:50:39 +00001462
Bill Wendlingf5da1332006-12-07 22:21:48 +00001463
1464/* The look-ahead symbol. */
1465int yychar;
1466
1467/* The semantic value of the look-ahead symbol. */
1468YYSTYPE yylval;
1469
1470/* Number of syntax errors so far. */
1471int yynerrs;
1472
1473
1474
1475/*----------.
1476| yyparse. |
1477`----------*/
1478
1479#ifdef YYPARSE_PARAM
1480#if (defined __STDC__ || defined __C99__FUNC__ \
1481 || defined __cplusplus || defined _MSC_VER)
1482int
1483yyparse (void *YYPARSE_PARAM)
1484#else
1485int
1486yyparse (YYPARSE_PARAM)
1487 void *YYPARSE_PARAM;
1488#endif
1489#else /* ! YYPARSE_PARAM */
1490#if (defined __STDC__ || defined __C99__FUNC__ \
1491 || defined __cplusplus || defined _MSC_VER)
1492int
1493yyparse (void)
1494#else
1495int
1496yyparse ()
1497
Chris Lattner81779692006-03-30 22:51:12 +00001498#endif
1499#endif
Bill Wendlingf5da1332006-12-07 22:21:48 +00001500{
1501
1502 int yystate;
1503 int yyn;
1504 int yyresult;
1505 /* Number of tokens to shift before error messages enabled. */
1506 int yyerrstatus;
1507 /* Look-ahead token as an internal (translated) token number. */
1508 int yytoken = 0;
1509#if YYERROR_VERBOSE
1510 /* Buffer for error messages, and its allocated size. */
1511 char yymsgbuf[128];
1512 char *yymsg = yymsgbuf;
1513 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Chris Lattner81779692006-03-30 22:51:12 +00001514#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001515
Bill Wendlingf5da1332006-12-07 22:21:48 +00001516 /* Three stacks and their tools:
1517 `yyss': related to states,
1518 `yyvs': related to semantic values,
1519 `yyls': related to locations.
1520
1521 Refer to the stacks thru separate pointers, to allow yyoverflow
1522 to reallocate them elsewhere. */
1523
1524 /* The state stack. */
1525 yytype_int16 yyssa[YYINITDEPTH];
1526 yytype_int16 *yyss = yyssa;
1527 yytype_int16 *yyssp;
1528
1529 /* The semantic value stack. */
1530 YYSTYPE yyvsa[YYINITDEPTH];
1531 YYSTYPE *yyvs = yyvsa;
1532 YYSTYPE *yyvsp;
1533
1534
1535
1536#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1537
1538 YYSIZE_T yystacksize = YYINITDEPTH;
1539
1540 /* The variables used to return semantic value and location from the
1541 action routines. */
1542 YYSTYPE yyval;
1543
1544
1545 /* The number of symbols on the RHS of the reduced rule.
1546 Keep to zero when no symbol should be popped. */
1547 int yylen = 0;
1548
1549 YYDPRINTF ((stderr, "Starting parse\n"));
1550
Reid Spencer68a24bd2005-08-27 18:50:39 +00001551 yystate = 0;
1552 yyerrstatus = 0;
1553 yynerrs = 0;
1554 yychar = YYEMPTY; /* Cause a token to be read. */
1555
1556 /* Initialize stack pointers.
1557 Waste one element of value and location stack
1558 so that they stay on the same level as the state stack.
1559 The wasted elements are never initialized. */
1560
Bill Wendlingf5da1332006-12-07 22:21:48 +00001561 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001562 yyvsp = yyvs;
1563
Bill Wendlingf5da1332006-12-07 22:21:48 +00001564 goto yysetstate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001565
Bill Wendlingf5da1332006-12-07 22:21:48 +00001566/*------------------------------------------------------------.
1567| yynewstate -- Push a new state, which is found in yystate. |
1568`------------------------------------------------------------*/
1569 yynewstate:
1570 /* In all cases, when you get here, the value and location stacks
1571 have just been pushed. So pushing a state here evens the stacks. */
1572 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001573
Bill Wendlingf5da1332006-12-07 22:21:48 +00001574 yysetstate:
1575 *yyssp = yystate;
1576
1577 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001578 {
1579 /* Get the current used size of the three stacks, in elements. */
Bill Wendlingf5da1332006-12-07 22:21:48 +00001580 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001581
1582#ifdef yyoverflow
Bill Wendlingf5da1332006-12-07 22:21:48 +00001583 {
1584 /* Give user a chance to reallocate the stack. Use copies of
1585 these so that the &'s don't force the real ones into
1586 memory. */
1587 YYSTYPE *yyvs1 = yyvs;
1588 yytype_int16 *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001589
Bill Wendlingf5da1332006-12-07 22:21:48 +00001590
1591 /* Each stack pointer address is followed by the size of the
1592 data in use in that stack, in bytes. This used to be a
1593 conditional around just the two extra args, but that might
1594 be undefined if yyoverflow is a macro. */
1595 yyoverflow (YY_("memory exhausted"),
1596 &yyss1, yysize * sizeof (*yyssp),
1597 &yyvs1, yysize * sizeof (*yyvsp),
1598
1599 &yystacksize);
1600
1601 yyss = yyss1;
1602 yyvs = yyvs1;
1603 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001604#else /* no yyoverflow */
Bill Wendlingf5da1332006-12-07 22:21:48 +00001605# ifndef YYSTACK_RELOCATE
1606 goto yyexhaustedlab;
1607# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00001608 /* Extend the stack our own way. */
Bill Wendlingf5da1332006-12-07 22:21:48 +00001609 if (YYMAXDEPTH <= yystacksize)
1610 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001611 yystacksize *= 2;
Bill Wendlingf5da1332006-12-07 22:21:48 +00001612 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001613 yystacksize = YYMAXDEPTH;
Bill Wendlingf5da1332006-12-07 22:21:48 +00001614
1615 {
1616 yytype_int16 *yyss1 = yyss;
1617 union yyalloc *yyptr =
1618 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1619 if (! yyptr)
1620 goto yyexhaustedlab;
1621 YYSTACK_RELOCATE (yyss);
1622 YYSTACK_RELOCATE (yyvs);
1623
1624# undef YYSTACK_RELOCATE
1625 if (yyss1 != yyssa)
1626 YYSTACK_FREE (yyss1);
1627 }
1628# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001629#endif /* no yyoverflow */
1630
Bill Wendlingf5da1332006-12-07 22:21:48 +00001631 yyssp = yyss + yysize - 1;
1632 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001633
1634
Bill Wendlingf5da1332006-12-07 22:21:48 +00001635 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1636 (unsigned long int) yystacksize));
1637
1638 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001639 YYABORT;
1640 }
1641
Bill Wendlingf5da1332006-12-07 22:21:48 +00001642 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00001643
1644 goto yybackup;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001645
Bill Wendlingf5da1332006-12-07 22:21:48 +00001646/*-----------.
1647| yybackup. |
1648`-----------*/
1649yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00001650
Bill Wendlingf5da1332006-12-07 22:21:48 +00001651 /* Do appropriate processing given the current state. Read a
1652 look-ahead token if we need one and don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001653
Bill Wendlingf5da1332006-12-07 22:21:48 +00001654 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001655 yyn = yypact[yystate];
Bill Wendlingf5da1332006-12-07 22:21:48 +00001656 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001657 goto yydefault;
1658
Bill Wendlingf5da1332006-12-07 22:21:48 +00001659 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001660
Bill Wendlingf5da1332006-12-07 22:21:48 +00001661 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001662 if (yychar == YYEMPTY)
1663 {
Bill Wendlingf5da1332006-12-07 22:21:48 +00001664 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00001665 yychar = YYLEX;
1666 }
1667
Bill Wendlingf5da1332006-12-07 22:21:48 +00001668 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001669 {
Bill Wendlingf5da1332006-12-07 22:21:48 +00001670 yychar = yytoken = YYEOF;
1671 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00001672 }
1673 else
1674 {
Bill Wendlingf5da1332006-12-07 22:21:48 +00001675 yytoken = YYTRANSLATE (yychar);
1676 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001677 }
1678
Bill Wendlingf5da1332006-12-07 22:21:48 +00001679 /* If the proper action on seeing token YYTOKEN is to reduce or to
1680 detect an error, take that action. */
1681 yyn += yytoken;
1682 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001683 goto yydefault;
1684 yyn = yytable[yyn];
Bill Wendlingf5da1332006-12-07 22:21:48 +00001685 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001686 {
Bill Wendlingf5da1332006-12-07 22:21:48 +00001687 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001688 goto yyerrlab;
1689 yyn = -yyn;
1690 goto yyreduce;
1691 }
1692
1693 if (yyn == YYFINAL)
1694 YYACCEPT;
1695
Bill Wendlingf5da1332006-12-07 22:21:48 +00001696 /* Count tokens shifted since error; after three, turn off error
1697 status. */
1698 if (yyerrstatus)
1699 yyerrstatus--;
Chris Lattner81779692006-03-30 22:51:12 +00001700
Bill Wendlingf5da1332006-12-07 22:21:48 +00001701 /* Shift the look-ahead token. */
1702 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001703
Bill Wendlingf5da1332006-12-07 22:21:48 +00001704 /* Discard the shifted token unless it is eof. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001705 if (yychar != YYEOF)
1706 yychar = YYEMPTY;
1707
Reid Spencer68a24bd2005-08-27 18:50:39 +00001708 yystate = yyn;
Bill Wendlingf5da1332006-12-07 22:21:48 +00001709 *++yyvsp = yylval;
1710
Reid Spencer68a24bd2005-08-27 18:50:39 +00001711 goto yynewstate;
1712
Chris Lattner81779692006-03-30 22:51:12 +00001713
Bill Wendlingf5da1332006-12-07 22:21:48 +00001714/*-----------------------------------------------------------.
1715| yydefault -- do the default action for the current state. |
1716`-----------------------------------------------------------*/
1717yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00001718 yyn = yydefact[yystate];
1719 if (yyn == 0)
1720 goto yyerrlab;
Bill Wendlingf5da1332006-12-07 22:21:48 +00001721 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001722
Bill Wendlingf5da1332006-12-07 22:21:48 +00001723
1724/*-----------------------------.
1725| yyreduce -- Do a reduction. |
1726`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00001727yyreduce:
Bill Wendlingf5da1332006-12-07 22:21:48 +00001728 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001729 yylen = yyr2[yyn];
1730
Bill Wendlingf5da1332006-12-07 22:21:48 +00001731 /* If YYLEN is nonzero, implement the default value of the action:
1732 `$$ = $1'.
1733
1734 Otherwise, the following line sets YYVAL to garbage.
1735 This behavior is undocumented and Bison
1736 users should not rely upon it. Assigning to YYVAL
1737 unconditionally makes the parser a bit smaller, and it avoids a
1738 GCC warning that YYVAL may be used uninitialized. */
1739 yyval = yyvsp[1-yylen];
1740
1741
1742 YY_REDUCE_PRINT (yyn);
1743 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001744 {
Bill Wendlingf5da1332006-12-07 22:21:48 +00001745 case 2:
1746#line 246 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1747 {
Chris Lattner27627382006-09-01 21:14:42 +00001748 if (CurDefmPrefix) {
1749 // If CurDefmPrefix is set, we're parsing a defm, which means that this is
1750 // actually the name of a multiclass.
Bill Wendlingf5da1332006-12-07 22:21:48 +00001751 MultiClass *MC = MultiClasses[*(yyvsp[(1) - (1)].StrVal)];
Chris Lattner27627382006-09-01 21:14:42 +00001752 if (MC == 0) {
Bill Wendlingf5da1332006-12-07 22:21:48 +00001753 err() << "Couldn't find class '" << *(yyvsp[(1) - (1)].StrVal) << "'!\n";
Chris Lattner27627382006-09-01 21:14:42 +00001754 exit(1);
1755 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00001756 (yyval.Rec) = &MC->Rec;
Chris Lattner27627382006-09-01 21:14:42 +00001757 } else {
Bill Wendlingf5da1332006-12-07 22:21:48 +00001758 (yyval.Rec) = Records.getClass(*(yyvsp[(1) - (1)].StrVal));
Chris Lattner27627382006-09-01 21:14:42 +00001759 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00001760 if ((yyval.Rec) == 0) {
1761 err() << "Couldn't find class '" << *(yyvsp[(1) - (1)].StrVal) << "'!\n";
Reid Spencer68a24bd2005-08-27 18:50:39 +00001762 exit(1);
1763 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00001764 delete (yyvsp[(1) - (1)].StrVal);
1765 ;}
1766 break;
1767
1768 case 3:
1769#line 268 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1770 { // string type
1771 (yyval.Ty) = new StringRecTy();
1772 ;}
1773 break;
1774
1775 case 4:
1776#line 270 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1777 { // bit type
1778 (yyval.Ty) = new BitRecTy();
1779 ;}
1780 break;
1781
1782 case 5:
1783#line 272 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1784 { // bits<x> type
1785 (yyval.Ty) = new BitsRecTy((yyvsp[(3) - (4)].IntVal));
1786 ;}
1787 break;
1788
1789 case 6:
1790#line 274 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1791 { // int type
1792 (yyval.Ty) = new IntRecTy();
1793 ;}
1794 break;
1795
1796 case 7:
1797#line 276 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1798 { // list<x> type
1799 (yyval.Ty) = new ListRecTy((yyvsp[(3) - (4)].Ty));
1800 ;}
1801 break;
1802
1803 case 8:
1804#line 278 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1805 { // code type
1806 (yyval.Ty) = new CodeRecTy();
1807 ;}
1808 break;
1809
1810 case 9:
1811#line 280 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1812 { // dag type
1813 (yyval.Ty) = new DagRecTy();
1814 ;}
1815 break;
1816
1817 case 10:
1818#line 282 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1819 { // Record Type
1820 (yyval.Ty) = new RecordRecTy((yyvsp[(1) - (1)].Rec));
1821 ;}
1822 break;
1823
1824 case 11:
1825#line 286 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1826 { (yyval.IntVal) = 0; ;}
1827 break;
1828
1829 case 12:
1830#line 286 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1831 { (yyval.IntVal) = 1; ;}
1832 break;
1833
1834 case 13:
1835#line 288 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1836 { (yyval.Initializer) = 0; ;}
1837 break;
1838
1839 case 14:
1840#line 288 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1841 { (yyval.Initializer) = (yyvsp[(2) - (2)].Initializer); ;}
1842 break;
1843
1844 case 15:
1845#line 290 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1846 {
1847 if (const RecordVal *RV = (CurRec ? CurRec->getValue(*(yyvsp[(1) - (1)].StrVal)) : 0)) {
1848 (yyval.Initializer) = new VarInit(*(yyvsp[(1) - (1)].StrVal), RV->getType());
1849 } else if (CurRec && CurRec->isTemplateArg(CurRec->getName()+":"+*(yyvsp[(1) - (1)].StrVal))) {
1850 const RecordVal *RV = CurRec->getValue(CurRec->getName()+":"+*(yyvsp[(1) - (1)].StrVal));
Chris Lattner81779692006-03-30 22:51:12 +00001851 assert(RV && "Template arg doesn't exist??");
Bill Wendlingf5da1332006-12-07 22:21:48 +00001852 (yyval.Initializer) = new VarInit(CurRec->getName()+":"+*(yyvsp[(1) - (1)].StrVal), RV->getType());
Chris Lattner27627382006-09-01 21:14:42 +00001853 } else if (CurMultiClass &&
Bill Wendlingf5da1332006-12-07 22:21:48 +00001854 CurMultiClass->Rec.isTemplateArg(CurMultiClass->Rec.getName()+"::"+*(yyvsp[(1) - (1)].StrVal))) {
1855 std::string Name = CurMultiClass->Rec.getName()+"::"+*(yyvsp[(1) - (1)].StrVal);
Chris Lattner27627382006-09-01 21:14:42 +00001856 const RecordVal *RV = CurMultiClass->Rec.getValue(Name);
1857 assert(RV && "Template arg doesn't exist??");
Bill Wendlingf5da1332006-12-07 22:21:48 +00001858 (yyval.Initializer) = new VarInit(Name, RV->getType());
1859 } else if (Record *D = Records.getDef(*(yyvsp[(1) - (1)].StrVal))) {
1860 (yyval.Initializer) = new DefInit(D);
Chris Lattner81779692006-03-30 22:51:12 +00001861 } else {
Bill Wendlingf5da1332006-12-07 22:21:48 +00001862 err() << "Variable not defined: '" << *(yyvsp[(1) - (1)].StrVal) << "'!\n";
Chris Lattner81779692006-03-30 22:51:12 +00001863 exit(1);
1864 }
1865
Bill Wendlingf5da1332006-12-07 22:21:48 +00001866 delete (yyvsp[(1) - (1)].StrVal);
1867;}
1868 break;
1869
1870 case 16:
1871#line 313 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1872 {
1873 (yyval.Initializer) = (yyvsp[(1) - (1)].Initializer);
1874 ;}
1875 break;
1876
1877 case 17:
1878#line 315 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1879 {
1880 (yyval.Initializer) = new IntInit((yyvsp[(1) - (1)].IntVal));
1881 ;}
1882 break;
1883
1884 case 18:
1885#line 317 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1886 {
1887 (yyval.Initializer) = new StringInit(*(yyvsp[(1) - (1)].StrVal));
1888 delete (yyvsp[(1) - (1)].StrVal);
1889 ;}
1890 break;
1891
1892 case 19:
1893#line 320 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1894 {
1895 (yyval.Initializer) = new CodeInit(*(yyvsp[(1) - (1)].StrVal));
1896 delete (yyvsp[(1) - (1)].StrVal);
1897 ;}
1898 break;
1899
1900 case 20:
1901#line 323 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1902 {
1903 (yyval.Initializer) = new UnsetInit();
1904 ;}
1905 break;
1906
1907 case 21:
1908#line 325 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1909 {
1910 BitsInit *Init = new BitsInit((yyvsp[(2) - (3)].FieldList)->size());
1911 for (unsigned i = 0, e = (yyvsp[(2) - (3)].FieldList)->size(); i != e; ++i) {
1912 struct Init *Bit = (*(yyvsp[(2) - (3)].FieldList))[i]->convertInitializerTo(new BitRecTy());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001913 if (Bit == 0) {
Bill Wendlingf5da1332006-12-07 22:21:48 +00001914 err() << "Element #" << i << " (" << *(*(yyvsp[(2) - (3)].FieldList))[i]
Chris Lattnerba4b1442005-09-08 18:22:57 +00001915 << ") is not convertable to a bit!\n";
1916 exit(1);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001917 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00001918 Init->setBit((yyvsp[(2) - (3)].FieldList)->size()-i-1, Bit);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001919 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00001920 (yyval.Initializer) = Init;
1921 delete (yyvsp[(2) - (3)].FieldList);
1922 ;}
1923 break;
1924
1925 case 22:
1926#line 338 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1927 {
Chris Lattnerca572be2005-09-08 18:48:47 +00001928 // This is a CLASS<initvalslist> expression. This is supposed to synthesize
1929 // a new anonymous definition, deriving from CLASS<initvalslist> with no
1930 // body.
Bill Wendlingf5da1332006-12-07 22:21:48 +00001931 Record *Class = Records.getClass(*(yyvsp[(1) - (4)].StrVal));
Chris Lattnerca572be2005-09-08 18:48:47 +00001932 if (!Class) {
Bill Wendlingf5da1332006-12-07 22:21:48 +00001933 err() << "Expected a class, got '" << *(yyvsp[(1) - (4)].StrVal) << "'!\n";
Chris Lattnerca572be2005-09-08 18:48:47 +00001934 exit(1);
1935 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00001936 delete (yyvsp[(1) - (4)].StrVal);
Chris Lattnerca572be2005-09-08 18:48:47 +00001937
1938 static unsigned AnonCounter = 0;
1939 Record *OldRec = CurRec; // Save CurRec.
1940
1941 // Create the new record, set it as CurRec temporarily.
1942 CurRec = new Record("anonymous.val."+utostr(AnonCounter++));
Bill Wendlingf5da1332006-12-07 22:21:48 +00001943 addSubClass(Class, *(yyvsp[(3) - (4)].FieldList)); // Add info about the subclass to CurRec.
1944 delete (yyvsp[(3) - (4)].FieldList); // Free up the template args.
Chris Lattnerca572be2005-09-08 18:48:47 +00001945
Chris Lattner751eabf2005-09-08 19:47:28 +00001946 CurRec->resolveReferences();
Chris Lattnerca572be2005-09-08 18:48:47 +00001947
1948 Records.addDef(CurRec);
1949
1950 // The result of the expression is a reference to the new record.
Bill Wendlingf5da1332006-12-07 22:21:48 +00001951 (yyval.Initializer) = new DefInit(CurRec);
Chris Lattnerca572be2005-09-08 18:48:47 +00001952
1953 // Restore the old CurRec
1954 CurRec = OldRec;
Bill Wendlingf5da1332006-12-07 22:21:48 +00001955 ;}
1956 break;
1957
1958 case 23:
1959#line 366 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1960 {
1961 (yyval.Initializer) = (yyvsp[(1) - (4)].Initializer)->convertInitializerBitRange(*(yyvsp[(3) - (4)].BitList));
1962 if ((yyval.Initializer) == 0) {
1963 err() << "Invalid bit range for value '" << *(yyvsp[(1) - (4)].Initializer) << "'!\n";
Reid Spencer68a24bd2005-08-27 18:50:39 +00001964 exit(1);
1965 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00001966 delete (yyvsp[(3) - (4)].BitList);
1967 ;}
1968 break;
1969
1970 case 24:
1971#line 373 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1972 {
1973 (yyval.Initializer) = new ListInit(*(yyvsp[(2) - (3)].FieldList));
1974 delete (yyvsp[(2) - (3)].FieldList);
1975 ;}
1976 break;
1977
1978 case 25:
1979#line 376 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1980 {
1981 if (!(yyvsp[(1) - (3)].Initializer)->getFieldType(*(yyvsp[(3) - (3)].StrVal))) {
1982 err() << "Cannot access field '" << *(yyvsp[(3) - (3)].StrVal) << "' of value '" << *(yyvsp[(1) - (3)].Initializer) << "!\n";
Reid Spencer68a24bd2005-08-27 18:50:39 +00001983 exit(1);
1984 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00001985 (yyval.Initializer) = new FieldInit((yyvsp[(1) - (3)].Initializer), *(yyvsp[(3) - (3)].StrVal));
1986 delete (yyvsp[(3) - (3)].StrVal);
1987 ;}
1988 break;
1989
1990 case 26:
1991#line 383 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
1992 {
1993 (yyval.Initializer) = new DagInit((yyvsp[(2) - (4)].Initializer), *(yyvsp[(3) - (4)].DagValueList));
1994 delete (yyvsp[(3) - (4)].DagValueList);
1995 ;}
1996 break;
1997
1998 case 27:
1999#line 386 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2000 {
2001 std::reverse((yyvsp[(3) - (4)].BitList)->begin(), (yyvsp[(3) - (4)].BitList)->end());
2002 (yyval.Initializer) = (yyvsp[(1) - (4)].Initializer)->convertInitListSlice(*(yyvsp[(3) - (4)].BitList));
2003 if ((yyval.Initializer) == 0) {
2004 err() << "Invalid list slice for value '" << *(yyvsp[(1) - (4)].Initializer) << "'!\n";
Reid Spencer68a24bd2005-08-27 18:50:39 +00002005 exit(1);
2006 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00002007 delete (yyvsp[(3) - (4)].BitList);
2008 ;}
2009 break;
2010
2011 case 28:
2012#line 394 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2013 {
2014 (yyval.Initializer) = (new BinOpInit(BinOpInit::SHL, (yyvsp[(3) - (6)].Initializer), (yyvsp[(5) - (6)].Initializer)))->Fold();
2015 ;}
2016 break;
2017
2018 case 29:
2019#line 396 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2020 {
2021 (yyval.Initializer) = (new BinOpInit(BinOpInit::SRA, (yyvsp[(3) - (6)].Initializer), (yyvsp[(5) - (6)].Initializer)))->Fold();
2022 ;}
2023 break;
2024
2025 case 30:
2026#line 398 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2027 {
2028 (yyval.Initializer) = (new BinOpInit(BinOpInit::SRL, (yyvsp[(3) - (6)].Initializer), (yyvsp[(5) - (6)].Initializer)))->Fold();
2029 ;}
2030 break;
2031
2032 case 31:
2033#line 400 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2034 {
2035 (yyval.Initializer) = (new BinOpInit(BinOpInit::STRCONCAT, (yyvsp[(3) - (6)].Initializer), (yyvsp[(5) - (6)].Initializer)))->Fold();
2036 ;}
2037 break;
2038
2039 case 32:
2040#line 404 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2041 {
2042 (yyval.StrVal) = new std::string();
2043 ;}
2044 break;
2045
2046 case 33:
2047#line 407 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2048 {
2049 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
2050 ;}
2051 break;
2052
2053 case 34:
2054#line 411 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2055 {
2056 (yyval.DagValueList) = new std::vector<std::pair<Init*, std::string> >();
2057 (yyval.DagValueList)->push_back(std::make_pair((yyvsp[(1) - (2)].Initializer), *(yyvsp[(2) - (2)].StrVal)));
2058 delete (yyvsp[(2) - (2)].StrVal);
2059 ;}
2060 break;
2061
2062 case 35:
2063#line 416 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2064 {
2065 (yyvsp[(1) - (4)].DagValueList)->push_back(std::make_pair((yyvsp[(3) - (4)].Initializer), *(yyvsp[(4) - (4)].StrVal)));
2066 delete (yyvsp[(4) - (4)].StrVal);
2067 (yyval.DagValueList) = (yyvsp[(1) - (4)].DagValueList);
2068 ;}
2069 break;
2070
2071 case 36:
2072#line 422 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2073 {
2074 (yyval.DagValueList) = new std::vector<std::pair<Init*, std::string> >();
2075 ;}
2076 break;
2077
2078 case 37:
2079#line 425 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2080 { (yyval.DagValueList) = (yyvsp[(1) - (1)].DagValueList); ;}
2081 break;
2082
2083 case 38:
2084#line 428 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2085 {
2086 (yyval.BitList) = new std::vector<unsigned>();
2087 (yyval.BitList)->push_back((yyvsp[(1) - (1)].IntVal));
2088 ;}
2089 break;
2090
2091 case 39:
2092#line 431 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2093 {
2094 if ((yyvsp[(1) - (3)].IntVal) < 0 || (yyvsp[(3) - (3)].IntVal) < 0) {
2095 err() << "Invalid range: " << (yyvsp[(1) - (3)].IntVal) << "-" << (yyvsp[(3) - (3)].IntVal) << "!\n";
Reid Spencer68a24bd2005-08-27 18:50:39 +00002096 exit(1);
2097 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00002098 (yyval.BitList) = new std::vector<unsigned>();
2099 if ((yyvsp[(1) - (3)].IntVal) < (yyvsp[(3) - (3)].IntVal)) {
2100 for (int i = (yyvsp[(1) - (3)].IntVal); i <= (yyvsp[(3) - (3)].IntVal); ++i)
2101 (yyval.BitList)->push_back(i);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002102 } else {
Bill Wendlingf5da1332006-12-07 22:21:48 +00002103 for (int i = (yyvsp[(1) - (3)].IntVal); i >= (yyvsp[(3) - (3)].IntVal); --i)
2104 (yyval.BitList)->push_back(i);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002105 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00002106 ;}
2107 break;
2108
2109 case 40:
2110#line 444 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2111 {
2112 (yyvsp[(2) - (2)].IntVal) = -(yyvsp[(2) - (2)].IntVal);
2113 if ((yyvsp[(1) - (2)].IntVal) < 0 || (yyvsp[(2) - (2)].IntVal) < 0) {
2114 err() << "Invalid range: " << (yyvsp[(1) - (2)].IntVal) << "-" << (yyvsp[(2) - (2)].IntVal) << "!\n";
Reid Spencer68a24bd2005-08-27 18:50:39 +00002115 exit(1);
2116 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00002117 (yyval.BitList) = new std::vector<unsigned>();
2118 if ((yyvsp[(1) - (2)].IntVal) < (yyvsp[(2) - (2)].IntVal)) {
2119 for (int i = (yyvsp[(1) - (2)].IntVal); i <= (yyvsp[(2) - (2)].IntVal); ++i)
2120 (yyval.BitList)->push_back(i);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002121 } else {
Bill Wendlingf5da1332006-12-07 22:21:48 +00002122 for (int i = (yyvsp[(1) - (2)].IntVal); i >= (yyvsp[(2) - (2)].IntVal); --i)
2123 (yyval.BitList)->push_back(i);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002124 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00002125 ;}
2126 break;
2127
2128 case 41:
2129#line 458 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2130 {
2131 ((yyval.BitList)=(yyvsp[(1) - (3)].BitList))->push_back((yyvsp[(3) - (3)].IntVal));
2132 ;}
2133 break;
2134
2135 case 42:
2136#line 460 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2137 {
2138 if ((yyvsp[(3) - (5)].IntVal) < 0 || (yyvsp[(5) - (5)].IntVal) < 0) {
2139 err() << "Invalid range: " << (yyvsp[(3) - (5)].IntVal) << "-" << (yyvsp[(5) - (5)].IntVal) << "!\n";
Reid Spencer68a24bd2005-08-27 18:50:39 +00002140 exit(1);
2141 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00002142 (yyval.BitList) = (yyvsp[(1) - (5)].BitList);
2143 if ((yyvsp[(3) - (5)].IntVal) < (yyvsp[(5) - (5)].IntVal)) {
2144 for (int i = (yyvsp[(3) - (5)].IntVal); i <= (yyvsp[(5) - (5)].IntVal); ++i)
2145 (yyval.BitList)->push_back(i);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002146 } else {
Bill Wendlingf5da1332006-12-07 22:21:48 +00002147 for (int i = (yyvsp[(3) - (5)].IntVal); i >= (yyvsp[(5) - (5)].IntVal); --i)
2148 (yyval.BitList)->push_back(i);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002149 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00002150 ;}
2151 break;
2152
2153 case 43:
2154#line 473 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2155 {
2156 (yyvsp[(4) - (4)].IntVal) = -(yyvsp[(4) - (4)].IntVal);
2157 if ((yyvsp[(3) - (4)].IntVal) < 0 || (yyvsp[(4) - (4)].IntVal) < 0) {
2158 err() << "Invalid range: " << (yyvsp[(3) - (4)].IntVal) << "-" << (yyvsp[(4) - (4)].IntVal) << "!\n";
Reid Spencer68a24bd2005-08-27 18:50:39 +00002159 exit(1);
2160 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00002161 (yyval.BitList) = (yyvsp[(1) - (4)].BitList);
2162 if ((yyvsp[(3) - (4)].IntVal) < (yyvsp[(4) - (4)].IntVal)) {
2163 for (int i = (yyvsp[(3) - (4)].IntVal); i <= (yyvsp[(4) - (4)].IntVal); ++i)
2164 (yyval.BitList)->push_back(i);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002165 } else {
Bill Wendlingf5da1332006-12-07 22:21:48 +00002166 for (int i = (yyvsp[(3) - (4)].IntVal); i >= (yyvsp[(4) - (4)].IntVal); --i)
2167 (yyval.BitList)->push_back(i);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002168 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00002169 ;}
2170 break;
2171
2172 case 44:
2173#line 489 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2174 { (yyval.BitList) = (yyvsp[(1) - (1)].BitList); std::reverse((yyvsp[(1) - (1)].BitList)->begin(), (yyvsp[(1) - (1)].BitList)->end()); ;}
2175 break;
2176
2177 case 45:
2178#line 491 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2179 { (yyval.BitList) = 0; ;}
2180 break;
2181
2182 case 46:
2183#line 491 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2184 { (yyval.BitList) = (yyvsp[(2) - (3)].BitList); ;}
2185 break;
2186
2187 case 47:
2188#line 495 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2189 {
2190 (yyval.FieldList) = new std::vector<Init*>();
2191 ;}
2192 break;
2193
2194 case 48:
2195#line 497 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2196 {
2197 (yyval.FieldList) = (yyvsp[(1) - (1)].FieldList);
2198 ;}
2199 break;
2200
2201 case 49:
2202#line 501 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2203 {
2204 (yyval.FieldList) = new std::vector<Init*>();
2205 (yyval.FieldList)->push_back((yyvsp[(1) - (1)].Initializer));
2206 ;}
2207 break;
2208
2209 case 50:
2210#line 504 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2211 {
2212 ((yyval.FieldList) = (yyvsp[(1) - (3)].FieldList))->push_back((yyvsp[(3) - (3)].Initializer));
2213 ;}
2214 break;
2215
2216 case 51:
2217#line 508 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2218 {
2219 std::string DecName = *(yyvsp[(3) - (4)].StrVal);
Chris Lattner27627382006-09-01 21:14:42 +00002220 if (ParsingTemplateArgs) {
2221 if (CurRec) {
2222 DecName = CurRec->getName() + ":" + DecName;
2223 } else {
2224 assert(CurMultiClass);
2225 }
2226 if (CurMultiClass)
2227 DecName = CurMultiClass->Rec.getName() + "::" + DecName;
2228 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002229
Bill Wendlingf5da1332006-12-07 22:21:48 +00002230 addValue(RecordVal(DecName, (yyvsp[(2) - (4)].Ty), (yyvsp[(1) - (4)].IntVal)));
2231 setValue(DecName, 0, (yyvsp[(4) - (4)].Initializer));
2232 (yyval.StrVal) = new std::string(DecName);
2233;}
2234 break;
2235
2236 case 52:
2237#line 525 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2238 {
2239 delete (yyvsp[(1) - (2)].StrVal);
2240;}
2241 break;
2242
2243 case 53:
2244#line 527 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2245 {
2246 setValue(*(yyvsp[(2) - (6)].StrVal), (yyvsp[(3) - (6)].BitList), (yyvsp[(5) - (6)].Initializer));
2247 delete (yyvsp[(2) - (6)].StrVal);
2248 delete (yyvsp[(3) - (6)].BitList);
2249;}
2250 break;
2251
2252 case 58:
2253#line 536 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2254 {
2255 (yyval.SubClassRef) = new SubClassRefTy((yyvsp[(1) - (1)].Rec), new std::vector<Init*>());
2256 ;}
2257 break;
2258
2259 case 59:
2260#line 538 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2261 {
2262 (yyval.SubClassRef) = new SubClassRefTy((yyvsp[(1) - (4)].Rec), (yyvsp[(3) - (4)].FieldList));
2263 ;}
2264 break;
2265
2266 case 60:
2267#line 542 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2268 {
2269 (yyval.SubClassList) = new std::vector<SubClassRefTy>();
2270 (yyval.SubClassList)->push_back(*(yyvsp[(1) - (1)].SubClassRef));
2271 delete (yyvsp[(1) - (1)].SubClassRef);
2272 ;}
2273 break;
2274
2275 case 61:
2276#line 547 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2277 {
2278 ((yyval.SubClassList)=(yyvsp[(1) - (3)].SubClassList))->push_back(*(yyvsp[(3) - (3)].SubClassRef));
2279 delete (yyvsp[(3) - (3)].SubClassRef);
2280 ;}
2281 break;
2282
2283 case 62:
2284#line 552 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2285 {
2286 (yyval.SubClassList) = new std::vector<SubClassRefTy>();
2287 ;}
2288 break;
2289
2290 case 63:
2291#line 555 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2292 {
2293 (yyval.SubClassList) = (yyvsp[(2) - (2)].SubClassList);
2294 ;}
2295 break;
2296
2297 case 64:
2298#line 559 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2299 {
2300 getActiveRec()->addTemplateArg(*(yyvsp[(1) - (1)].StrVal));
2301 delete (yyvsp[(1) - (1)].StrVal);
2302;}
2303 break;
2304
2305 case 65:
2306#line 562 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2307 {
2308 getActiveRec()->addTemplateArg(*(yyvsp[(3) - (3)].StrVal));
2309 delete (yyvsp[(3) - (3)].StrVal);
2310;}
2311 break;
2312
2313 case 66:
2314#line 567 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2315 {;}
2316 break;
2317
2318 case 69:
2319#line 570 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2320 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
2321 break;
2322
2323 case 70:
2324#line 570 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2325 { (yyval.StrVal) = new std::string(); ;}
2326 break;
2327
2328 case 71:
2329#line 572 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2330 {
Chris Lattner8d354e92005-09-30 04:11:27 +00002331 static unsigned AnonCounter = 0;
Bill Wendlingf5da1332006-12-07 22:21:48 +00002332 if ((yyvsp[(1) - (1)].StrVal)->empty())
2333 *(yyvsp[(1) - (1)].StrVal) = "anonymous."+utostr(AnonCounter++);
2334 (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal);
2335;}
2336 break;
2337
2338 case 72:
2339#line 579 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2340 {
Chris Lattner946ac932005-09-30 04:53:25 +00002341 // If a class of this name already exists, it must be a forward ref.
Bill Wendlingf5da1332006-12-07 22:21:48 +00002342 if ((CurRec = Records.getClass(*(yyvsp[(1) - (1)].StrVal)))) {
Chris Lattner946ac932005-09-30 04:53:25 +00002343 // If the body was previously defined, this is an error.
2344 if (!CurRec->getValues().empty() ||
2345 !CurRec->getSuperClasses().empty() ||
2346 !CurRec->getTemplateArgs().empty()) {
2347 err() << "Class '" << CurRec->getName() << "' already defined!\n";
2348 exit(1);
2349 }
2350 } else {
2351 // If this is the first reference to this class, create and add it.
Bill Wendlingf5da1332006-12-07 22:21:48 +00002352 CurRec = new Record(*(yyvsp[(1) - (1)].StrVal));
Chris Lattner946ac932005-09-30 04:53:25 +00002353 Records.addClass(CurRec);
Chris Lattner8d354e92005-09-30 04:11:27 +00002354 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00002355 delete (yyvsp[(1) - (1)].StrVal);
2356;}
2357 break;
2358
2359 case 73:
2360#line 597 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2361 {
2362 CurRec = new Record(*(yyvsp[(1) - (1)].StrVal));
2363 delete (yyvsp[(1) - (1)].StrVal);
Chris Lattner946ac932005-09-30 04:53:25 +00002364
Chris Lattner27627382006-09-01 21:14:42 +00002365 if (!CurMultiClass) {
2366 // Top-level def definition.
2367
2368 // Ensure redefinition doesn't happen.
2369 if (Records.getDef(CurRec->getName())) {
2370 err() << "def '" << CurRec->getName() << "' already defined!\n";
2371 exit(1);
2372 }
2373 Records.addDef(CurRec);
2374 } else {
2375 // Otherwise, a def inside a multiclass, add it to the multiclass.
2376 for (unsigned i = 0, e = CurMultiClass->DefPrototypes.size(); i != e; ++i)
2377 if (CurMultiClass->DefPrototypes[i]->getName() == CurRec->getName()) {
2378 err() << "def '" << CurRec->getName()
2379 << "' already defined in this multiclass!\n";
2380 exit(1);
2381 }
2382 CurMultiClass->DefPrototypes.push_back(CurRec);
Chris Lattner8d354e92005-09-30 04:11:27 +00002383 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00002384;}
2385 break;
2386
2387 case 74:
2388#line 622 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2389 {
2390 for (unsigned i = 0, e = (yyvsp[(1) - (1)].SubClassList)->size(); i != e; ++i) {
2391 addSubClass((*(yyvsp[(1) - (1)].SubClassList))[i].first, *(*(yyvsp[(1) - (1)].SubClassList))[i].second);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002392 // Delete the template arg values for the class
Bill Wendlingf5da1332006-12-07 22:21:48 +00002393 delete (*(yyvsp[(1) - (1)].SubClassList))[i].second;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002394 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00002395 delete (yyvsp[(1) - (1)].SubClassList); // Delete the class list.
Chris Lattner0a284052005-09-30 04:42:56 +00002396
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00002397 // Process any variables on the let stack.
Chris Lattnerba4b1442005-09-08 18:22:57 +00002398 for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002399 for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
2400 setValue(LetStack[i][j].Name,
2401 LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0,
2402 LetStack[i][j].Value);
Bill Wendlingf5da1332006-12-07 22:21:48 +00002403 ;}
2404 break;
2405
2406 case 75:
2407#line 636 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2408 {
2409 (yyval.Rec) = CurRec;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002410 CurRec = 0;
Bill Wendlingf5da1332006-12-07 22:21:48 +00002411 ;}
2412 break;
2413
2414 case 76:
2415#line 641 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2416 {
Chris Lattner946ac932005-09-30 04:53:25 +00002417 ParsingTemplateArgs = true;
Bill Wendlingf5da1332006-12-07 22:21:48 +00002418 ;}
2419 break;
2420
2421 case 77:
2422#line 643 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2423 {
Chris Lattner946ac932005-09-30 04:53:25 +00002424 ParsingTemplateArgs = false;
Bill Wendlingf5da1332006-12-07 22:21:48 +00002425 ;}
2426 break;
2427
2428 case 78:
2429#line 645 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2430 {
2431 (yyval.Rec) = (yyvsp[(6) - (6)].Rec);
2432 ;}
2433 break;
2434
2435 case 79:
2436#line 649 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2437 {
Chris Lattner7717d092006-09-01 21:59:03 +00002438 if (CurMultiClass == 0) // Def's in multiclasses aren't really defs.
Bill Wendlingf5da1332006-12-07 22:21:48 +00002439 (yyvsp[(3) - (3)].Rec)->resolveReferences();
Reid Spencer68a24bd2005-08-27 18:50:39 +00002440
Chris Lattnerca572be2005-09-08 18:48:47 +00002441 // If ObjectBody has template arguments, it's an error.
Bill Wendlingf5da1332006-12-07 22:21:48 +00002442 assert((yyvsp[(3) - (3)].Rec)->getTemplateArgs().empty() && "How'd this get template args?");
2443 (yyval.Rec) = (yyvsp[(3) - (3)].Rec);
2444;}
2445 break;
2446
2447 case 80:
2448#line 659 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2449 {
2450 (yyval.Rec) = (yyvsp[(1) - (1)].Rec);
Chris Lattner27627382006-09-01 21:14:42 +00002451 // Copy the template arguments for the multiclass into the def.
2452 const std::vector<std::string> &TArgs = CurMultiClass->Rec.getTemplateArgs();
2453
2454 for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
2455 const RecordVal *RV = CurMultiClass->Rec.getValue(TArgs[i]);
2456 assert(RV && "Template arg doesn't exist?");
Bill Wendlingf5da1332006-12-07 22:21:48 +00002457 (yyval.Rec)->addValue(*RV);
Chris Lattner27627382006-09-01 21:14:42 +00002458 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00002459;}
2460 break;
2461
2462 case 81:
2463#line 673 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2464 {
2465 (yyval.RecList) = new std::vector<Record*>();
2466 (yyval.RecList)->push_back((yyvsp[(1) - (1)].Rec));
2467;}
2468 break;
2469
2470 case 82:
2471#line 676 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2472 {
2473 (yyval.RecList)->push_back((yyvsp[(2) - (2)].Rec));
2474;}
2475 break;
2476
2477 case 83:
2478#line 680 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2479 {
2480 MultiClass *&MCE = MultiClasses[*(yyvsp[(1) - (1)].StrVal)];
Chris Lattner27627382006-09-01 21:14:42 +00002481 if (MCE) {
Bill Wendlingf5da1332006-12-07 22:21:48 +00002482 err() << "multiclass '" << *(yyvsp[(1) - (1)].StrVal) << "' already defined!\n";
Chris Lattner27627382006-09-01 21:14:42 +00002483 exit(1);
2484 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00002485 MCE = CurMultiClass = new MultiClass(*(yyvsp[(1) - (1)].StrVal));
2486 delete (yyvsp[(1) - (1)].StrVal);
2487;}
2488 break;
2489
2490 case 84:
2491#line 691 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2492 {
Chris Lattner27627382006-09-01 21:14:42 +00002493 ParsingTemplateArgs = true;
Bill Wendlingf5da1332006-12-07 22:21:48 +00002494 ;}
2495 break;
2496
2497 case 85:
2498#line 693 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2499 {
Chris Lattner27627382006-09-01 21:14:42 +00002500 ParsingTemplateArgs = false;
Bill Wendlingf5da1332006-12-07 22:21:48 +00002501 ;}
2502 break;
2503
2504 case 86:
2505#line 695 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2506 {
Chris Lattner27627382006-09-01 21:14:42 +00002507 CurMultiClass = 0;
Bill Wendlingf5da1332006-12-07 22:21:48 +00002508;}
2509 break;
2510
2511 case 87:
2512#line 700 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2513 { CurDefmPrefix = (yyvsp[(2) - (2)].StrVal); ;}
2514 break;
2515
2516 case 88:
2517#line 700 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2518 {
Chris Lattner27627382006-09-01 21:14:42 +00002519 // To instantiate a multiclass, we need to first get the multiclass, then
2520 // instantiate each def contained in the multiclass with the SubClassRef
2521 // template parameters.
Bill Wendlingf5da1332006-12-07 22:21:48 +00002522 MultiClass *MC = MultiClasses[(yyvsp[(5) - (6)].SubClassRef)->first->getName()];
Chris Lattner27627382006-09-01 21:14:42 +00002523 assert(MC && "Didn't lookup multiclass correctly?");
Bill Wendlingf5da1332006-12-07 22:21:48 +00002524 std::vector<Init*> &TemplateVals = *(yyvsp[(5) - (6)].SubClassRef)->second;
2525 delete (yyvsp[(5) - (6)].SubClassRef);
Chris Lattner27627382006-09-01 21:14:42 +00002526
2527 // Verify that the correct number of template arguments were specified.
2528 const std::vector<std::string> &TArgs = MC->Rec.getTemplateArgs();
2529 if (TArgs.size() < TemplateVals.size()) {
2530 err() << "ERROR: More template args specified than multiclass expects!\n";
2531 exit(1);
2532 }
2533
2534 // Loop over all the def's in the multiclass, instantiating each one.
2535 for (unsigned i = 0, e = MC->DefPrototypes.size(); i != e; ++i) {
2536 Record *DefProto = MC->DefPrototypes[i];
2537
2538 // Add the suffix to the defm name to get the new name.
2539 assert(CurRec == 0 && "A def is current?");
Bill Wendlingf5da1332006-12-07 22:21:48 +00002540 CurRec = new Record(*(yyvsp[(2) - (6)].StrVal) + DefProto->getName());
Chris Lattner27627382006-09-01 21:14:42 +00002541
2542 addSubClass(DefProto, std::vector<Init*>());
2543
2544 // Loop over all of the template arguments, setting them to the specified
2545 // value or leaving them as the default if necessary.
2546 for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
2547 if (i < TemplateVals.size()) { // A value is specified for this temp-arg?
2548 // Set it now.
2549 setValue(TArgs[i], 0, TemplateVals[i]);
2550
2551 // Resolve it next.
2552 CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i]));
2553
2554 // Now remove it.
2555 CurRec->removeValue(TArgs[i]);
2556
2557 } else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) {
2558 err() << "ERROR: Value not specified for template argument #"
2559 << i << " (" << TArgs[i] << ") of multiclassclass '"
2560 << MC->Rec.getName() << "'!\n";
2561 exit(1);
2562 }
2563 }
2564
Chris Lattnerbcc3f0a2006-10-11 18:13:09 +00002565 // If the mdef is inside a 'let' expression, add to each def.
2566 for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
2567 for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
2568 setValue(LetStack[i][j].Name,
2569 LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0,
2570 LetStack[i][j].Value);
2571
2572
Chris Lattner27627382006-09-01 21:14:42 +00002573 // Ensure redefinition doesn't happen.
2574 if (Records.getDef(CurRec->getName())) {
2575 err() << "def '" << CurRec->getName() << "' already defined, "
Bill Wendlingf5da1332006-12-07 22:21:48 +00002576 << "instantiating defm '" << *(yyvsp[(2) - (6)].StrVal) << "' with subdef '"
Chris Lattner27627382006-09-01 21:14:42 +00002577 << DefProto->getName() << "'!\n";
2578 exit(1);
2579 }
2580 Records.addDef(CurRec);
Chris Lattner7717d092006-09-01 21:59:03 +00002581
2582 CurRec->resolveReferences();
2583
Chris Lattner27627382006-09-01 21:14:42 +00002584 CurRec = 0;
2585 }
2586
2587 delete &TemplateVals;
Bill Wendlingf5da1332006-12-07 22:21:48 +00002588 delete (yyvsp[(2) - (6)].StrVal);
Chris Lattnercce56af2006-09-01 22:07:27 +00002589 CurDefmPrefix = 0;
Bill Wendlingf5da1332006-12-07 22:21:48 +00002590;}
2591 break;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002592
Bill Wendlingf5da1332006-12-07 22:21:48 +00002593 case 89:
2594#line 774 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2595 {;}
2596 break;
2597
2598 case 90:
2599#line 774 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2600 {;}
2601 break;
2602
2603 case 93:
2604#line 777 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
Chris Lattner81779692006-03-30 22:51:12 +00002605 {
Bill Wendlingf5da1332006-12-07 22:21:48 +00002606 LetStack.back().push_back(LetRecord(*(yyvsp[(1) - (4)].StrVal), (yyvsp[(2) - (4)].BitList), (yyvsp[(4) - (4)].Initializer)));
2607 delete (yyvsp[(1) - (4)].StrVal); delete (yyvsp[(2) - (4)].BitList);
2608;}
2609 break;
2610
2611 case 96:
2612#line 785 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2613 { LetStack.push_back(std::vector<LetRecord>()); ;}
2614 break;
2615
2616 case 98:
2617#line 788 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2618 {
2619 LetStack.pop_back();
2620 ;}
2621 break;
2622
2623 case 99:
2624#line 791 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2625 {
2626 LetStack.pop_back();
2627 ;}
2628 break;
2629
2630 case 100:
2631#line 795 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2632 {;}
2633 break;
2634
2635 case 101:
2636#line 795 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
2637 {;}
2638 break;
2639
2640
2641/* Line 1267 of yacc.c. */
2642#line 2643 "FileParser.tab.c"
2643 default: break;
Chris Lattner81779692006-03-30 22:51:12 +00002644 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00002645 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2646
2647 YYPOPSTACK (yylen);
2648 yylen = 0;
2649 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002650
2651 *++yyvsp = yyval;
2652
2653
Bill Wendlingf5da1332006-12-07 22:21:48 +00002654 /* Now `shift' the result of the reduction. Determine what state
2655 that goes to, based on the state we popped back to and the rule
2656 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002657
2658 yyn = yyr1[yyn];
2659
Bill Wendlingf5da1332006-12-07 22:21:48 +00002660 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2661 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002662 yystate = yytable[yystate];
2663 else
Bill Wendlingf5da1332006-12-07 22:21:48 +00002664 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00002665
2666 goto yynewstate;
2667
2668
Bill Wendlingf5da1332006-12-07 22:21:48 +00002669/*------------------------------------.
2670| yyerrlab -- here on detecting error |
2671`------------------------------------*/
2672yyerrlab:
2673 /* If not already recovering from an error, report this error. */
2674 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002675 {
2676 ++yynerrs;
Bill Wendlingf5da1332006-12-07 22:21:48 +00002677#if ! YYERROR_VERBOSE
2678 yyerror (YY_("syntax error"));
2679#else
2680 {
2681 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2682 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2683 {
2684 YYSIZE_T yyalloc = 2 * yysize;
2685 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2686 yyalloc = YYSTACK_ALLOC_MAXIMUM;
2687 if (yymsg != yymsgbuf)
2688 YYSTACK_FREE (yymsg);
2689 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2690 if (yymsg)
2691 yymsg_alloc = yyalloc;
2692 else
2693 {
2694 yymsg = yymsgbuf;
2695 yymsg_alloc = sizeof yymsgbuf;
2696 }
2697 }
Chris Lattner81779692006-03-30 22:51:12 +00002698
Bill Wendlingf5da1332006-12-07 22:21:48 +00002699 if (0 < yysize && yysize <= yymsg_alloc)
2700 {
2701 (void) yysyntax_error (yymsg, yystate, yychar);
2702 yyerror (yymsg);
2703 }
2704 else
2705 {
2706 yyerror (YY_("syntax error"));
2707 if (yysize != 0)
2708 goto yyexhaustedlab;
2709 }
2710 }
2711#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002712 }
2713
Bill Wendlingf5da1332006-12-07 22:21:48 +00002714
Reid Spencer68a24bd2005-08-27 18:50:39 +00002715
2716 if (yyerrstatus == 3)
2717 {
Bill Wendlingf5da1332006-12-07 22:21:48 +00002718 /* If just tried and failed to reuse look-ahead token after an
2719 error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002720
Bill Wendlingf5da1332006-12-07 22:21:48 +00002721 if (yychar <= YYEOF)
2722 {
2723 /* Return failure if at end of input. */
2724 if (yychar == YYEOF)
2725 YYABORT;
2726 }
2727 else
2728 {
2729 yydestruct ("Error: discarding",
2730 yytoken, &yylval);
2731 yychar = YYEMPTY;
2732 }
2733 }
2734
2735 /* Else will try to reuse look-ahead token after shifting the error
2736 token. */
2737 goto yyerrlab1;
2738
2739
2740/*---------------------------------------------------.
2741| yyerrorlab -- error raised explicitly by YYERROR. |
2742`---------------------------------------------------*/
2743yyerrorlab:
2744
2745 /* Pacify compilers like GCC when the user code never invokes
2746 YYERROR and the label yyerrorlab therefore never appears in user
2747 code. */
2748 if (/*CONSTCOND*/ 0)
2749 goto yyerrorlab;
2750
2751 /* Do not reclaim the symbols of the rule which action triggered
2752 this YYERROR. */
2753 YYPOPSTACK (yylen);
2754 yylen = 0;
2755 YY_STACK_PRINT (yyss, yyssp);
2756 yystate = *yyssp;
2757 goto yyerrlab1;
2758
2759
2760/*-------------------------------------------------------------.
2761| yyerrlab1 -- common code for both syntax error and YYERROR. |
2762`-------------------------------------------------------------*/
2763yyerrlab1:
2764 yyerrstatus = 3; /* Each real token shifted decrements this. */
2765
2766 for (;;)
2767 {
2768 yyn = yypact[yystate];
2769 if (yyn != YYPACT_NINF)
2770 {
2771 yyn += YYTERROR;
2772 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2773 {
2774 yyn = yytable[yyn];
2775 if (0 < yyn)
2776 break;
2777 }
2778 }
2779
2780 /* Pop the current state because it cannot handle the error token. */
2781 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002782 YYABORT;
2783
Chris Lattnerba4b1442005-09-08 18:22:57 +00002784
Bill Wendlingf5da1332006-12-07 22:21:48 +00002785 yydestruct ("Error: popping",
2786 yystos[yystate], yyvsp);
2787 YYPOPSTACK (1);
2788 yystate = *yyssp;
2789 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002790 }
2791
2792 if (yyn == YYFINAL)
2793 YYACCEPT;
2794
Reid Spencer68a24bd2005-08-27 18:50:39 +00002795 *++yyvsp = yylval;
Bill Wendlingf5da1332006-12-07 22:21:48 +00002796
2797
2798 /* Shift the error token. */
2799 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002800
2801 yystate = yyn;
2802 goto yynewstate;
2803
John Criswelld7881242006-01-17 17:01:34 +00002804
Bill Wendlingf5da1332006-12-07 22:21:48 +00002805/*-------------------------------------.
2806| yyacceptlab -- YYACCEPT comes here. |
2807`-------------------------------------*/
2808yyacceptlab:
2809 yyresult = 0;
2810 goto yyreturn;
2811
2812/*-----------------------------------.
2813| yyabortlab -- YYABORT comes here. |
2814`-----------------------------------*/
2815yyabortlab:
2816 yyresult = 1;
2817 goto yyreturn;
2818
2819#ifndef yyoverflow
2820/*-------------------------------------------------.
2821| yyexhaustedlab -- memory exhaustion comes here. |
2822`-------------------------------------------------*/
2823yyexhaustedlab:
2824 yyerror (YY_("memory exhausted"));
2825 yyresult = 2;
2826 /* Fall through. */
John Criswelld7881242006-01-17 17:01:34 +00002827#endif
Bill Wendlingf5da1332006-12-07 22:21:48 +00002828
2829yyreturn:
2830 if (yychar != YYEOF && yychar != YYEMPTY)
2831 yydestruct ("Cleanup: discarding lookahead",
2832 yytoken, &yylval);
2833 /* Do not reclaim the symbols of the rule which action triggered
2834 this YYABORT or YYACCEPT. */
2835 YYPOPSTACK (yylen);
2836 YY_STACK_PRINT (yyss, yyssp);
2837 while (yyssp != yyss)
2838 {
2839 yydestruct ("Cleanup: popping",
2840 yystos[*yyssp], yyvsp);
2841 YYPOPSTACK (1);
Chris Lattner81779692006-03-30 22:51:12 +00002842 }
Bill Wendlingf5da1332006-12-07 22:21:48 +00002843#ifndef yyoverflow
2844 if (yyss != yyssa)
2845 YYSTACK_FREE (yyss);
2846#endif
2847#if YYERROR_VERBOSE
2848 if (yymsg != yymsgbuf)
2849 YYSTACK_FREE (yymsg);
2850#endif
2851 /* Make sure YYID is used. */
2852 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002853}
Bill Wendlingf5da1332006-12-07 22:21:48 +00002854
2855
2856#line 799 "/Volumes/Gir/devel/llvm/llvm.src/utils/TableGen/FileParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002857
2858
2859int yyerror(const char *ErrorMsg) {
2860 err() << "Error parsing: " << ErrorMsg << "\n";
2861 exit(1);
2862}
Bill Wendlingf5da1332006-12-07 22:21:48 +00002863