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 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005
8 Free Software Foundation, Inc.
10 This file is part of the GNU Binutils and GDB, the GNU debugger.
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2, or (at your option)
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
26 /* ??? Eventually more and more of this stuff can go to cpu-independent files.
35 #include "libiberty.h"
36 #include "m32c-desc.h"
40 /* Default text to print if an instruction isn't recognized. */
41 #define UNKNOWN_INSN_MSG _("*unknown*")
43 static void print_normal
44 (CGEN_CPU_DESC, void *, long, unsigned int, bfd_vma, int);
45 static void print_address
46 (CGEN_CPU_DESC, void *, bfd_vma, unsigned int, bfd_vma, int) ATTRIBUTE_UNUSED;
47 static void print_keyword
48 (CGEN_CPU_DESC, void *, CGEN_KEYWORD *, long, unsigned int) ATTRIBUTE_UNUSED;
49 static void print_insn_normal
50 (CGEN_CPU_DESC, void *, const CGEN_INSN *, CGEN_FIELDS *, bfd_vma, int);
52 (CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, unsigned);
53 static int default_print_insn
54 (CGEN_CPU_DESC, bfd_vma, disassemble_info *) ATTRIBUTE_UNUSED;
56 (CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, int, CGEN_EXTRACT_INFO *,
59 /* -- disassembler routines inserted here. */
66 /* Always print the short insn format suffix as ':<char>'. */
69 print_suffix (void * dis_info, char suffix)
71 disassemble_info *info = dis_info;
73 (*info->fprintf_func) (info->stream, ":%c", suffix);
77 print_S (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
79 long value ATTRIBUTE_UNUSED,
80 unsigned int attrs ATTRIBUTE_UNUSED,
81 bfd_vma pc ATTRIBUTE_UNUSED,
82 int length ATTRIBUTE_UNUSED)
84 print_suffix (dis_info, 's');
89 print_G (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
91 long value ATTRIBUTE_UNUSED,
92 unsigned int attrs ATTRIBUTE_UNUSED,
93 bfd_vma pc ATTRIBUTE_UNUSED,
94 int length ATTRIBUTE_UNUSED)
96 print_suffix (dis_info, 'g');
100 print_Q (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
102 long value ATTRIBUTE_UNUSED,
103 unsigned int attrs ATTRIBUTE_UNUSED,
104 bfd_vma pc ATTRIBUTE_UNUSED,
105 int length ATTRIBUTE_UNUSED)
107 print_suffix (dis_info, 'q');
111 print_Z (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
113 long value ATTRIBUTE_UNUSED,
114 unsigned int attrs ATTRIBUTE_UNUSED,
115 bfd_vma pc ATTRIBUTE_UNUSED,
116 int length ATTRIBUTE_UNUSED)
118 print_suffix (dis_info, 'z');
121 /* Print the empty suffix. */
124 print_X (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
125 void * dis_info ATTRIBUTE_UNUSED,
126 long value ATTRIBUTE_UNUSED,
127 unsigned int attrs ATTRIBUTE_UNUSED,
128 bfd_vma pc ATTRIBUTE_UNUSED,
129 int length ATTRIBUTE_UNUSED)
135 print_r0l_r0h (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
138 unsigned int attrs ATTRIBUTE_UNUSED,
139 bfd_vma pc ATTRIBUTE_UNUSED,
140 int length ATTRIBUTE_UNUSED)
142 disassemble_info *info = dis_info;
145 (*info->fprintf_func) (info->stream, "r0h,r0l");
147 (*info->fprintf_func) (info->stream, "r0l,r0h");
151 print_unsigned_bitbase (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
154 unsigned int attrs ATTRIBUTE_UNUSED,
155 bfd_vma pc ATTRIBUTE_UNUSED,
156 int length ATTRIBUTE_UNUSED)
158 disassemble_info *info = dis_info;
160 (*info->fprintf_func) (info->stream, "%ld,0x%lx", value & 0x7, value >> 3);
164 print_signed_bitbase (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
167 unsigned int attrs ATTRIBUTE_UNUSED,
168 bfd_vma pc ATTRIBUTE_UNUSED,
169 int length ATTRIBUTE_UNUSED)
171 disassemble_info *info = dis_info;
173 (*info->fprintf_func) (info->stream, "%ld,%ld", value & 0x7, value >> 3);
177 print_size (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
179 long value ATTRIBUTE_UNUSED,
180 unsigned int attrs ATTRIBUTE_UNUSED,
181 bfd_vma pc ATTRIBUTE_UNUSED,
182 int length ATTRIBUTE_UNUSED)
184 /* Always print the size as '.w'. */
185 disassemble_info *info = dis_info;
187 (*info->fprintf_func) (info->stream, ".w");
193 static void print_pop_regset (CGEN_CPU_DESC, void *, long, unsigned int, bfd_vma, int);
194 static void print_push_regset (CGEN_CPU_DESC, void *, long, unsigned int, bfd_vma, int);
196 /* Print a set of registers, R0,R1,A0,A1,SB,FB. */
199 print_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
202 unsigned int attrs ATTRIBUTE_UNUSED,
203 bfd_vma pc ATTRIBUTE_UNUSED,
204 int length ATTRIBUTE_UNUSED,
207 static char * m16c_register_names [] =
209 "r0", "r1", "r2", "r3", "a0", "a1", "sb", "fb"
211 disassemble_info *info = dis_info;
223 (*info->fprintf_func) (info->stream, "%s", m16c_register_names [0]);
227 for (index = 1; index <= 7; ++index)
236 (*info->fprintf_func) (info->stream, "%s%s", comma,
237 m16c_register_names [index]);
244 print_pop_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
247 unsigned int attrs ATTRIBUTE_UNUSED,
248 bfd_vma pc ATTRIBUTE_UNUSED,
249 int length ATTRIBUTE_UNUSED)
251 print_regset (cd, dis_info, value, attrs, pc, length, POP);
255 print_push_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
258 unsigned int attrs ATTRIBUTE_UNUSED,
259 bfd_vma pc ATTRIBUTE_UNUSED,
260 int length ATTRIBUTE_UNUSED)
262 print_regset (cd, dis_info, value, attrs, pc, length, PUSH);
266 print_signed4n (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
269 unsigned int attrs ATTRIBUTE_UNUSED,
270 bfd_vma pc ATTRIBUTE_UNUSED,
271 int length ATTRIBUTE_UNUSED)
273 disassemble_info *info = dis_info;
275 (*info->fprintf_func) (info->stream, "%ld", -value);
278 void m32c_cgen_print_operand
279 (CGEN_CPU_DESC, int, PTR, CGEN_FIELDS *, void const *, bfd_vma, int);
281 /* Main entry point for printing operands.
282 XINFO is a `void *' and not a `disassemble_info *' to not put a requirement
283 of dis-asm.h on cgen.h.
285 This function is basically just a big switch statement. Earlier versions
286 used tables to look up the function to use, but
287 - if the table contains both assembler and disassembler functions then
288 the disassembler contains much of the assembler and vice-versa,
289 - there's a lot of inlining possibilities as things grow,
290 - using a switch statement avoids the function call overhead.
292 This function could be moved into `print_insn_normal', but keeping it
293 separate makes clear the interface between `print_insn_normal' and each of
297 m32c_cgen_print_operand (CGEN_CPU_DESC cd,
301 void const *attrs ATTRIBUTE_UNUSED,
305 disassemble_info *info = (disassemble_info *) xinfo;
309 case M32C_OPERAND_A0 :
310 print_keyword (cd, info, & m32c_cgen_opval_h_a0, 0, 0);
312 case M32C_OPERAND_A1 :
313 print_keyword (cd, info, & m32c_cgen_opval_h_a1, 0, 0);
315 case M32C_OPERAND_AN16_PUSH_S :
316 print_keyword (cd, info, & m32c_cgen_opval_h_ar_HI, fields->f_4_1, 0);
318 case M32C_OPERAND_BIT16AN :
319 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst16_an, 0);
321 case M32C_OPERAND_BIT16RN :
322 print_keyword (cd, info, & m32c_cgen_opval_h_gr_HI, fields->f_dst16_rn, 0);
324 case M32C_OPERAND_BIT3_S :
325 print_normal (cd, info, fields->f_imm3_S, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
327 case M32C_OPERAND_BIT32ANPREFIXED :
328 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst32_an_prefixed, 0);
330 case M32C_OPERAND_BIT32ANUNPREFIXED :
331 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst32_an_unprefixed, 0);
333 case M32C_OPERAND_BIT32RNPREFIXED :
334 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_dst32_rn_prefixed_QI, 0);
336 case M32C_OPERAND_BIT32RNUNPREFIXED :
337 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_dst32_rn_unprefixed_QI, 0);
339 case M32C_OPERAND_BITBASE16_16_S8 :
340 print_signed_bitbase (cd, info, fields->f_dsp_16_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
342 case M32C_OPERAND_BITBASE16_16_U16 :
343 print_unsigned_bitbase (cd, info, fields->f_dsp_16_u16, 0, pc, length);
345 case M32C_OPERAND_BITBASE16_16_U8 :
346 print_unsigned_bitbase (cd, info, fields->f_dsp_16_u8, 0, pc, length);
348 case M32C_OPERAND_BITBASE16_8_U11_S :
349 print_unsigned_bitbase (cd, info, fields->f_bitbase16_u11_S, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
351 case M32C_OPERAND_BITBASE32_16_S11_UNPREFIXED :
352 print_signed_bitbase (cd, info, fields->f_bitbase32_16_s11_unprefixed, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
354 case M32C_OPERAND_BITBASE32_16_S19_UNPREFIXED :
355 print_signed_bitbase (cd, info, fields->f_bitbase32_16_s19_unprefixed, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
357 case M32C_OPERAND_BITBASE32_16_U11_UNPREFIXED :
358 print_unsigned_bitbase (cd, info, fields->f_bitbase32_16_u11_unprefixed, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
360 case M32C_OPERAND_BITBASE32_16_U19_UNPREFIXED :
361 print_unsigned_bitbase (cd, info, fields->f_bitbase32_16_u19_unprefixed, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
363 case M32C_OPERAND_BITBASE32_16_U27_UNPREFIXED :
364 print_unsigned_bitbase (cd, info, fields->f_bitbase32_16_u27_unprefixed, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
366 case M32C_OPERAND_BITBASE32_24_S11_PREFIXED :
367 print_signed_bitbase (cd, info, fields->f_bitbase32_24_s11_prefixed, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
369 case M32C_OPERAND_BITBASE32_24_S19_PREFIXED :
370 print_signed_bitbase (cd, info, fields->f_bitbase32_24_s19_prefixed, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
372 case M32C_OPERAND_BITBASE32_24_U11_PREFIXED :
373 print_unsigned_bitbase (cd, info, fields->f_bitbase32_24_u11_prefixed, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
375 case M32C_OPERAND_BITBASE32_24_U19_PREFIXED :
376 print_unsigned_bitbase (cd, info, fields->f_bitbase32_24_u19_prefixed, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
378 case M32C_OPERAND_BITBASE32_24_U27_PREFIXED :
379 print_unsigned_bitbase (cd, info, fields->f_bitbase32_24_u27_prefixed, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
381 case M32C_OPERAND_BITNO16R :
382 print_normal (cd, info, fields->f_dsp_16_u8, 0, pc, length);
384 case M32C_OPERAND_BITNO32PREFIXED :
385 print_normal (cd, info, fields->f_bitno32_prefixed, 0, pc, length);
387 case M32C_OPERAND_BITNO32UNPREFIXED :
388 print_normal (cd, info, fields->f_bitno32_unprefixed, 0, pc, length);
390 case M32C_OPERAND_DSP_10_U6 :
391 print_normal (cd, info, fields->f_dsp_10_u6, 0, pc, length);
393 case M32C_OPERAND_DSP_16_S16 :
394 print_normal (cd, info, fields->f_dsp_16_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
396 case M32C_OPERAND_DSP_16_S8 :
397 print_normal (cd, info, fields->f_dsp_16_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
399 case M32C_OPERAND_DSP_16_U16 :
400 print_normal (cd, info, fields->f_dsp_16_u16, 0, pc, length);
402 case M32C_OPERAND_DSP_16_U20 :
403 print_normal (cd, info, fields->f_dsp_16_u24, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
405 case M32C_OPERAND_DSP_16_U24 :
406 print_normal (cd, info, fields->f_dsp_16_u24, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
408 case M32C_OPERAND_DSP_16_U8 :
409 print_normal (cd, info, fields->f_dsp_16_u8, 0, pc, length);
411 case M32C_OPERAND_DSP_24_S16 :
412 print_normal (cd, info, fields->f_dsp_24_s16, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
414 case M32C_OPERAND_DSP_24_S8 :
415 print_normal (cd, info, fields->f_dsp_24_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
417 case M32C_OPERAND_DSP_24_U16 :
418 print_normal (cd, info, fields->f_dsp_24_u16, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
420 case M32C_OPERAND_DSP_24_U20 :
421 print_normal (cd, info, fields->f_dsp_24_u24, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
423 case M32C_OPERAND_DSP_24_U24 :
424 print_normal (cd, info, fields->f_dsp_24_u24, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
426 case M32C_OPERAND_DSP_24_U8 :
427 print_normal (cd, info, fields->f_dsp_24_u8, 0, pc, length);
429 case M32C_OPERAND_DSP_32_S16 :
430 print_normal (cd, info, fields->f_dsp_32_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
432 case M32C_OPERAND_DSP_32_S8 :
433 print_normal (cd, info, fields->f_dsp_32_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
435 case M32C_OPERAND_DSP_32_U16 :
436 print_normal (cd, info, fields->f_dsp_32_u16, 0, pc, length);
438 case M32C_OPERAND_DSP_32_U20 :
439 print_normal (cd, info, fields->f_dsp_32_u24, 0, pc, length);
441 case M32C_OPERAND_DSP_32_U24 :
442 print_normal (cd, info, fields->f_dsp_32_u24, 0, pc, length);
444 case M32C_OPERAND_DSP_32_U8 :
445 print_normal (cd, info, fields->f_dsp_32_u8, 0, pc, length);
447 case M32C_OPERAND_DSP_40_S16 :
448 print_normal (cd, info, fields->f_dsp_40_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
450 case M32C_OPERAND_DSP_40_S8 :
451 print_normal (cd, info, fields->f_dsp_40_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
453 case M32C_OPERAND_DSP_40_U16 :
454 print_normal (cd, info, fields->f_dsp_40_u16, 0, pc, length);
456 case M32C_OPERAND_DSP_40_U24 :
457 print_normal (cd, info, fields->f_dsp_40_u24, 0, pc, length);
459 case M32C_OPERAND_DSP_40_U8 :
460 print_normal (cd, info, fields->f_dsp_40_u8, 0, pc, length);
462 case M32C_OPERAND_DSP_48_S16 :
463 print_normal (cd, info, fields->f_dsp_48_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
465 case M32C_OPERAND_DSP_48_S8 :
466 print_normal (cd, info, fields->f_dsp_48_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
468 case M32C_OPERAND_DSP_48_U16 :
469 print_normal (cd, info, fields->f_dsp_48_u16, 0, pc, length);
471 case M32C_OPERAND_DSP_48_U24 :
472 print_normal (cd, info, fields->f_dsp_48_u24, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
474 case M32C_OPERAND_DSP_48_U8 :
475 print_normal (cd, info, fields->f_dsp_48_u8, 0, pc, length);
477 case M32C_OPERAND_DSP_8_S24 :
478 print_normal (cd, info, fields->f_dsp_8_s24, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
480 case M32C_OPERAND_DSP_8_S8 :
481 print_normal (cd, info, fields->f_dsp_8_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
483 case M32C_OPERAND_DSP_8_U16 :
484 print_normal (cd, info, fields->f_dsp_8_u16, 0, pc, length);
486 case M32C_OPERAND_DSP_8_U24 :
487 print_normal (cd, info, fields->f_dsp_8_u24, 0, pc, length);
489 case M32C_OPERAND_DSP_8_U6 :
490 print_normal (cd, info, fields->f_dsp_8_u6, 0, pc, length);
492 case M32C_OPERAND_DSP_8_U8 :
493 print_normal (cd, info, fields->f_dsp_8_u8, 0, pc, length);
495 case M32C_OPERAND_DST16AN :
496 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst16_an, 0);
498 case M32C_OPERAND_DST16AN_S :
499 print_keyword (cd, info, & m32c_cgen_opval_h_ar_HI, fields->f_dst16_an_s, 0);
501 case M32C_OPERAND_DST16ANHI :
502 print_keyword (cd, info, & m32c_cgen_opval_h_ar_HI, fields->f_dst16_an, 0);
504 case M32C_OPERAND_DST16ANQI :
505 print_keyword (cd, info, & m32c_cgen_opval_h_ar_QI, fields->f_dst16_an, 0);
507 case M32C_OPERAND_DST16ANQI_S :
508 print_keyword (cd, info, & m32c_cgen_opval_h_ar_QI, fields->f_dst16_rn_QI_s, 0);
510 case M32C_OPERAND_DST16ANSI :
511 print_keyword (cd, info, & m32c_cgen_opval_h_ar_SI, fields->f_dst16_an, 0);
513 case M32C_OPERAND_DST16RNEXTQI :
514 print_keyword (cd, info, & m32c_cgen_opval_h_gr_ext_QI, fields->f_dst16_rn_ext, 0);
516 case M32C_OPERAND_DST16RNHI :
517 print_keyword (cd, info, & m32c_cgen_opval_h_gr_HI, fields->f_dst16_rn, 0);
519 case M32C_OPERAND_DST16RNQI :
520 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_dst16_rn, 0);
522 case M32C_OPERAND_DST16RNQI_S :
523 print_keyword (cd, info, & m32c_cgen_opval_h_r0l_r0h, fields->f_dst16_rn_QI_s, 0);
525 case M32C_OPERAND_DST16RNSI :
526 print_keyword (cd, info, & m32c_cgen_opval_h_gr_SI, fields->f_dst16_rn, 0);
528 case M32C_OPERAND_DST32ANEXTUNPREFIXED :
529 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst32_an_unprefixed, 0);
531 case M32C_OPERAND_DST32ANPREFIXED :
532 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst32_an_prefixed, 0);
534 case M32C_OPERAND_DST32ANPREFIXEDHI :
535 print_keyword (cd, info, & m32c_cgen_opval_h_ar_HI, fields->f_dst32_an_prefixed, 0);
537 case M32C_OPERAND_DST32ANPREFIXEDQI :
538 print_keyword (cd, info, & m32c_cgen_opval_h_ar_QI, fields->f_dst32_an_prefixed, 0);
540 case M32C_OPERAND_DST32ANPREFIXEDSI :
541 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst32_an_prefixed, 0);
543 case M32C_OPERAND_DST32ANUNPREFIXED :
544 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst32_an_unprefixed, 0);
546 case M32C_OPERAND_DST32ANUNPREFIXEDHI :
547 print_keyword (cd, info, & m32c_cgen_opval_h_ar_HI, fields->f_dst32_an_unprefixed, 0);
549 case M32C_OPERAND_DST32ANUNPREFIXEDQI :
550 print_keyword (cd, info, & m32c_cgen_opval_h_ar_QI, fields->f_dst32_an_unprefixed, 0);
552 case M32C_OPERAND_DST32ANUNPREFIXEDSI :
553 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_dst32_an_unprefixed, 0);
555 case M32C_OPERAND_DST32R0HI_S :
556 print_keyword (cd, info, & m32c_cgen_opval_h_r0, 0, 0);
558 case M32C_OPERAND_DST32R0QI_S :
559 print_keyword (cd, info, & m32c_cgen_opval_h_r0l, 0, 0);
561 case M32C_OPERAND_DST32RNEXTUNPREFIXEDHI :
562 print_keyword (cd, info, & m32c_cgen_opval_h_gr_ext_HI, fields->f_dst32_rn_ext_unprefixed, 0);
564 case M32C_OPERAND_DST32RNEXTUNPREFIXEDQI :
565 print_keyword (cd, info, & m32c_cgen_opval_h_gr_ext_QI, fields->f_dst32_rn_ext_unprefixed, 0);
567 case M32C_OPERAND_DST32RNPREFIXEDHI :
568 print_keyword (cd, info, & m32c_cgen_opval_h_gr_HI, fields->f_dst32_rn_prefixed_HI, 0);
570 case M32C_OPERAND_DST32RNPREFIXEDQI :
571 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_dst32_rn_prefixed_QI, 0);
573 case M32C_OPERAND_DST32RNPREFIXEDSI :
574 print_keyword (cd, info, & m32c_cgen_opval_h_gr_SI, fields->f_dst32_rn_prefixed_SI, 0);
576 case M32C_OPERAND_DST32RNUNPREFIXEDHI :
577 print_keyword (cd, info, & m32c_cgen_opval_h_gr_HI, fields->f_dst32_rn_unprefixed_HI, 0);
579 case M32C_OPERAND_DST32RNUNPREFIXEDQI :
580 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_dst32_rn_unprefixed_QI, 0);
582 case M32C_OPERAND_DST32RNUNPREFIXEDSI :
583 print_keyword (cd, info, & m32c_cgen_opval_h_gr_SI, fields->f_dst32_rn_unprefixed_SI, 0);
585 case M32C_OPERAND_G :
586 print_G (cd, info, 0, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
588 case M32C_OPERAND_IMM_12_S4 :
589 print_normal (cd, info, fields->f_imm_12_s4, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
591 case M32C_OPERAND_IMM_12_S4N :
592 print_signed4n (cd, info, fields->f_imm_12_s4, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
594 case M32C_OPERAND_IMM_13_U3 :
595 print_normal (cd, info, fields->f_imm_13_u3, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
597 case M32C_OPERAND_IMM_16_HI :
598 print_normal (cd, info, fields->f_dsp_16_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
600 case M32C_OPERAND_IMM_16_QI :
601 print_normal (cd, info, fields->f_dsp_16_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
603 case M32C_OPERAND_IMM_16_SI :
604 print_normal (cd, info, fields->f_dsp_16_s32, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
606 case M32C_OPERAND_IMM_20_S4 :
607 print_normal (cd, info, fields->f_imm_20_s4, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
609 case M32C_OPERAND_IMM_24_HI :
610 print_normal (cd, info, fields->f_dsp_24_s16, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
612 case M32C_OPERAND_IMM_24_QI :
613 print_normal (cd, info, fields->f_dsp_24_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
615 case M32C_OPERAND_IMM_24_SI :
616 print_normal (cd, info, fields->f_dsp_24_s32, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
618 case M32C_OPERAND_IMM_32_HI :
619 print_normal (cd, info, fields->f_dsp_32_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
621 case M32C_OPERAND_IMM_32_QI :
622 print_normal (cd, info, fields->f_dsp_32_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
624 case M32C_OPERAND_IMM_32_SI :
625 print_normal (cd, info, fields->f_dsp_32_s32, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
627 case M32C_OPERAND_IMM_40_HI :
628 print_normal (cd, info, fields->f_dsp_40_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
630 case M32C_OPERAND_IMM_40_QI :
631 print_normal (cd, info, fields->f_dsp_40_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
633 case M32C_OPERAND_IMM_40_SI :
634 print_normal (cd, info, fields->f_dsp_40_s32, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
636 case M32C_OPERAND_IMM_48_HI :
637 print_normal (cd, info, fields->f_dsp_48_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
639 case M32C_OPERAND_IMM_48_QI :
640 print_normal (cd, info, fields->f_dsp_48_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
642 case M32C_OPERAND_IMM_48_SI :
643 print_normal (cd, info, fields->f_dsp_48_s32, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
645 case M32C_OPERAND_IMM_56_HI :
646 print_normal (cd, info, fields->f_dsp_56_s16, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
648 case M32C_OPERAND_IMM_56_QI :
649 print_normal (cd, info, fields->f_dsp_56_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
651 case M32C_OPERAND_IMM_64_HI :
652 print_normal (cd, info, fields->f_dsp_64_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
654 case M32C_OPERAND_IMM_8_HI :
655 print_normal (cd, info, fields->f_dsp_8_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
657 case M32C_OPERAND_IMM_8_QI :
658 print_normal (cd, info, fields->f_dsp_8_s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
660 case M32C_OPERAND_IMM_8_S4 :
661 print_normal (cd, info, fields->f_imm_8_s4, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
663 case M32C_OPERAND_IMM_8_S4N :
664 print_normal (cd, info, fields->f_imm_8_s4, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
666 case M32C_OPERAND_IMM_SH_12_S4 :
667 print_keyword (cd, info, & m32c_cgen_opval_h_shimm, fields->f_imm_12_s4, 0);
669 case M32C_OPERAND_IMM_SH_20_S4 :
670 print_keyword (cd, info, & m32c_cgen_opval_h_shimm, fields->f_imm_20_s4, 0);
672 case M32C_OPERAND_IMM_SH_8_S4 :
673 print_keyword (cd, info, & m32c_cgen_opval_h_shimm, fields->f_imm_8_s4, 0);
675 case M32C_OPERAND_IMM1_S :
676 print_normal (cd, info, fields->f_imm1_S, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
678 case M32C_OPERAND_IMM3_S :
679 print_normal (cd, info, fields->f_imm3_S, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
681 case M32C_OPERAND_LAB_16_8 :
682 print_address (cd, info, fields->f_lab_16_8, 0|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
684 case M32C_OPERAND_LAB_24_8 :
685 print_address (cd, info, fields->f_lab_24_8, 0|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
687 case M32C_OPERAND_LAB_32_8 :
688 print_address (cd, info, fields->f_lab_32_8, 0|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
690 case M32C_OPERAND_LAB_40_8 :
691 print_address (cd, info, fields->f_lab_40_8, 0|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
693 case M32C_OPERAND_LAB_5_3 :
694 print_address (cd, info, fields->f_lab_5_3, 0|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
696 case M32C_OPERAND_LAB_8_16 :
697 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);
699 case M32C_OPERAND_LAB_8_24 :
700 print_address (cd, info, fields->f_lab_8_24, 0|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_ABS_ADDR), pc, length);
702 case M32C_OPERAND_LAB_8_8 :
703 print_address (cd, info, fields->f_lab_8_8, 0|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
705 case M32C_OPERAND_LAB32_JMP_S :
706 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);
708 case M32C_OPERAND_Q :
709 print_Q (cd, info, 0, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
711 case M32C_OPERAND_R0 :
712 print_keyword (cd, info, & m32c_cgen_opval_h_r0, 0, 0);
714 case M32C_OPERAND_R0H :
715 print_keyword (cd, info, & m32c_cgen_opval_h_r0h, 0, 0);
717 case M32C_OPERAND_R0L :
718 print_keyword (cd, info, & m32c_cgen_opval_h_r0l, 0, 0);
720 case M32C_OPERAND_R1 :
721 print_keyword (cd, info, & m32c_cgen_opval_h_r1, 0, 0);
723 case M32C_OPERAND_R1R2R0 :
724 print_keyword (cd, info, & m32c_cgen_opval_h_r1r2r0, 0, 0);
726 case M32C_OPERAND_R2 :
727 print_keyword (cd, info, & m32c_cgen_opval_h_r2, 0, 0);
729 case M32C_OPERAND_R2R0 :
730 print_keyword (cd, info, & m32c_cgen_opval_h_r2r0, 0, 0);
732 case M32C_OPERAND_R3 :
733 print_keyword (cd, info, & m32c_cgen_opval_h_r3, 0, 0);
735 case M32C_OPERAND_R3R1 :
736 print_keyword (cd, info, & m32c_cgen_opval_h_r3r1, 0, 0);
738 case M32C_OPERAND_REGSETPOP :
739 print_pop_regset (cd, info, fields->f_8_8, 0, pc, length);
741 case M32C_OPERAND_REGSETPUSH :
742 print_push_regset (cd, info, fields->f_8_8, 0, pc, length);
744 case M32C_OPERAND_RN16_PUSH_S :
745 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_4_1, 0);
747 case M32C_OPERAND_S :
748 print_S (cd, info, 0, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
750 case M32C_OPERAND_SRC16AN :
751 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_src16_an, 0);
753 case M32C_OPERAND_SRC16ANHI :
754 print_keyword (cd, info, & m32c_cgen_opval_h_ar_HI, fields->f_src16_an, 0);
756 case M32C_OPERAND_SRC16ANQI :
757 print_keyword (cd, info, & m32c_cgen_opval_h_ar_QI, fields->f_src16_an, 0);
759 case M32C_OPERAND_SRC16RNHI :
760 print_keyword (cd, info, & m32c_cgen_opval_h_gr_HI, fields->f_src16_rn, 0);
762 case M32C_OPERAND_SRC16RNQI :
763 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_src16_rn, 0);
765 case M32C_OPERAND_SRC32ANPREFIXED :
766 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_src32_an_prefixed, 0);
768 case M32C_OPERAND_SRC32ANPREFIXEDHI :
769 print_keyword (cd, info, & m32c_cgen_opval_h_ar_HI, fields->f_src32_an_prefixed, 0);
771 case M32C_OPERAND_SRC32ANPREFIXEDQI :
772 print_keyword (cd, info, & m32c_cgen_opval_h_ar_QI, fields->f_src32_an_prefixed, 0);
774 case M32C_OPERAND_SRC32ANPREFIXEDSI :
775 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_src32_an_prefixed, 0);
777 case M32C_OPERAND_SRC32ANUNPREFIXED :
778 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_src32_an_unprefixed, 0);
780 case M32C_OPERAND_SRC32ANUNPREFIXEDHI :
781 print_keyword (cd, info, & m32c_cgen_opval_h_ar_HI, fields->f_src32_an_unprefixed, 0);
783 case M32C_OPERAND_SRC32ANUNPREFIXEDQI :
784 print_keyword (cd, info, & m32c_cgen_opval_h_ar_QI, fields->f_src32_an_unprefixed, 0);
786 case M32C_OPERAND_SRC32ANUNPREFIXEDSI :
787 print_keyword (cd, info, & m32c_cgen_opval_h_ar, fields->f_src32_an_unprefixed, 0);
789 case M32C_OPERAND_SRC32RNPREFIXEDHI :
790 print_keyword (cd, info, & m32c_cgen_opval_h_gr_HI, fields->f_src32_rn_prefixed_HI, 0);
792 case M32C_OPERAND_SRC32RNPREFIXEDQI :
793 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_src32_rn_prefixed_QI, 0);
795 case M32C_OPERAND_SRC32RNPREFIXEDSI :
796 print_keyword (cd, info, & m32c_cgen_opval_h_gr_SI, fields->f_src32_rn_prefixed_SI, 0);
798 case M32C_OPERAND_SRC32RNUNPREFIXEDHI :
799 print_keyword (cd, info, & m32c_cgen_opval_h_gr_HI, fields->f_src32_rn_unprefixed_HI, 0);
801 case M32C_OPERAND_SRC32RNUNPREFIXEDQI :
802 print_keyword (cd, info, & m32c_cgen_opval_h_gr_QI, fields->f_src32_rn_unprefixed_QI, 0);
804 case M32C_OPERAND_SRC32RNUNPREFIXEDSI :
805 print_keyword (cd, info, & m32c_cgen_opval_h_gr_SI, fields->f_src32_rn_unprefixed_SI, 0);
807 case M32C_OPERAND_SRCDST16_R0L_R0H_S_NORMAL :
808 print_r0l_r0h (cd, info, fields->f_5_1, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
810 case M32C_OPERAND_X :
811 print_X (cd, info, 0, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
813 case M32C_OPERAND_Z :
814 print_Z (cd, info, 0, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
816 case M32C_OPERAND_COND16_16 :
817 print_keyword (cd, info, & m32c_cgen_opval_h_cond16, fields->f_dsp_16_u8, 0);
819 case M32C_OPERAND_COND16_24 :
820 print_keyword (cd, info, & m32c_cgen_opval_h_cond16, fields->f_dsp_24_u8, 0);
822 case M32C_OPERAND_COND16_32 :
823 print_keyword (cd, info, & m32c_cgen_opval_h_cond16, fields->f_dsp_32_u8, 0);
825 case M32C_OPERAND_COND16C :
826 print_keyword (cd, info, & m32c_cgen_opval_h_cond16c, fields->f_cond16, 0);
828 case M32C_OPERAND_COND16J :
829 print_keyword (cd, info, & m32c_cgen_opval_h_cond16j, fields->f_cond16, 0);
831 case M32C_OPERAND_COND16J5 :
832 print_keyword (cd, info, & m32c_cgen_opval_h_cond16j_5, fields->f_cond16j_5, 0);
834 case M32C_OPERAND_COND32 :
835 print_keyword (cd, info, & m32c_cgen_opval_h_cond32, fields->f_cond32, 0|(1<<CGEN_OPERAND_VIRTUAL));
837 case M32C_OPERAND_COND32_16 :
838 print_keyword (cd, info, & m32c_cgen_opval_h_cond32, fields->f_dsp_16_u8, 0);
840 case M32C_OPERAND_COND32_24 :
841 print_keyword (cd, info, & m32c_cgen_opval_h_cond32, fields->f_dsp_24_u8, 0);
843 case M32C_OPERAND_COND32_32 :
844 print_keyword (cd, info, & m32c_cgen_opval_h_cond32, fields->f_dsp_32_u8, 0);
846 case M32C_OPERAND_COND32_40 :
847 print_keyword (cd, info, & m32c_cgen_opval_h_cond32, fields->f_dsp_40_u8, 0);
849 case M32C_OPERAND_COND32J :
850 print_keyword (cd, info, & m32c_cgen_opval_h_cond32, fields->f_cond32j, 0|(1<<CGEN_OPERAND_VIRTUAL));
852 case M32C_OPERAND_CR1_PREFIXED_32 :
853 print_keyword (cd, info, & m32c_cgen_opval_h_cr1_32, fields->f_21_3, 0);
855 case M32C_OPERAND_CR1_UNPREFIXED_32 :
856 print_keyword (cd, info, & m32c_cgen_opval_h_cr1_32, fields->f_13_3, 0);
858 case M32C_OPERAND_CR16 :
859 print_keyword (cd, info, & m32c_cgen_opval_h_cr_16, fields->f_9_3, 0);
861 case M32C_OPERAND_CR2_32 :
862 print_keyword (cd, info, & m32c_cgen_opval_h_cr2_32, fields->f_13_3, 0);
864 case M32C_OPERAND_CR3_PREFIXED_32 :
865 print_keyword (cd, info, & m32c_cgen_opval_h_cr3_32, fields->f_21_3, 0);
867 case M32C_OPERAND_CR3_UNPREFIXED_32 :
868 print_keyword (cd, info, & m32c_cgen_opval_h_cr3_32, fields->f_13_3, 0);
870 case M32C_OPERAND_FLAGS16 :
871 print_keyword (cd, info, & m32c_cgen_opval_h_flags, fields->f_9_3, 0);
873 case M32C_OPERAND_FLAGS32 :
874 print_keyword (cd, info, & m32c_cgen_opval_h_flags, fields->f_13_3, 0);
876 case M32C_OPERAND_SCCOND32 :
877 print_keyword (cd, info, & m32c_cgen_opval_h_cond32, fields->f_cond16, 0);
879 case M32C_OPERAND_SIZE :
880 print_size (cd, info, 0, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
884 /* xgettext:c-format */
885 fprintf (stderr, _("Unrecognized field %d while printing insn.\n"),
891 cgen_print_fn * const m32c_cgen_print_handlers[] =
898 m32c_cgen_init_dis (CGEN_CPU_DESC cd)
900 m32c_cgen_init_opcode_table (cd);
901 m32c_cgen_init_ibld_table (cd);
902 cd->print_handlers = & m32c_cgen_print_handlers[0];
903 cd->print_operand = m32c_cgen_print_operand;
907 /* Default print handler. */
910 print_normal (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
914 bfd_vma pc ATTRIBUTE_UNUSED,
915 int length ATTRIBUTE_UNUSED)
917 disassemble_info *info = (disassemble_info *) dis_info;
919 #ifdef CGEN_PRINT_NORMAL
920 CGEN_PRINT_NORMAL (cd, info, value, attrs, pc, length);
923 /* Print the operand as directed by the attributes. */
924 if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY))
925 ; /* nothing to do */
926 else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED))
927 (*info->fprintf_func) (info->stream, "%ld", value);
929 (*info->fprintf_func) (info->stream, "0x%lx", value);
932 /* Default address handler. */
935 print_address (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
939 bfd_vma pc ATTRIBUTE_UNUSED,
940 int length ATTRIBUTE_UNUSED)
942 disassemble_info *info = (disassemble_info *) dis_info;
944 #ifdef CGEN_PRINT_ADDRESS
945 CGEN_PRINT_ADDRESS (cd, info, value, attrs, pc, length);
948 /* Print the operand as directed by the attributes. */
949 if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY))
950 ; /* Nothing to do. */
951 else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_PCREL_ADDR))
952 (*info->print_address_func) (value, info);
953 else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_ABS_ADDR))
954 (*info->print_address_func) (value, info);
955 else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED))
956 (*info->fprintf_func) (info->stream, "%ld", (long) value);
958 (*info->fprintf_func) (info->stream, "0x%lx", (long) value);
961 /* Keyword print handler. */
964 print_keyword (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
966 CGEN_KEYWORD *keyword_table,
968 unsigned int attrs ATTRIBUTE_UNUSED)
970 disassemble_info *info = (disassemble_info *) dis_info;
971 const CGEN_KEYWORD_ENTRY *ke;
973 ke = cgen_keyword_lookup_value (keyword_table, value);
975 (*info->fprintf_func) (info->stream, "%s", ke->name);
977 (*info->fprintf_func) (info->stream, "???");
980 /* Default insn printer.
982 DIS_INFO is defined as `void *' so the disassembler needn't know anything
983 about disassemble_info. */
986 print_insn_normal (CGEN_CPU_DESC cd,
988 const CGEN_INSN *insn,
993 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
994 disassemble_info *info = (disassemble_info *) dis_info;
995 const CGEN_SYNTAX_CHAR_TYPE *syn;
997 CGEN_INIT_PRINT (cd);
999 for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
1001 if (CGEN_SYNTAX_MNEMONIC_P (*syn))
1003 (*info->fprintf_func) (info->stream, "%s", CGEN_INSN_MNEMONIC (insn));
1006 if (CGEN_SYNTAX_CHAR_P (*syn))
1008 (*info->fprintf_func) (info->stream, "%c", CGEN_SYNTAX_CHAR (*syn));
1012 /* We have an operand. */
1013 m32c_cgen_print_operand (cd, CGEN_SYNTAX_FIELD (*syn), info,
1014 fields, CGEN_INSN_ATTRS (insn), pc, length);
1018 /* Subroutine of print_insn. Reads an insn into the given buffers and updates
1020 Returns 0 if all is well, non-zero otherwise. */
1023 read_insn (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1025 disassemble_info *info,
1028 CGEN_EXTRACT_INFO *ex_info,
1029 unsigned long *insn_value)
1031 int status = (*info->read_memory_func) (pc, buf, buflen, info);
1035 (*info->memory_error_func) (status, pc, info);
1039 ex_info->dis_info = info;
1040 ex_info->valid = (1 << buflen) - 1;
1041 ex_info->insn_bytes = buf;
1043 *insn_value = bfd_get_bits (buf, buflen * 8, info->endian == BFD_ENDIAN_BIG);
1047 /* Utility to print an insn.
1048 BUF is the base part of the insn, target byte order, BUFLEN bytes long.
1049 The result is the size of the insn in bytes or zero for an unknown insn
1050 or -1 if an error occurs fetching data (memory_error_func will have
1054 print_insn (CGEN_CPU_DESC cd,
1056 disassemble_info *info,
1058 unsigned int buflen)
1060 CGEN_INSN_INT insn_value;
1061 const CGEN_INSN_LIST *insn_list;
1062 CGEN_EXTRACT_INFO ex_info;
1065 /* Extract base part of instruction, just in case CGEN_DIS_* uses it. */
1066 basesize = cd->base_insn_bitsize < buflen * 8 ?
1067 cd->base_insn_bitsize : buflen * 8;
1068 insn_value = cgen_get_insn_value (cd, buf, basesize);
1071 /* Fill in ex_info fields like read_insn would. Don't actually call
1072 read_insn, since the incoming buffer is already read (and possibly
1073 modified a la m32r). */
1074 ex_info.valid = (1 << buflen) - 1;
1075 ex_info.dis_info = info;
1076 ex_info.insn_bytes = buf;
1078 /* The instructions are stored in hash lists.
1079 Pick the first one and keep trying until we find the right one. */
1081 insn_list = CGEN_DIS_LOOKUP_INSN (cd, (char *) buf, insn_value);
1082 while (insn_list != NULL)
1084 const CGEN_INSN *insn = insn_list->insn;
1087 unsigned long insn_value_cropped;
1089 #ifdef CGEN_VALIDATE_INSN_SUPPORTED
1090 /* Not needed as insn shouldn't be in hash lists if not supported. */
1091 /* Supported by this cpu? */
1092 if (! m32c_cgen_insn_supported (cd, insn))
1094 insn_list = CGEN_DIS_NEXT_INSN (insn_list);
1099 /* Basic bit mask must be correct. */
1100 /* ??? May wish to allow target to defer this check until the extract
1103 /* Base size may exceed this instruction's size. Extract the
1104 relevant part from the buffer. */
1105 if ((unsigned) (CGEN_INSN_BITSIZE (insn) / 8) < buflen &&
1106 (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long))
1107 insn_value_cropped = bfd_get_bits (buf, CGEN_INSN_BITSIZE (insn),
1108 info->endian == BFD_ENDIAN_BIG);
1110 insn_value_cropped = insn_value;
1112 if ((insn_value_cropped & CGEN_INSN_BASE_MASK (insn))
1113 == CGEN_INSN_BASE_VALUE (insn))
1115 /* Printing is handled in two passes. The first pass parses the
1116 machine insn and extracts the fields. The second pass prints
1119 /* Make sure the entire insn is loaded into insn_value, if it
1121 if (((unsigned) CGEN_INSN_BITSIZE (insn) > cd->base_insn_bitsize) &&
1122 (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long))
1124 unsigned long full_insn_value;
1125 int rc = read_insn (cd, pc, info, buf,
1126 CGEN_INSN_BITSIZE (insn) / 8,
1127 & ex_info, & full_insn_value);
1130 length = CGEN_EXTRACT_FN (cd, insn)
1131 (cd, insn, &ex_info, full_insn_value, &fields, pc);
1134 length = CGEN_EXTRACT_FN (cd, insn)
1135 (cd, insn, &ex_info, insn_value_cropped, &fields, pc);
1137 /* Length < 0 -> error. */
1142 CGEN_PRINT_FN (cd, insn) (cd, info, insn, &fields, pc, length);
1143 /* Length is in bits, result is in bytes. */
1148 insn_list = CGEN_DIS_NEXT_INSN (insn_list);
1154 /* Default value for CGEN_PRINT_INSN.
1155 The result is the size of the insn in bytes or zero for an unknown insn
1156 or -1 if an error occured fetching bytes. */
1158 #ifndef CGEN_PRINT_INSN
1159 #define CGEN_PRINT_INSN default_print_insn
1163 default_print_insn (CGEN_CPU_DESC cd, bfd_vma pc, disassemble_info *info)
1165 bfd_byte buf[CGEN_MAX_INSN_SIZE];
1169 /* Attempt to read the base part of the insn. */
1170 buflen = cd->base_insn_bitsize / 8;
1171 status = (*info->read_memory_func) (pc, buf, buflen, info);
1173 /* Try again with the minimum part, if min < base. */
1174 if (status != 0 && (cd->min_insn_bitsize < cd->base_insn_bitsize))
1176 buflen = cd->min_insn_bitsize / 8;
1177 status = (*info->read_memory_func) (pc, buf, buflen, info);
1182 (*info->memory_error_func) (status, pc, info);
1186 return print_insn (cd, pc, info, buf, buflen);
1189 /* Main entry point.
1190 Print one instruction from PC on INFO->STREAM.
1191 Return the size of the instruction (in bytes). */
1193 typedef struct cpu_desc_list
1195 struct cpu_desc_list *next;
1203 print_insn_m32c (bfd_vma pc, disassemble_info *info)
1205 static cpu_desc_list *cd_list = 0;
1206 cpu_desc_list *cl = 0;
1207 static CGEN_CPU_DESC cd = 0;
1208 static CGEN_BITSET *prev_isa;
1209 static int prev_mach;
1210 static int prev_endian;
1214 int endian = (info->endian == BFD_ENDIAN_BIG
1216 : CGEN_ENDIAN_LITTLE);
1217 enum bfd_architecture arch;
1219 /* ??? gdb will set mach but leave the architecture as "unknown" */
1220 #ifndef CGEN_BFD_ARCH
1221 #define CGEN_BFD_ARCH bfd_arch_m32c
1224 if (arch == bfd_arch_unknown)
1225 arch = CGEN_BFD_ARCH;
1227 /* There's no standard way to compute the machine or isa number
1228 so we leave it to the target. */
1229 #ifdef CGEN_COMPUTE_MACH
1230 mach = CGEN_COMPUTE_MACH (info);
1235 #ifdef CGEN_COMPUTE_ISA
1237 static CGEN_BITSET *permanent_isa;
1240 permanent_isa = cgen_bitset_create (MAX_ISAS);
1241 isa = permanent_isa;
1242 cgen_bitset_clear (isa);
1243 cgen_bitset_add (isa, CGEN_COMPUTE_ISA (info));
1246 isa = info->insn_sets;
1249 /* If we've switched cpu's, try to find a handle we've used before */
1251 && (cgen_bitset_compare (isa, prev_isa) != 0
1252 || mach != prev_mach
1253 || endian != prev_endian))
1256 for (cl = cd_list; cl; cl = cl->next)
1258 if (cgen_bitset_compare (cl->isa, isa) == 0 &&
1260 cl->endian == endian)
1263 prev_isa = cd->isas;
1269 /* If we haven't initialized yet, initialize the opcode table. */
1272 const bfd_arch_info_type *arch_type = bfd_lookup_arch (arch, mach);
1273 const char *mach_name;
1277 mach_name = arch_type->printable_name;
1279 prev_isa = cgen_bitset_copy (isa);
1281 prev_endian = endian;
1282 cd = m32c_cgen_cpu_open (CGEN_CPU_OPEN_ISAS, prev_isa,
1283 CGEN_CPU_OPEN_BFDMACH, mach_name,
1284 CGEN_CPU_OPEN_ENDIAN, prev_endian,
1289 /* Save this away for future reference. */
1290 cl = xmalloc (sizeof (struct cpu_desc_list));
1294 cl->endian = endian;
1298 m32c_cgen_init_dis (cd);
1301 /* We try to have as much common code as possible.
1302 But at this point some targets need to take over. */
1303 /* ??? Some targets may need a hook elsewhere. Try to avoid this,
1304 but if not possible try to move this hook elsewhere rather than
1306 length = CGEN_PRINT_INSN (cd, pc, info);
1312 (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG);
1313 return cd->default_insn_bitsize / 8;