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 hexadecimal
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 sensitive 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
289
# define YYSTYPE_IS_TRIVIAL 1
298
#define YYFLAG -32768
301
/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
302
#define YYTRANSLATE(x) ((unsigned)(x) <= 266 ? yytranslate[x] : 34)
304
/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
305
static const char yytranslate[] =
307
0, 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, 2, 2, 2, 2, 2, 2, 2, 2,
311
2, 2, 17, 2, 13, 19, 2, 2, 2, 2,
312
2, 2, 2, 2, 2, 2, 2, 2, 18, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2,
316
2, 15, 2, 16, 2, 2, 2, 2, 2, 2,
317
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
318
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
319
2, 2, 2, 2, 14, 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, 2, 2, 2, 2,
332
2, 2, 2, 2, 2, 2, 1, 3, 4, 5,
333
6, 7, 8, 9, 10, 11, 12
337
static const short yyprhs[] =
339
0, 0, 2, 5, 6, 12, 13, 23, 25, 28,
340
32, 35, 36, 38, 40, 42, 46, 50, 54, 56,
341
59, 60, 65, 66, 68, 70, 72, 74, 76, 78
343
static const short yyrhs[] =
345
21, 0, 22, 21, 0, 0, 30, 31, 32, 33,
346
11, 0, 0, 30, 8, 32, 33, 29, 28, 23,
347
24, 11, 0, 11, 0, 1, 11, 0, 13, 26,
348
24, 0, 26, 24, 0, 0, 31, 0, 7, 0,
349
6, 0, 25, 29, 28, 0, 9, 14, 27, 0,
350
15, 27, 16, 0, 9, 0, 17, 27, 0, 0,
351
18, 9, 19, 9, 0, 0, 12, 0, 3, 0,
352
4, 0, 5, 0, 10, 0, 9, 0, 9, 0
358
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
359
static const short yyrline[] =
361
0, 300, 304, 306, 309, 316, 316, 325, 326, 329,
362
331, 332, 335, 341, 346, 353, 362, 367, 371, 377,
363
383, 389, 396, 403, 411, 417, 422, 429, 437, 445
368
#if (YYDEBUG) || defined YYERROR_VERBOSE
370
/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
371
static const char *const yytname[] =
373
"$", "error", "$undefined.", "DREG", "CREG", "GREG", "IMMED", "ADDR",
374
"INSN", "NUM", "ID", "NL", "PNUM", "','", "'|'", "'['", "']'", "'*'",
375
"':'", "'-'", "insntbl", "entrys", "entry", "@1", "fieldspecs", "ftype",
376
"fieldspec", "flagexpr", "flags", "range", "pnum", "regtype", "name",
381
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
382
static const short yyr1[] =
384
0, 20, 21, 21, 22, 23, 22, 22, 22, 24,
385
24, 24, 25, 25, 25, 26, 27, 27, 27, 28,
386
28, 29, 29, 30, 31, 31, 31, 32, 34, 33
389
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
390
static const short yyr2[] =
392
0, 1, 2, 0, 5, 0, 9, 1, 2, 3,
393
2, 0, 1, 1, 1, 3, 3, 3, 1, 2,
394
0, 4, 0, 1, 1, 1, 1, 1, 1, 1
397
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
398
doesn't specify something else to do. Zero means the default is an
400
static const short yydefact[] =
402
0, 0, 7, 23, 1, 0, 0, 8, 2, 24,
403
25, 26, 0, 0, 27, 0, 0, 29, 22, 0,
404
0, 20, 4, 0, 0, 5, 0, 18, 0, 19,
405
11, 21, 0, 0, 14, 13, 0, 0, 22, 11,
406
12, 16, 17, 11, 6, 20, 10, 9, 15, 0,
410
static const short yydefgoto[] =
412
49, 4, 5, 30, 37, 38, 39, 29, 25, 21,
416
static const short yypact[] =
418
0, -9,-32768,-32768,-32768, 0, 12,-32768,-32768,-32768,
419
-32768,-32768, 3, 3,-32768, 9, 9,-32768, -8, 8,
420
19, 15,-32768, 10, -6,-32768, 24, 20, -6,-32768,
421
1,-32768, -6, 21,-32768,-32768, 18, 25, -8, 1,
422
-32768,-32768,-32768, 1,-32768, 15,-32768,-32768,-32768, 35,
426
static const short yypgoto[] =
428
-32768, 34,-32768,-32768, -13,-32768, 4, -1, -4, 5,
436
static const short yytable[] =
438
-3, 1, 7, 27, 9, 10, 11, 34, 35, 28,
439
20, 2, 3, 14, 36, 9, 10, 11, 17, 22,
440
12, 9, 10, 11, 34, 35, 46, 33, 23, 26,
441
47, 41, 24, 31, 32, 50, 44, 42, 51, 8,
442
43, 48, 13, 45, 16, 19
445
static const short yycheck[] =
447
0, 1, 11, 9, 3, 4, 5, 6, 7, 15,
448
18, 11, 12, 10, 13, 3, 4, 5, 9, 11,
449
8, 3, 4, 5, 6, 7, 39, 28, 9, 19,
450
43, 32, 17, 9, 14, 0, 11, 16, 0, 5,
451
36, 45, 6, 38, 13, 16
453
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
454
#line 3 "/usr/share/bison-1.35/bison.simple"
456
/* Skeleton output parser for bison,
458
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
461
This program is free software; you can redistribute it and/or modify
462
it under the terms of the GNU General Public License as published by
463
the Free Software Foundation; either version 2, or (at your option)
466
This program is distributed in the hope that it will be useful,
467
but WITHOUT ANY WARRANTY; without even the implied warranty of
468
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
469
GNU General Public License for more details.
471
You should have received a copy of the GNU General Public License
472
along with this program; if not, write to the Free Software
473
Foundation, Inc., 59 Temple Place - Suite 330,
474
Boston, MA 02111-1307, USA. */
476
/* As a special exception, when this file is copied by Bison into a
477
Bison output file, you may use that output file without restriction.
478
This special exception was added by the Free Software Foundation
479
in version 1.24 of Bison. */
481
/* This is the parser code that is written into each bison parser when
482
the %semantic_parser declaration is not specified in the grammar.
483
It was written by Richard Stallman by simplifying the hairy parser
484
used when %semantic_parser is specified. */
486
/* All symbols defined below should begin with yy or YY, to avoid
487
infringing on user name space. This should be done even for local
488
variables, as they might otherwise be expanded by user macros.
489
There are some unavoidable exceptions within include files to
490
define necessary library symbols; they are noted "INFRINGES ON
491
USER NAME SPACE" below. */
493
#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
495
/* The parser invokes alloca or malloc; define the necessary symbols. */
497
# if YYSTACK_USE_ALLOCA
498
# define YYSTACK_ALLOC alloca
500
# ifndef YYSTACK_USE_ALLOCA
501
# if defined (alloca) || defined (_ALLOCA_H)
502
# define YYSTACK_ALLOC alloca
505
# define YYSTACK_ALLOC __builtin_alloca
511
# ifdef YYSTACK_ALLOC
512
/* Pacify GCC's `empty if-body' warning. */
513
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
515
# if defined (__STDC__) || defined (__cplusplus)
516
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
517
# define YYSIZE_T size_t
519
# define YYSTACK_ALLOC malloc
520
# define YYSTACK_FREE free
522
#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
525
#if (! defined (yyoverflow) \
526
&& (! defined (__cplusplus) \
527
|| (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
529
/* A type that is properly aligned for any stack member. */
539
/* The size of the maximum gap between one aligned stack and the next. */
540
# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
542
/* The size of an array large to enough to hold all stacks, each with
545
# define YYSTACK_BYTES(N) \
546
((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
547
+ 2 * YYSTACK_GAP_MAX)
549
# define YYSTACK_BYTES(N) \
550
((N) * (sizeof (short) + sizeof (YYSTYPE)) \
554
/* Copy COUNT objects from FROM to TO. The source and destination do
558
# define YYCOPY(To, From, Count) \
559
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
561
# define YYCOPY(To, From, Count) \
564
register YYSIZE_T yyi; \
565
for (yyi = 0; yyi < (Count); yyi++) \
566
(To)[yyi] = (From)[yyi]; \
572
/* Relocate STACK from its old location to the new one. The
573
local variables YYSIZE and YYSTACKSIZE give the old and new number of
574
elements in the stack, and YYPTR gives the new location of the
575
stack. Advance YYPTR to a properly aligned location for the next
577
# define YYSTACK_RELOCATE(Stack) \
580
YYSIZE_T yynewbytes; \
581
YYCOPY (&yyptr->Stack, Stack, yysize); \
582
Stack = &yyptr->Stack; \
583
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
584
yyptr += yynewbytes / sizeof (*yyptr); \
591
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
592
# define YYSIZE_T __SIZE_TYPE__
594
#if ! defined (YYSIZE_T) && defined (size_t)
595
# define YYSIZE_T size_t
597
#if ! defined (YYSIZE_T)
598
# if defined (__STDC__) || defined (__cplusplus)
599
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
600
# define YYSIZE_T size_t
603
#if ! defined (YYSIZE_T)
604
# define YYSIZE_T unsigned int
607
#define yyerrok (yyerrstatus = 0)
608
#define yyclearin (yychar = YYEMPTY)
611
#define YYACCEPT goto yyacceptlab
612
#define YYABORT goto yyabortlab
613
#define YYERROR goto yyerrlab1
614
/* Like YYERROR except do call yyerror. This remains here temporarily
615
to ease the transition to the new meaning of YYERROR, for GCC.
616
Once GCC version 2 has supplanted version 1, this can go. */
617
#define YYFAIL goto yyerrlab
618
#define YYRECOVERING() (!!yyerrstatus)
619
#define YYBACKUP(Token, Value) \
621
if (yychar == YYEMPTY && yylen == 1) \
625
yychar1 = YYTRANSLATE (yychar); \
631
yyerror ("syntax error: cannot back up"); \
637
#define YYERRCODE 256
640
/* YYLLOC_DEFAULT -- Compute the default location (before the actions
643
When YYLLOC_DEFAULT is run, CURRENT is set the location of the
644
first token. By default, to implement support for ranges, extend
645
its range to the last symbol. */
647
#ifndef YYLLOC_DEFAULT
648
# define YYLLOC_DEFAULT(Current, Rhs, N) \
649
Current.last_line = Rhs[N].last_line; \
650
Current.last_column = Rhs[N].last_column;
654
/* YYLEX -- calling `yylex' with the right arguments. */
659
# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
661
# define YYLEX yylex (&yylval, &yylloc)
663
# else /* !YYLSP_NEEDED */
665
# define YYLEX yylex (&yylval, YYLEX_PARAM)
667
# define YYLEX yylex (&yylval)
669
# endif /* !YYLSP_NEEDED */
671
# define YYLEX yylex ()
675
/* Enable debugging if requested. */
679
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
680
# define YYFPRINTF fprintf
683
# define YYDPRINTF(Args) \
688
/* Nonzero means print parse trace. It is left uninitialized so that
689
multiple parsers can coexist. */
692
# define YYDPRINTF(Args)
693
#endif /* !YYDEBUG */
695
/* YYINITDEPTH -- initial size of the parser's stacks. */
697
# define YYINITDEPTH 200
700
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
701
if the built-in stack extension method is used).
703
Do not make this value too large; the results are undefined if
704
SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
705
evaluated with infinite-precision integer arithmetic. */
712
# define YYMAXDEPTH 10000
715
#ifdef YYERROR_VERBOSE
718
# if defined (__GLIBC__) && defined (_STRING_H)
719
# define yystrlen strlen
721
/* Return the length of YYSTR. */
723
# if defined (__STDC__) || defined (__cplusplus)
724
yystrlen (const char *yystr)
730
register const char *yys = yystr;
732
while (*yys++ != '\0')
735
return yys - yystr - 1;
741
# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
742
# define yystpcpy stpcpy
744
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
747
# if defined (__STDC__) || defined (__cplusplus)
748
yystpcpy (char *yydest, const char *yysrc)
750
yystpcpy (yydest, yysrc)
755
register char *yyd = yydest;
756
register const char *yys = yysrc;
758
while ((*yyd++ = *yys++) != '\0')
767
#line 315 "/usr/share/bison-1.35/bison.simple"
770
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
771
into yyparse. The argument should have type void *.
772
It should actually point to an object.
773
Grammar actions can access the variable by casting it
774
to the proper pointer type. */
777
# if defined (__STDC__) || defined (__cplusplus)
778
# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
779
# define YYPARSE_PARAM_DECL
781
# define YYPARSE_PARAM_ARG YYPARSE_PARAM
782
# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
784
#else /* !YYPARSE_PARAM */
785
# define YYPARSE_PARAM_ARG
786
# define YYPARSE_PARAM_DECL
787
#endif /* !YYPARSE_PARAM */
789
/* Prevent warning if -Wstrict-prototypes. */
791
# ifdef YYPARSE_PARAM
792
int yyparse (void *);
798
/* YY_DECL_VARIABLES -- depending whether we use a pure parser,
799
variables are global, or local to YYPARSE. */
801
#define YY_DECL_NON_LSP_VARIABLES \
802
/* The lookahead symbol. */ \
805
/* The semantic value of the lookahead symbol. */ \
808
/* Number of parse errors so far. */ \
812
# define YY_DECL_VARIABLES \
813
YY_DECL_NON_LSP_VARIABLES \
815
/* Location data for the lookahead symbol. */ \
818
# define YY_DECL_VARIABLES \
819
YY_DECL_NON_LSP_VARIABLES
823
/* If nonreentrant, generate the variables here. */
830
yyparse (YYPARSE_PARAM_ARG)
833
/* If reentrant, generate the variables here. */
838
register int yystate;
841
/* Number of tokens to shift before error messages enabled. */
843
/* Lookahead token as an internal (translated) token number. */
846
/* Three stacks and their tools:
847
`yyss': related to states,
848
`yyvs': related to semantic values,
849
`yyls': related to locations.
851
Refer to the stacks thru separate pointers, to allow yyoverflow
852
to reallocate them elsewhere. */
854
/* The state stack. */
855
short yyssa[YYINITDEPTH];
857
register short *yyssp;
859
/* The semantic value stack. */
860
YYSTYPE yyvsa[YYINITDEPTH];
861
YYSTYPE *yyvs = yyvsa;
862
register YYSTYPE *yyvsp;
865
/* The location stack. */
866
YYLTYPE yylsa[YYINITDEPTH];
867
YYLTYPE *yyls = yylsa;
872
# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
874
# define YYPOPSTACK (yyvsp--, yyssp--)
877
YYSIZE_T yystacksize = YYINITDEPTH;
880
/* The variables used to return semantic value and location from the
887
/* When reducing, the number of symbols on the RHS of the reduced
891
YYDPRINTF ((stderr, "Starting parse\n"));
896
yychar = YYEMPTY; /* Cause a token to be read. */
898
/* Initialize stack pointers.
899
Waste one element of value and location stack
900
so that they stay on the same level as the state stack.
901
The wasted elements are never initialized. */
910
/*------------------------------------------------------------.
911
| yynewstate -- Push a new state, which is found in yystate. |
912
`------------------------------------------------------------*/
914
/* In all cases, when you get here, the value and location stacks
915
have just been pushed. so pushing a state here evens the stacks.
922
if (yyssp >= yyss + yystacksize - 1)
924
/* Get the current used size of the three stacks, in elements. */
925
YYSIZE_T yysize = yyssp - yyss + 1;
929
/* Give user a chance to reallocate the stack. Use copies of
930
these so that the &'s don't force the real ones into
932
YYSTYPE *yyvs1 = yyvs;
935
/* Each stack pointer address is followed by the size of the
936
data in use in that stack, in bytes. */
938
YYLTYPE *yyls1 = yyls;
939
/* This used to be a conditional around just the two extra args,
940
but that might be undefined if yyoverflow is a macro. */
941
yyoverflow ("parser stack overflow",
942
&yyss1, yysize * sizeof (*yyssp),
943
&yyvs1, yysize * sizeof (*yyvsp),
944
&yyls1, yysize * sizeof (*yylsp),
948
yyoverflow ("parser stack overflow",
949
&yyss1, yysize * sizeof (*yyssp),
950
&yyvs1, yysize * sizeof (*yyvsp),
956
#else /* no yyoverflow */
957
# ifndef YYSTACK_RELOCATE
960
/* Extend the stack our own way. */
961
if (yystacksize >= YYMAXDEPTH)
964
if (yystacksize > YYMAXDEPTH)
965
yystacksize = YYMAXDEPTH;
969
union yyalloc *yyptr =
970
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
973
YYSTACK_RELOCATE (yyss);
974
YYSTACK_RELOCATE (yyvs);
976
YYSTACK_RELOCATE (yyls);
978
# undef YYSTACK_RELOCATE
980
YYSTACK_FREE (yyss1);
983
#endif /* no yyoverflow */
985
yyssp = yyss + yysize - 1;
986
yyvsp = yyvs + yysize - 1;
988
yylsp = yyls + yysize - 1;
991
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
992
(unsigned long int) yystacksize));
994
if (yyssp >= yyss + yystacksize - 1)
998
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1008
/* Do appropriate processing given the current state. */
1009
/* Read a lookahead token if we need one and don't already have one. */
1012
/* First try to decide what to do without reference to lookahead token. */
1014
yyn = yypact[yystate];
1018
/* Not known => get a lookahead token if don't already have one. */
1020
/* yychar is either YYEMPTY or YYEOF
1021
or a valid token in external form. */
1023
if (yychar == YYEMPTY)
1025
YYDPRINTF ((stderr, "Reading a token: "));
1029
/* Convert token to internal form (in yychar1) for indexing tables with */
1031
if (yychar <= 0) /* This means end of input. */
1034
yychar = YYEOF; /* Don't call YYLEX any more */
1036
YYDPRINTF ((stderr, "Now at end of input.\n"));
1040
yychar1 = YYTRANSLATE (yychar);
1043
/* We have to keep this `#if YYDEBUG', since we use variables
1044
which are defined only if `YYDEBUG' is set. */
1047
YYFPRINTF (stderr, "Next token is %d (%s",
1048
yychar, yytname[yychar1]);
1049
/* Give the individual parser a way to print the precise
1050
meaning of a token, for further debugging info. */
1052
YYPRINT (stderr, yychar, yylval);
1054
YYFPRINTF (stderr, ")\n");
1060
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
1065
/* yyn is what to do for this token type in this state.
1066
Negative => reduce, -yyn is rule number.
1067
Positive => shift, yyn is new state.
1068
New state is final state => don't bother to shift,
1069
just return success.
1070
0, or most negative number => error. */
1085
/* Shift the lookahead token. */
1086
YYDPRINTF ((stderr, "Shifting token %d (%s), ",
1087
yychar, yytname[yychar1]));
1089
/* Discard the token being shifted unless it is eof. */
1090
if (yychar != YYEOF)
1098
/* Count tokens shifted since error; after three, turn off error
1107
/*-----------------------------------------------------------.
1108
| yydefault -- do the default action for the current state. |
1109
`-----------------------------------------------------------*/
1111
yyn = yydefact[yystate];
1117
/*-----------------------------.
1118
| yyreduce -- Do a reduction. |
1119
`-----------------------------*/
1121
/* yyn is the number of a rule to reduce with. */
1124
/* If YYLEN is nonzero, implement the default value of the action:
1127
Otherwise, the following line sets YYVAL to the semantic value of
1128
the lookahead token. This behavior is undocumented and Bison
1129
users should not rely upon it. Assigning to YYVAL
1130
unconditionally makes the parser a bit smaller, and it avoids a
1131
GCC warning that YYVAL may be used uninitialized. */
1132
yyval = yyvsp[1-yylen];
1135
/* Similarly for the default location. Let the user run additional
1136
commands if for instance locations are ranges. */
1137
yyloc = yylsp[1-yylen];
1138
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1142
/* We have to keep this `#if YYDEBUG', since we use variables which
1143
are defined only if `YYDEBUG' is set. */
1148
YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
1151
/* Print the symbols being reduced, and their result. */
1152
for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
1153
YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
1154
YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1161
#line 311 "itbl-parse.y"
1163
DBG (("line %d: entry pnum=%d type=%d name=%s value=x%x\n",
1164
insntbl_line, yyvsp[-4].num, yyvsp[-3].num, yyvsp[-2].str, yyvsp[-1].val));
1165
itbl_add_reg (yyvsp[-4].num, yyvsp[-3].num, yyvsp[-2].str, yyvsp[-1].val);
1169
#line 317 "itbl-parse.y"
1171
DBG (("line %d: entry pnum=%d type=INSN name=%s value=x%x",
1172
insntbl_line, yyvsp[-5].num, yyvsp[-3].str, yyvsp[-2].val));
1173
DBG ((" sbit=%d ebit=%d flags=0x%x\n", sbit, ebit, yyvsp[0].val));
1174
insn=itbl_add_insn (yyvsp[-5].num, yyvsp[-3].str, yyvsp[-2].val, sbit, ebit, yyvsp[0].val);
1178
#line 324 "itbl-parse.y"
1182
#line 337 "itbl-parse.y"
1184
DBGL2 (("ftype\n"));
1185
yyval.num = yyvsp[0].num;
1189
#line 342 "itbl-parse.y"
1196
#line 347 "itbl-parse.y"
1198
DBGL2 (("immed\n"));
1203
#line 355 "itbl-parse.y"
1205
DBG (("line %d: field type=%d sbit=%d ebit=%d, flags=0x%x\n",
1206
insntbl_line, yyvsp[-2].num, sbit, ebit, yyvsp[0].val));
1207
itbl_add_operand (insn, yyvsp[-2].num, sbit, ebit, yyvsp[0].val);
1211
#line 364 "itbl-parse.y"
1213
yyval.val = yyvsp[-2].num | yyvsp[0].val;
1217
#line 368 "itbl-parse.y"
1219
yyval.val = yyvsp[-1].val;
1223
#line 372 "itbl-parse.y"
1225
yyval.val = yyvsp[0].num;
1229
#line 379 "itbl-parse.y"
1231
DBGL2 (("flags=%d\n", yyvsp[0].val));
1232
yyval.val = yyvsp[0].val;
1236
#line 384 "itbl-parse.y"
1242
#line 391 "itbl-parse.y"
1244
DBGL2 (("range %d %d\n", yyvsp[-2].num, yyvsp[0].num));
1245
sbit = yyvsp[-2].num;
1246
ebit = yyvsp[0].num;
1250
#line 397 "itbl-parse.y"
1257
#line 405 "itbl-parse.y"
1259
DBGL2 (("pnum=%d\n",yyvsp[0].num));
1260
yyval.num = yyvsp[0].num;
1264
#line 413 "itbl-parse.y"
1271
#line 418 "itbl-parse.y"
1278
#line 423 "itbl-parse.y"
1285
#line 431 "itbl-parse.y"
1287
DBGL2 (("name=%s\n",yyvsp[0].str));
1288
yyval.str = yyvsp[0].str;
1292
#line 439 "itbl-parse.y"
1294
DBGL2 (("num=%d\n",yyvsp[0].num));
1295
yyval.num = yyvsp[0].num;
1299
#line 447 "itbl-parse.y"
1301
DBGL2 (("val=x%x\n",yyvsp[0].num));
1302
yyval.val = yyvsp[0].num;
1307
#line 705 "/usr/share/bison-1.35/bison.simple"
1319
short *yyssp1 = yyss - 1;
1320
YYFPRINTF (stderr, "state stack now");
1321
while (yyssp1 != yyssp)
1322
YYFPRINTF (stderr, " %d", *++yyssp1);
1323
YYFPRINTF (stderr, "\n");
1332
/* Now `shift' the result of the reduction. Determine what state
1333
that goes to, based on the state we popped back to and the rule
1334
number reduced by. */
1338
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1339
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1340
yystate = yytable[yystate];
1342
yystate = yydefgoto[yyn - YYNTBASE];
1347
/*------------------------------------.
1348
| yyerrlab -- here on detecting error |
1349
`------------------------------------*/
1351
/* If not already recovering from an error, report this error. */
1356
#ifdef YYERROR_VERBOSE
1357
yyn = yypact[yystate];
1359
if (yyn > YYFLAG && yyn < YYLAST)
1361
YYSIZE_T yysize = 0;
1366
/* Start YYX at -YYN if negative to avoid negative indexes in
1368
for (yyx = yyn < 0 ? -yyn : 0;
1369
yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1370
if (yycheck[yyx + yyn] == yyx)
1371
yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1372
yysize += yystrlen ("parse error, unexpected ") + 1;
1373
yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
1374
yymsg = (char *) YYSTACK_ALLOC (yysize);
1377
char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1378
yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
1383
for (yyx = yyn < 0 ? -yyn : 0;
1384
yyx < (int) (sizeof (yytname) / sizeof (char *));
1386
if (yycheck[yyx + yyn] == yyx)
1388
const char *yyq = ! yycount ? ", expecting " : " or ";
1389
yyp = yystpcpy (yyp, yyq);
1390
yyp = yystpcpy (yyp, yytname[yyx]);
1395
YYSTACK_FREE (yymsg);
1398
yyerror ("parse error; also virtual memory exhausted");
1401
#endif /* defined (YYERROR_VERBOSE) */
1402
yyerror ("parse error");
1407
/*--------------------------------------------------.
1408
| yyerrlab1 -- error raised explicitly by an action |
1409
`--------------------------------------------------*/
1411
if (yyerrstatus == 3)
1413
/* If just tried and failed to reuse lookahead token after an
1414
error, discard it. */
1416
/* return failure if at end of input */
1417
if (yychar == YYEOF)
1419
YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1420
yychar, yytname[yychar1]));
1424
/* Else will try to reuse lookahead token after shifting the error
1427
yyerrstatus = 3; /* Each real token shifted decrements this */
1432
/*-------------------------------------------------------------------.
1433
| yyerrdefault -- current state does not do anything special for the |
1435
`-------------------------------------------------------------------*/
1438
/* This is wrong; only states that explicitly want error tokens
1439
should shift them. */
1441
/* If its default is to accept any token, ok. Otherwise pop it. */
1442
yyn = yydefact[yystate];
1448
/*---------------------------------------------------------------.
1449
| yyerrpop -- pop the current state because it cannot handle the |
1451
`---------------------------------------------------------------*/
1464
short *yyssp1 = yyss - 1;
1465
YYFPRINTF (stderr, "Error: state stack now");
1466
while (yyssp1 != yyssp)
1467
YYFPRINTF (stderr, " %d", *++yyssp1);
1468
YYFPRINTF (stderr, "\n");
1476
yyn = yypact[yystate];
1481
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1498
YYDPRINTF ((stderr, "Shifting error token, "));
1509
/*-------------------------------------.
1510
| yyacceptlab -- YYACCEPT comes here. |
1511
`-------------------------------------*/
1516
/*-----------------------------------.
1517
| yyabortlab -- YYABORT comes here. |
1518
`-----------------------------------*/
1523
/*---------------------------------------------.
1524
| yyoverflowab -- parser overflow comes here. |
1525
`---------------------------------------------*/
1527
yyerror ("parser stack overflow");
1534
YYSTACK_FREE (yyss);
1538
#line 452 "itbl-parse.y"
1545
printf ("line %d: %s\n", insntbl_line, msg);