* config/tc-mcore.c (mcore_pool_count): New function.
[binutils.git] / opcodes / ip2k-opc.c
blob311a0f76d96ade74a95c721d922e654a11baa5d3
1 /* Instruction opcode table for ip2k.
3 THIS FILE IS MACHINE GENERATED WITH CGEN.
5 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
7 This file is part of the GNU Binutils and/or GDB, the GNU debugger.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License along
20 with this program; if not, write to the Free Software Foundation, Inc.,
21 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include "sysdep.h"
26 #include "ansidecl.h"
27 #include "bfd.h"
28 #include "symcat.h"
29 #include "ip2k-desc.h"
30 #include "ip2k-opc.h"
31 #include "libiberty.h"
33 /* -- opc.c */
35 /* A better hash function for instruction mnemonics. */
36 unsigned int
37 ip2k_asm_hash (insn)
38 const char* insn;
40 unsigned int hash;
41 const char* m = insn;
43 for (hash = 0; *m && !isspace(*m); m++)
44 hash = (hash * 23) ^ (0x1F & tolower(*m));
46 /* printf ("%s %d\n", insn, (hash % CGEN_ASM_HASH_SIZE)); */
48 return hash % CGEN_ASM_HASH_SIZE;
54 /* -- asm.c */
55 /* The hash functions are recorded here to help keep assembler code out of
56 the disassembler and vice versa. */
58 static int asm_hash_insn_p PARAMS ((const CGEN_INSN *));
59 static unsigned int asm_hash_insn PARAMS ((const char *));
60 static int dis_hash_insn_p PARAMS ((const CGEN_INSN *));
61 static unsigned int dis_hash_insn PARAMS ((const char *, CGEN_INSN_INT));
63 /* Instruction formats. */
65 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
66 #define F(f) & ip2k_cgen_ifld_table[IP2K_##f]
67 #else
68 #define F(f) & ip2k_cgen_ifld_table[IP2K_/**/f]
69 #endif
70 static const CGEN_IFMT ifmt_empty = {
71 0, 0, 0x0, { { 0 } }
74 static const CGEN_IFMT ifmt_jmp = {
75 16, 16, 0xe000, { { F (F_OP3) }, { F (F_ADDR16CJP) }, { 0 } }
78 static const CGEN_IFMT ifmt_sb = {
79 16, 16, 0xf000, { { F (F_OP4) }, { F (F_BITNO) }, { F (F_REG) }, { 0 } }
82 static const CGEN_IFMT ifmt_xorw_l = {
83 16, 16, 0xff00, { { F (F_OP4) }, { F (F_OP4MID) }, { F (F_IMM8) }, { 0 } }
86 static const CGEN_IFMT ifmt_loadl_a = {
87 16, 16, 0xff00, { { F (F_OP4) }, { F (F_OP4MID) }, { F (F_IMM8) }, { 0 } }
90 static const CGEN_IFMT ifmt_loadh_a = {
91 16, 16, 0xff00, { { F (F_OP4) }, { F (F_OP4MID) }, { F (F_IMM8) }, { 0 } }
94 static const CGEN_IFMT ifmt_addcfr_w = {
95 16, 16, 0xfe00, { { F (F_OP6) }, { F (F_DIR) }, { F (F_REG) }, { 0 } }
98 static const CGEN_IFMT ifmt_speed = {
99 16, 16, 0xff00, { { F (F_OP8) }, { F (F_IMM8) }, { 0 } }
102 static const CGEN_IFMT ifmt_ireadi = {
103 16, 16, 0xffff, { { F (F_OP6) }, { F (F_OP6_10LOW) }, { 0 } }
106 static const CGEN_IFMT ifmt_page = {
107 16, 16, 0xfff8, { { F (F_OP6) }, { F (F_OP6_7LOW) }, { F (F_PAGE3) }, { 0 } }
110 static const CGEN_IFMT ifmt_reti = {
111 16, 16, 0xfff8, { { F (F_OP6) }, { F (F_OP6_7LOW) }, { F (F_RETI3) }, { 0 } }
114 #undef F
116 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
117 #define A(a) (1 << CGEN_INSN_##a)
118 #else
119 #define A(a) (1 << CGEN_INSN_/**/a)
120 #endif
121 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
122 #define OPERAND(op) IP2K_OPERAND_##op
123 #else
124 #define OPERAND(op) IP2K_OPERAND_/**/op
125 #endif
126 #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
127 #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
129 /* The instruction table. */
131 static const CGEN_OPCODE ip2k_cgen_insn_opcode_table[MAX_INSNS] =
133 /* Special null first entry.
134 A `num' value of zero is thus invalid.
135 Also, the special `invalid' insn resides here. */
136 { { 0, 0, 0, 0 }, {{0}}, 0, {0}},
137 /* jmp $addr16cjp */
139 { 0, 0, 0, 0 },
140 { { MNEM, ' ', OP (ADDR16CJP), 0 } },
141 & ifmt_jmp, { 0xe000 }
143 /* call $addr16cjp */
145 { 0, 0, 0, 0 },
146 { { MNEM, ' ', OP (ADDR16CJP), 0 } },
147 & ifmt_jmp, { 0xc000 }
149 /* sb $fr,$bitno */
151 { 0, 0, 0, 0 },
152 { { MNEM, ' ', OP (FR), ',', OP (BITNO), 0 } },
153 & ifmt_sb, { 0xb000 }
155 /* snb $fr,$bitno */
157 { 0, 0, 0, 0 },
158 { { MNEM, ' ', OP (FR), ',', OP (BITNO), 0 } },
159 & ifmt_sb, { 0xa000 }
161 /* setb $fr,$bitno */
163 { 0, 0, 0, 0 },
164 { { MNEM, ' ', OP (FR), ',', OP (BITNO), 0 } },
165 & ifmt_sb, { 0x9000 }
167 /* clrb $fr,$bitno */
169 { 0, 0, 0, 0 },
170 { { MNEM, ' ', OP (FR), ',', OP (BITNO), 0 } },
171 & ifmt_sb, { 0x8000 }
173 /* xor W,#$lit8 */
175 { 0, 0, 0, 0 },
176 { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
177 & ifmt_xorw_l, { 0x7f00 }
179 /* and W,#$lit8 */
181 { 0, 0, 0, 0 },
182 { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
183 & ifmt_xorw_l, { 0x7e00 }
185 /* or W,#$lit8 */
187 { 0, 0, 0, 0 },
188 { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
189 & ifmt_xorw_l, { 0x7d00 }
191 /* add W,#$lit8 */
193 { 0, 0, 0, 0 },
194 { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
195 & ifmt_xorw_l, { 0x7b00 }
197 /* sub W,#$lit8 */
199 { 0, 0, 0, 0 },
200 { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
201 & ifmt_xorw_l, { 0x7a00 }
203 /* cmp W,#$lit8 */
205 { 0, 0, 0, 0 },
206 { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
207 & ifmt_xorw_l, { 0x7900 }
209 /* retw #$lit8 */
211 { 0, 0, 0, 0 },
212 { { MNEM, ' ', '#', OP (LIT8), 0 } },
213 & ifmt_xorw_l, { 0x7800 }
215 /* cse W,#$lit8 */
217 { 0, 0, 0, 0 },
218 { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
219 & ifmt_xorw_l, { 0x7700 }
221 /* csne W,#$lit8 */
223 { 0, 0, 0, 0 },
224 { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
225 & ifmt_xorw_l, { 0x7600 }
227 /* push #$lit8 */
229 { 0, 0, 0, 0 },
230 { { MNEM, ' ', '#', OP (LIT8), 0 } },
231 & ifmt_xorw_l, { 0x7400 }
233 /* muls W,#$lit8 */
235 { 0, 0, 0, 0 },
236 { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
237 & ifmt_xorw_l, { 0x7300 }
239 /* mulu W,#$lit8 */
241 { 0, 0, 0, 0 },
242 { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
243 & ifmt_xorw_l, { 0x7200 }
245 /* loadl #$lit8 */
247 { 0, 0, 0, 0 },
248 { { MNEM, ' ', '#', OP (LIT8), 0 } },
249 & ifmt_xorw_l, { 0x7100 }
251 /* loadh #$lit8 */
253 { 0, 0, 0, 0 },
254 { { MNEM, ' ', '#', OP (LIT8), 0 } },
255 & ifmt_xorw_l, { 0x7000 }
257 /* loadl $addr16l */
259 { 0, 0, 0, 0 },
260 { { MNEM, ' ', OP (ADDR16L), 0 } },
261 & ifmt_loadl_a, { 0x7100 }
263 /* loadh $addr16h */
265 { 0, 0, 0, 0 },
266 { { MNEM, ' ', OP (ADDR16H), 0 } },
267 & ifmt_loadh_a, { 0x7000 }
269 /* addc $fr,W */
271 { 0, 0, 0, 0 },
272 { { MNEM, ' ', OP (FR), ',', 'W', 0 } },
273 & ifmt_addcfr_w, { 0x5e00 }
275 /* addc W,$fr */
277 { 0, 0, 0, 0 },
278 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
279 & ifmt_addcfr_w, { 0x5c00 }
281 /* incsnz $fr */
283 { 0, 0, 0, 0 },
284 { { MNEM, ' ', OP (FR), 0 } },
285 & ifmt_addcfr_w, { 0x5a00 }
287 /* incsnz W,$fr */
289 { 0, 0, 0, 0 },
290 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
291 & ifmt_addcfr_w, { 0x5800 }
293 /* muls W,$fr */
295 { 0, 0, 0, 0 },
296 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
297 & ifmt_addcfr_w, { 0x5400 }
299 /* mulu W,$fr */
301 { 0, 0, 0, 0 },
302 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
303 & ifmt_addcfr_w, { 0x5000 }
305 /* decsnz $fr */
307 { 0, 0, 0, 0 },
308 { { MNEM, ' ', OP (FR), 0 } },
309 & ifmt_addcfr_w, { 0x4e00 }
311 /* decsnz W,$fr */
313 { 0, 0, 0, 0 },
314 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
315 & ifmt_addcfr_w, { 0x4c00 }
317 /* subc W,$fr */
319 { 0, 0, 0, 0 },
320 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
321 & ifmt_addcfr_w, { 0x4800 }
323 /* subc $fr,W */
325 { 0, 0, 0, 0 },
326 { { MNEM, ' ', OP (FR), ',', 'W', 0 } },
327 & ifmt_addcfr_w, { 0x4a00 }
329 /* pop $fr */
331 { 0, 0, 0, 0 },
332 { { MNEM, ' ', OP (FR), 0 } },
333 & ifmt_addcfr_w, { 0x4600 }
335 /* push $fr */
337 { 0, 0, 0, 0 },
338 { { MNEM, ' ', OP (FR), 0 } },
339 & ifmt_addcfr_w, { 0x4400 }
341 /* cse W,$fr */
343 { 0, 0, 0, 0 },
344 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
345 & ifmt_addcfr_w, { 0x4200 }
347 /* csne W,$fr */
349 { 0, 0, 0, 0 },
350 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
351 & ifmt_addcfr_w, { 0x4000 }
353 /* incsz $fr */
355 { 0, 0, 0, 0 },
356 { { MNEM, ' ', OP (FR), 0 } },
357 & ifmt_addcfr_w, { 0x3e00 }
359 /* incsz W,$fr */
361 { 0, 0, 0, 0 },
362 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
363 & ifmt_addcfr_w, { 0x3c00 }
365 /* swap $fr */
367 { 0, 0, 0, 0 },
368 { { MNEM, ' ', OP (FR), 0 } },
369 & ifmt_addcfr_w, { 0x3a00 }
371 /* swap W,$fr */
373 { 0, 0, 0, 0 },
374 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
375 & ifmt_addcfr_w, { 0x3800 }
377 /* rl $fr */
379 { 0, 0, 0, 0 },
380 { { MNEM, ' ', OP (FR), 0 } },
381 & ifmt_addcfr_w, { 0x3600 }
383 /* rl W,$fr */
385 { 0, 0, 0, 0 },
386 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
387 & ifmt_addcfr_w, { 0x3400 }
389 /* rr $fr */
391 { 0, 0, 0, 0 },
392 { { MNEM, ' ', OP (FR), 0 } },
393 & ifmt_addcfr_w, { 0x3200 }
395 /* rr W,$fr */
397 { 0, 0, 0, 0 },
398 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
399 & ifmt_addcfr_w, { 0x3000 }
401 /* decsz $fr */
403 { 0, 0, 0, 0 },
404 { { MNEM, ' ', OP (FR), 0 } },
405 & ifmt_addcfr_w, { 0x2e00 }
407 /* decsz W,$fr */
409 { 0, 0, 0, 0 },
410 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
411 & ifmt_addcfr_w, { 0x2c00 }
413 /* inc $fr */
415 { 0, 0, 0, 0 },
416 { { MNEM, ' ', OP (FR), 0 } },
417 & ifmt_addcfr_w, { 0x2a00 }
419 /* inc W,$fr */
421 { 0, 0, 0, 0 },
422 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
423 & ifmt_addcfr_w, { 0x2800 }
425 /* not $fr */
427 { 0, 0, 0, 0 },
428 { { MNEM, ' ', OP (FR), 0 } },
429 & ifmt_addcfr_w, { 0x2600 }
431 /* not W,$fr */
433 { 0, 0, 0, 0 },
434 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
435 & ifmt_addcfr_w, { 0x2400 }
437 /* test $fr */
439 { 0, 0, 0, 0 },
440 { { MNEM, ' ', OP (FR), 0 } },
441 & ifmt_addcfr_w, { 0x2200 }
443 /* mov W,#$lit8 */
445 { 0, 0, 0, 0 },
446 { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
447 & ifmt_xorw_l, { 0x7c00 }
449 /* mov $fr,W */
451 { 0, 0, 0, 0 },
452 { { MNEM, ' ', OP (FR), ',', 'W', 0 } },
453 & ifmt_addcfr_w, { 0x200 }
455 /* mov W,$fr */
457 { 0, 0, 0, 0 },
458 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
459 & ifmt_addcfr_w, { 0x2000 }
461 /* add $fr,W */
463 { 0, 0, 0, 0 },
464 { { MNEM, ' ', OP (FR), ',', 'W', 0 } },
465 & ifmt_addcfr_w, { 0x1e00 }
467 /* add W,$fr */
469 { 0, 0, 0, 0 },
470 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
471 & ifmt_addcfr_w, { 0x1c00 }
473 /* xor $fr,W */
475 { 0, 0, 0, 0 },
476 { { MNEM, ' ', OP (FR), ',', 'W', 0 } },
477 & ifmt_addcfr_w, { 0x1a00 }
479 /* xor W,$fr */
481 { 0, 0, 0, 0 },
482 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
483 & ifmt_addcfr_w, { 0x1800 }
485 /* and $fr,W */
487 { 0, 0, 0, 0 },
488 { { MNEM, ' ', OP (FR), ',', 'W', 0 } },
489 & ifmt_addcfr_w, { 0x1600 }
491 /* and W,$fr */
493 { 0, 0, 0, 0 },
494 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
495 & ifmt_addcfr_w, { 0x1400 }
497 /* or $fr,W */
499 { 0, 0, 0, 0 },
500 { { MNEM, ' ', OP (FR), ',', 'W', 0 } },
501 & ifmt_addcfr_w, { 0x1200 }
503 /* or W,$fr */
505 { 0, 0, 0, 0 },
506 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
507 & ifmt_addcfr_w, { 0x1000 }
509 /* dec $fr */
511 { 0, 0, 0, 0 },
512 { { MNEM, ' ', OP (FR), 0 } },
513 & ifmt_addcfr_w, { 0xe00 }
515 /* dec W,$fr */
517 { 0, 0, 0, 0 },
518 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
519 & ifmt_addcfr_w, { 0xc00 }
521 /* sub $fr,W */
523 { 0, 0, 0, 0 },
524 { { MNEM, ' ', OP (FR), ',', 'W', 0 } },
525 & ifmt_addcfr_w, { 0xa00 }
527 /* sub W,$fr */
529 { 0, 0, 0, 0 },
530 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
531 & ifmt_addcfr_w, { 0x800 }
533 /* clr $fr */
535 { 0, 0, 0, 0 },
536 { { MNEM, ' ', OP (FR), 0 } },
537 & ifmt_addcfr_w, { 0x600 }
539 /* cmp W,$fr */
541 { 0, 0, 0, 0 },
542 { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
543 & ifmt_addcfr_w, { 0x400 }
545 /* speed #$lit8 */
547 { 0, 0, 0, 0 },
548 { { MNEM, ' ', '#', OP (LIT8), 0 } },
549 & ifmt_speed, { 0x100 }
551 /* ireadi */
553 { 0, 0, 0, 0 },
554 { { MNEM, 0 } },
555 & ifmt_ireadi, { 0x1d }
557 /* iwritei */
559 { 0, 0, 0, 0 },
560 { { MNEM, 0 } },
561 & ifmt_ireadi, { 0x1c }
563 /* fread */
565 { 0, 0, 0, 0 },
566 { { MNEM, 0 } },
567 & ifmt_ireadi, { 0x1b }
569 /* fwrite */
571 { 0, 0, 0, 0 },
572 { { MNEM, 0 } },
573 & ifmt_ireadi, { 0x1a }
575 /* iread */
577 { 0, 0, 0, 0 },
578 { { MNEM, 0 } },
579 & ifmt_ireadi, { 0x19 }
581 /* iwrite */
583 { 0, 0, 0, 0 },
584 { { MNEM, 0 } },
585 & ifmt_ireadi, { 0x18 }
587 /* page $addr16p */
589 { 0, 0, 0, 0 },
590 { { MNEM, ' ', OP (ADDR16P), 0 } },
591 & ifmt_page, { 0x10 }
593 /* system */
595 { 0, 0, 0, 0 },
596 { { MNEM, 0 } },
597 & ifmt_ireadi, { 0xff }
599 /* reti #$reti3 */
601 { 0, 0, 0, 0 },
602 { { MNEM, ' ', '#', OP (RETI3), 0 } },
603 & ifmt_reti, { 0x8 }
605 /* ret */
607 { 0, 0, 0, 0 },
608 { { MNEM, 0 } },
609 & ifmt_ireadi, { 0x7 }
611 /* int */
613 { 0, 0, 0, 0 },
614 { { MNEM, 0 } },
615 & ifmt_ireadi, { 0x6 }
617 /* breakx */
619 { 0, 0, 0, 0 },
620 { { MNEM, 0 } },
621 & ifmt_ireadi, { 0x5 }
623 /* cwdt */
625 { 0, 0, 0, 0 },
626 { { MNEM, 0 } },
627 & ifmt_ireadi, { 0x4 }
629 /* ferase */
631 { 0, 0, 0, 0 },
632 { { MNEM, 0 } },
633 & ifmt_ireadi, { 0x3 }
635 /* retnp */
637 { 0, 0, 0, 0 },
638 { { MNEM, 0 } },
639 & ifmt_ireadi, { 0x2 }
641 /* break */
643 { 0, 0, 0, 0 },
644 { { MNEM, 0 } },
645 & ifmt_ireadi, { 0x1 }
647 /* nop */
649 { 0, 0, 0, 0 },
650 { { MNEM, 0 } },
651 & ifmt_ireadi, { 0x0 }
655 #undef A
656 #undef OPERAND
657 #undef MNEM
658 #undef OP
660 /* Formats for ALIAS macro-insns. */
662 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
663 #define F(f) & ip2k_cgen_ifld_table[IP2K_##f]
664 #else
665 #define F(f) & ip2k_cgen_ifld_table[IP2K_/**/f]
666 #endif
667 static const CGEN_IFMT ifmt_sc = {
668 16, 16, 0xffff, { { F (F_OP4) }, { F (F_BITNO) }, { F (F_REG) }, { 0 } }
671 static const CGEN_IFMT ifmt_snc = {
672 16, 16, 0xffff, { { F (F_OP4) }, { F (F_BITNO) }, { F (F_REG) }, { 0 } }
675 static const CGEN_IFMT ifmt_sz = {
676 16, 16, 0xffff, { { F (F_OP4) }, { F (F_BITNO) }, { F (F_REG) }, { 0 } }
679 static const CGEN_IFMT ifmt_snz = {
680 16, 16, 0xffff, { { F (F_OP4) }, { F (F_BITNO) }, { F (F_REG) }, { 0 } }
683 static const CGEN_IFMT ifmt_skip = {
684 16, 16, 0xffff, { { F (F_OP4) }, { F (F_BITNO) }, { F (F_REG) }, { 0 } }
687 static const CGEN_IFMT ifmt_skipb = {
688 16, 16, 0xffff, { { F (F_OP4) }, { F (F_BITNO) }, { F (F_REG) }, { 0 } }
691 #undef F
693 /* Each non-simple macro entry points to an array of expansion possibilities. */
695 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
696 #define A(a) (1 << CGEN_INSN_##a)
697 #else
698 #define A(a) (1 << CGEN_INSN_/**/a)
699 #endif
700 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
701 #define OPERAND(op) IP2K_OPERAND_##op
702 #else
703 #define OPERAND(op) IP2K_OPERAND_/**/op
704 #endif
705 #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
706 #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
708 /* The macro instruction table. */
710 static const CGEN_IBASE ip2k_cgen_macro_insn_table[] =
712 /* sc */
714 -1, "sc", "sc", 16,
715 { 0|A(ALIAS), { (1<<MACH_BASE) } }
717 /* snc */
719 -1, "snc", "snc", 16,
720 { 0|A(ALIAS), { (1<<MACH_BASE) } }
722 /* sz */
724 -1, "sz", "sz", 16,
725 { 0|A(ALIAS), { (1<<MACH_BASE) } }
727 /* snz */
729 -1, "snz", "snz", 16,
730 { 0|A(ALIAS), { (1<<MACH_BASE) } }
732 /* skip */
734 -1, "skip", "skip", 16,
735 { 0|A(SKIPA)|A(ALIAS), { (1<<MACH_BASE) } }
737 /* skip */
739 -1, "skipb", "skip", 16,
740 { 0|A(SKIPA)|A(ALIAS), { (1<<MACH_BASE) } }
744 /* The macro instruction opcode table. */
746 static const CGEN_OPCODE ip2k_cgen_macro_insn_opcode_table[] =
748 /* sc */
750 { 0, 0, 0, 0 },
751 { { MNEM, 0 } },
752 & ifmt_sc, { 0xb00b }
754 /* snc */
756 { 0, 0, 0, 0 },
757 { { MNEM, 0 } },
758 & ifmt_snc, { 0xa00b }
760 /* sz */
762 { 0, 0, 0, 0 },
763 { { MNEM, 0 } },
764 & ifmt_sz, { 0xb40b }
766 /* snz */
768 { 0, 0, 0, 0 },
769 { { MNEM, 0 } },
770 & ifmt_snz, { 0xa40b }
772 /* skip */
774 { 0, 0, 0, 0 },
775 { { MNEM, 0 } },
776 & ifmt_skip, { 0xa009 }
778 /* skip */
780 { 0, 0, 0, 0 },
781 { { MNEM, 0 } },
782 & ifmt_skipb, { 0xb009 }
786 #undef A
787 #undef OPERAND
788 #undef MNEM
789 #undef OP
791 #ifndef CGEN_ASM_HASH_P
792 #define CGEN_ASM_HASH_P(insn) 1
793 #endif
795 #ifndef CGEN_DIS_HASH_P
796 #define CGEN_DIS_HASH_P(insn) 1
797 #endif
799 /* Return non-zero if INSN is to be added to the hash table.
800 Targets are free to override CGEN_{ASM,DIS}_HASH_P in the .opc file. */
802 static int
803 asm_hash_insn_p (insn)
804 const CGEN_INSN *insn ATTRIBUTE_UNUSED;
806 return CGEN_ASM_HASH_P (insn);
809 static int
810 dis_hash_insn_p (insn)
811 const CGEN_INSN *insn;
813 /* If building the hash table and the NO-DIS attribute is present,
814 ignore. */
815 if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_NO_DIS))
816 return 0;
817 return CGEN_DIS_HASH_P (insn);
820 #ifndef CGEN_ASM_HASH
821 #define CGEN_ASM_HASH_SIZE 127
822 #ifdef CGEN_MNEMONIC_OPERANDS
823 #define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE)
824 #else
825 #define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE) /*FIXME*/
826 #endif
827 #endif
829 /* It doesn't make much sense to provide a default here,
830 but while this is under development we do.
831 BUFFER is a pointer to the bytes of the insn, target order.
832 VALUE is the first base_insn_bitsize bits as an int in host order. */
834 #ifndef CGEN_DIS_HASH
835 #define CGEN_DIS_HASH_SIZE 256
836 #define CGEN_DIS_HASH(buf, value) (*(unsigned char *) (buf))
837 #endif
839 /* The result is the hash value of the insn.
840 Targets are free to override CGEN_{ASM,DIS}_HASH in the .opc file. */
842 static unsigned int
843 asm_hash_insn (mnem)
844 const char * mnem;
846 return CGEN_ASM_HASH (mnem);
849 /* BUF is a pointer to the bytes of the insn, target order.
850 VALUE is the first base_insn_bitsize bits as an int in host order. */
852 static unsigned int
853 dis_hash_insn (buf, value)
854 const char * buf ATTRIBUTE_UNUSED;
855 CGEN_INSN_INT value ATTRIBUTE_UNUSED;
857 return CGEN_DIS_HASH (buf, value);
860 static void set_fields_bitsize PARAMS ((CGEN_FIELDS *, int));
862 /* Set the recorded length of the insn in the CGEN_FIELDS struct. */
864 static void
865 set_fields_bitsize (fields, size)
866 CGEN_FIELDS *fields;
867 int size;
869 CGEN_FIELDS_BITSIZE (fields) = size;
872 /* Function to call before using the operand instance table.
873 This plugs the opcode entries and macro instructions into the cpu table. */
875 void
876 ip2k_cgen_init_opcode_table (cd)
877 CGEN_CPU_DESC cd;
879 int i;
880 int num_macros = (sizeof (ip2k_cgen_macro_insn_table) /
881 sizeof (ip2k_cgen_macro_insn_table[0]));
882 const CGEN_IBASE *ib = & ip2k_cgen_macro_insn_table[0];
883 const CGEN_OPCODE *oc = & ip2k_cgen_macro_insn_opcode_table[0];
884 CGEN_INSN *insns = (CGEN_INSN *) xmalloc (num_macros * sizeof (CGEN_INSN));
885 memset (insns, 0, num_macros * sizeof (CGEN_INSN));
886 for (i = 0; i < num_macros; ++i)
888 insns[i].base = &ib[i];
889 insns[i].opcode = &oc[i];
890 ip2k_cgen_build_insn_regex (& insns[i]);
892 cd->macro_insn_table.init_entries = insns;
893 cd->macro_insn_table.entry_size = sizeof (CGEN_IBASE);
894 cd->macro_insn_table.num_init_entries = num_macros;
896 oc = & ip2k_cgen_insn_opcode_table[0];
897 insns = (CGEN_INSN *) cd->insn_table.init_entries;
898 for (i = 0; i < MAX_INSNS; ++i)
900 insns[i].opcode = &oc[i];
901 ip2k_cgen_build_insn_regex (& insns[i]);
904 cd->sizeof_fields = sizeof (CGEN_FIELDS);
905 cd->set_fields_bitsize = set_fields_bitsize;
907 cd->asm_hash_p = asm_hash_insn_p;
908 cd->asm_hash = asm_hash_insn;
909 cd->asm_hash_size = CGEN_ASM_HASH_SIZE;
911 cd->dis_hash_p = dis_hash_insn_p;
912 cd->dis_hash = dis_hash_insn;
913 cd->dis_hash_size = CGEN_DIS_HASH_SIZE;