xref: /openbsd-src/gnu/usr.bin/binutils/gas/itbl-parse.c (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1 
2 /*  A Bison parser, made from itbl-parse.y
3     by GNU Bison version 1.28  */
4 
5 #define YYBISON 1  /* Identify Bison output.  */
6 
7 #define	DREG	257
8 #define	CREG	258
9 #define	GREG	259
10 #define	IMMED	260
11 #define	ADDR	261
12 #define	INSN	262
13 #define	NUM	263
14 #define	ID	264
15 #define	NL	265
16 #define	PNUM	266
17 
18 #line 21 "itbl-parse.y"
19 
20 
21 /*
22 
23 Yacc grammar for instruction table entries.
24 
25 =======================================================================
26 Original Instruction table specification document:
27 
28 	    MIPS Coprocessor Table Specification
29 	    ====================================
30 
31 This document describes the format of the MIPS coprocessor table.  The
32 table specifies a list of valid functions, data registers and control
33 registers that can be used in coprocessor instructions.  This list,
34 together with the coprocessor instruction classes listed below,
35 specifies the complete list of coprocessor instructions that will
36 be recognized and assembled by the GNU assembler.  In effect,
37 this makes the GNU assembler table-driven, where the table is
38 specified by the programmer.
39 
40 The table is an ordinary text file that the GNU assembler reads when
41 it starts.  Using the information in the table, the assembler
42 generates an internal list of valid coprocessor registers and
43 functions.  The assembler uses this internal list in addition to the
44 standard MIPS registers and instructions which are built-in to the
45 assembler during code generation.
46 
47 To specify the coprocessor table when invoking the GNU assembler, use
48 the command line option "--itbl file", where file is the
49 complete name of the table, including path and extension.
50 
51 Examples:
52 
53 	    gas -t cop.tbl test.s -o test.o
54 	    gas -t /usr/local/lib/cop.tbl test.s -o test.o
55 	    gas --itbl d:\gnu\data\cop.tbl test.s -o test.o
56 
57 Only one table may be supplied during a single invocation of
58 the assembler.
59 
60 
61 Instruction classes
62 ===================
63 
64 Below is a list of the valid coprocessor instruction classes for
65 any given coprocessor "z".  These instructions are already recognized
66 by the assembler, and are listed here only for reference.
67 
68 Class   format	    	    	      instructions
69 -------------------------------------------------
70 Class1:
71 	op base rt offset
72 	    	    	    	    	    	    	    LWCz rt,offset (base)
73 	    	    	    	    	    	    	    SWCz rt,offset (base)
74 Class2:
75 	COPz sub rt rd 0
76 	    	    	    	    	    	    	    MTCz rt,rd
77 	    	    	    	    	    	    	    MFCz rt,rd
78 	    	    	    	    	    	    	    CTCz rt,rd
79 	    	    	    	    	    	    	    CFCz rt,rd
80 Class3:
81 	COPz CO cofun
82 	    	    	    	    	    	    	    COPz cofun
83 Class4:
84 	COPz BC br offset
85 	    	    	    	    	    	    	    BCzT offset
86 	    	    	    	    	    	    	    BCzF offset
87 Class5:
88 	COPz sub rt rd 0
89 	    	    	    	    	    	    	    DMFCz rt,rd
90 	    	    	    	    	    	    	    DMTCz rt,rd
91 Class6:
92 	op base rt offset
93 	    	    	    	    	    	    	    LDCz rt,offset (base)
94 	    	    	    	    	    	    	    SDCz rt,offset (base)
95 Class7:
96 	COPz BC br offset
97 	    	    	    	    	    	    	    BCzTL offset
98 	    	    	    	    	    	    	    BCzFL offset
99 
100 The coprocessor table defines coprocessor-specific registers that can
101 be used with all of the above classes of instructions, where
102 appropriate.  It also defines additional coprocessor-specific
103 functions for Class3 (COPz cofun) instructions, Thus, the table allows
104 the programmer to use convenient mnemonics and operands for these
105 functions, instead of the COPz mmenmonic and cofun operand.
106 
107 The names of the MIPS general registers and their aliases are defined
108 by the assembler and will be recognized as valid register names by the
109 assembler when used (where allowed) in coprocessor instructions.
110 However, the names and values of all coprocessor data and control
111 register mnemonics must be specified in the coprocessor table.
112 
113 
114 Table Grammar
115 =============
116 
117 Here is the grammar for the coprocessor table:
118 
119 	    table -> entry*
120 
121 	    entry -> [z entrydef] [comment] '\n'
122 
123 	    entrydef -> type name val
124 	    entrydef -> 'insn' name val funcdef ; type of entry (instruction)
125 
126 	    z -> 'p'['0'..'3']	    	     ; processor number
127 	    type -> ['dreg' | 'creg' | 'greg' ]	     ; type of entry (register)
128 	; 'dreg', 'creg' or 'greg' specifies a data, control, or general
129 	;	    register mnemonic, respectively
130 	    name -> [ltr|dec]*	    	     ; mnemonic of register/function
131 	    val -> [dec|hex]	    	     ; register/function number (integer constant)
132 
133 	    funcdef -> frange flags fields
134 	    	    	    	; bitfield range for opcode
135 	    	    	    	; list of fields' formats
136 	    fields -> field*
137 	    field -> [','] ftype frange flags
138 	    flags -> ['*' flagexpr]
139 	    flagexpr -> '[' flagexpr ']'
140 	    flagexpr -> val '|' flagexpr
141 	    ftype -> [ type | 'immed' | 'addr' ]
142 	; 'immed' specifies an immediate value; see grammar for "val" above
143 	    	; 'addr' specifies a C identifier; name of symbol to be resolved at
144 	;	    link time
145 	    frange -> ':' val '-' val	; starting to ending bit positions, where
146 	    	    	    	; where 0 is least significant bit
147 	    frange -> (null)	    	; default range of 31-0 will be assumed
148 
149 	    comment -> [';'|'#'] [char]*
150 	    char -> any printable character
151 	    ltr -> ['a'..'z'|'A'..'Z']
152 	    dec -> ['0'..'9']*	    	    	    	    	     ; value in decimal
153 	    hex -> '0x'['0'..'9' | 'a'..'f' | 'A'..'F']*	; value in hexidecimal
154 
155 
156 Examples
157 ========
158 
159 Example 1:
160 
161 The table:
162 
163 	    p1 dreg d1 1	     ; data register "d1" for COP1 has value 1
164 	    p1 creg c3 3	     ; ctrl register "c3" for COP1 has value 3
165 	    p3 func fill 0x1f:24-20	      ; function "fill" for COP3 has value 31 and
166 	    	    	; no fields
167 
168 will allow the assembler to accept the following coprocessor instructions:
169 
170 	    LWC1 d1,0x100 ($2)
171 	    fill
172 
173 Here, the general purpose register "$2", and instruction "LWC1", are standard
174 mnemonics built-in to the MIPS assembler.
175 
176 
177 Example 2:
178 
179 The table:
180 
181 	    p3 dreg d3 3	     ; data register "d3" for COP3 has value 3
182 	    p3 creg c2 22	     ; control register "c2" for COP3 has value 22
183 	    p3 func fee 0x1f:24-20 dreg:17-13 creg:12-8 immed:7-0
184 	    	; function "fee" for COP3 has value 31, and 3 fields
185 	    	; consisting of a data register, a control register,
186 	    	; and an immediate value.
187 
188 will allow the assembler to accept the following coprocessor instruction:
189 
190 	    fee d3,c2,0x1
191 
192 and will emit the object code:
193 
194 	    31-26  25 24-20 19-18  17-13 12-8  7-0
195 	    COPz   CO fun	    	      dreg  creg  immed
196 	    010011 1  11111 00	     00011 10110 00000001
197 
198 	    0x4ff07601
199 
200 
201 Example 3:
202 
203 The table:
204 
205 	    p3 dreg d3 3	     ; data register "d3" for COP3 has value 3
206 	    p3 creg c2 22	     ; control register "c2" for COP3 has value 22
207 	    p3 func fuu 0x01f00001 dreg:17-13 creg:12-8
208 
209 will allow the assembler to accept the following coprocessor
210 instruction:
211 
212 	    fuu d3,c2
213 
214 and will emit the object code:
215 
216 	    31-26  25 24-20 19-18  17-13 12-8  7-0
217 	    COPz   CO fun	    	      dreg  creg
218 	    010011 1  11111 00	     00011 10110 00000001
219 
220 	    0x4ff07601
221 
222 In this way, the programmer can force arbitrary bits of an instruction
223 to have predefined values.
224 
225 =======================================================================
226 Additional notes:
227 
228 Encoding of ranges:
229 To handle more than one bit position range within an instruction,
230 use 0s to mask out the ranges which don't apply.
231 May decide to modify the syntax to allow commas separate multiple
232 ranges within an instruction (range','range).
233 
234 Changes in grammar:
235 	The number of parms argument to the function entry
236 was deleted from the original format such that we now count the fields.
237 
238 ----
239 FIXME! should really change lexical analyzer
240 to recognize 'dreg' etc. in context sensative way.
241 Currently function names or mnemonics may be incorrectly parsed as keywords
242 
243 FIXME! hex is ambiguous with any digit
244 
245 */
246 
247 #include <stdio.h>
248 #include "itbl-ops.h"
249 
250 /* #define DEBUG */
251 
252 #ifdef DEBUG
253 #ifndef DBG_LVL
254 #define DBG_LVL 1
255 #endif
256 #else
257 #define DBG_LVL 0
258 #endif
259 
260 #if DBG_LVL >= 1
261 #define DBG(x) printf x
262 #else
263 #define DBG(x)
264 #endif
265 
266 #if DBG_LVL >= 2
267 #define DBGL2(x) printf x
268 #else
269 #define DBGL2(x)
270 #endif
271 
272 static int sbit, ebit;
273 static struct itbl_entry *insn=0;
274 extern int insntbl_line;
275 int yyparse PARAMS ((void));
276 int yylex PARAMS ((void));
277 static int yyerror PARAMS ((const char *));
278 
279 
280 #line 283 "itbl-parse.y"
281 typedef union
282   {
283     char *str;
284     int num;
285     int processor;
286     unsigned long val;
287   } YYSTYPE;
288 #include <stdio.h>
289 
290 #ifndef __cplusplus
291 #ifndef __STDC__
292 #define const
293 #endif
294 #endif
295 
296 
297 
298 #define	YYFINAL		51
299 #define	YYFLAG		-32768
300 #define	YYNTBASE	20
301 
302 #define YYTRANSLATE(x) ((unsigned)(x) <= 266 ? yytranslate[x] : 34)
303 
304 static const char yytranslate[] = {     0,
305      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
306      2,     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,    17,     2,    13,    19,     2,     2,     2,     2,     2,
310      2,     2,     2,     2,     2,     2,     2,    18,     2,     2,
311      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
312      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
313      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
314     15,     2,    16,     2,     2,     2,     2,     2,     2,     2,
315      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
316      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
317      2,     2,     2,    14,     2,     2,     2,     2,     2,     2,
318      2,     2,     2,     2,     2,     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,     1,     3,     4,     5,     6,
331      7,     8,     9,    10,    11,    12
332 };
333 
334 #if YYDEBUG != 0
335 static const short yyprhs[] = {     0,
336      0,     2,     5,     6,    12,    13,    23,    25,    28,    32,
337     35,    36,    38,    40,    42,    46,    50,    54,    56,    59,
338     60,    65,    66,    68,    70,    72,    74,    76,    78
339 };
340 
341 static const short yyrhs[] = {    21,
342      0,    22,    21,     0,     0,    30,    31,    32,    33,    11,
343      0,     0,    30,     8,    32,    33,    29,    28,    23,    24,
344     11,     0,    11,     0,     1,    11,     0,    13,    26,    24,
345      0,    26,    24,     0,     0,    31,     0,     7,     0,     6,
346      0,    25,    29,    28,     0,     9,    14,    27,     0,    15,
347     27,    16,     0,     9,     0,    17,    27,     0,     0,    18,
348      9,    19,     9,     0,     0,    12,     0,     3,     0,     4,
349      0,     5,     0,    10,     0,     9,     0,     9,     0
350 };
351 
352 #endif
353 
354 #if YYDEBUG != 0
355 static const short yyrline[] = { 0,
356    300,   304,   306,   309,   316,   323,   324,   325,   328,   330,
357    331,   334,   340,   345,   352,   361,   366,   370,   376,   382,
358    388,   395,   402,   410,   416,   421,   428,   436,   444
359 };
360 #endif
361 
362 
363 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
364 
365 static const char * const yytname[] = {   "$","error","$undefined.","DREG","CREG",
366 "GREG","IMMED","ADDR","INSN","NUM","ID","NL","PNUM","','","'|'","'['","']'",
367 "'*'","':'","'-'","insntbl","entrys","entry","@1","fieldspecs","ftype","fieldspec",
368 "flagexpr","flags","range","pnum","regtype","name","value", NULL
369 };
370 #endif
371 
372 static const short yyr1[] = {     0,
373     20,    21,    21,    22,    23,    22,    22,    22,    24,    24,
374     24,    25,    25,    25,    26,    27,    27,    27,    28,    28,
375     29,    29,    30,    31,    31,    31,    32,    -1,    33
376 };
377 
378 static const short yyr2[] = {     0,
379      1,     2,     0,     5,     0,     9,     1,     2,     3,     2,
380      0,     1,     1,     1,     3,     3,     3,     1,     2,     0,
381      4,     0,     1,     1,     1,     1,     1,     1,     1
382 };
383 
384 static const short yydefact[] = {     0,
385      0,     7,    23,     1,     0,     0,     8,     2,    24,    25,
386     26,     0,     0,    27,     0,     0,    29,    22,     0,     0,
387     20,     4,     0,     0,     5,     0,    18,     0,    19,    11,
388     21,     0,     0,    14,    13,     0,     0,    22,    11,    12,
389     16,    17,    11,     6,    20,    10,     9,    15,     0,     0,
390      0
391 };
392 
393 static const short yydefgoto[] = {    49,
394      4,     5,    30,    37,    38,    39,    29,    25,    21,     6,
395     40,    15,    18
396 };
397 
398 static const short yypact[] = {     0,
399     -9,-32768,-32768,-32768,     0,    12,-32768,-32768,-32768,-32768,
400 -32768,     3,     3,-32768,     9,     9,-32768,    -8,     8,    19,
401     15,-32768,    10,    -6,-32768,    24,    20,    -6,-32768,     1,
402 -32768,    -6,    21,-32768,-32768,    18,    25,    -8,     1,-32768,
403 -32768,-32768,     1,-32768,    15,-32768,-32768,-32768,    35,    38,
404 -32768
405 };
406 
407 static const short yypgoto[] = {-32768,
408     34,-32768,-32768,   -13,-32768,     4,    -1,    -4,     5,-32768,
409     36,    31,    29
410 };
411 
412 
413 #define	YYLAST		45
414 
415 
416 static const short yytable[] = {    -3,
417      1,     7,    27,     9,    10,    11,    34,    35,    28,    20,
418      2,     3,    14,    36,     9,    10,    11,    17,    22,    12,
419      9,    10,    11,    34,    35,    46,    33,    23,    26,    47,
420     41,    24,    31,    32,    50,    44,    42,    51,     8,    43,
421     48,    13,    45,    16,    19
422 };
423 
424 static const short yycheck[] = {     0,
425      1,    11,     9,     3,     4,     5,     6,     7,    15,    18,
426     11,    12,    10,    13,     3,     4,     5,     9,    11,     8,
427      3,     4,     5,     6,     7,    39,    28,     9,    19,    43,
428     32,    17,     9,    14,     0,    11,    16,     0,     5,    36,
429     45,     6,    38,    13,    16
430 };
431 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
432 #line 3 "/usr/share/misc/bison.simple"
433 /* This file comes from bison-1.28.  */
434 
435 /* Skeleton output parser for bison,
436    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
437 
438    This program is free software; you can redistribute it and/or modify
439    it under the terms of the GNU General Public License as published by
440    the Free Software Foundation; either version 2, or (at your option)
441    any later version.
442 
443    This program is distributed in the hope that it will be useful,
444    but WITHOUT ANY WARRANTY; without even the implied warranty of
445    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
446    GNU General Public License for more details.
447 
448    You should have received a copy of the GNU General Public License
449    along with this program; if not, write to the Free Software
450    Foundation, Inc., 59 Temple Place - Suite 330,
451    Boston, MA 02111-1307, USA.  */
452 
453 /* As a special exception, when this file is copied by Bison into a
454    Bison output file, you may use that output file without restriction.
455    This special exception was added by the Free Software Foundation
456    in version 1.24 of Bison.  */
457 
458 /* This is the parser code that is written into each bison parser
459   when the %semantic_parser declaration is not specified in the grammar.
460   It was written by Richard Stallman by simplifying the hairy parser
461   used when %semantic_parser is specified.  */
462 
463 #ifndef YYSTACK_USE_ALLOCA
464 #ifdef alloca
465 #define YYSTACK_USE_ALLOCA
466 #else /* alloca not defined */
467 #ifdef __GNUC__
468 #define YYSTACK_USE_ALLOCA
469 #define alloca __builtin_alloca
470 #else /* not GNU C.  */
471 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
472 #define YYSTACK_USE_ALLOCA
473 #include <alloca.h>
474 #else /* not sparc */
475 /* We think this test detects Watcom and Microsoft C.  */
476 /* This used to test MSDOS, but that is a bad idea
477    since that symbol is in the user namespace.  */
478 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
479 #if 0 /* No need for malloc.h, which pollutes the namespace;
480 	 instead, just don't use alloca.  */
481 #include <malloc.h>
482 #endif
483 #else /* not MSDOS, or __TURBOC__ */
484 #if defined(_AIX)
485 /* I don't know what this was needed for, but it pollutes the namespace.
486    So I turned it off.   rms, 2 May 1997.  */
487 /* #include <malloc.h>  */
488  #pragma alloca
489 #define YYSTACK_USE_ALLOCA
490 #else /* not MSDOS, or __TURBOC__, or _AIX */
491 #if 0
492 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
493 		 and on HPUX 10.  Eventually we can turn this on.  */
494 #define YYSTACK_USE_ALLOCA
495 #define alloca __builtin_alloca
496 #endif /* __hpux */
497 #endif
498 #endif /* not _AIX */
499 #endif /* not MSDOS, or __TURBOC__ */
500 #endif /* not sparc */
501 #endif /* not GNU C */
502 #endif /* alloca not defined */
503 #endif /* YYSTACK_USE_ALLOCA not defined */
504 
505 #ifdef YYSTACK_USE_ALLOCA
506 #define YYSTACK_ALLOC alloca
507 #else
508 #define YYSTACK_ALLOC malloc
509 #endif
510 
511 /* Note: there must be only one dollar sign in this file.
512    It is replaced by the list of actions, each action
513    as one case of the switch.  */
514 
515 #define yyerrok		(yyerrstatus = 0)
516 #define yyclearin	(yychar = YYEMPTY)
517 #define YYEMPTY		-2
518 #define YYEOF		0
519 #define YYACCEPT	goto yyacceptlab
520 #define YYABORT 	goto yyabortlab
521 #define YYERROR		goto yyerrlab1
522 /* Like YYERROR except do call yyerror.
523    This remains here temporarily to ease the
524    transition to the new meaning of YYERROR, for GCC.
525    Once GCC version 2 has supplanted version 1, this can go.  */
526 #define YYFAIL		goto yyerrlab
527 #define YYRECOVERING()  (!!yyerrstatus)
528 #define YYBACKUP(token, value) \
529 do								\
530   if (yychar == YYEMPTY && yylen == 1)				\
531     { yychar = (token), yylval = (value);			\
532       yychar1 = YYTRANSLATE (yychar);				\
533       YYPOPSTACK;						\
534       goto yybackup;						\
535     }								\
536   else								\
537     { yyerror ("syntax error: cannot back up"); YYERROR; }	\
538 while (0)
539 
540 #define YYTERROR	1
541 #define YYERRCODE	256
542 
543 #ifndef YYPURE
544 #define YYLEX		yylex()
545 #endif
546 
547 #ifdef YYPURE
548 #ifdef YYLSP_NEEDED
549 #ifdef YYLEX_PARAM
550 #define YYLEX		yylex(&yylval, &yylloc, YYLEX_PARAM)
551 #else
552 #define YYLEX		yylex(&yylval, &yylloc)
553 #endif
554 #else /* not YYLSP_NEEDED */
555 #ifdef YYLEX_PARAM
556 #define YYLEX		yylex(&yylval, YYLEX_PARAM)
557 #else
558 #define YYLEX		yylex(&yylval)
559 #endif
560 #endif /* not YYLSP_NEEDED */
561 #endif
562 
563 /* If nonreentrant, generate the variables here */
564 
565 #ifndef YYPURE
566 
567 int	yychar;			/*  the lookahead symbol		*/
568 YYSTYPE	yylval;			/*  the semantic value of the		*/
569 				/*  lookahead symbol			*/
570 
571 #ifdef YYLSP_NEEDED
572 YYLTYPE yylloc;			/*  location data for the lookahead	*/
573 				/*  symbol				*/
574 #endif
575 
576 int yynerrs;			/*  number of parse errors so far       */
577 #endif  /* not YYPURE */
578 
579 #if YYDEBUG != 0
580 int yydebug;			/*  nonzero means print parse trace	*/
581 /* Since this is uninitialized, it does not stop multiple parsers
582    from coexisting.  */
583 #endif
584 
585 /*  YYINITDEPTH indicates the initial size of the parser's stacks	*/
586 
587 #ifndef	YYINITDEPTH
588 #define YYINITDEPTH 200
589 #endif
590 
591 /*  YYMAXDEPTH is the maximum size the stacks can grow to
592     (effective only if the built-in stack extension method is used).  */
593 
594 #if YYMAXDEPTH == 0
595 #undef YYMAXDEPTH
596 #endif
597 
598 #ifndef YYMAXDEPTH
599 #define YYMAXDEPTH 10000
600 #endif
601 
602 /* Define __yy_memcpy.  Note that the size argument
603    should be passed with type unsigned int, because that is what the non-GCC
604    definitions require.  With GCC, __builtin_memcpy takes an arg
605    of type size_t, but it can handle unsigned int.  */
606 
607 #if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
608 #define __yy_memcpy(TO,FROM,COUNT)	__builtin_memcpy(TO,FROM,COUNT)
609 #else				/* not GNU C or C++ */
610 #ifndef __cplusplus
611 
612 /* This is the most reliable way to avoid incompatibilities
613    in available built-in functions on various systems.  */
614 static void
615 __yy_memcpy (to, from, count)
616      char *to;
617      char *from;
618      unsigned int count;
619 {
620   register char *f = from;
621   register char *t = to;
622   register int i = count;
623 
624   while (i-- > 0)
625     *t++ = *f++;
626 }
627 
628 #else /* __cplusplus */
629 
630 /* This is the most reliable way to avoid incompatibilities
631    in available built-in functions on various systems.  */
632 static void
633 __yy_memcpy (char *to, char *from, unsigned int count)
634 {
635   register char *t = to;
636   register char *f = from;
637   register int i = count;
638 
639   while (i-- > 0)
640     *t++ = *f++;
641 }
642 
643 #endif
644 #endif
645 
646 #line 217 "/usr/share/misc/bison.simple"
647 
648 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
649    into yyparse.  The argument should have type void *.
650    It should actually point to an object.
651    Grammar actions can access the variable by casting it
652    to the proper pointer type.  */
653 
654 #ifdef YYPARSE_PARAM
655 #ifdef __cplusplus
656 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
657 #define YYPARSE_PARAM_DECL
658 #else /* not __cplusplus */
659 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
660 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
661 #endif /* not __cplusplus */
662 #else /* not YYPARSE_PARAM */
663 #define YYPARSE_PARAM_ARG
664 #define YYPARSE_PARAM_DECL
665 #endif /* not YYPARSE_PARAM */
666 
667 /* Prevent warning if -Wstrict-prototypes.  */
668 #ifdef __GNUC__
669 #ifdef YYPARSE_PARAM
670 int yyparse (void *);
671 #else
672 int yyparse (void);
673 #endif
674 #endif
675 
676 int
677 yyparse(YYPARSE_PARAM_ARG)
678      YYPARSE_PARAM_DECL
679 {
680   register int yystate;
681   register int yyn;
682   register short *yyssp;
683   register YYSTYPE *yyvsp;
684   int yyerrstatus;	/*  number of tokens to shift before error messages enabled */
685   int yychar1 = 0;		/*  lookahead token as an internal (translated) token number */
686 
687   short	yyssa[YYINITDEPTH];	/*  the state stack			*/
688   YYSTYPE yyvsa[YYINITDEPTH];	/*  the semantic value stack		*/
689 
690   short *yyss = yyssa;		/*  refer to the stacks thru separate pointers */
691   YYSTYPE *yyvs = yyvsa;	/*  to allow yyoverflow to reallocate them elsewhere */
692 
693 #ifdef YYLSP_NEEDED
694   YYLTYPE yylsa[YYINITDEPTH];	/*  the location stack			*/
695   YYLTYPE *yyls = yylsa;
696   YYLTYPE *yylsp;
697 
698 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
699 #else
700 #define YYPOPSTACK   (yyvsp--, yyssp--)
701 #endif
702 
703   int yystacksize = YYINITDEPTH;
704   int yyfree_stacks = 0;
705 
706 #ifdef YYPURE
707   int yychar;
708   YYSTYPE yylval;
709   int yynerrs;
710 #ifdef YYLSP_NEEDED
711   YYLTYPE yylloc;
712 #endif
713 #endif
714 
715   YYSTYPE yyval;		/*  the variable used to return		*/
716 				/*  semantic values from the action	*/
717 				/*  routines				*/
718 
719   int yylen;
720 
721 #if YYDEBUG != 0
722   if (yydebug)
723     fprintf(stderr, "Starting parse\n");
724 #endif
725 
726   yystate = 0;
727   yyerrstatus = 0;
728   yynerrs = 0;
729   yychar = YYEMPTY;		/* Cause a token to be read.  */
730 
731   /* Initialize stack pointers.
732      Waste one element of value and location stack
733      so that they stay on the same level as the state stack.
734      The wasted elements are never initialized.  */
735 
736   yyssp = yyss - 1;
737   yyvsp = yyvs;
738 #ifdef YYLSP_NEEDED
739   yylsp = yyls;
740 #endif
741 
742 /* Push a new state, which is found in  yystate  .  */
743 /* In all cases, when you get here, the value and location stacks
744    have just been pushed. so pushing a state here evens the stacks.  */
745 yynewstate:
746 
747   *++yyssp = yystate;
748 
749   if (yyssp >= yyss + yystacksize - 1)
750     {
751       /* Give user a chance to reallocate the stack */
752       /* Use copies of these so that the &'s don't force the real ones into memory. */
753       YYSTYPE *yyvs1 = yyvs;
754       short *yyss1 = yyss;
755 #ifdef YYLSP_NEEDED
756       YYLTYPE *yyls1 = yyls;
757 #endif
758 
759       /* Get the current used size of the three stacks, in elements.  */
760       int size = yyssp - yyss + 1;
761 
762 #ifdef yyoverflow
763       /* Each stack pointer address is followed by the size of
764 	 the data in use in that stack, in bytes.  */
765 #ifdef YYLSP_NEEDED
766       /* This used to be a conditional around just the two extra args,
767 	 but that might be undefined if yyoverflow is a macro.  */
768       yyoverflow("parser stack overflow",
769 		 &yyss1, size * sizeof (*yyssp),
770 		 &yyvs1, size * sizeof (*yyvsp),
771 		 &yyls1, size * sizeof (*yylsp),
772 		 &yystacksize);
773 #else
774       yyoverflow("parser stack overflow",
775 		 &yyss1, size * sizeof (*yyssp),
776 		 &yyvs1, size * sizeof (*yyvsp),
777 		 &yystacksize);
778 #endif
779 
780       yyss = yyss1; yyvs = yyvs1;
781 #ifdef YYLSP_NEEDED
782       yyls = yyls1;
783 #endif
784 #else /* no yyoverflow */
785       /* Extend the stack our own way.  */
786       if (yystacksize >= YYMAXDEPTH)
787 	{
788 	  yyerror("parser stack overflow");
789 	  if (yyfree_stacks)
790 	    {
791 	      free (yyss);
792 	      free (yyvs);
793 #ifdef YYLSP_NEEDED
794 	      free (yyls);
795 #endif
796 	    }
797 	  return 2;
798 	}
799       yystacksize *= 2;
800       if (yystacksize > YYMAXDEPTH)
801 	yystacksize = YYMAXDEPTH;
802 #ifndef YYSTACK_USE_ALLOCA
803       yyfree_stacks = 1;
804 #endif
805       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
806       __yy_memcpy ((char *)yyss, (char *)yyss1,
807 		   size * (unsigned int) sizeof (*yyssp));
808       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
809       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
810 		   size * (unsigned int) sizeof (*yyvsp));
811 #ifdef YYLSP_NEEDED
812       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
813       __yy_memcpy ((char *)yyls, (char *)yyls1,
814 		   size * (unsigned int) sizeof (*yylsp));
815 #endif
816 #endif /* no yyoverflow */
817 
818       yyssp = yyss + size - 1;
819       yyvsp = yyvs + size - 1;
820 #ifdef YYLSP_NEEDED
821       yylsp = yyls + size - 1;
822 #endif
823 
824 #if YYDEBUG != 0
825       if (yydebug)
826 	fprintf(stderr, "Stack size increased to %d\n", yystacksize);
827 #endif
828 
829       if (yyssp >= yyss + yystacksize - 1)
830 	YYABORT;
831     }
832 
833 #if YYDEBUG != 0
834   if (yydebug)
835     fprintf(stderr, "Entering state %d\n", yystate);
836 #endif
837 
838   goto yybackup;
839  yybackup:
840 
841 /* Do appropriate processing given the current state.  */
842 /* Read a lookahead token if we need one and don't already have one.  */
843 /* yyresume: */
844 
845   /* First try to decide what to do without reference to lookahead token.  */
846 
847   yyn = yypact[yystate];
848   if (yyn == YYFLAG)
849     goto yydefault;
850 
851   /* Not known => get a lookahead token if don't already have one.  */
852 
853   /* yychar is either YYEMPTY or YYEOF
854      or a valid token in external form.  */
855 
856   if (yychar == YYEMPTY)
857     {
858 #if YYDEBUG != 0
859       if (yydebug)
860 	fprintf(stderr, "Reading a token: ");
861 #endif
862       yychar = YYLEX;
863     }
864 
865   /* Convert token to internal form (in yychar1) for indexing tables with */
866 
867   if (yychar <= 0)		/* This means end of input. */
868     {
869       yychar1 = 0;
870       yychar = YYEOF;		/* Don't call YYLEX any more */
871 
872 #if YYDEBUG != 0
873       if (yydebug)
874 	fprintf(stderr, "Now at end of input.\n");
875 #endif
876     }
877   else
878     {
879       yychar1 = YYTRANSLATE(yychar);
880 
881 #if YYDEBUG != 0
882       if (yydebug)
883 	{
884 	  fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
885 	  /* Give the individual parser a way to print the precise meaning
886 	     of a token, for further debugging info.  */
887 #ifdef YYPRINT
888 	  YYPRINT (stderr, yychar, yylval);
889 #endif
890 	  fprintf (stderr, ")\n");
891 	}
892 #endif
893     }
894 
895   yyn += yychar1;
896   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
897     goto yydefault;
898 
899   yyn = yytable[yyn];
900 
901   /* yyn is what to do for this token type in this state.
902      Negative => reduce, -yyn is rule number.
903      Positive => shift, yyn is new state.
904        New state is final state => don't bother to shift,
905        just return success.
906      0, or most negative number => error.  */
907 
908   if (yyn < 0)
909     {
910       if (yyn == YYFLAG)
911 	goto yyerrlab;
912       yyn = -yyn;
913       goto yyreduce;
914     }
915   else if (yyn == 0)
916     goto yyerrlab;
917 
918   if (yyn == YYFINAL)
919     YYACCEPT;
920 
921   /* Shift the lookahead token.  */
922 
923 #if YYDEBUG != 0
924   if (yydebug)
925     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
926 #endif
927 
928   /* Discard the token being shifted unless it is eof.  */
929   if (yychar != YYEOF)
930     yychar = YYEMPTY;
931 
932   *++yyvsp = yylval;
933 #ifdef YYLSP_NEEDED
934   *++yylsp = yylloc;
935 #endif
936 
937   /* count tokens shifted since error; after three, turn off error status.  */
938   if (yyerrstatus) yyerrstatus--;
939 
940   yystate = yyn;
941   goto yynewstate;
942 
943 /* Do the default action for the current state.  */
944 yydefault:
945 
946   yyn = yydefact[yystate];
947   if (yyn == 0)
948     goto yyerrlab;
949 
950 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
951 yyreduce:
952   yylen = yyr2[yyn];
953   if (yylen > 0)
954     yyval = yyvsp[1-yylen]; /* implement default value of the action */
955 
956 #if YYDEBUG != 0
957   if (yydebug)
958     {
959       int i;
960 
961       fprintf (stderr, "Reducing via rule %d (line %d), ",
962 	       yyn, yyrline[yyn]);
963 
964       /* Print the symbols being reduced, and their result.  */
965       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
966 	fprintf (stderr, "%s ", yytname[yyrhs[i]]);
967       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
968     }
969 #endif
970 
971 
972   switch (yyn) {
973 
974 case 4:
975 #line 311 "itbl-parse.y"
976 {
977 	    DBG (("line %d: entry pnum=%d type=%d name=%s value=x%x\n",
978 	    	    insntbl_line, yyvsp[-4].num, yyvsp[-3].num, yyvsp[-2].str, yyvsp[-1].val));
979 	    itbl_add_reg (yyvsp[-4].num, yyvsp[-3].num, yyvsp[-2].str, yyvsp[-1].val);
980 	  ;
981     break;}
982 case 5:
983 #line 317 "itbl-parse.y"
984 {
985 	    DBG (("line %d: entry pnum=%d type=INSN name=%s value=x%x",
986 	    	    insntbl_line, yyvsp[-5].num, yyvsp[-3].str, yyvsp[-2].val));
987 	    DBG ((" sbit=%d ebit=%d flags=0x%x\n", sbit, ebit, yyvsp[0].val));
988 	    insn=itbl_add_insn (yyvsp[-5].num, yyvsp[-3].str, yyvsp[-2].val, sbit, ebit, yyvsp[0].val);
989 	  ;
990     break;}
991 case 12:
992 #line 336 "itbl-parse.y"
993 {
994 	    DBGL2 (("ftype\n"));
995 	    yyval.num = yyvsp[0].num;
996 	  ;
997     break;}
998 case 13:
999 #line 341 "itbl-parse.y"
1000 {
1001 	    DBGL2 (("addr\n"));
1002 	    yyval.num = ADDR;
1003 	  ;
1004     break;}
1005 case 14:
1006 #line 346 "itbl-parse.y"
1007 {
1008 	    DBGL2 (("immed\n"));
1009 	    yyval.num = IMMED;
1010 	  ;
1011     break;}
1012 case 15:
1013 #line 354 "itbl-parse.y"
1014 {
1015 	    DBG (("line %d: field type=%d sbit=%d ebit=%d, flags=0x%x\n",
1016 	    	    insntbl_line, yyvsp[-2].num, sbit, ebit, yyvsp[0].val));
1017 	    itbl_add_operand (insn, yyvsp[-2].num, sbit, ebit, yyvsp[0].val);
1018 	  ;
1019     break;}
1020 case 16:
1021 #line 363 "itbl-parse.y"
1022 {
1023 	    yyval.val = yyvsp[-2].num | yyvsp[0].val;
1024 	  ;
1025     break;}
1026 case 17:
1027 #line 367 "itbl-parse.y"
1028 {
1029 	    yyval.val = yyvsp[-1].val;
1030 	  ;
1031     break;}
1032 case 18:
1033 #line 371 "itbl-parse.y"
1034 {
1035 	    yyval.val = yyvsp[0].num;
1036 	  ;
1037     break;}
1038 case 19:
1039 #line 378 "itbl-parse.y"
1040 {
1041 	    DBGL2 (("flags=%d\n", yyvsp[0].val));
1042 	    yyval.val = yyvsp[0].val;
1043 	  ;
1044     break;}
1045 case 20:
1046 #line 383 "itbl-parse.y"
1047 {
1048 	    yyval.val = 0;
1049 	  ;
1050     break;}
1051 case 21:
1052 #line 390 "itbl-parse.y"
1053 {
1054 	    DBGL2 (("range %d %d\n", yyvsp[-2].num, yyvsp[0].num));
1055 	    sbit = yyvsp[-2].num;
1056 	    ebit = yyvsp[0].num;
1057 	  ;
1058     break;}
1059 case 22:
1060 #line 396 "itbl-parse.y"
1061 {
1062 	    sbit = 31;
1063 	    ebit = 0;
1064 	  ;
1065     break;}
1066 case 23:
1067 #line 404 "itbl-parse.y"
1068 {
1069 	    DBGL2 (("pnum=%d\n",yyvsp[0].num));
1070 	    yyval.num = yyvsp[0].num;
1071 	  ;
1072     break;}
1073 case 24:
1074 #line 412 "itbl-parse.y"
1075 {
1076 	    DBGL2 (("dreg\n"));
1077 	    yyval.num = DREG;
1078 	  ;
1079     break;}
1080 case 25:
1081 #line 417 "itbl-parse.y"
1082 {
1083 	    DBGL2 (("creg\n"));
1084 	    yyval.num = CREG;
1085 	  ;
1086     break;}
1087 case 26:
1088 #line 422 "itbl-parse.y"
1089 {
1090 	    DBGL2 (("greg\n"));
1091 	    yyval.num = GREG;
1092 	  ;
1093     break;}
1094 case 27:
1095 #line 430 "itbl-parse.y"
1096 {
1097 	    DBGL2 (("name=%s\n",yyvsp[0].str));
1098 	    yyval.str = yyvsp[0].str;
1099 	  ;
1100     break;}
1101 case 28:
1102 #line 438 "itbl-parse.y"
1103 {
1104 	    DBGL2 (("num=%d\n",yyvsp[0].num));
1105 	    yyval.num = yyvsp[0].num;
1106 	  ;
1107     break;}
1108 case 29:
1109 #line 446 "itbl-parse.y"
1110 {
1111 	    DBGL2 (("val=x%x\n",yyvsp[0].num));
1112 	    yyval.val = yyvsp[0].num;
1113 	  ;
1114     break;}
1115 }
1116    /* the action file gets copied in in place of this dollarsign */
1117 #line 543 "/usr/share/misc/bison.simple"
1118 
1119   yyvsp -= yylen;
1120   yyssp -= yylen;
1121 #ifdef YYLSP_NEEDED
1122   yylsp -= yylen;
1123 #endif
1124 
1125 #if YYDEBUG != 0
1126   if (yydebug)
1127     {
1128       short *ssp1 = yyss - 1;
1129       fprintf (stderr, "state stack now");
1130       while (ssp1 != yyssp)
1131 	fprintf (stderr, " %d", *++ssp1);
1132       fprintf (stderr, "\n");
1133     }
1134 #endif
1135 
1136   *++yyvsp = yyval;
1137 
1138 #ifdef YYLSP_NEEDED
1139   yylsp++;
1140   if (yylen == 0)
1141     {
1142       yylsp->first_line = yylloc.first_line;
1143       yylsp->first_column = yylloc.first_column;
1144       yylsp->last_line = (yylsp-1)->last_line;
1145       yylsp->last_column = (yylsp-1)->last_column;
1146       yylsp->text = 0;
1147     }
1148   else
1149     {
1150       yylsp->last_line = (yylsp+yylen-1)->last_line;
1151       yylsp->last_column = (yylsp+yylen-1)->last_column;
1152     }
1153 #endif
1154 
1155   /* Now "shift" the result of the reduction.
1156      Determine what state that goes to,
1157      based on the state we popped back to
1158      and the rule number reduced by.  */
1159 
1160   yyn = yyr1[yyn];
1161 
1162   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1163   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1164     yystate = yytable[yystate];
1165   else
1166     yystate = yydefgoto[yyn - YYNTBASE];
1167 
1168   goto yynewstate;
1169 
1170 yyerrlab:   /* here on detecting error */
1171 
1172   if (! yyerrstatus)
1173     /* If not already recovering from an error, report this error.  */
1174     {
1175       ++yynerrs;
1176 
1177 #ifdef YYERROR_VERBOSE
1178       yyn = yypact[yystate];
1179 
1180       if (yyn > YYFLAG && yyn < YYLAST)
1181 	{
1182 	  int size = 0;
1183 	  char *msg;
1184 	  int x, count;
1185 
1186 	  count = 0;
1187 	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
1188 	  for (x = (yyn < 0 ? -yyn : 0);
1189 	       x < (sizeof(yytname) / sizeof(char *)); x++)
1190 	    if (yycheck[x + yyn] == x)
1191 	      size += strlen(yytname[x]) + 15, count++;
1192 	  msg = (char *) malloc(size + 15);
1193 	  if (msg != 0)
1194 	    {
1195 	      strcpy(msg, "parse error");
1196 
1197 	      if (count < 5)
1198 		{
1199 		  count = 0;
1200 		  for (x = (yyn < 0 ? -yyn : 0);
1201 		       x < (sizeof(yytname) / sizeof(char *)); x++)
1202 		    if (yycheck[x + yyn] == x)
1203 		      {
1204 			strcat(msg, count == 0 ? ", expecting `" : " or `");
1205 			strcat(msg, yytname[x]);
1206 			strcat(msg, "'");
1207 			count++;
1208 		      }
1209 		}
1210 	      yyerror(msg);
1211 	      free(msg);
1212 	    }
1213 	  else
1214 	    yyerror ("parse error; also virtual memory exceeded");
1215 	}
1216       else
1217 #endif /* YYERROR_VERBOSE */
1218 	yyerror("parse error");
1219     }
1220 
1221   goto yyerrlab1;
1222 yyerrlab1:   /* here on error raised explicitly by an action */
1223 
1224   if (yyerrstatus == 3)
1225     {
1226       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
1227 
1228       /* return failure if at end of input */
1229       if (yychar == YYEOF)
1230 	YYABORT;
1231 
1232 #if YYDEBUG != 0
1233       if (yydebug)
1234 	fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1235 #endif
1236 
1237       yychar = YYEMPTY;
1238     }
1239 
1240   /* Else will try to reuse lookahead token
1241      after shifting the error token.  */
1242 
1243   yyerrstatus = 3;		/* Each real token shifted decrements this */
1244 
1245   goto yyerrhandle;
1246 
1247 yyerrdefault:  /* current state does not do anything special for the error token. */
1248 
1249 #if 0
1250   /* This is wrong; only states that explicitly want error tokens
1251      should shift them.  */
1252   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
1253   if (yyn) goto yydefault;
1254 #endif
1255 
1256 yyerrpop:   /* pop the current state because it cannot handle the error token */
1257 
1258   if (yyssp == yyss) YYABORT;
1259   yyvsp--;
1260   yystate = *--yyssp;
1261 #ifdef YYLSP_NEEDED
1262   yylsp--;
1263 #endif
1264 
1265 #if YYDEBUG != 0
1266   if (yydebug)
1267     {
1268       short *ssp1 = yyss - 1;
1269       fprintf (stderr, "Error: state stack now");
1270       while (ssp1 != yyssp)
1271 	fprintf (stderr, " %d", *++ssp1);
1272       fprintf (stderr, "\n");
1273     }
1274 #endif
1275 
1276 yyerrhandle:
1277 
1278   yyn = yypact[yystate];
1279   if (yyn == YYFLAG)
1280     goto yyerrdefault;
1281 
1282   yyn += YYTERROR;
1283   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1284     goto yyerrdefault;
1285 
1286   yyn = yytable[yyn];
1287   if (yyn < 0)
1288     {
1289       if (yyn == YYFLAG)
1290 	goto yyerrpop;
1291       yyn = -yyn;
1292       goto yyreduce;
1293     }
1294   else if (yyn == 0)
1295     goto yyerrpop;
1296 
1297   if (yyn == YYFINAL)
1298     YYACCEPT;
1299 
1300 #if YYDEBUG != 0
1301   if (yydebug)
1302     fprintf(stderr, "Shifting error token, ");
1303 #endif
1304 
1305   *++yyvsp = yylval;
1306 #ifdef YYLSP_NEEDED
1307   *++yylsp = yylloc;
1308 #endif
1309 
1310   yystate = yyn;
1311   goto yynewstate;
1312 
1313  yyacceptlab:
1314   /* YYACCEPT comes here.  */
1315   if (yyfree_stacks)
1316     {
1317       free (yyss);
1318       free (yyvs);
1319 #ifdef YYLSP_NEEDED
1320       free (yyls);
1321 #endif
1322     }
1323   return 0;
1324 
1325  yyabortlab:
1326   /* YYABORT comes here.  */
1327   if (yyfree_stacks)
1328     {
1329       free (yyss);
1330       free (yyvs);
1331 #ifdef YYLSP_NEEDED
1332       free (yyls);
1333 #endif
1334     }
1335   return 1;
1336 }
1337 #line 451 "itbl-parse.y"
1338 
1339 
1340 static int
1341 yyerror (msg)
1342      const char *msg;
1343 {
1344   printf ("line %d: %s\n", insntbl_line, msg);
1345   return 0;
1346 }
1347