1 /* Disassembler interface for targets using CGEN. -*- C -*-
2 CGEN: Cpu tools GENerator
4 THIS FILE IS MACHINE GENERATED WITH CGEN.
5 - the resultant file is machine generated, cgen-dis.in isn't
7 Copyright (C) 1996-2016 Free Software Foundation, Inc.
9 This file is part of libopcodes.
11 This library is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3, or (at your option)
16 It is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
25 /* ??? Eventually more and more of this stuff can go to cpu-independent files.
34 #include "libiberty.h"
35 #include "m32c-desc.h"
39 /* Default text to print if an instruction isn't recognized. */
40 #define UNKNOWN_INSN_MSG _("*unknown*")
42 static void print_normal
43 (CGEN_CPU_DESC, void *, long, unsigned int, bfd_vma, int);
44 static void print_address
45 (CGEN_CPU_DESC, void *, bfd_vma, unsigned int, bfd_vma, int) ATTRIBUTE_UNUSED;
46 static void print_keyword
47 (CGEN_CPU_DESC, void *, CGEN_KEYWORD *, long, unsigned int) ATTRIBUTE_UNUSED;
48 static void print_insn_normal
49 (CGEN_CPU_DESC, void *, const CGEN_INSN *, CGEN_FIELDS *, bfd_vma, int);
51 (CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, unsigned);
52 static int default_print_insn
53 (CGEN_CPU_DESC, bfd_vma, disassemble_info *) ATTRIBUTE_UNUSED;
55 (CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, int, CGEN_EXTRACT_INFO *,
58 /* -- disassembler routines inserted here. */
65 /* Always print the short insn format suffix as ':<char>'. */
68 print_suffix (void * dis_info, char suffix)
70 disassemble_info *info = dis_info;
72 (*info->fprintf_func) (info->stream, ":%c", suffix);
76 print_S (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
78 long value ATTRIBUTE_UNUSED,
79 unsigned int attrs ATTRIBUTE_UNUSED,
80 bfd_vma pc ATTRIBUTE_UNUSED,
81 int length ATTRIBUTE_UNUSED)
83 print_suffix (dis_info, 's');
88 print_G (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
90 long value ATTRIBUTE_UNUSED,
91 unsigned int attrs ATTRIBUTE_UNUSED,
92 bfd_vma pc ATTRIBUTE_UNUSED,
93 int length ATTRIBUTE_UNUSED)
95 print_suffix (dis_info, 'g');
99 print_Q (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
101 long value ATTRIBUTE_UNUSED,
102 unsigned int attrs ATTRIBUTE_UNUSED,
103 bfd_vma pc ATTRIBUTE_UNUSED,
104 int length ATTRIBUTE_UNUSED)
106 print_suffix (dis_info, 'q');
110 print_Z (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
112 long value ATTRIBUTE_UNUSED,
113 unsigned int attrs ATTRIBUTE_UNUSED,
114 bfd_vma pc ATTRIBUTE_UNUSED,
115 int length ATTRIBUTE_UNUSED)
117 print_suffix (dis_info, 'z');
120 /* Print the empty suffix. */
123 print_X (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
124 void * dis_info ATTRIBUTE_UNUSED,
125 long value ATTRIBUTE_UNUSED,
126 unsigned int attrs ATTRIBUTE_UNUSED,
127 bfd_vma pc ATTRIBUTE_UNUSED,
128 int length ATTRIBUTE_UNUSED)
134 print_r0l_r0h (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
137 unsigned int attrs ATTRIBUTE_UNUSED,
138 bfd_vma pc ATTRIBUTE_UNUSED,
139 int length ATTRIBUTE_UNUSED)
141 disassemble_info *info = dis_info;
144 (*info->fprintf_func) (info->stream, "r0h,r0l");
146 (*info->fprintf_func) (info->stream, "r0l,r0h");
150 print_unsigned_bitbase (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
153 unsigned int attrs ATTRIBUTE_UNUSED,
154 bfd_vma pc ATTRIBUTE_UNUSED,
155 int length ATTRIBUTE_UNUSED)
157 disassemble_info *info = dis_info;
159 (*info->fprintf_func) (info->stream, "%ld,0x%lx", value & 0x7, value >> 3);
163 print_signed_bitbase (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
166 unsigned int attrs ATTRIBUTE_UNUSED,
167 bfd_vma pc ATTRIBUTE_UNUSED,
168 int length ATTRIBUTE_UNUSED)
170 disassemble_info *info = dis_info;
172 (*info->fprintf_func) (info->stream, "%ld,%ld", value & 0x7, value >> 3);
176 print_size (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
178 long value ATTRIBUTE_UNUSED,
179 unsigned int attrs ATTRIBUTE_UNUSED,
180 bfd_vma pc ATTRIBUTE_UNUSED,
181 int length ATTRIBUTE_UNUSED)
183 /* Always print the size as '.w'. */
184 disassemble_info *info = dis_info;
186 (*info->fprintf_func) (info->stream, ".w");
192 static void print_pop_regset (CGEN_CPU_DESC, void *, long, unsigned int, bfd_vma, int);
193 static void print_push_regset (CGEN_CPU_DESC, void *, long, unsigned int, bfd_vma, int);
195 /* Print a set of registers, R0,R1,A0,A1,SB,FB. */
198 print_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
201 unsigned int attrs ATTRIBUTE_UNUSED,
202 bfd_vma pc ATTRIBUTE_UNUSED,
203 int length ATTRIBUTE_UNUSED,
206 static char * m16c_register_names [] =
208 "r0", "r1", "r2", "r3", "a0", "a1", "sb", "fb"
210 disassemble_info *info = dis_info;
222 (*info->fprintf_func) (info->stream, "%s", m16c_register_names [0]);
226 for (reg_index = 1; reg_index <= 7; ++reg_index)
235 (*info->fprintf_func) (info->stream, "%s%s", comma,
236 m16c_register_names [reg_index]);
243 print_pop_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
246 unsigned int attrs ATTRIBUTE_UNUSED,
247 bfd_vma pc ATTRIBUTE_UNUSED,
248 int length ATTRIBUTE_UNUSED)
250 print_regset (cd, dis_info, value, attrs, pc, length, POP);
254 print_push_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
257 unsigned int attrs ATTRIBUTE_UNUSED,
258 bfd_vma pc ATTRIBUTE_UNUSED,
259 int length ATTRIBUTE_UNUSED)
261 print_regset (cd, dis_info, value, attrs, pc, length, PUSH);
265 print_signed4n (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
268 unsigned int attrs ATTRIBUTE_UNUSED,
269 bfd_vma pc ATTRIBUTE_UNUSED,
270 int length ATTRIBUTE_UNUSED)
272 disassemble_info *info = dis_info;
274 (*info->fprintf_func) (info->stream, "%ld", -value);
277 void m32c_cgen_print_operand
278 (CGEN_CPU_DESC, int, PTR, CGEN_FIELDS *, void const *, bfd_vma, int);
280 /* Main entry point for printing operands.
281 XINFO is a `void *' and not a `disassemble_info *' to not put a requirement
282 of dis-asm.h on cgen.h.
284 This function is basically just a big switch statement. Earlier versions
285 used tables to look up the function to use, but
286 - if the table contains both assembler and disassembler functions then
287 the disassembler contains much of the assembler and vice-versa,
288 - there's a lot of inlining possibilities as things grow,
289 - using a switch statement avoids the function call overhead.
291 This function could be moved into `print_insn_normal', but keeping it
292 separate makes clear the interface between `print_insn_normal' and each of
296 m32c_cgen_print_operand (CGEN_CPU_DESC cd,
300 void const *attrs ATTRIBUTE_UNUSED,
304 disassemble_info *info = (disassemble_info *) xinfo;
308 case M32C_OPERAND_A0 :
309 print_keyword (cd, info, & m32c_cgen_opval_h_a0, 0, 0);
311 case M32C_OPERAND_A1 :
312 print_keyword (cd, info, & m32c_cgen_opval_h_a1, 0, 0);
314 case M32C_OPERAND_AN16_PUSH_S :
315 print_keyword (cd, info, & m32c_cgen_opval_h_ar_HI, fields->f_4_1, 0);
317 case M32C_OPERAND_BIT16AN :
318 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst16_an, 0);
320 case M32C_OPERAND_BIT16RN :
321 print_keyword (cd, info, & m32c_cgen_opval_h_gr_HI, fields->f_dst16_rn, 0);
323 case M32C_OPERAND_BIT3_S :
324 print_normal (cd, info, fields->f_imm3_S, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
326 case M32C_OPERAND_BIT32ANPREFIXED :
327 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst32_an_prefixed, 0);
329 case M32C_OPERAND_BIT32ANUNPREFIXED :
330 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst32_an_unprefixed, 0);
332 case M32C_OPERAND_BIT32RNPREFIXED :
333 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_dst32_rn_prefixed_QI, 0);
335 case M32C_OPERAND_BIT32RNUNPREFIXED :
336 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_dst32_rn_unprefixed_QI, 0);
338 case M32C_OPERAND_BITBASE16_16_S8 :
339 print_signed_bitbase (cd, info, fields->f_dsp_16_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
341 case M32C_OPERAND_BITBASE16_16_U16 :
342 print_unsigned_bitbase (cd, info, fields->f_dsp_16_u16, 0, pc, length);
344 case M32C_OPERAND_BITBASE16_16_U8 :
345 print_unsigned_bitbase (cd, info, fields->f_dsp_16_u8, 0, pc, length);
347 case M32C_OPERAND_BITBASE16_8_U11_S :
348 print_unsigned_bitbase (cd, info, fields->f_bitbase16_u11_S, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
350 case M32C_OPERAND_BITBASE32_16_S11_UNPREFIXED :
351 print_signed_bitbase (cd, info, fields->f_bitbase32_16_s11_unprefixed, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
353 case M32C_OPERAND_BITBASE32_16_S19_UNPREFIXED :
354 print_signed_bitbase (cd, info, fields->f_bitbase32_16_s19_unprefixed, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
356 case M32C_OPERAND_BITBASE32_16_U11_UNPREFIXED :
357 print_unsigned_bitbase (cd, info, fields->f_bitbase32_16_u11_unprefixed, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
359 case M32C_OPERAND_BITBASE32_16_U19_UNPREFIXED :
360 print_unsigned_bitbase (cd, info, fields->f_bitbase32_16_u19_unprefixed, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
362 case M32C_OPERAND_BITBASE32_16_U27_UNPREFIXED :
363 print_unsigned_bitbase (cd, info, fields->f_bitbase32_16_u27_unprefixed, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
365 case M32C_OPERAND_BITBASE32_24_S11_PREFIXED :
366 print_signed_bitbase (cd, info, fields->f_bitbase32_24_s11_prefixed, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
368 case M32C_OPERAND_BITBASE32_24_S19_PREFIXED :
369 print_signed_bitbase (cd, info, fields->f_bitbase32_24_s19_prefixed, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
371 case M32C_OPERAND_BITBASE32_24_U11_PREFIXED :
372 print_unsigned_bitbase (cd, info, fields->f_bitbase32_24_u11_prefixed, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
374 case M32C_OPERAND_BITBASE32_24_U19_PREFIXED :
375 print_unsigned_bitbase (cd, info, fields->f_bitbase32_24_u19_prefixed, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
377 case M32C_OPERAND_BITBASE32_24_U27_PREFIXED :
378 print_unsigned_bitbase (cd, info, fields->f_bitbase32_24_u27_prefixed, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
380 case M32C_OPERAND_BITNO16R :
381 print_normal (cd, info, fields->f_dsp_16_u8, 0, pc, length);
383 case M32C_OPERAND_BITNO32PREFIXED :
384 print_normal (cd, info, fields->f_bitno32_prefixed, 0, pc, length);
386 case M32C_OPERAND_BITNO32UNPREFIXED :
387 print_normal (cd, info, fields->f_bitno32_unprefixed, 0, pc, length);
389 case M32C_OPERAND_DSP_10_U6 :
390 print_normal (cd, info, fields->f_dsp_10_u6, 0, pc, length);
392 case M32C_OPERAND_DSP_16_S16 :
393 print_normal (cd, info, fields->f_dsp_16_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
395 case M32C_OPERAND_DSP_16_S8 :
396 print_normal (cd, info, fields->f_dsp_16_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
398 case M32C_OPERAND_DSP_16_U16 :
399 print_normal (cd, info, fields->f_dsp_16_u16, 0, pc, length);
401 case M32C_OPERAND_DSP_16_U20 :
402 print_normal (cd, info, fields->f_dsp_16_u24, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
404 case M32C_OPERAND_DSP_16_U24 :
405 print_normal (cd, info, fields->f_dsp_16_u24, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
407 case M32C_OPERAND_DSP_16_U8 :
408 print_normal (cd, info, fields->f_dsp_16_u8, 0, pc, length);
410 case M32C_OPERAND_DSP_24_S16 :
411 print_normal (cd, info, fields->f_dsp_24_s16, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
413 case M32C_OPERAND_DSP_24_S8 :
414 print_normal (cd, info, fields->f_dsp_24_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
416 case M32C_OPERAND_DSP_24_U16 :
417 print_normal (cd, info, fields->f_dsp_24_u16, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
419 case M32C_OPERAND_DSP_24_U20 :
420 print_normal (cd, info, fields->f_dsp_24_u24, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
422 case M32C_OPERAND_DSP_24_U24 :
423 print_normal (cd, info, fields->f_dsp_24_u24, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
425 case M32C_OPERAND_DSP_24_U8 :
426 print_normal (cd, info, fields->f_dsp_24_u8, 0, pc, length);
428 case M32C_OPERAND_DSP_32_S16 :
429 print_normal (cd, info, fields->f_dsp_32_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
431 case M32C_OPERAND_DSP_32_S8 :
432 print_normal (cd, info, fields->f_dsp_32_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
434 case M32C_OPERAND_DSP_32_U16 :
435 print_normal (cd, info, fields->f_dsp_32_u16, 0, pc, length);
437 case M32C_OPERAND_DSP_32_U20 :
438 print_normal (cd, info, fields->f_dsp_32_u24, 0, pc, length);
440 case M32C_OPERAND_DSP_32_U24 :
441 print_normal (cd, info, fields->f_dsp_32_u24, 0, pc, length);
443 case M32C_OPERAND_DSP_32_U8 :
444 print_normal (cd, info, fields->f_dsp_32_u8, 0, pc, length);
446 case M32C_OPERAND_DSP_40_S16 :
447 print_normal (cd, info, fields->f_dsp_40_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
449 case M32C_OPERAND_DSP_40_S8 :
450 print_normal (cd, info, fields->f_dsp_40_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
452 case M32C_OPERAND_DSP_40_U16 :
453 print_normal (cd, info, fields->f_dsp_40_u16, 0, pc, length);
455 case M32C_OPERAND_DSP_40_U20 :
456 print_normal (cd, info, fields->f_dsp_40_u20, 0, pc, length);
458 case M32C_OPERAND_DSP_40_U24 :
459 print_normal (cd, info, fields->f_dsp_40_u24, 0, pc, length);
461 case M32C_OPERAND_DSP_40_U8 :
462 print_normal (cd, info, fields->f_dsp_40_u8, 0, pc, length);
464 case M32C_OPERAND_DSP_48_S16 :
465 print_normal (cd, info, fields->f_dsp_48_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
467 case M32C_OPERAND_DSP_48_S8 :
468 print_normal (cd, info, fields->f_dsp_48_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
470 case M32C_OPERAND_DSP_48_U16 :
471 print_normal (cd, info, fields->f_dsp_48_u16, 0, pc, length);
473 case M32C_OPERAND_DSP_48_U20 :
474 print_normal (cd, info, fields->f_dsp_48_u20, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
476 case M32C_OPERAND_DSP_48_U24 :
477 print_normal (cd, info, fields->f_dsp_48_u24, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
479 case M32C_OPERAND_DSP_48_U8 :
480 print_normal (cd, info, fields->f_dsp_48_u8, 0, pc, length);
482 case M32C_OPERAND_DSP_8_S24 :
483 print_normal (cd, info, fields->f_dsp_8_s24, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
485 case M32C_OPERAND_DSP_8_S8 :
486 print_normal (cd, info, fields->f_dsp_8_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
488 case M32C_OPERAND_DSP_8_U16 :
489 print_normal (cd, info, fields->f_dsp_8_u16, 0, pc, length);
491 case M32C_OPERAND_DSP_8_U24 :
492 print_normal (cd, info, fields->f_dsp_8_u24, 0, pc, length);
494 case M32C_OPERAND_DSP_8_U6 :
495 print_normal (cd, info, fields->f_dsp_8_u6, 0, pc, length);
497 case M32C_OPERAND_DSP_8_U8 :
498 print_normal (cd, info, fields->f_dsp_8_u8, 0, pc, length);
500 case M32C_OPERAND_DST16AN :
501 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst16_an, 0);
503 case M32C_OPERAND_DST16AN_S :
504 print_keyword (cd, info, & m32c_cgen_opval_h_ar_HI, fields->f_dst16_an_s, 0);
506 case M32C_OPERAND_DST16ANHI :
507 print_keyword (cd, info, & m32c_cgen_opval_h_ar_HI, fields->f_dst16_an, 0);
509 case M32C_OPERAND_DST16ANQI :
510 print_keyword (cd, info, & m32c_cgen_opval_h_ar_QI, fields->f_dst16_an, 0);
512 case M32C_OPERAND_DST16ANQI_S :
513 print_keyword (cd, info, & m32c_cgen_opval_h_ar_QI, fields->f_dst16_rn_QI_s, 0);
515 case M32C_OPERAND_DST16ANSI :
516 print_keyword (cd, info, & m32c_cgen_opval_h_ar_SI, fields->f_dst16_an, 0);
518 case M32C_OPERAND_DST16RNEXTQI :
519 print_keyword (cd, info, & m32c_cgen_opval_h_gr_ext_QI, fields->f_dst16_rn_ext, 0);
521 case M32C_OPERAND_DST16RNHI :
522 print_keyword (cd, info, & m32c_cgen_opval_h_gr_HI, fields->f_dst16_rn, 0);
524 case M32C_OPERAND_DST16RNQI :
525 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_dst16_rn, 0);
527 case M32C_OPERAND_DST16RNQI_S :
528 print_keyword (cd, info, & m32c_cgen_opval_h_r0l_r0h, fields->f_dst16_rn_QI_s, 0);
530 case M32C_OPERAND_DST16RNSI :
531 print_keyword (cd, info, & m32c_cgen_opval_h_gr_SI, fields->f_dst16_rn, 0);
533 case M32C_OPERAND_DST32ANEXTUNPREFIXED :
534 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst32_an_unprefixed, 0);
536 case M32C_OPERAND_DST32ANPREFIXED :
537 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst32_an_prefixed, 0);
539 case M32C_OPERAND_DST32ANPREFIXEDHI :
540 print_keyword (cd, info, & m32c_cgen_opval_h_ar_HI, fields->f_dst32_an_prefixed, 0);
542 case M32C_OPERAND_DST32ANPREFIXEDQI :
543 print_keyword (cd, info, & m32c_cgen_opval_h_ar_QI, fields->f_dst32_an_prefixed, 0);
545 case M32C_OPERAND_DST32ANPREFIXEDSI :
546 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst32_an_prefixed, 0);
548 case M32C_OPERAND_DST32ANUNPREFIXED :
549 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst32_an_unprefixed, 0);
551 case M32C_OPERAND_DST32ANUNPREFIXEDHI :
552 print_keyword (cd, info, & m32c_cgen_opval_h_ar_HI, fields->f_dst32_an_unprefixed, 0);
554 case M32C_OPERAND_DST32ANUNPREFIXEDQI :
555 print_keyword (cd, info, & m32c_cgen_opval_h_ar_QI, fields->f_dst32_an_unprefixed, 0);
557 case M32C_OPERAND_DST32ANUNPREFIXEDSI :
558 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst32_an_unprefixed, 0);
560 case M32C_OPERAND_DST32R0HI_S :
561 print_keyword (cd, info, & m32c_cgen_opval_h_r0, 0, 0);
563 case M32C_OPERAND_DST32R0QI_S :
564 print_keyword (cd, info, & m32c_cgen_opval_h_r0l, 0, 0);
566 case M32C_OPERAND_DST32RNEXTUNPREFIXEDHI :
567 print_keyword (cd, info, & m32c_cgen_opval_h_gr_ext_HI, fields->f_dst32_rn_ext_unprefixed, 0);
569 case M32C_OPERAND_DST32RNEXTUNPREFIXEDQI :
570 print_keyword (cd, info, & m32c_cgen_opval_h_gr_ext_QI, fields->f_dst32_rn_ext_unprefixed, 0);
572 case M32C_OPERAND_DST32RNPREFIXEDHI :
573 print_keyword (cd, info, & m32c_cgen_opval_h_gr_HI, fields->f_dst32_rn_prefixed_HI, 0);
575 case M32C_OPERAND_DST32RNPREFIXEDQI :
576 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_dst32_rn_prefixed_QI, 0);
578 case M32C_OPERAND_DST32RNPREFIXEDSI :
579 print_keyword (cd, info, & m32c_cgen_opval_h_gr_SI, fields->f_dst32_rn_prefixed_SI, 0);
581 case M32C_OPERAND_DST32RNUNPREFIXEDHI :
582 print_keyword (cd, info, & m32c_cgen_opval_h_gr_HI, fields->f_dst32_rn_unprefixed_HI, 0);
584 case M32C_OPERAND_DST32RNUNPREFIXEDQI :
585 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_dst32_rn_unprefixed_QI, 0);
587 case M32C_OPERAND_DST32RNUNPREFIXEDSI :
588 print_keyword (cd, info, & m32c_cgen_opval_h_gr_SI, fields->f_dst32_rn_unprefixed_SI, 0);
590 case M32C_OPERAND_G :
591 print_G (cd, info, 0, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
593 case M32C_OPERAND_IMM_12_S4 :
594 print_normal (cd, info, fields->f_imm_12_s4, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
596 case M32C_OPERAND_IMM_12_S4N :
597 print_signed4n (cd, info, fields->f_imm_12_s4, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
599 case M32C_OPERAND_IMM_13_U3 :
600 print_normal (cd, info, fields->f_imm_13_u3, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
602 case M32C_OPERAND_IMM_16_HI :
603 print_normal (cd, info, fields->f_dsp_16_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
605 case M32C_OPERAND_IMM_16_QI :
606 print_normal (cd, info, fields->f_dsp_16_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
608 case M32C_OPERAND_IMM_16_SI :
609 print_normal (cd, info, fields->f_dsp_16_s32, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
611 case M32C_OPERAND_IMM_20_S4 :
612 print_normal (cd, info, fields->f_imm_20_s4, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
614 case M32C_OPERAND_IMM_24_HI :
615 print_normal (cd, info, fields->f_dsp_24_s16, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
617 case M32C_OPERAND_IMM_24_QI :
618 print_normal (cd, info, fields->f_dsp_24_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
620 case M32C_OPERAND_IMM_24_SI :
621 print_normal (cd, info, fields->f_dsp_24_s32, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
623 case M32C_OPERAND_IMM_32_HI :
624 print_normal (cd, info, fields->f_dsp_32_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
626 case M32C_OPERAND_IMM_32_QI :
627 print_normal (cd, info, fields->f_dsp_32_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
629 case M32C_OPERAND_IMM_32_SI :
630 print_normal (cd, info, fields->f_dsp_32_s32, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
632 case M32C_OPERAND_IMM_40_HI :
633 print_normal (cd, info, fields->f_dsp_40_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
635 case M32C_OPERAND_IMM_40_QI :
636 print_normal (cd, info, fields->f_dsp_40_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
638 case M32C_OPERAND_IMM_40_SI :
639 print_normal (cd, info, fields->f_dsp_40_s32, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
641 case M32C_OPERAND_IMM_48_HI :
642 print_normal (cd, info, fields->f_dsp_48_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
644 case M32C_OPERAND_IMM_48_QI :
645 print_normal (cd, info, fields->f_dsp_48_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
647 case M32C_OPERAND_IMM_48_SI :
648 print_normal (cd, info, fields->f_dsp_48_s32, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
650 case M32C_OPERAND_IMM_56_HI :
651 print_normal (cd, info, fields->f_dsp_56_s16, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
653 case M32C_OPERAND_IMM_56_QI :
654 print_normal (cd, info, fields->f_dsp_56_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
656 case M32C_OPERAND_IMM_64_HI :
657 print_normal (cd, info, fields->f_dsp_64_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
659 case M32C_OPERAND_IMM_8_HI :
660 print_normal (cd, info, fields->f_dsp_8_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
662 case M32C_OPERAND_IMM_8_QI :
663 print_normal (cd, info, fields->f_dsp_8_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
665 case M32C_OPERAND_IMM_8_S4 :
666 print_normal (cd, info, fields->f_imm_8_s4, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
668 case M32C_OPERAND_IMM_8_S4N :
669 print_signed4n (cd, info, fields->f_imm_8_s4, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
671 case M32C_OPERAND_IMM_SH_12_S4 :
672 print_keyword (cd, info, & m32c_cgen_opval_h_shimm, fields->f_imm_12_s4, 0);
674 case M32C_OPERAND_IMM_SH_20_S4 :
675 print_keyword (cd, info, & m32c_cgen_opval_h_shimm, fields->f_imm_20_s4, 0);
677 case M32C_OPERAND_IMM_SH_8_S4 :
678 print_keyword (cd, info, & m32c_cgen_opval_h_shimm, fields->f_imm_8_s4, 0);
680 case M32C_OPERAND_IMM1_S :
681 print_normal (cd, info, fields->f_imm1_S, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
683 case M32C_OPERAND_IMM3_S :
684 print_normal (cd, info, fields->f_imm3_S, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
686 case M32C_OPERAND_LAB_16_8 :
687 print_address (cd, info, fields->f_lab_16_8, 0|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
689 case M32C_OPERAND_LAB_24_8 :
690 print_address (cd, info, fields->f_lab_24_8, 0|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
692 case M32C_OPERAND_LAB_32_8 :
693 print_address (cd, info, fields->f_lab_32_8, 0|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
695 case M32C_OPERAND_LAB_40_8 :
696 print_address (cd, info, fields->f_lab_40_8, 0|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
698 case M32C_OPERAND_LAB_5_3 :
699 print_address (cd, info, fields->f_lab_5_3, 0|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
701 case M32C_OPERAND_LAB_8_16 :
702 print_address (cd, info, fields->f_lab_8_16, 0|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_SIGN_OPT)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
704 case M32C_OPERAND_LAB_8_24 :
705 print_address (cd, info, fields->f_lab_8_24, 0|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_ABS_ADDR), pc, length);
707 case M32C_OPERAND_LAB_8_8 :
708 print_address (cd, info, fields->f_lab_8_8, 0|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
710 case M32C_OPERAND_LAB32_JMP_S :
711 print_address (cd, info, fields->f_lab32_jmp_s, 0|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_PCREL_ADDR)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
713 case M32C_OPERAND_Q :
714 print_Q (cd, info, 0, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
716 case M32C_OPERAND_R0 :
717 print_keyword (cd, info, & m32c_cgen_opval_h_r0, 0, 0);
719 case M32C_OPERAND_R0H :
720 print_keyword (cd, info, & m32c_cgen_opval_h_r0h, 0, 0);
722 case M32C_OPERAND_R0L :
723 print_keyword (cd, info, & m32c_cgen_opval_h_r0l, 0, 0);
725 case M32C_OPERAND_R1 :
726 print_keyword (cd, info, & m32c_cgen_opval_h_r1, 0, 0);
728 case M32C_OPERAND_R1R2R0 :
729 print_keyword (cd, info, & m32c_cgen_opval_h_r1r2r0, 0, 0);
731 case M32C_OPERAND_R2 :
732 print_keyword (cd, info, & m32c_cgen_opval_h_r2, 0, 0);
734 case M32C_OPERAND_R2R0 :
735 print_keyword (cd, info, & m32c_cgen_opval_h_r2r0, 0, 0);
737 case M32C_OPERAND_R3 :
738 print_keyword (cd, info, & m32c_cgen_opval_h_r3, 0, 0);
740 case M32C_OPERAND_R3R1 :
741 print_keyword (cd, info, & m32c_cgen_opval_h_r3r1, 0, 0);
743 case M32C_OPERAND_REGSETPOP :
744 print_pop_regset (cd, info, fields->f_8_8, 0, pc, length);
746 case M32C_OPERAND_REGSETPUSH :
747 print_push_regset (cd, info, fields->f_8_8, 0, pc, length);
749 case M32C_OPERAND_RN16_PUSH_S :
750 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_4_1, 0);
752 case M32C_OPERAND_S :
753 print_S (cd, info, 0, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
755 case M32C_OPERAND_SRC16AN :
756 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_src16_an, 0);
758 case M32C_OPERAND_SRC16ANHI :
759 print_keyword (cd, info, & m32c_cgen_opval_h_ar_HI, fields->f_src16_an, 0);
761 case M32C_OPERAND_SRC16ANQI :
762 print_keyword (cd, info, & m32c_cgen_opval_h_ar_QI, fields->f_src16_an, 0);
764 case M32C_OPERAND_SRC16RNHI :
765 print_keyword (cd, info, & m32c_cgen_opval_h_gr_HI, fields->f_src16_rn, 0);
767 case M32C_OPERAND_SRC16RNQI :
768 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_src16_rn, 0);
770 case M32C_OPERAND_SRC32ANPREFIXED :
771 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_src32_an_prefixed, 0);
773 case M32C_OPERAND_SRC32ANPREFIXEDHI :
774 print_keyword (cd, info, & m32c_cgen_opval_h_ar_HI, fields->f_src32_an_prefixed, 0);
776 case M32C_OPERAND_SRC32ANPREFIXEDQI :
777 print_keyword (cd, info, & m32c_cgen_opval_h_ar_QI, fields->f_src32_an_prefixed, 0);
779 case M32C_OPERAND_SRC32ANPREFIXEDSI :
780 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_src32_an_prefixed, 0);
782 case M32C_OPERAND_SRC32ANUNPREFIXED :
783 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_src32_an_unprefixed, 0);
785 case M32C_OPERAND_SRC32ANUNPREFIXEDHI :
786 print_keyword (cd, info, & m32c_cgen_opval_h_ar_HI, fields->f_src32_an_unprefixed, 0);
788 case M32C_OPERAND_SRC32ANUNPREFIXEDQI :
789 print_keyword (cd, info, & m32c_cgen_opval_h_ar_QI, fields->f_src32_an_unprefixed, 0);
791 case M32C_OPERAND_SRC32ANUNPREFIXEDSI :
792 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_src32_an_unprefixed, 0);
794 case M32C_OPERAND_SRC32RNPREFIXEDHI :
795 print_keyword (cd, info, & m32c_cgen_opval_h_gr_HI, fields->f_src32_rn_prefixed_HI, 0);
797 case M32C_OPERAND_SRC32RNPREFIXEDQI :
798 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_src32_rn_prefixed_QI, 0);
800 case M32C_OPERAND_SRC32RNPREFIXEDSI :
801 print_keyword (cd, info, & m32c_cgen_opval_h_gr_SI, fields->f_src32_rn_prefixed_SI, 0);
803 case M32C_OPERAND_SRC32RNUNPREFIXEDHI :
804 print_keyword (cd, info, & m32c_cgen_opval_h_gr_HI, fields->f_src32_rn_unprefixed_HI, 0);
806 case M32C_OPERAND_SRC32RNUNPREFIXEDQI :
807 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_src32_rn_unprefixed_QI, 0);
809 case M32C_OPERAND_SRC32RNUNPREFIXEDSI :
810 print_keyword (cd, info, & m32c_cgen_opval_h_gr_SI, fields->f_src32_rn_unprefixed_SI, 0);
812 case M32C_OPERAND_SRCDST16_R0L_R0H_S_NORMAL :
813 print_r0l_r0h (cd, info, fields->f_5_1, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
815 case M32C_OPERAND_X :
816 print_X (cd, info, 0, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
818 case M32C_OPERAND_Z :
819 print_Z (cd, info, 0, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
821 case M32C_OPERAND_COND16_16 :
822 print_keyword (cd, info, & m32c_cgen_opval_h_cond16, fields->f_dsp_16_u8, 0);
824 case M32C_OPERAND_COND16_24 :
825 print_keyword (cd, info, & m32c_cgen_opval_h_cond16, fields->f_dsp_24_u8, 0);
827 case M32C_OPERAND_COND16_32 :
828 print_keyword (cd, info, & m32c_cgen_opval_h_cond16, fields->f_dsp_32_u8, 0);
830 case M32C_OPERAND_COND16C :
831 print_keyword (cd, info, & m32c_cgen_opval_h_cond16c, fields->f_cond16, 0);
833 case M32C_OPERAND_COND16J :
834 print_keyword (cd, info, & m32c_cgen_opval_h_cond16j, fields->f_cond16, 0);
836 case M32C_OPERAND_COND16J5 :
837 print_keyword (cd, info, & m32c_cgen_opval_h_cond16j_5, fields->f_cond16j_5, 0);
839 case M32C_OPERAND_COND32 :
840 print_keyword (cd, info, & m32c_cgen_opval_h_cond32, fields->f_cond32, 0|(1<<CGEN_OPERAND_VIRTUAL));
842 case M32C_OPERAND_COND32_16 :
843 print_keyword (cd, info, & m32c_cgen_opval_h_cond32, fields->f_dsp_16_u8, 0);
845 case M32C_OPERAND_COND32_24 :
846 print_keyword (cd, info, & m32c_cgen_opval_h_cond32, fields->f_dsp_24_u8, 0);
848 case M32C_OPERAND_COND32_32 :
849 print_keyword (cd, info, & m32c_cgen_opval_h_cond32, fields->f_dsp_32_u8, 0);
851 case M32C_OPERAND_COND32_40 :
852 print_keyword (cd, info, & m32c_cgen_opval_h_cond32, fields->f_dsp_40_u8, 0);
854 case M32C_OPERAND_COND32J :
855 print_keyword (cd, info, & m32c_cgen_opval_h_cond32, fields->f_cond32j, 0|(1<<CGEN_OPERAND_VIRTUAL));
857 case M32C_OPERAND_CR1_PREFIXED_32 :
858 print_keyword (cd, info, & m32c_cgen_opval_h_cr1_32, fields->f_21_3, 0);
860 case M32C_OPERAND_CR1_UNPREFIXED_32 :
861 print_keyword (cd, info, & m32c_cgen_opval_h_cr1_32, fields->f_13_3, 0);
863 case M32C_OPERAND_CR16 :
864 print_keyword (cd, info, & m32c_cgen_opval_h_cr_16, fields->f_9_3, 0);
866 case M32C_OPERAND_CR2_32 :
867 print_keyword (cd, info, & m32c_cgen_opval_h_cr2_32, fields->f_13_3, 0);
869 case M32C_OPERAND_CR3_PREFIXED_32 :
870 print_keyword (cd, info, & m32c_cgen_opval_h_cr3_32, fields->f_21_3, 0);
872 case M32C_OPERAND_CR3_UNPREFIXED_32 :
873 print_keyword (cd, info, & m32c_cgen_opval_h_cr3_32, fields->f_13_3, 0);
875 case M32C_OPERAND_FLAGS16 :
876 print_keyword (cd, info, & m32c_cgen_opval_h_flags, fields->f_9_3, 0);
878 case M32C_OPERAND_FLAGS32 :
879 print_keyword (cd, info, & m32c_cgen_opval_h_flags, fields->f_13_3, 0);
881 case M32C_OPERAND_SCCOND32 :
882 print_keyword (cd, info, & m32c_cgen_opval_h_cond32, fields->f_cond16, 0);
884 case M32C_OPERAND_SIZE :
885 print_size (cd, info, 0, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
889 /* xgettext:c-format */
890 fprintf (stderr, _("Unrecognized field %d while printing insn.\n"),
896 cgen_print_fn * const m32c_cgen_print_handlers[] =
903 m32c_cgen_init_dis (CGEN_CPU_DESC cd)
905 m32c_cgen_init_opcode_table (cd);
906 m32c_cgen_init_ibld_table (cd);
907 cd->print_handlers = & m32c_cgen_print_handlers[0];
908 cd->print_operand = m32c_cgen_print_operand;
912 /* Default print handler. */
915 print_normal (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
919 bfd_vma pc ATTRIBUTE_UNUSED,
920 int length ATTRIBUTE_UNUSED)
922 disassemble_info *info = (disassemble_info *) dis_info;
924 /* Print the operand as directed by the attributes. */
925 if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY))
926 ; /* nothing to do */
927 else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED))
928 (*info->fprintf_func) (info->stream, "%ld", value);
930 (*info->fprintf_func) (info->stream, "0x%lx", value);
933 /* Default address handler. */
936 print_address (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
940 bfd_vma pc ATTRIBUTE_UNUSED,
941 int length ATTRIBUTE_UNUSED)
943 disassemble_info *info = (disassemble_info *) dis_info;
945 /* Print the operand as directed by the attributes. */
946 if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY))
947 ; /* Nothing to do. */
948 else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_PCREL_ADDR))
949 (*info->print_address_func) (value, info);
950 else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_ABS_ADDR))
951 (*info->print_address_func) (value, info);
952 else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED))
953 (*info->fprintf_func) (info->stream, "%ld", (long) value);
955 (*info->fprintf_func) (info->stream, "0x%lx", (long) value);
958 /* Keyword print handler. */
961 print_keyword (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
963 CGEN_KEYWORD *keyword_table,
965 unsigned int attrs ATTRIBUTE_UNUSED)
967 disassemble_info *info = (disassemble_info *) dis_info;
968 const CGEN_KEYWORD_ENTRY *ke;
970 ke = cgen_keyword_lookup_value (keyword_table, value);
972 (*info->fprintf_func) (info->stream, "%s", ke->name);
974 (*info->fprintf_func) (info->stream, "???");
977 /* Default insn printer.
979 DIS_INFO is defined as `void *' so the disassembler needn't know anything
980 about disassemble_info. */
983 print_insn_normal (CGEN_CPU_DESC cd,
985 const CGEN_INSN *insn,
990 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
991 disassemble_info *info = (disassemble_info *) dis_info;
992 const CGEN_SYNTAX_CHAR_TYPE *syn;
994 CGEN_INIT_PRINT (cd);
996 for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
998 if (CGEN_SYNTAX_MNEMONIC_P (*syn))
1000 (*info->fprintf_func) (info->stream, "%s", CGEN_INSN_MNEMONIC (insn));
1003 if (CGEN_SYNTAX_CHAR_P (*syn))
1005 (*info->fprintf_func) (info->stream, "%c", CGEN_SYNTAX_CHAR (*syn));
1009 /* We have an operand. */
1010 m32c_cgen_print_operand (cd, CGEN_SYNTAX_FIELD (*syn), info,
1011 fields, CGEN_INSN_ATTRS (insn), pc, length);
1015 /* Subroutine of print_insn. Reads an insn into the given buffers and updates
1017 Returns 0 if all is well, non-zero otherwise. */
1020 read_insn (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1022 disassemble_info *info,
1025 CGEN_EXTRACT_INFO *ex_info,
1026 unsigned long *insn_value)
1028 int status = (*info->read_memory_func) (pc, buf, buflen, info);
1032 (*info->memory_error_func) (status, pc, info);
1036 ex_info->dis_info = info;
1037 ex_info->valid = (1 << buflen) - 1;
1038 ex_info->insn_bytes = buf;
1040 *insn_value = bfd_get_bits (buf, buflen * 8, info->endian == BFD_ENDIAN_BIG);
1044 /* Utility to print an insn.
1045 BUF is the base part of the insn, target byte order, BUFLEN bytes long.
1046 The result is the size of the insn in bytes or zero for an unknown insn
1047 or -1 if an error occurs fetching data (memory_error_func will have
1051 print_insn (CGEN_CPU_DESC cd,
1053 disassemble_info *info,
1055 unsigned int buflen)
1057 CGEN_INSN_INT insn_value;
1058 const CGEN_INSN_LIST *insn_list;
1059 CGEN_EXTRACT_INFO ex_info;
1062 /* Extract base part of instruction, just in case CGEN_DIS_* uses it. */
1063 basesize = cd->base_insn_bitsize < buflen * 8 ?
1064 cd->base_insn_bitsize : buflen * 8;
1065 insn_value = cgen_get_insn_value (cd, buf, basesize);
1068 /* Fill in ex_info fields like read_insn would. Don't actually call
1069 read_insn, since the incoming buffer is already read (and possibly
1070 modified a la m32r). */
1071 ex_info.valid = (1 << buflen) - 1;
1072 ex_info.dis_info = info;
1073 ex_info.insn_bytes = buf;
1075 /* The instructions are stored in hash lists.
1076 Pick the first one and keep trying until we find the right one. */
1078 insn_list = CGEN_DIS_LOOKUP_INSN (cd, (char *) buf, insn_value);
1079 while (insn_list != NULL)
1081 const CGEN_INSN *insn = insn_list->insn;
1084 unsigned long insn_value_cropped;
1086 #ifdef CGEN_VALIDATE_INSN_SUPPORTED
1087 /* Not needed as insn shouldn't be in hash lists if not supported. */
1088 /* Supported by this cpu? */
1089 if (! m32c_cgen_insn_supported (cd, insn))
1091 insn_list = CGEN_DIS_NEXT_INSN (insn_list);
1096 /* Basic bit mask must be correct. */
1097 /* ??? May wish to allow target to defer this check until the extract
1100 /* Base size may exceed this instruction's size. Extract the
1101 relevant part from the buffer. */
1102 if ((unsigned) (CGEN_INSN_BITSIZE (insn) / 8) < buflen &&
1103 (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long))
1104 insn_value_cropped = bfd_get_bits (buf, CGEN_INSN_BITSIZE (insn),
1105 info->endian == BFD_ENDIAN_BIG);
1107 insn_value_cropped = insn_value;
1109 if ((insn_value_cropped & CGEN_INSN_BASE_MASK (insn))
1110 == CGEN_INSN_BASE_VALUE (insn))
1112 /* Printing is handled in two passes. The first pass parses the
1113 machine insn and extracts the fields. The second pass prints
1116 /* Make sure the entire insn is loaded into insn_value, if it
1118 if (((unsigned) CGEN_INSN_BITSIZE (insn) > cd->base_insn_bitsize) &&
1119 (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long))
1121 unsigned long full_insn_value;
1122 int rc = read_insn (cd, pc, info, buf,
1123 CGEN_INSN_BITSIZE (insn) / 8,
1124 & ex_info, & full_insn_value);
1127 length = CGEN_EXTRACT_FN (cd, insn)
1128 (cd, insn, &ex_info, full_insn_value, &fields, pc);
1131 length = CGEN_EXTRACT_FN (cd, insn)
1132 (cd, insn, &ex_info, insn_value_cropped, &fields, pc);
1134 /* Length < 0 -> error. */
1139 CGEN_PRINT_FN (cd, insn) (cd, info, insn, &fields, pc, length);
1140 /* Length is in bits, result is in bytes. */
1145 insn_list = CGEN_DIS_NEXT_INSN (insn_list);
1151 /* Default value for CGEN_PRINT_INSN.
1152 The result is the size of the insn in bytes or zero for an unknown insn
1153 or -1 if an error occured fetching bytes. */
1155 #ifndef CGEN_PRINT_INSN
1156 #define CGEN_PRINT_INSN default_print_insn
1160 default_print_insn (CGEN_CPU_DESC cd, bfd_vma pc, disassemble_info *info)
1162 bfd_byte buf[CGEN_MAX_INSN_SIZE];
1166 /* Attempt to read the base part of the insn. */
1167 buflen = cd->base_insn_bitsize / 8;
1168 status = (*info->read_memory_func) (pc, buf, buflen, info);
1170 /* Try again with the minimum part, if min < base. */
1171 if (status != 0 && (cd->min_insn_bitsize < cd->base_insn_bitsize))
1173 buflen = cd->min_insn_bitsize / 8;
1174 status = (*info->read_memory_func) (pc, buf, buflen, info);
1179 (*info->memory_error_func) (status, pc, info);
1183 return print_insn (cd, pc, info, buf, buflen);
1186 /* Main entry point.
1187 Print one instruction from PC on INFO->STREAM.
1188 Return the size of the instruction (in bytes). */
1190 typedef struct cpu_desc_list
1192 struct cpu_desc_list *next;
1200 print_insn_m32c (bfd_vma pc, disassemble_info *info)
1202 static cpu_desc_list *cd_list = 0;
1203 cpu_desc_list *cl = 0;
1204 static CGEN_CPU_DESC cd = 0;
1205 static CGEN_BITSET *prev_isa;
1206 static int prev_mach;
1207 static int prev_endian;
1211 int endian = (info->endian == BFD_ENDIAN_BIG
1213 : CGEN_ENDIAN_LITTLE);
1214 enum bfd_architecture arch;
1216 /* ??? gdb will set mach but leave the architecture as "unknown" */
1217 #ifndef CGEN_BFD_ARCH
1218 #define CGEN_BFD_ARCH bfd_arch_m32c
1221 if (arch == bfd_arch_unknown)
1222 arch = CGEN_BFD_ARCH;
1224 /* There's no standard way to compute the machine or isa number
1225 so we leave it to the target. */
1226 #ifdef CGEN_COMPUTE_MACH
1227 mach = CGEN_COMPUTE_MACH (info);
1232 #ifdef CGEN_COMPUTE_ISA
1234 static CGEN_BITSET *permanent_isa;
1237 permanent_isa = cgen_bitset_create (MAX_ISAS);
1238 isa = permanent_isa;
1239 cgen_bitset_clear (isa);
1240 cgen_bitset_add (isa, CGEN_COMPUTE_ISA (info));
1243 isa = info->insn_sets;
1246 /* If we've switched cpu's, try to find a handle we've used before */
1248 && (cgen_bitset_compare (isa, prev_isa) != 0
1249 || mach != prev_mach
1250 || endian != prev_endian))
1253 for (cl = cd_list; cl; cl = cl->next)
1255 if (cgen_bitset_compare (cl->isa, isa) == 0 &&
1257 cl->endian == endian)
1260 prev_isa = cd->isas;
1266 /* If we haven't initialized yet, initialize the opcode table. */
1269 const bfd_arch_info_type *arch_type = bfd_lookup_arch (arch, mach);
1270 const char *mach_name;
1274 mach_name = arch_type->printable_name;
1276 prev_isa = cgen_bitset_copy (isa);
1278 prev_endian = endian;
1279 cd = m32c_cgen_cpu_open (CGEN_CPU_OPEN_ISAS, prev_isa,
1280 CGEN_CPU_OPEN_BFDMACH, mach_name,
1281 CGEN_CPU_OPEN_ENDIAN, prev_endian,
1286 /* Save this away for future reference. */
1287 cl = xmalloc (sizeof (struct cpu_desc_list));
1291 cl->endian = endian;
1295 m32c_cgen_init_dis (cd);
1298 /* We try to have as much common code as possible.
1299 But at this point some targets need to take over. */
1300 /* ??? Some targets may need a hook elsewhere. Try to avoid this,
1301 but if not possible try to move this hook elsewhere rather than
1303 length = CGEN_PRINT_INSN (cd, pc, info);
1309 (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG);
1310 return cd->default_insn_bitsize / 8;