1 /* A Bison parser, made from itbl-parse.y
4 #define YYBISON 1 /* Identify Bison output. */
17 #line 21 "itbl-parse.y"
22 Yacc grammar for instruction table entries.
24 =======================================================================
25 Original Instruction table specification document:
27 MIPS Coprocessor Table Specification
28 ====================================
30 This document describes the format of the MIPS coprocessor table. The
31 table specifies a list of valid functions, data registers and control
32 registers that can be used in coprocessor instructions. This list,
33 together with the coprocessor instruction classes listed below,
34 specifies the complete list of coprocessor instructions that will
35 be recognized and assembled by the GNU assembler. In effect,
36 this makes the GNU assembler table-driven, where the table is
37 specified by the programmer.
39 The table is an ordinary text file that the GNU assembler reads when
40 it starts. Using the information in the table, the assembler
41 generates an internal list of valid coprocessor registers and
42 functions. The assembler uses this internal list in addition to the
43 standard MIPS registers and instructions which are built-in to the
44 assembler during code generation.
46 To specify the coprocessor table when invoking the GNU assembler, use
47 the command line option "--itbl file", where file is the
48 complete name of the table, including path and extension.
52 gas -t cop.tbl test.s -o test.o
53 gas -t /usr/local/lib/cop.tbl test.s -o test.o
54 gas --itbl d:\gnu\data\cop.tbl test.s -o test.o
56 Only one table may be supplied during a single invocation of
63 Below is a list of the valid coprocessor instruction classes for
64 any given coprocessor "z". These instructions are already recognized
65 by the assembler, and are listed here only for reference.
67 Class format instructions
68 -------------------------------------------------
99 The coprocessor table defines coprocessor-specific registers that can
100 be used with all of the above classes of instructions, where
101 appropriate. It also defines additional coprocessor-specific
102 functions for Class3 (COPz cofun) instructions, Thus, the table allows
103 the programmer to use convenient mnemonics and operands for these
104 functions, instead of the COPz mmenmonic and cofun operand.
106 The names of the MIPS general registers and their aliases are defined
107 by the assembler and will be recognized as valid register names by the
108 assembler when used (where allowed) in coprocessor instructions.
109 However, the names and values of all coprocessor data and control
110 register mnemonics must be specified in the coprocessor table.
116 Here is the grammar for the coprocessor table:
120 entry -> [z entrydef] [comment] '\n'
122 entrydef -> type name val
123 entrydef -> 'insn' name val funcdef ; type of entry (instruction)
125 z -> 'p'['0'..'3'] ; processor number
126 type -> ['dreg' | 'creg' | 'greg' ] ; type of entry (register)
127 ; 'dreg', 'creg' or 'greg' specifies a data, control, or general
128 ; register mnemonic, respectively
129 name -> [ltr|dec]* ; mnemonic of register/function
130 val -> [dec|hex] ; register/function number (integer constant)
132 funcdef -> frange flags fields
133 ; bitfield range for opcode
134 ; list of fields' formats
136 field -> [','] ftype frange flags
137 flags -> ['*' flagexpr]
138 flagexpr -> '[' flagexpr ']'
139 flagexpr -> val '|' flagexpr
140 ftype -> [ type | 'immed' | 'addr' ]
141 ; 'immed' specifies an immediate value; see grammar for "val" above
142 ; 'addr' specifies a C identifier; name of symbol to be resolved at
144 frange -> ':' val '-' val ; starting to ending bit positions, where
145 ; where 0 is least significant bit
146 frange -> (null) ; default range of 31-0 will be assumed
148 comment -> [';'|'#'] [char]*
149 char -> any printable character
150 ltr -> ['a'..'z'|'A'..'Z']
151 dec -> ['0'..'9']* ; value in decimal
152 hex -> '0x'['0'..'9' | 'a'..'f' | 'A'..'F']* ; value in hexidecimal
162 p1 dreg d1 1 ; data register "d1" for COP1 has value 1
163 p1 creg c3 3 ; ctrl register "c3" for COP1 has value 3
164 p3 func fill 0x1f:24-20 ; function "fill" for COP3 has value 31 and
167 will allow the assembler to accept the following coprocessor instructions:
172 Here, the general purpose register "$2", and instruction "LWC1", are standard
173 mnemonics built-in to the MIPS assembler.
180 p3 dreg d3 3 ; data register "d3" for COP3 has value 3
181 p3 creg c2 22 ; control register "c2" for COP3 has value 22
182 p3 func fee 0x1f:24-20 dreg:17-13 creg:12-8 immed:7-0
183 ; function "fee" for COP3 has value 31, and 3 fields
184 ; consisting of a data register, a control register,
185 ; and an immediate value.
187 will allow the assembler to accept the following coprocessor instruction:
191 and will emit the object code:
193 31-26 25 24-20 19-18 17-13 12-8 7-0
194 COPz CO fun dreg creg immed
195 010011 1 11111 00 00011 10110 00000001
204 p3 dreg d3 3 ; data register "d3" for COP3 has value 3
205 p3 creg c2 22 ; control register "c2" for COP3 has value 22
206 p3 func fuu 0x01f00001 dreg:17-13 creg:12-8
208 will allow the assembler to accept the following coprocessor
213 and will emit the object code:
215 31-26 25 24-20 19-18 17-13 12-8 7-0
216 COPz CO fun dreg creg
217 010011 1 11111 00 00011 10110 00000001
221 In this way, the programmer can force arbitrary bits of an instruction
222 to have predefined values.
224 =======================================================================
228 To handle more than one bit position range within an instruction,
229 use 0s to mask out the ranges which don't apply.
230 May decide to modify the syntax to allow commas separate multiple
231 ranges within an instruction (range','range).
234 The number of parms argument to the function entry
235 was deleted from the original format such that we now count the fields.
238 FIXME! should really change lexical analyzer
239 to recognize 'dreg' etc. in context sensative way.
240 Currently function names or mnemonics may be incorrectly parsed as keywords
242 FIXME! hex is ambiguous with any digit
247 #include "itbl-ops.h"
260 #define DBG(x) printf x
266 #define DBGL2(x) printf x
271 static int sbit
, ebit
;
272 static struct itbl_entry
*insn
=0;
273 extern int insntbl_line
;
274 int yyparse
PARAMS ((void));
275 int yylex
PARAMS ((void));
276 static int yyerror
PARAMS ((const char *));
279 #line 283 "itbl-parse.y"
288 # define YYSTYPE yystype
297 #define YYFLAG -32768
300 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
301 #define YYTRANSLATE(x) ((unsigned)(x) <= 266 ? yytranslate[x] : 34)
303 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
304 static const char yytranslate
[] =
306 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
307 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
308 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
309 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
310 2, 2, 17, 2, 13, 19, 2, 2, 2, 2,
311 2, 2, 2, 2, 2, 2, 2, 2, 18, 2,
312 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
313 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
314 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
315 2, 15, 2, 16, 2, 2, 2, 2, 2, 2,
316 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
317 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
318 2, 2, 2, 2, 14, 2, 2, 2, 2, 2,
319 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
320 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
321 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
322 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
323 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
324 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
325 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
326 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
327 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
328 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
329 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
330 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
331 2, 2, 2, 2, 2, 2, 1, 3, 4, 5,
332 6, 7, 8, 9, 10, 11, 12
336 static const short yyprhs
[] =
338 0, 0, 2, 5, 6, 12, 13, 23, 25, 28,
339 32, 35, 36, 38, 40, 42, 46, 50, 54, 56,
340 59, 60, 65, 66, 68, 70, 72, 74, 76, 78
342 static const short yyrhs
[] =
344 21, 0, 22, 21, 0, 0, 30, 31, 32, 33,
345 11, 0, 0, 30, 8, 32, 33, 29, 28, 23,
346 24, 11, 0, 11, 0, 1, 11, 0, 13, 26,
347 24, 0, 26, 24, 0, 0, 31, 0, 7, 0,
348 6, 0, 25, 29, 28, 0, 9, 14, 27, 0,
349 15, 27, 16, 0, 9, 0, 17, 27, 0, 0,
350 18, 9, 19, 9, 0, 0, 12, 0, 3, 0,
351 4, 0, 5, 0, 10, 0, 9, 0, 9, 0
357 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
358 static const short yyrline
[] =
360 0, 300, 304, 306, 309, 316, 316, 324, 325, 328,
361 330, 331, 334, 340, 345, 352, 361, 366, 370, 376,
362 382, 388, 395, 402, 410, 416, 421, 428, 436, 444
367 #if (YYDEBUG) || defined YYERROR_VERBOSE
369 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
370 static const char *const yytname
[] =
372 "$", "error", "$undefined.", "DREG", "CREG", "GREG", "IMMED", "ADDR",
373 "INSN", "NUM", "ID", "NL", "PNUM", "','", "'|'", "'['", "']'", "'*'",
374 "':'", "'-'", "insntbl", "entrys", "entry", "@1", "fieldspecs", "ftype",
375 "fieldspec", "flagexpr", "flags", "range", "pnum", "regtype", "name",
380 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
381 static const short yyr1
[] =
383 0, 20, 21, 21, 22, 23, 22, 22, 22, 24,
384 24, 24, 25, 25, 25, 26, 27, 27, 27, 28,
385 28, 29, 29, 30, 31, 31, 31, 32, 34, 33
388 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
389 static const short yyr2
[] =
391 0, 1, 2, 0, 5, 0, 9, 1, 2, 3,
392 2, 0, 1, 1, 1, 3, 3, 3, 1, 2,
393 0, 4, 0, 1, 1, 1, 1, 1, 1, 1
396 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
397 doesn't specify something else to do. Zero means the default is an
399 static const short yydefact
[] =
401 0, 0, 7, 23, 1, 0, 0, 8, 2, 24,
402 25, 26, 0, 0, 27, 0, 0, 29, 22, 0,
403 0, 20, 4, 0, 0, 5, 0, 18, 0, 19,
404 11, 21, 0, 0, 14, 13, 0, 0, 22, 11,
405 12, 16, 17, 11, 6, 20, 10, 9, 15, 0,
409 static const short yydefgoto
[] =
411 49, 4, 5, 30, 37, 38, 39, 29, 25, 21,
415 static const short yypact
[] =
417 0, -9,-32768,-32768,-32768, 0, 12,-32768,-32768,-32768,
418 -32768,-32768, 3, 3,-32768, 9, 9,-32768, -8, 8,
419 19, 15,-32768, 10, -6,-32768, 24, 20, -6,-32768,
420 1,-32768, -6, 21,-32768,-32768, 18, 25, -8, 1,
421 -32768,-32768,-32768, 1,-32768, 15,-32768,-32768,-32768, 35,
425 static const short yypgoto
[] =
427 -32768, 34,-32768,-32768, -13,-32768, 4, -1, -4, 5,
435 static const short yytable
[] =
437 -3, 1, 7, 27, 9, 10, 11, 34, 35, 28,
438 20, 2, 3, 14, 36, 9, 10, 11, 17, 22,
439 12, 9, 10, 11, 34, 35, 46, 33, 23, 26,
440 47, 41, 24, 31, 32, 50, 44, 42, 51, 8,
441 43, 48, 13, 45, 16, 19
444 static const short yycheck
[] =
446 0, 1, 11, 9, 3, 4, 5, 6, 7, 15,
447 18, 11, 12, 10, 13, 3, 4, 5, 9, 11,
448 8, 3, 4, 5, 6, 7, 39, 28, 9, 19,
449 43, 32, 17, 9, 14, 0, 11, 16, 0, 5,
450 36, 45, 6, 38, 13, 16
452 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
453 #line 3 "/usr/share/bison/bison.simple"
455 /* Skeleton output parser for bison,
457 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
460 This program is free software; you can redistribute it and/or modify
461 it under the terms of the GNU General Public License as published by
462 the Free Software Foundation; either version 2, or (at your option)
465 This program is distributed in the hope that it will be useful,
466 but WITHOUT ANY WARRANTY; without even the implied warranty of
467 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
468 GNU General Public License for more details.
470 You should have received a copy of the GNU General Public License
471 along with this program; if not, write to the Free Software
472 Foundation, Inc., 59 Temple Place - Suite 330,
473 Boston, MA 02111-1307, USA. */
475 /* As a special exception, when this file is copied by Bison into a
476 Bison output file, you may use that output file without restriction.
477 This special exception was added by the Free Software Foundation
478 in version 1.24 of Bison. */
480 /* This is the parser code that is written into each bison parser when
481 the %semantic_parser declaration is not specified in the grammar.
482 It was written by Richard Stallman by simplifying the hairy parser
483 used when %semantic_parser is specified. */
485 /* All symbols defined below should begin with yy or YY, to avoid
486 infringing on user name space. This should be done even for local
487 variables, as they might otherwise be expanded by user macros.
488 There are some unavoidable exceptions within include files to
489 define necessary library symbols; they are noted "INFRINGES ON
490 USER NAME SPACE" below. */
493 # define YYSTD(x) std::x
498 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
500 /* The parser invokes alloca or malloc; define the necessary symbols. */
502 # if YYSTACK_USE_ALLOCA
503 # define YYSTACK_ALLOC alloca
505 # ifndef YYSTACK_USE_ALLOCA
506 # if defined (alloca) || defined (_ALLOCA_H)
507 # define YYSTACK_ALLOC alloca
510 # define YYSTACK_ALLOC __builtin_alloca
516 # ifdef YYSTACK_ALLOC
517 /* Pacify GCC's `empty if-body' warning. */
518 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
521 # include <cstdlib> /* INFRINGES ON USER NAME SPACE */
522 # define YYSIZE_T std::size_t
525 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
526 # define YYSIZE_T size_t
529 # define YYSTACK_ALLOC YYSTD (malloc)
530 # define YYSTACK_FREE YYSTD (free)
533 /* A type that is properly aligned for any stack member. */
543 /* The size of the maximum gap between one aligned stack and the next. */
544 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
546 /* The size of an array large to enough to hold all stacks, each with
549 # define YYSTACK_BYTES(N) \
550 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
551 + 2 * YYSTACK_GAP_MAX)
553 # define YYSTACK_BYTES(N) \
554 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
558 /* Relocate the TYPE STACK from its old location to the new one. The
559 local variables YYSIZE and YYSTACKSIZE give the old and new number of
560 elements in the stack, and YYPTR gives the new location of the
561 stack. Advance YYPTR to a properly aligned location for the next
563 # define YYSTACK_RELOCATE(Type, Stack) \
566 YYSIZE_T yynewbytes; \
567 yymemcpy ((char *) yyptr, (char *) (Stack), \
568 yysize * (YYSIZE_T) sizeof (Type)); \
569 Stack = &yyptr->Stack; \
570 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
571 yyptr += yynewbytes / sizeof (*yyptr); \
575 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
578 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
579 # define YYSIZE_T __SIZE_TYPE__
581 #if ! defined (YYSIZE_T) && defined (size_t)
582 # define YYSIZE_T size_t
584 #if ! defined (YYSIZE_T)
586 # include <cstddef> /* INFRINGES ON USER NAME SPACE */
587 # define YYSIZE_T std::size_t
590 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
591 # define YYSIZE_T size_t
595 #if ! defined (YYSIZE_T)
596 # define YYSIZE_T unsigned int
599 #define yyerrok (yyerrstatus = 0)
600 #define yyclearin (yychar = YYEMPTY)
603 #define YYACCEPT goto yyacceptlab
604 #define YYABORT goto yyabortlab
605 #define YYERROR goto yyerrlab1
606 /* Like YYERROR except do call yyerror. This remains here temporarily
607 to ease the transition to the new meaning of YYERROR, for GCC.
608 Once GCC version 2 has supplanted version 1, this can go. */
609 #define YYFAIL goto yyerrlab
610 #define YYRECOVERING() (!!yyerrstatus)
611 #define YYBACKUP(Token, Value) \
613 if (yychar == YYEMPTY && yylen == 1) \
617 yychar1 = YYTRANSLATE (yychar); \
623 yyerror ("syntax error: cannot back up"); \
629 #define YYERRCODE 256
632 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
635 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
636 first token. By default, to implement support for ranges, extend
637 its range to the last symbol. */
639 #ifndef YYLLOC_DEFAULT
640 # define YYLLOC_DEFAULT(Current, Rhs, N) \
641 Current.last_line = Rhs[N].last_line; \
642 Current.last_column = Rhs[N].last_column;
646 /* YYLEX -- calling `yylex' with the right arguments. */
651 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
653 # define YYLEX yylex (&yylval, &yylloc)
655 # else /* !YYLSP_NEEDED */
657 # define YYLEX yylex (&yylval, YYLEX_PARAM)
659 # define YYLEX yylex (&yylval)
661 # endif /* !YYLSP_NEEDED */
663 # define YYLEX yylex ()
667 /* Enable debugging if requested. */
672 # include <cstdio> /* INFRINGES ON USER NAME SPACE */
674 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
676 # define YYFPRINTF YYSTD (fprintf)
679 # define YYDPRINTF(Args) \
684 /* Nonzero means print parse trace. [The following comment makes no
685 sense to me. Could someone clarify it? --akim] Since this is
686 uninitialized, it does not stop multiple parsers from coexisting.
690 # define YYDPRINTF(Args)
691 #endif /* !YYDEBUG */
693 /* YYINITDEPTH -- initial size of the parser's stacks. */
695 # define YYINITDEPTH 200
698 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
699 if the built-in stack extension method is used).
701 Do not make this value too large; the results are undefined if
702 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
703 evaluated with infinite-precision integer arithmetic. */
710 # define YYMAXDEPTH 10000
713 #if ! defined (yyoverflow) && ! defined (yymemcpy)
714 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
715 # define yymemcpy __builtin_memcpy
716 # else /* not GNU C or C++ */
718 /* This is the most reliable way to avoid incompatibilities
719 in available built-in functions on various systems. */
721 # if defined (__STDC__) || defined (__cplusplus)
722 yymemcpy (char *yyto
, const char *yyfrom
, YYSIZE_T yycount
)
724 yymemcpy (yyto
, yyfrom
, yycount
)
730 register const char *yyf
= yyfrom
;
731 register char *yyt
= yyto
;
732 register YYSIZE_T yyi
= yycount
;
740 #ifdef YYERROR_VERBOSE
743 # if defined (__GLIBC__) && defined (_STRING_H)
744 # define yystrlen strlen
746 /* Return the length of YYSTR. */
748 # if defined (__STDC__) || defined (__cplusplus)
749 yystrlen (const char *yystr
)
755 register const char *yys
= yystr
;
757 while (*yys
++ != '\0')
760 return yys
- yystr
- 1;
766 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
767 # define yystpcpy stpcpy
769 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
772 # if defined (__STDC__) || defined (__cplusplus)
773 yystpcpy (char *yydest
, const char *yysrc
)
775 yystpcpy (yydest
, yysrc
)
780 register char *yyd
= yydest
;
781 register const char *yys
= yysrc
;
783 while ((*yyd
++ = *yys
++) != '\0')
792 #line 341 "/usr/share/bison/bison.simple"
795 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
796 into yyparse. The argument should have type void *.
797 It should actually point to an object.
798 Grammar actions can access the variable by casting it
799 to the proper pointer type. */
803 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
804 # define YYPARSE_PARAM_DECL
805 # else /* !__cplusplus */
806 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
807 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
808 # endif /* !__cplusplus */
809 #else /* !YYPARSE_PARAM */
810 # define YYPARSE_PARAM_ARG
811 # define YYPARSE_PARAM_DECL
812 #endif /* !YYPARSE_PARAM */
814 /* Prevent warning if -Wstrict-prototypes. */
816 # ifdef YYPARSE_PARAM
817 int yyparse (void *);
823 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
824 variables are global, or local to YYPARSE. */
826 #define YY_DECL_NON_LSP_VARIABLES \
827 /* The lookahead symbol. */ \
830 /* The semantic value of the lookahead symbol. */ \
833 /* Number of parse errors so far. */ \
837 # define YY_DECL_VARIABLES \
838 YY_DECL_NON_LSP_VARIABLES \
840 /* Location data for the lookahead symbol. */ \
843 # define YY_DECL_VARIABLES \
844 YY_DECL_NON_LSP_VARIABLES
848 /* If nonreentrant, generate the variables here. */
855 yyparse (YYPARSE_PARAM_ARG
)
858 /* If reentrant, generate the variables here. */
863 register int yystate
;
866 /* Number of tokens to shift before error messages enabled. */
868 /* Lookahead token as an internal (translated) token number. */
871 /* Three stacks and their tools:
872 `yyss': related to states,
873 `yyvs': related to semantic values,
874 `yyls': related to locations.
876 Refer to the stacks thru separate pointers, to allow yyoverflow
877 to reallocate them elsewhere. */
879 /* The state stack. */
880 short yyssa
[YYINITDEPTH
];
882 register short *yyssp
;
884 /* The semantic value stack. */
885 YYSTYPE yyvsa
[YYINITDEPTH
];
886 YYSTYPE
*yyvs
= yyvsa
;
887 register YYSTYPE
*yyvsp
;
890 /* The location stack. */
891 YYLTYPE yylsa
[YYINITDEPTH
];
892 YYLTYPE
*yyls
= yylsa
;
897 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
899 # define YYPOPSTACK (yyvsp--, yyssp--)
902 YYSIZE_T yystacksize
= YYINITDEPTH
;
905 /* The variables used to return semantic value and location from the
912 /* When reducing, the number of symbols on the RHS of the reduced
916 YYDPRINTF ((stderr
, "Starting parse\n"));
921 yychar
= YYEMPTY
; /* Cause a token to be read. */
923 /* Initialize stack pointers.
924 Waste one element of value and location stack
925 so that they stay on the same level as the state stack.
926 The wasted elements are never initialized. */
935 /*------------------------------------------------------------.
936 | yynewstate -- Push a new state, which is found in yystate. |
937 `------------------------------------------------------------*/
939 /* In all cases, when you get here, the value and location stacks
940 have just been pushed. so pushing a state here evens the stacks.
947 if (yyssp
>= yyss
+ yystacksize
- 1)
949 /* Get the current used size of the three stacks, in elements. */
950 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
954 /* Give user a chance to reallocate the stack. Use copies of
955 these so that the &'s don't force the real ones into
957 YYSTYPE
*yyvs1
= yyvs
;
960 /* Each stack pointer address is followed by the size of the
961 data in use in that stack, in bytes. */
963 YYLTYPE
*yyls1
= yyls
;
964 /* This used to be a conditional around just the two extra args,
965 but that might be undefined if yyoverflow is a macro. */
966 yyoverflow ("parser stack overflow",
967 &yyss1
, yysize
* sizeof (*yyssp
),
968 &yyvs1
, yysize
* sizeof (*yyvsp
),
969 &yyls1
, yysize
* sizeof (*yylsp
),
973 yyoverflow ("parser stack overflow",
974 &yyss1
, yysize
* sizeof (*yyssp
),
975 &yyvs1
, yysize
* sizeof (*yyvsp
),
981 #else /* no yyoverflow */
982 /* Extend the stack our own way. */
983 if (yystacksize
>= YYMAXDEPTH
)
986 if (yystacksize
> YYMAXDEPTH
)
987 yystacksize
= YYMAXDEPTH
;
991 union yyalloc
*yyptr
=
992 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
995 YYSTACK_RELOCATE (short, yyss
);
996 YYSTACK_RELOCATE (YYSTYPE
, yyvs
);
998 YYSTACK_RELOCATE (YYLTYPE
, yyls
);
1000 # undef YYSTACK_RELOCATE
1002 YYSTACK_FREE (yyss1
);
1004 #endif /* no yyoverflow */
1006 yyssp
= yyss
+ yysize
- 1;
1007 yyvsp
= yyvs
+ yysize
- 1;
1009 yylsp
= yyls
+ yysize
- 1;
1012 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1013 (unsigned long int) yystacksize
));
1015 if (yyssp
>= yyss
+ yystacksize
- 1)
1019 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1029 /* Do appropriate processing given the current state. */
1030 /* Read a lookahead token if we need one and don't already have one. */
1033 /* First try to decide what to do without reference to lookahead token. */
1035 yyn
= yypact
[yystate
];
1039 /* Not known => get a lookahead token if don't already have one. */
1041 /* yychar is either YYEMPTY or YYEOF
1042 or a valid token in external form. */
1044 if (yychar
== YYEMPTY
)
1046 YYDPRINTF ((stderr
, "Reading a token: "));
1050 /* Convert token to internal form (in yychar1) for indexing tables with */
1052 if (yychar
<= 0) /* This means end of input. */
1055 yychar
= YYEOF
; /* Don't call YYLEX any more */
1057 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1061 yychar1
= YYTRANSLATE (yychar
);
1064 /* We have to keep this `#if YYDEBUG', since we use variables
1065 which are defined only if `YYDEBUG' is set. */
1068 YYFPRINTF (stderr
, "Next token is %d (%s",
1069 yychar
, yytname
[yychar1
]);
1070 /* Give the individual parser a way to print the precise
1071 meaning of a token, for further debugging info. */
1073 YYPRINT (stderr
, yychar
, yylval
);
1075 YYFPRINTF (stderr
, ")\n");
1081 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
1086 /* yyn is what to do for this token type in this state.
1087 Negative => reduce, -yyn is rule number.
1088 Positive => shift, yyn is new state.
1089 New state is final state => don't bother to shift,
1090 just return success.
1091 0, or most negative number => error. */
1106 /* Shift the lookahead token. */
1107 YYDPRINTF ((stderr
, "Shifting token %d (%s), ",
1108 yychar
, yytname
[yychar1
]));
1110 /* Discard the token being shifted unless it is eof. */
1111 if (yychar
!= YYEOF
)
1119 /* Count tokens shifted since error; after three, turn off error
1128 /*-----------------------------------------------------------.
1129 | yydefault -- do the default action for the current state. |
1130 `-----------------------------------------------------------*/
1132 yyn
= yydefact
[yystate
];
1138 /*-----------------------------.
1139 | yyreduce -- Do a reduction. |
1140 `-----------------------------*/
1142 /* yyn is the number of a rule to reduce with. */
1145 /* If YYLEN is nonzero, implement the default value of the action:
1148 Otherwise, the following line sets YYVAL to the semantic value of
1149 the lookahead token. This behavior is undocumented and Bison
1150 users should not rely upon it. Assigning to YYVAL
1151 unconditionally makes the parser a bit smaller, and it avoids a
1152 GCC warning that YYVAL may be used uninitialized. */
1153 yyval
= yyvsp
[1-yylen
];
1156 /* Similarly for the default location. Let the user run additional
1157 commands if for instance locations are ranges. */
1158 yyloc
= yylsp
[1-yylen
];
1159 YYLLOC_DEFAULT (yyloc
, (yylsp
- yylen
), yylen
);
1163 /* We have to keep this `#if YYDEBUG', since we use variables which
1164 are defined only if `YYDEBUG' is set. */
1169 YYFPRINTF (stderr
, "Reducing via rule %d (line %d), ",
1172 /* Print the symbols being reduced, and their result. */
1173 for (yyi
= yyprhs
[yyn
]; yyrhs
[yyi
] > 0; yyi
++)
1174 YYFPRINTF (stderr
, "%s ", yytname
[yyrhs
[yyi
]]);
1175 YYFPRINTF (stderr
, " -> %s\n", yytname
[yyr1
[yyn
]]);
1182 #line 311 "itbl-parse.y"
1184 DBG (("line %d: entry pnum=%d type=%d name=%s value=x%x\n",
1185 insntbl_line
, yyvsp
[-4].num
, yyvsp
[-3].num
, yyvsp
[-2].str
, yyvsp
[-1].val
));
1186 itbl_add_reg (yyvsp
[-4].num
, yyvsp
[-3].num
, yyvsp
[-2].str
, yyvsp
[-1].val
);
1190 #line 317 "itbl-parse.y"
1192 DBG (("line %d: entry pnum=%d type=INSN name=%s value=x%x",
1193 insntbl_line
, yyvsp
[-5].num
, yyvsp
[-3].str
, yyvsp
[-2].val
));
1194 DBG ((" sbit=%d ebit=%d flags=0x%x\n", sbit
, ebit
, yyvsp
[0].val
));
1195 insn
=itbl_add_insn (yyvsp
[-5].num
, yyvsp
[-3].str
, yyvsp
[-2].val
, sbit
, ebit
, yyvsp
[0].val
);
1199 #line 336 "itbl-parse.y"
1201 DBGL2 (("ftype\n"));
1202 yyval
.num
= yyvsp
[0].num
;
1206 #line 341 "itbl-parse.y"
1213 #line 346 "itbl-parse.y"
1215 DBGL2 (("immed\n"));
1220 #line 354 "itbl-parse.y"
1222 DBG (("line %d: field type=%d sbit=%d ebit=%d, flags=0x%x\n",
1223 insntbl_line
, yyvsp
[-2].num
, sbit
, ebit
, yyvsp
[0].val
));
1224 itbl_add_operand (insn
, yyvsp
[-2].num
, sbit
, ebit
, yyvsp
[0].val
);
1228 #line 363 "itbl-parse.y"
1230 yyval
.val
= yyvsp
[-2].num
| yyvsp
[0].val
;
1234 #line 367 "itbl-parse.y"
1236 yyval
.val
= yyvsp
[-1].val
;
1240 #line 371 "itbl-parse.y"
1242 yyval
.val
= yyvsp
[0].num
;
1246 #line 378 "itbl-parse.y"
1248 DBGL2 (("flags=%d\n", yyvsp
[0].val
));
1249 yyval
.val
= yyvsp
[0].val
;
1253 #line 383 "itbl-parse.y"
1259 #line 390 "itbl-parse.y"
1261 DBGL2 (("range %d %d\n", yyvsp
[-2].num
, yyvsp
[0].num
));
1262 sbit
= yyvsp
[-2].num
;
1263 ebit
= yyvsp
[0].num
;
1267 #line 396 "itbl-parse.y"
1274 #line 404 "itbl-parse.y"
1276 DBGL2 (("pnum=%d\n",yyvsp
[0].num
));
1277 yyval
.num
= yyvsp
[0].num
;
1281 #line 412 "itbl-parse.y"
1288 #line 417 "itbl-parse.y"
1295 #line 422 "itbl-parse.y"
1302 #line 430 "itbl-parse.y"
1304 DBGL2 (("name=%s\n",yyvsp
[0].str
));
1305 yyval
.str
= yyvsp
[0].str
;
1309 #line 438 "itbl-parse.y"
1311 DBGL2 (("num=%d\n",yyvsp
[0].num
));
1312 yyval
.num
= yyvsp
[0].num
;
1316 #line 446 "itbl-parse.y"
1318 DBGL2 (("val=x%x\n",yyvsp
[0].num
));
1319 yyval
.val
= yyvsp
[0].num
;
1324 #line 727 "/usr/share/bison/bison.simple"
1336 short *yyssp1
= yyss
- 1;
1337 YYFPRINTF (stderr
, "state stack now");
1338 while (yyssp1
!= yyssp
)
1339 YYFPRINTF (stderr
, " %d", *++yyssp1
);
1340 YYFPRINTF (stderr
, "\n");
1349 /* Now `shift' the result of the reduction. Determine what state
1350 that goes to, based on the state we popped back to and the rule
1351 number reduced by. */
1355 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1356 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1357 yystate
= yytable
[yystate
];
1359 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1364 /*------------------------------------.
1365 | yyerrlab -- here on detecting error |
1366 `------------------------------------*/
1368 /* If not already recovering from an error, report this error. */
1373 #ifdef YYERROR_VERBOSE
1374 yyn
= yypact
[yystate
];
1376 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
1378 YYSIZE_T yysize
= 0;
1383 /* Start YYX at -YYN if negative to avoid negative indexes in
1385 for (yyx
= yyn
< 0 ? -yyn
: 0;
1386 yyx
< (int) (sizeof (yytname
) / sizeof (char *)); yyx
++)
1387 if (yycheck
[yyx
+ yyn
] == yyx
)
1388 yysize
+= yystrlen (yytname
[yyx
]) + 15, yycount
++;
1389 yysize
+= yystrlen ("parse error, unexpected ") + 1;
1390 yysize
+= yystrlen (yytname
[YYTRANSLATE (yychar
)]);
1391 yymsg
= (char *) YYSTACK_ALLOC (yysize
);
1394 char *yyp
= yystpcpy (yymsg
, "parse error, unexpected ");
1395 yyp
= yystpcpy (yyp
, yytname
[YYTRANSLATE (yychar
)]);
1400 for (yyx
= yyn
< 0 ? -yyn
: 0;
1401 yyx
< (int) (sizeof (yytname
) / sizeof (char *));
1403 if (yycheck
[yyx
+ yyn
] == yyx
)
1405 const char *yyq
= ! yycount
? ", expecting " : " or ";
1406 yyp
= yystpcpy (yyp
, yyq
);
1407 yyp
= yystpcpy (yyp
, yytname
[yyx
]);
1412 YYSTACK_FREE (yymsg
);
1415 yyerror ("parse error; also virtual memory exhausted");
1418 #endif /* defined (YYERROR_VERBOSE) */
1419 yyerror ("parse error");
1424 /*--------------------------------------------------.
1425 | yyerrlab1 -- error raised explicitly by an action |
1426 `--------------------------------------------------*/
1428 if (yyerrstatus
== 3)
1430 /* If just tried and failed to reuse lookahead token after an
1431 error, discard it. */
1433 /* return failure if at end of input */
1434 if (yychar
== YYEOF
)
1436 YYDPRINTF ((stderr
, "Discarding token %d (%s).\n",
1437 yychar
, yytname
[yychar1
]));
1441 /* Else will try to reuse lookahead token after shifting the error
1444 yyerrstatus
= 3; /* Each real token shifted decrements this */
1449 /*-------------------------------------------------------------------.
1450 | yyerrdefault -- current state does not do anything special for the |
1452 `-------------------------------------------------------------------*/
1455 /* This is wrong; only states that explicitly want error tokens
1456 should shift them. */
1458 /* If its default is to accept any token, ok. Otherwise pop it. */
1459 yyn
= yydefact
[yystate
];
1465 /*---------------------------------------------------------------.
1466 | yyerrpop -- pop the current state because it cannot handle the |
1468 `---------------------------------------------------------------*/
1481 short *yyssp1
= yyss
- 1;
1482 YYFPRINTF (stderr
, "Error: state stack now");
1483 while (yyssp1
!= yyssp
)
1484 YYFPRINTF (stderr
, " %d", *++yyssp1
);
1485 YYFPRINTF (stderr
, "\n");
1493 yyn
= yypact
[yystate
];
1498 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1515 YYDPRINTF ((stderr
, "Shifting error token, "));
1526 /*-------------------------------------.
1527 | yyacceptlab -- YYACCEPT comes here. |
1528 `-------------------------------------*/
1533 /*-----------------------------------.
1534 | yyabortlab -- YYABORT comes here. |
1535 `-----------------------------------*/
1540 /*---------------------------------------------.
1541 | yyoverflowab -- parser overflow comes here. |
1542 `---------------------------------------------*/
1544 yyerror ("parser stack overflow");
1551 YYSTACK_FREE (yyss
);
1555 #line 451 "itbl-parse.y"
1562 printf ("line %d: %s\n", insntbl_line
, msg
);