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, 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
);
265 void m32c_cgen_print_operand
266 (CGEN_CPU_DESC
, int, PTR
, CGEN_FIELDS
*, void const *, bfd_vma
, int);
268 /* Main entry point for printing operands.
269 XINFO is a `void *' and not a `disassemble_info *' to not put a requirement
270 of dis-asm.h on cgen.h.
272 This function is basically just a big switch statement. Earlier versions
273 used tables to look up the function to use, but
274 - if the table contains both assembler and disassembler functions then
275 the disassembler contains much of the assembler and vice-versa,
276 - there's a lot of inlining possibilities as things grow,
277 - using a switch statement avoids the function call overhead.
279 This function could be moved into `print_insn_normal', but keeping it
280 separate makes clear the interface between `print_insn_normal' and each of
284 m32c_cgen_print_operand (CGEN_CPU_DESC cd
,
288 void const *attrs ATTRIBUTE_UNUSED
,
292 disassemble_info
*info
= (disassemble_info
*) xinfo
;
296 case M32C_OPERAND_A0
:
297 print_keyword (cd
, info
, & m32c_cgen_opval_h_a0
, 0, 0);
299 case M32C_OPERAND_A1
:
300 print_keyword (cd
, info
, & m32c_cgen_opval_h_a1
, 0, 0);
302 case M32C_OPERAND_AN16_PUSH_S
:
303 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar_HI
, fields
->f_4_1
, 0);
305 case M32C_OPERAND_BIT16AN
:
306 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar
, fields
->f_dst16_an
, 0);
308 case M32C_OPERAND_BIT16RN
:
309 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_HI
, fields
->f_dst16_rn
, 0);
311 case M32C_OPERAND_BIT32ANPREFIXED
:
312 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar
, fields
->f_dst32_an_prefixed
, 0);
314 case M32C_OPERAND_BIT32ANUNPREFIXED
:
315 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar
, fields
->f_dst32_an_unprefixed
, 0);
317 case M32C_OPERAND_BIT32RNPREFIXED
:
318 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_QI
, fields
->f_dst32_rn_prefixed_QI
, 0);
320 case M32C_OPERAND_BIT32RNUNPREFIXED
:
321 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_QI
, fields
->f_dst32_rn_unprefixed_QI
, 0);
323 case M32C_OPERAND_BITBASE16_16_S8
:
324 print_signed_bitbase (cd
, info
, fields
->f_dsp_16_s8
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
326 case M32C_OPERAND_BITBASE16_16_U16
:
327 print_unsigned_bitbase (cd
, info
, fields
->f_dsp_16_u16
, 0, pc
, length
);
329 case M32C_OPERAND_BITBASE16_16_U8
:
330 print_unsigned_bitbase (cd
, info
, fields
->f_dsp_16_u8
, 0, pc
, length
);
332 case M32C_OPERAND_BITBASE16_8_U11_S
:
333 print_unsigned_bitbase (cd
, info
, fields
->f_bitbase16_u11_S
, 0|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
335 case M32C_OPERAND_BITBASE32_16_S11_UNPREFIXED
:
336 print_signed_bitbase (cd
, info
, fields
->f_bitbase32_16_s11_unprefixed
, 0|(1<<CGEN_OPERAND_SIGNED
)|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
338 case M32C_OPERAND_BITBASE32_16_S19_UNPREFIXED
:
339 print_signed_bitbase (cd
, info
, fields
->f_bitbase32_16_s19_unprefixed
, 0|(1<<CGEN_OPERAND_SIGNED
)|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
341 case M32C_OPERAND_BITBASE32_16_U11_UNPREFIXED
:
342 print_unsigned_bitbase (cd
, info
, fields
->f_bitbase32_16_u11_unprefixed
, 0|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
344 case M32C_OPERAND_BITBASE32_16_U19_UNPREFIXED
:
345 print_unsigned_bitbase (cd
, info
, fields
->f_bitbase32_16_u19_unprefixed
, 0|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
347 case M32C_OPERAND_BITBASE32_16_U27_UNPREFIXED
:
348 print_unsigned_bitbase (cd
, info
, fields
->f_bitbase32_16_u27_unprefixed
, 0|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
350 case M32C_OPERAND_BITBASE32_24_S11_PREFIXED
:
351 print_signed_bitbase (cd
, info
, fields
->f_bitbase32_24_s11_prefixed
, 0|(1<<CGEN_OPERAND_SIGNED
)|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
353 case M32C_OPERAND_BITBASE32_24_S19_PREFIXED
:
354 print_signed_bitbase (cd
, info
, fields
->f_bitbase32_24_s19_prefixed
, 0|(1<<CGEN_OPERAND_SIGNED
)|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
356 case M32C_OPERAND_BITBASE32_24_U11_PREFIXED
:
357 print_unsigned_bitbase (cd
, info
, fields
->f_bitbase32_24_u11_prefixed
, 0|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
359 case M32C_OPERAND_BITBASE32_24_U19_PREFIXED
:
360 print_unsigned_bitbase (cd
, info
, fields
->f_bitbase32_24_u19_prefixed
, 0|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
362 case M32C_OPERAND_BITBASE32_24_U27_PREFIXED
:
363 print_unsigned_bitbase (cd
, info
, fields
->f_bitbase32_24_u27_prefixed
, 0|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
365 case M32C_OPERAND_BITNO16R
:
366 print_normal (cd
, info
, fields
->f_dsp_16_u8
, 0, pc
, length
);
368 case M32C_OPERAND_BITNO32PREFIXED
:
369 print_normal (cd
, info
, fields
->f_bitno32_prefixed
, 0, pc
, length
);
371 case M32C_OPERAND_BITNO32UNPREFIXED
:
372 print_normal (cd
, info
, fields
->f_bitno32_unprefixed
, 0, pc
, length
);
374 case M32C_OPERAND_DSP_10_U6
:
375 print_normal (cd
, info
, fields
->f_dsp_10_u6
, 0, pc
, length
);
377 case M32C_OPERAND_DSP_16_S16
:
378 print_normal (cd
, info
, fields
->f_dsp_16_s16
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
380 case M32C_OPERAND_DSP_16_S8
:
381 print_normal (cd
, info
, fields
->f_dsp_16_s8
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
383 case M32C_OPERAND_DSP_16_U16
:
384 print_normal (cd
, info
, fields
->f_dsp_16_u16
, 0, pc
, length
);
386 case M32C_OPERAND_DSP_16_U20
:
387 print_normal (cd
, info
, fields
->f_dsp_16_u24
, 0|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
389 case M32C_OPERAND_DSP_16_U24
:
390 print_normal (cd
, info
, fields
->f_dsp_16_u24
, 0|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
392 case M32C_OPERAND_DSP_16_U8
:
393 print_normal (cd
, info
, fields
->f_dsp_16_u8
, 0, pc
, length
);
395 case M32C_OPERAND_DSP_24_S16
:
396 print_normal (cd
, info
, fields
->f_dsp_24_s16
, 0|(1<<CGEN_OPERAND_SIGNED
)|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
398 case M32C_OPERAND_DSP_24_S8
:
399 print_normal (cd
, info
, fields
->f_dsp_24_s8
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
401 case M32C_OPERAND_DSP_24_U16
:
402 print_normal (cd
, info
, fields
->f_dsp_24_u16
, 0|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
404 case M32C_OPERAND_DSP_24_U20
:
405 print_normal (cd
, info
, fields
->f_dsp_24_u24
, 0|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
407 case M32C_OPERAND_DSP_24_U24
:
408 print_normal (cd
, info
, fields
->f_dsp_24_u24
, 0|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
410 case M32C_OPERAND_DSP_24_U8
:
411 print_normal (cd
, info
, fields
->f_dsp_24_u8
, 0, pc
, length
);
413 case M32C_OPERAND_DSP_32_S16
:
414 print_normal (cd
, info
, fields
->f_dsp_32_s16
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
416 case M32C_OPERAND_DSP_32_S8
:
417 print_normal (cd
, info
, fields
->f_dsp_32_s8
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
419 case M32C_OPERAND_DSP_32_U16
:
420 print_normal (cd
, info
, fields
->f_dsp_32_u16
, 0, pc
, length
);
422 case M32C_OPERAND_DSP_32_U20
:
423 print_normal (cd
, info
, fields
->f_dsp_32_u24
, 0, pc
, length
);
425 case M32C_OPERAND_DSP_32_U24
:
426 print_normal (cd
, info
, fields
->f_dsp_32_u24
, 0, pc
, length
);
428 case M32C_OPERAND_DSP_32_U8
:
429 print_normal (cd
, info
, fields
->f_dsp_32_u8
, 0, pc
, length
);
431 case M32C_OPERAND_DSP_40_S16
:
432 print_normal (cd
, info
, fields
->f_dsp_40_s16
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
434 case M32C_OPERAND_DSP_40_S8
:
435 print_normal (cd
, info
, fields
->f_dsp_40_s8
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
437 case M32C_OPERAND_DSP_40_U16
:
438 print_normal (cd
, info
, fields
->f_dsp_40_u16
, 0, pc
, length
);
440 case M32C_OPERAND_DSP_40_U24
:
441 print_normal (cd
, info
, fields
->f_dsp_40_u24
, 0, pc
, length
);
443 case M32C_OPERAND_DSP_40_U8
:
444 print_normal (cd
, info
, fields
->f_dsp_40_u8
, 0, pc
, length
);
446 case M32C_OPERAND_DSP_48_S16
:
447 print_normal (cd
, info
, fields
->f_dsp_48_s16
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
449 case M32C_OPERAND_DSP_48_S8
:
450 print_normal (cd
, info
, fields
->f_dsp_48_s8
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
452 case M32C_OPERAND_DSP_48_U16
:
453 print_normal (cd
, info
, fields
->f_dsp_48_u16
, 0, pc
, length
);
455 case M32C_OPERAND_DSP_48_U24
:
456 print_normal (cd
, info
, fields
->f_dsp_48_u24
, 0|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
458 case M32C_OPERAND_DSP_48_U8
:
459 print_normal (cd
, info
, fields
->f_dsp_48_u8
, 0, pc
, length
);
461 case M32C_OPERAND_DSP_8_S8
:
462 print_normal (cd
, info
, fields
->f_dsp_8_s8
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
464 case M32C_OPERAND_DSP_8_U16
:
465 print_normal (cd
, info
, fields
->f_dsp_8_u16
, 0, pc
, length
);
467 case M32C_OPERAND_DSP_8_U24
:
468 print_normal (cd
, info
, fields
->f_dsp_8_u24
, 0, pc
, length
);
470 case M32C_OPERAND_DSP_8_U6
:
471 print_normal (cd
, info
, fields
->f_dsp_8_u6
, 0, pc
, length
);
473 case M32C_OPERAND_DSP_8_U8
:
474 print_normal (cd
, info
, fields
->f_dsp_8_u8
, 0, pc
, length
);
476 case M32C_OPERAND_DST16AN
:
477 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar
, fields
->f_dst16_an
, 0);
479 case M32C_OPERAND_DST16AN_S
:
480 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar_HI
, fields
->f_dst16_an_s
, 0);
482 case M32C_OPERAND_DST16ANHI
:
483 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar_HI
, fields
->f_dst16_an
, 0);
485 case M32C_OPERAND_DST16ANQI
:
486 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar_QI
, fields
->f_dst16_an
, 0);
488 case M32C_OPERAND_DST16ANQI_S
:
489 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar_QI
, fields
->f_dst16_rn_QI_s
, 0);
491 case M32C_OPERAND_DST16ANSI
:
492 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar_SI
, fields
->f_dst16_an
, 0);
494 case M32C_OPERAND_DST16RNEXTQI
:
495 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_ext_QI
, fields
->f_dst16_rn_ext
, 0);
497 case M32C_OPERAND_DST16RNHI
:
498 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_HI
, fields
->f_dst16_rn
, 0);
500 case M32C_OPERAND_DST16RNQI
:
501 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_QI
, fields
->f_dst16_rn
, 0);
503 case M32C_OPERAND_DST16RNQI_S
:
504 print_keyword (cd
, info
, & m32c_cgen_opval_h_r0l_r0h
, fields
->f_dst16_rn_QI_s
, 0);
506 case M32C_OPERAND_DST16RNSI
:
507 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_SI
, fields
->f_dst16_rn
, 0);
509 case M32C_OPERAND_DST32ANEXTUNPREFIXED
:
510 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar
, fields
->f_dst32_an_unprefixed
, 0);
512 case M32C_OPERAND_DST32ANPREFIXED
:
513 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar
, fields
->f_dst32_an_prefixed
, 0);
515 case M32C_OPERAND_DST32ANPREFIXEDHI
:
516 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar_HI
, fields
->f_dst32_an_prefixed
, 0);
518 case M32C_OPERAND_DST32ANPREFIXEDQI
:
519 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar_QI
, fields
->f_dst32_an_prefixed
, 0);
521 case M32C_OPERAND_DST32ANPREFIXEDSI
:
522 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar
, fields
->f_dst32_an_prefixed
, 0);
524 case M32C_OPERAND_DST32ANUNPREFIXED
:
525 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar
, fields
->f_dst32_an_unprefixed
, 0);
527 case M32C_OPERAND_DST32ANUNPREFIXEDHI
:
528 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar_HI
, fields
->f_dst32_an_unprefixed
, 0);
530 case M32C_OPERAND_DST32ANUNPREFIXEDQI
:
531 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar_QI
, fields
->f_dst32_an_unprefixed
, 0);
533 case M32C_OPERAND_DST32ANUNPREFIXEDSI
:
534 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar
, fields
->f_dst32_an_unprefixed
, 0);
536 case M32C_OPERAND_DST32R0HI_S
:
537 print_keyword (cd
, info
, & m32c_cgen_opval_h_r0
, 0, 0);
539 case M32C_OPERAND_DST32R0QI_S
:
540 print_keyword (cd
, info
, & m32c_cgen_opval_h_r0l
, 0, 0);
542 case M32C_OPERAND_DST32RNEXTUNPREFIXEDHI
:
543 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_ext_HI
, fields
->f_dst32_rn_ext_unprefixed
, 0);
545 case M32C_OPERAND_DST32RNEXTUNPREFIXEDQI
:
546 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_ext_QI
, fields
->f_dst32_rn_ext_unprefixed
, 0);
548 case M32C_OPERAND_DST32RNPREFIXEDHI
:
549 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_HI
, fields
->f_dst32_rn_prefixed_HI
, 0);
551 case M32C_OPERAND_DST32RNPREFIXEDQI
:
552 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_QI
, fields
->f_dst32_rn_prefixed_QI
, 0);
554 case M32C_OPERAND_DST32RNPREFIXEDSI
:
555 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_SI
, fields
->f_dst32_rn_prefixed_SI
, 0);
557 case M32C_OPERAND_DST32RNUNPREFIXEDHI
:
558 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_HI
, fields
->f_dst32_rn_unprefixed_HI
, 0);
560 case M32C_OPERAND_DST32RNUNPREFIXEDQI
:
561 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_QI
, fields
->f_dst32_rn_unprefixed_QI
, 0);
563 case M32C_OPERAND_DST32RNUNPREFIXEDSI
:
564 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_SI
, fields
->f_dst32_rn_unprefixed_SI
, 0);
566 case M32C_OPERAND_G
:
567 print_G (cd
, info
, 0, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
569 case M32C_OPERAND_IMM_12_S4
:
570 print_normal (cd
, info
, fields
->f_imm_12_s4
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
572 case M32C_OPERAND_IMM_13_U3
:
573 print_normal (cd
, info
, fields
->f_imm_13_u3
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
575 case M32C_OPERAND_IMM_16_HI
:
576 print_normal (cd
, info
, fields
->f_dsp_16_s16
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
578 case M32C_OPERAND_IMM_16_QI
:
579 print_normal (cd
, info
, fields
->f_dsp_16_s8
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
581 case M32C_OPERAND_IMM_16_SI
:
582 print_normal (cd
, info
, fields
->f_dsp_16_s32
, 0|(1<<CGEN_OPERAND_SIGNED
)|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
584 case M32C_OPERAND_IMM_20_S4
:
585 print_normal (cd
, info
, fields
->f_imm_20_s4
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
587 case M32C_OPERAND_IMM_24_HI
:
588 print_normal (cd
, info
, fields
->f_dsp_24_s16
, 0|(1<<CGEN_OPERAND_SIGNED
)|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
590 case M32C_OPERAND_IMM_24_QI
:
591 print_normal (cd
, info
, fields
->f_dsp_24_s8
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
593 case M32C_OPERAND_IMM_24_SI
:
594 print_normal (cd
, info
, fields
->f_dsp_24_s32
, 0|(1<<CGEN_OPERAND_SIGNED
)|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
596 case M32C_OPERAND_IMM_32_HI
:
597 print_normal (cd
, info
, fields
->f_dsp_32_s16
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
599 case M32C_OPERAND_IMM_32_QI
:
600 print_normal (cd
, info
, fields
->f_dsp_32_s8
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
602 case M32C_OPERAND_IMM_32_SI
:
603 print_normal (cd
, info
, fields
->f_dsp_32_s32
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
605 case M32C_OPERAND_IMM_40_HI
:
606 print_normal (cd
, info
, fields
->f_dsp_40_s16
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
608 case M32C_OPERAND_IMM_40_QI
:
609 print_normal (cd
, info
, fields
->f_dsp_40_s8
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
611 case M32C_OPERAND_IMM_40_SI
:
612 print_normal (cd
, info
, fields
->f_dsp_40_s32
, 0|(1<<CGEN_OPERAND_SIGNED
)|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
614 case M32C_OPERAND_IMM_48_HI
:
615 print_normal (cd
, info
, fields
->f_dsp_48_s16
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
617 case M32C_OPERAND_IMM_48_QI
:
618 print_normal (cd
, info
, fields
->f_dsp_48_s8
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
620 case M32C_OPERAND_IMM_48_SI
:
621 print_normal (cd
, info
, fields
->f_dsp_48_s32
, 0|(1<<CGEN_OPERAND_SIGNED
)|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
623 case M32C_OPERAND_IMM_56_HI
:
624 print_normal (cd
, info
, fields
->f_dsp_56_s16
, 0|(1<<CGEN_OPERAND_SIGNED
)|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
626 case M32C_OPERAND_IMM_56_QI
:
627 print_normal (cd
, info
, fields
->f_dsp_56_s8
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
629 case M32C_OPERAND_IMM_64_HI
:
630 print_normal (cd
, info
, fields
->f_dsp_64_s16
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
632 case M32C_OPERAND_IMM_8_HI
:
633 print_normal (cd
, info
, fields
->f_dsp_8_s16
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
635 case M32C_OPERAND_IMM_8_QI
:
636 print_normal (cd
, info
, fields
->f_dsp_8_s8
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
638 case M32C_OPERAND_IMM_8_S4
:
639 print_normal (cd
, info
, fields
->f_imm_8_s4
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
641 case M32C_OPERAND_IMM_SH_12_S4
:
642 print_keyword (cd
, info
, & m32c_cgen_opval_h_shimm
, fields
->f_imm_12_s4
, 0);
644 case M32C_OPERAND_IMM_SH_20_S4
:
645 print_keyword (cd
, info
, & m32c_cgen_opval_h_shimm
, fields
->f_imm_20_s4
, 0);
647 case M32C_OPERAND_IMM_SH_8_S4
:
648 print_keyword (cd
, info
, & m32c_cgen_opval_h_shimm
, fields
->f_imm_8_s4
, 0);
650 case M32C_OPERAND_IMM1_S
:
651 print_normal (cd
, info
, fields
->f_imm1_S
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
653 case M32C_OPERAND_IMM3_S
:
654 print_normal (cd
, info
, fields
->f_imm3_S
, 0|(1<<CGEN_OPERAND_SIGNED
)|(1<<CGEN_OPERAND_VIRTUAL
), pc
, length
);
656 case M32C_OPERAND_LAB_16_8
:
657 print_address (cd
, info
, fields
->f_lab_16_8
, 0|(1<<CGEN_OPERAND_RELAX
)|(1<<CGEN_OPERAND_PCREL_ADDR
), pc
, length
);
659 case M32C_OPERAND_LAB_24_8
:
660 print_address (cd
, info
, fields
->f_lab_24_8
, 0|(1<<CGEN_OPERAND_PCREL_ADDR
), pc
, length
);
662 case M32C_OPERAND_LAB_32_8
:
663 print_address (cd
, info
, fields
->f_lab_32_8
, 0|(1<<CGEN_OPERAND_PCREL_ADDR
), pc
, length
);
665 case M32C_OPERAND_LAB_40_8
:
666 print_address (cd
, info
, fields
->f_lab_40_8
, 0|(1<<CGEN_OPERAND_PCREL_ADDR
), pc
, length
);
668 case M32C_OPERAND_LAB_5_3
:
669 print_address (cd
, info
, fields
->f_lab_5_3
, 0|(1<<CGEN_OPERAND_RELAX
)|(1<<CGEN_OPERAND_PCREL_ADDR
), pc
, length
);
671 case M32C_OPERAND_LAB_8_16
:
672 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
);
674 case M32C_OPERAND_LAB_8_24
:
675 print_address (cd
, info
, fields
->f_lab_8_24
, 0|(1<<CGEN_OPERAND_ABS_ADDR
), pc
, length
);
677 case M32C_OPERAND_LAB_8_8
:
678 print_address (cd
, info
, fields
->f_lab_8_8
, 0|(1<<CGEN_OPERAND_RELAX
)|(1<<CGEN_OPERAND_PCREL_ADDR
), pc
, length
);
680 case M32C_OPERAND_LAB32_JMP_S
:
681 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
);
683 case M32C_OPERAND_Q
:
684 print_Q (cd
, info
, 0, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
686 case M32C_OPERAND_R0
:
687 print_keyword (cd
, info
, & m32c_cgen_opval_h_r0
, 0, 0);
689 case M32C_OPERAND_R0H
:
690 print_keyword (cd
, info
, & m32c_cgen_opval_h_r0h
, 0, 0);
692 case M32C_OPERAND_R0L
:
693 print_keyword (cd
, info
, & m32c_cgen_opval_h_r0l
, 0, 0);
695 case M32C_OPERAND_R1
:
696 print_keyword (cd
, info
, & m32c_cgen_opval_h_r1
, 0, 0);
698 case M32C_OPERAND_R1R2R0
:
699 print_keyword (cd
, info
, & m32c_cgen_opval_h_r1r2r0
, 0, 0);
701 case M32C_OPERAND_R2
:
702 print_keyword (cd
, info
, & m32c_cgen_opval_h_r2
, 0, 0);
704 case M32C_OPERAND_R2R0
:
705 print_keyword (cd
, info
, & m32c_cgen_opval_h_r2r0
, 0, 0);
707 case M32C_OPERAND_R3
:
708 print_keyword (cd
, info
, & m32c_cgen_opval_h_r3
, 0, 0);
710 case M32C_OPERAND_R3R1
:
711 print_keyword (cd
, info
, & m32c_cgen_opval_h_r3r1
, 0, 0);
713 case M32C_OPERAND_REGSETPOP
:
714 print_pop_regset (cd
, info
, fields
->f_8_8
, 0, pc
, length
);
716 case M32C_OPERAND_REGSETPUSH
:
717 print_push_regset (cd
, info
, fields
->f_8_8
, 0, pc
, length
);
719 case M32C_OPERAND_RN16_PUSH_S
:
720 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_QI
, fields
->f_4_1
, 0);
722 case M32C_OPERAND_S
:
723 print_S (cd
, info
, 0, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
725 case M32C_OPERAND_SRC16AN
:
726 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar
, fields
->f_src16_an
, 0);
728 case M32C_OPERAND_SRC16ANHI
:
729 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar_HI
, fields
->f_src16_an
, 0);
731 case M32C_OPERAND_SRC16ANQI
:
732 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar_QI
, fields
->f_src16_an
, 0);
734 case M32C_OPERAND_SRC16RNHI
:
735 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_HI
, fields
->f_src16_rn
, 0);
737 case M32C_OPERAND_SRC16RNQI
:
738 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_QI
, fields
->f_src16_rn
, 0);
740 case M32C_OPERAND_SRC32ANPREFIXED
:
741 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar
, fields
->f_src32_an_prefixed
, 0);
743 case M32C_OPERAND_SRC32ANPREFIXEDHI
:
744 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar_HI
, fields
->f_src32_an_prefixed
, 0);
746 case M32C_OPERAND_SRC32ANPREFIXEDQI
:
747 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar_QI
, fields
->f_src32_an_prefixed
, 0);
749 case M32C_OPERAND_SRC32ANPREFIXEDSI
:
750 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar
, fields
->f_src32_an_prefixed
, 0);
752 case M32C_OPERAND_SRC32ANUNPREFIXED
:
753 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar
, fields
->f_src32_an_unprefixed
, 0);
755 case M32C_OPERAND_SRC32ANUNPREFIXEDHI
:
756 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar_HI
, fields
->f_src32_an_unprefixed
, 0);
758 case M32C_OPERAND_SRC32ANUNPREFIXEDQI
:
759 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar_QI
, fields
->f_src32_an_unprefixed
, 0);
761 case M32C_OPERAND_SRC32ANUNPREFIXEDSI
:
762 print_keyword (cd
, info
, & m32c_cgen_opval_h_ar
, fields
->f_src32_an_unprefixed
, 0);
764 case M32C_OPERAND_SRC32RNPREFIXEDHI
:
765 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_HI
, fields
->f_src32_rn_prefixed_HI
, 0);
767 case M32C_OPERAND_SRC32RNPREFIXEDQI
:
768 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_QI
, fields
->f_src32_rn_prefixed_QI
, 0);
770 case M32C_OPERAND_SRC32RNPREFIXEDSI
:
771 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_SI
, fields
->f_src32_rn_prefixed_SI
, 0);
773 case M32C_OPERAND_SRC32RNUNPREFIXEDHI
:
774 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_HI
, fields
->f_src32_rn_unprefixed_HI
, 0);
776 case M32C_OPERAND_SRC32RNUNPREFIXEDQI
:
777 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_QI
, fields
->f_src32_rn_unprefixed_QI
, 0);
779 case M32C_OPERAND_SRC32RNUNPREFIXEDSI
:
780 print_keyword (cd
, info
, & m32c_cgen_opval_h_gr_SI
, fields
->f_src32_rn_unprefixed_SI
, 0);
782 case M32C_OPERAND_SRCDST16_R0L_R0H_S_NORMAL
:
783 print_r0l_r0h (cd
, info
, fields
->f_5_1
, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
785 case M32C_OPERAND_X
:
786 print_X (cd
, info
, 0, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
788 case M32C_OPERAND_Z
:
789 print_Z (cd
, info
, 0, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
791 case M32C_OPERAND_COND16_16
:
792 print_keyword (cd
, info
, & m32c_cgen_opval_h_cond16
, fields
->f_dsp_16_u8
, 0);
794 case M32C_OPERAND_COND16_24
:
795 print_keyword (cd
, info
, & m32c_cgen_opval_h_cond16
, fields
->f_dsp_24_u8
, 0);
797 case M32C_OPERAND_COND16_32
:
798 print_keyword (cd
, info
, & m32c_cgen_opval_h_cond16
, fields
->f_dsp_32_u8
, 0);
800 case M32C_OPERAND_COND16C
:
801 print_keyword (cd
, info
, & m32c_cgen_opval_h_cond16c
, fields
->f_cond16
, 0);
803 case M32C_OPERAND_COND16J
:
804 print_keyword (cd
, info
, & m32c_cgen_opval_h_cond16j
, fields
->f_cond16
, 0);
806 case M32C_OPERAND_COND16J5
:
807 print_keyword (cd
, info
, & m32c_cgen_opval_h_cond16j_5
, fields
->f_cond16j_5
, 0);
809 case M32C_OPERAND_COND32
:
810 print_keyword (cd
, info
, & m32c_cgen_opval_h_cond32
, fields
->f_cond32
, 0|(1<<CGEN_OPERAND_VIRTUAL
));
812 case M32C_OPERAND_COND32_16
:
813 print_keyword (cd
, info
, & m32c_cgen_opval_h_cond32
, fields
->f_dsp_16_u8
, 0);
815 case M32C_OPERAND_COND32_24
:
816 print_keyword (cd
, info
, & m32c_cgen_opval_h_cond32
, fields
->f_dsp_24_u8
, 0);
818 case M32C_OPERAND_COND32_32
:
819 print_keyword (cd
, info
, & m32c_cgen_opval_h_cond32
, fields
->f_dsp_32_u8
, 0);
821 case M32C_OPERAND_COND32_40
:
822 print_keyword (cd
, info
, & m32c_cgen_opval_h_cond32
, fields
->f_dsp_40_u8
, 0);
824 case M32C_OPERAND_COND32J
:
825 print_keyword (cd
, info
, & m32c_cgen_opval_h_cond32
, fields
->f_cond32j
, 0|(1<<CGEN_OPERAND_VIRTUAL
));
827 case M32C_OPERAND_CR1_PREFIXED_32
:
828 print_keyword (cd
, info
, & m32c_cgen_opval_h_cr1_32
, fields
->f_21_3
, 0);
830 case M32C_OPERAND_CR1_UNPREFIXED_32
:
831 print_keyword (cd
, info
, & m32c_cgen_opval_h_cr1_32
, fields
->f_13_3
, 0);
833 case M32C_OPERAND_CR16
:
834 print_keyword (cd
, info
, & m32c_cgen_opval_h_cr_16
, fields
->f_9_3
, 0);
836 case M32C_OPERAND_CR2_32
:
837 print_keyword (cd
, info
, & m32c_cgen_opval_h_cr2_32
, fields
->f_13_3
, 0);
839 case M32C_OPERAND_CR3_PREFIXED_32
:
840 print_keyword (cd
, info
, & m32c_cgen_opval_h_cr3_32
, fields
->f_21_3
, 0);
842 case M32C_OPERAND_CR3_UNPREFIXED_32
:
843 print_keyword (cd
, info
, & m32c_cgen_opval_h_cr3_32
, fields
->f_13_3
, 0);
845 case M32C_OPERAND_FLAGS16
:
846 print_keyword (cd
, info
, & m32c_cgen_opval_h_flags
, fields
->f_9_3
, 0);
848 case M32C_OPERAND_FLAGS32
:
849 print_keyword (cd
, info
, & m32c_cgen_opval_h_flags
, fields
->f_13_3
, 0);
851 case M32C_OPERAND_SCCOND32
:
852 print_keyword (cd
, info
, & m32c_cgen_opval_h_cond32
, fields
->f_cond16
, 0);
854 case M32C_OPERAND_SIZE
:
855 print_size (cd
, info
, 0, 0|(1<<CGEN_OPERAND_SIGNED
), pc
, length
);
859 /* xgettext:c-format */
860 fprintf (stderr
, _("Unrecognized field %d while printing insn.\n"),
866 cgen_print_fn
* const m32c_cgen_print_handlers
[] =
873 m32c_cgen_init_dis (CGEN_CPU_DESC cd
)
875 m32c_cgen_init_opcode_table (cd
);
876 m32c_cgen_init_ibld_table (cd
);
877 cd
->print_handlers
= & m32c_cgen_print_handlers
[0];
878 cd
->print_operand
= m32c_cgen_print_operand
;
882 /* Default print handler. */
885 print_normal (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
889 bfd_vma pc ATTRIBUTE_UNUSED
,
890 int length ATTRIBUTE_UNUSED
)
892 disassemble_info
*info
= (disassemble_info
*) dis_info
;
894 #ifdef CGEN_PRINT_NORMAL
895 CGEN_PRINT_NORMAL (cd
, info
, value
, attrs
, pc
, length
);
898 /* Print the operand as directed by the attributes. */
899 if (CGEN_BOOL_ATTR (attrs
, CGEN_OPERAND_SEM_ONLY
))
900 ; /* nothing to do */
901 else if (CGEN_BOOL_ATTR (attrs
, CGEN_OPERAND_SIGNED
))
902 (*info
->fprintf_func
) (info
->stream
, "%ld", value
);
904 (*info
->fprintf_func
) (info
->stream
, "0x%lx", value
);
907 /* Default address handler. */
910 print_address (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_ADDRESS
920 CGEN_PRINT_ADDRESS (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_PCREL_ADDR
))
927 (*info
->print_address_func
) (value
, info
);
928 else if (CGEN_BOOL_ATTR (attrs
, CGEN_OPERAND_ABS_ADDR
))
929 (*info
->print_address_func
) (value
, info
);
930 else if (CGEN_BOOL_ATTR (attrs
, CGEN_OPERAND_SIGNED
))
931 (*info
->fprintf_func
) (info
->stream
, "%ld", (long) value
);
933 (*info
->fprintf_func
) (info
->stream
, "0x%lx", (long) value
);
936 /* Keyword print handler. */
939 print_keyword (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
941 CGEN_KEYWORD
*keyword_table
,
943 unsigned int attrs ATTRIBUTE_UNUSED
)
945 disassemble_info
*info
= (disassemble_info
*) dis_info
;
946 const CGEN_KEYWORD_ENTRY
*ke
;
948 ke
= cgen_keyword_lookup_value (keyword_table
, value
);
950 (*info
->fprintf_func
) (info
->stream
, "%s", ke
->name
);
952 (*info
->fprintf_func
) (info
->stream
, "???");
955 /* Default insn printer.
957 DIS_INFO is defined as `void *' so the disassembler needn't know anything
958 about disassemble_info. */
961 print_insn_normal (CGEN_CPU_DESC cd
,
963 const CGEN_INSN
*insn
,
968 const CGEN_SYNTAX
*syntax
= CGEN_INSN_SYNTAX (insn
);
969 disassemble_info
*info
= (disassemble_info
*) dis_info
;
970 const CGEN_SYNTAX_CHAR_TYPE
*syn
;
972 CGEN_INIT_PRINT (cd
);
974 for (syn
= CGEN_SYNTAX_STRING (syntax
); *syn
; ++syn
)
976 if (CGEN_SYNTAX_MNEMONIC_P (*syn
))
978 (*info
->fprintf_func
) (info
->stream
, "%s", CGEN_INSN_MNEMONIC (insn
));
981 if (CGEN_SYNTAX_CHAR_P (*syn
))
983 (*info
->fprintf_func
) (info
->stream
, "%c", CGEN_SYNTAX_CHAR (*syn
));
987 /* We have an operand. */
988 m32c_cgen_print_operand (cd
, CGEN_SYNTAX_FIELD (*syn
), info
,
989 fields
, CGEN_INSN_ATTRS (insn
), pc
, length
);
993 /* Subroutine of print_insn. Reads an insn into the given buffers and updates
995 Returns 0 if all is well, non-zero otherwise. */
998 read_insn (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1000 disassemble_info
*info
,
1003 CGEN_EXTRACT_INFO
*ex_info
,
1004 unsigned long *insn_value
)
1006 int status
= (*info
->read_memory_func
) (pc
, buf
, buflen
, info
);
1010 (*info
->memory_error_func
) (status
, pc
, info
);
1014 ex_info
->dis_info
= info
;
1015 ex_info
->valid
= (1 << buflen
) - 1;
1016 ex_info
->insn_bytes
= buf
;
1018 *insn_value
= bfd_get_bits (buf
, buflen
* 8, info
->endian
== BFD_ENDIAN_BIG
);
1022 /* Utility to print an insn.
1023 BUF is the base part of the insn, target byte order, BUFLEN bytes long.
1024 The result is the size of the insn in bytes or zero for an unknown insn
1025 or -1 if an error occurs fetching data (memory_error_func will have
1029 print_insn (CGEN_CPU_DESC cd
,
1031 disassemble_info
*info
,
1033 unsigned int buflen
)
1035 CGEN_INSN_INT insn_value
;
1036 const CGEN_INSN_LIST
*insn_list
;
1037 CGEN_EXTRACT_INFO ex_info
;
1040 /* Extract base part of instruction, just in case CGEN_DIS_* uses it. */
1041 basesize
= cd
->base_insn_bitsize
< buflen
* 8 ?
1042 cd
->base_insn_bitsize
: buflen
* 8;
1043 insn_value
= cgen_get_insn_value (cd
, buf
, basesize
);
1046 /* Fill in ex_info fields like read_insn would. Don't actually call
1047 read_insn, since the incoming buffer is already read (and possibly
1048 modified a la m32r). */
1049 ex_info
.valid
= (1 << buflen
) - 1;
1050 ex_info
.dis_info
= info
;
1051 ex_info
.insn_bytes
= buf
;
1053 /* The instructions are stored in hash lists.
1054 Pick the first one and keep trying until we find the right one. */
1056 insn_list
= CGEN_DIS_LOOKUP_INSN (cd
, (char *) buf
, insn_value
);
1057 while (insn_list
!= NULL
)
1059 const CGEN_INSN
*insn
= insn_list
->insn
;
1062 unsigned long insn_value_cropped
;
1064 #ifdef CGEN_VALIDATE_INSN_SUPPORTED
1065 /* Not needed as insn shouldn't be in hash lists if not supported. */
1066 /* Supported by this cpu? */
1067 if (! m32c_cgen_insn_supported (cd
, insn
))
1069 insn_list
= CGEN_DIS_NEXT_INSN (insn_list
);
1074 /* Basic bit mask must be correct. */
1075 /* ??? May wish to allow target to defer this check until the extract
1078 /* Base size may exceed this instruction's size. Extract the
1079 relevant part from the buffer. */
1080 if ((unsigned) (CGEN_INSN_BITSIZE (insn
) / 8) < buflen
&&
1081 (unsigned) (CGEN_INSN_BITSIZE (insn
) / 8) <= sizeof (unsigned long))
1082 insn_value_cropped
= bfd_get_bits (buf
, CGEN_INSN_BITSIZE (insn
),
1083 info
->endian
== BFD_ENDIAN_BIG
);
1085 insn_value_cropped
= insn_value
;
1087 if ((insn_value_cropped
& CGEN_INSN_BASE_MASK (insn
))
1088 == CGEN_INSN_BASE_VALUE (insn
))
1090 /* Printing is handled in two passes. The first pass parses the
1091 machine insn and extracts the fields. The second pass prints
1094 /* Make sure the entire insn is loaded into insn_value, if it
1096 if (((unsigned) CGEN_INSN_BITSIZE (insn
) > cd
->base_insn_bitsize
) &&
1097 (unsigned) (CGEN_INSN_BITSIZE (insn
) / 8) <= sizeof (unsigned long))
1099 unsigned long full_insn_value
;
1100 int rc
= read_insn (cd
, pc
, info
, buf
,
1101 CGEN_INSN_BITSIZE (insn
) / 8,
1102 & ex_info
, & full_insn_value
);
1105 length
= CGEN_EXTRACT_FN (cd
, insn
)
1106 (cd
, insn
, &ex_info
, full_insn_value
, &fields
, pc
);
1109 length
= CGEN_EXTRACT_FN (cd
, insn
)
1110 (cd
, insn
, &ex_info
, insn_value_cropped
, &fields
, pc
);
1112 /* Length < 0 -> error. */
1117 CGEN_PRINT_FN (cd
, insn
) (cd
, info
, insn
, &fields
, pc
, length
);
1118 /* Length is in bits, result is in bytes. */
1123 insn_list
= CGEN_DIS_NEXT_INSN (insn_list
);
1129 /* Default value for CGEN_PRINT_INSN.
1130 The result is the size of the insn in bytes or zero for an unknown insn
1131 or -1 if an error occured fetching bytes. */
1133 #ifndef CGEN_PRINT_INSN
1134 #define CGEN_PRINT_INSN default_print_insn
1138 default_print_insn (CGEN_CPU_DESC cd
, bfd_vma pc
, disassemble_info
*info
)
1140 bfd_byte buf
[CGEN_MAX_INSN_SIZE
];
1144 /* Attempt to read the base part of the insn. */
1145 buflen
= cd
->base_insn_bitsize
/ 8;
1146 status
= (*info
->read_memory_func
) (pc
, buf
, buflen
, info
);
1148 /* Try again with the minimum part, if min < base. */
1149 if (status
!= 0 && (cd
->min_insn_bitsize
< cd
->base_insn_bitsize
))
1151 buflen
= cd
->min_insn_bitsize
/ 8;
1152 status
= (*info
->read_memory_func
) (pc
, buf
, buflen
, info
);
1157 (*info
->memory_error_func
) (status
, pc
, info
);
1161 return print_insn (cd
, pc
, info
, buf
, buflen
);
1164 /* Main entry point.
1165 Print one instruction from PC on INFO->STREAM.
1166 Return the size of the instruction (in bytes). */
1168 typedef struct cpu_desc_list
1170 struct cpu_desc_list
*next
;
1178 print_insn_m32c (bfd_vma pc
, disassemble_info
*info
)
1180 static cpu_desc_list
*cd_list
= 0;
1181 cpu_desc_list
*cl
= 0;
1182 static CGEN_CPU_DESC cd
= 0;
1183 static int prev_isa
;
1184 static int prev_mach
;
1185 static int prev_endian
;
1188 int endian
= (info
->endian
== BFD_ENDIAN_BIG
1190 : CGEN_ENDIAN_LITTLE
);
1191 enum bfd_architecture arch
;
1193 /* ??? gdb will set mach but leave the architecture as "unknown" */
1194 #ifndef CGEN_BFD_ARCH
1195 #define CGEN_BFD_ARCH bfd_arch_m32c
1198 if (arch
== bfd_arch_unknown
)
1199 arch
= CGEN_BFD_ARCH
;
1201 /* There's no standard way to compute the machine or isa number
1202 so we leave it to the target. */
1203 #ifdef CGEN_COMPUTE_MACH
1204 mach
= CGEN_COMPUTE_MACH (info
);
1209 #ifdef CGEN_COMPUTE_ISA
1210 isa
= CGEN_COMPUTE_ISA (info
);
1212 isa
= info
->insn_sets
;
1215 /* If we've switched cpu's, try to find a handle we've used before */
1218 || mach
!= prev_mach
1219 || endian
!= prev_endian
))
1222 for (cl
= cd_list
; cl
; cl
= cl
->next
)
1224 if (cl
->isa
== isa
&&
1226 cl
->endian
== endian
)
1234 /* If we haven't initialized yet, initialize the opcode table. */
1237 const bfd_arch_info_type
*arch_type
= bfd_lookup_arch (arch
, mach
);
1238 const char *mach_name
;
1242 mach_name
= arch_type
->printable_name
;
1246 prev_endian
= endian
;
1247 cd
= m32c_cgen_cpu_open (CGEN_CPU_OPEN_ISAS
, prev_isa
,
1248 CGEN_CPU_OPEN_BFDMACH
, mach_name
,
1249 CGEN_CPU_OPEN_ENDIAN
, prev_endian
,
1254 /* Save this away for future reference. */
1255 cl
= xmalloc (sizeof (struct cpu_desc_list
));
1259 cl
->endian
= endian
;
1263 m32c_cgen_init_dis (cd
);
1266 /* We try to have as much common code as possible.
1267 But at this point some targets need to take over. */
1268 /* ??? Some targets may need a hook elsewhere. Try to avoid this,
1269 but if not possible try to move this hook elsewhere rather than
1271 length
= CGEN_PRINT_INSN (cd
, pc
, info
);
1277 (*info
->fprintf_func
) (info
->stream
, UNKNOWN_INSN_MSG
);
1278 return cd
->default_insn_bitsize
/ 8;