1*3d8817e4Smiod /* Disassembler interface for targets using CGEN. -*- C -*-
2*3d8817e4Smiod CGEN: Cpu tools GENerator
3*3d8817e4Smiod
4*3d8817e4Smiod THIS FILE IS MACHINE GENERATED WITH CGEN.
5*3d8817e4Smiod - the resultant file is machine generated, cgen-dis.in isn't
6*3d8817e4Smiod
7*3d8817e4Smiod Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005
8*3d8817e4Smiod Free Software Foundation, Inc.
9*3d8817e4Smiod
10*3d8817e4Smiod This file is part of the GNU Binutils and GDB, the GNU debugger.
11*3d8817e4Smiod
12*3d8817e4Smiod This program is free software; you can redistribute it and/or modify
13*3d8817e4Smiod it under the terms of the GNU General Public License as published by
14*3d8817e4Smiod the Free Software Foundation; either version 2, or (at your option)
15*3d8817e4Smiod any later version.
16*3d8817e4Smiod
17*3d8817e4Smiod This program is distributed in the hope that it will be useful,
18*3d8817e4Smiod but WITHOUT ANY WARRANTY; without even the implied warranty of
19*3d8817e4Smiod MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20*3d8817e4Smiod GNU General Public License for more details.
21*3d8817e4Smiod
22*3d8817e4Smiod You should have received a copy of the GNU General Public License
23*3d8817e4Smiod along with this program; if not, write to the Free Software Foundation, Inc.,
24*3d8817e4Smiod 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
25*3d8817e4Smiod
26*3d8817e4Smiod /* ??? Eventually more and more of this stuff can go to cpu-independent files.
27*3d8817e4Smiod Keep that in mind. */
28*3d8817e4Smiod
29*3d8817e4Smiod #include "sysdep.h"
30*3d8817e4Smiod #include <stdio.h>
31*3d8817e4Smiod #include "ansidecl.h"
32*3d8817e4Smiod #include "dis-asm.h"
33*3d8817e4Smiod #include "bfd.h"
34*3d8817e4Smiod #include "symcat.h"
35*3d8817e4Smiod #include "libiberty.h"
36*3d8817e4Smiod #include "fr30-desc.h"
37*3d8817e4Smiod #include "fr30-opc.h"
38*3d8817e4Smiod #include "opintl.h"
39*3d8817e4Smiod
40*3d8817e4Smiod /* Default text to print if an instruction isn't recognized. */
41*3d8817e4Smiod #define UNKNOWN_INSN_MSG _("*unknown*")
42*3d8817e4Smiod
43*3d8817e4Smiod static void print_normal
44*3d8817e4Smiod (CGEN_CPU_DESC, void *, long, unsigned int, bfd_vma, int);
45*3d8817e4Smiod static void print_address
46*3d8817e4Smiod (CGEN_CPU_DESC, void *, bfd_vma, unsigned int, bfd_vma, int) ATTRIBUTE_UNUSED;
47*3d8817e4Smiod static void print_keyword
48*3d8817e4Smiod (CGEN_CPU_DESC, void *, CGEN_KEYWORD *, long, unsigned int) ATTRIBUTE_UNUSED;
49*3d8817e4Smiod static void print_insn_normal
50*3d8817e4Smiod (CGEN_CPU_DESC, void *, const CGEN_INSN *, CGEN_FIELDS *, bfd_vma, int);
51*3d8817e4Smiod static int print_insn
52*3d8817e4Smiod (CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, unsigned);
53*3d8817e4Smiod static int default_print_insn
54*3d8817e4Smiod (CGEN_CPU_DESC, bfd_vma, disassemble_info *) ATTRIBUTE_UNUSED;
55*3d8817e4Smiod static int read_insn
56*3d8817e4Smiod (CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, int, CGEN_EXTRACT_INFO *,
57*3d8817e4Smiod unsigned long *);
58*3d8817e4Smiod
59*3d8817e4Smiod /* -- disassembler routines inserted here. */
60*3d8817e4Smiod
61*3d8817e4Smiod /* -- dis.c */
62*3d8817e4Smiod static void
print_register_list(void * dis_info,long value,long offset,int load_store)63*3d8817e4Smiod print_register_list (void * dis_info,
64*3d8817e4Smiod long value,
65*3d8817e4Smiod long offset,
66*3d8817e4Smiod int load_store) /* 0 == load, 1 == store. */
67*3d8817e4Smiod {
68*3d8817e4Smiod disassemble_info *info = dis_info;
69*3d8817e4Smiod int mask;
70*3d8817e4Smiod int index = 0;
71*3d8817e4Smiod char * comma = "";
72*3d8817e4Smiod
73*3d8817e4Smiod if (load_store)
74*3d8817e4Smiod mask = 0x80;
75*3d8817e4Smiod else
76*3d8817e4Smiod mask = 1;
77*3d8817e4Smiod
78*3d8817e4Smiod if (value & mask)
79*3d8817e4Smiod {
80*3d8817e4Smiod (*info->fprintf_func) (info->stream, "r%li", index + offset);
81*3d8817e4Smiod comma = ",";
82*3d8817e4Smiod }
83*3d8817e4Smiod
84*3d8817e4Smiod for (index = 1; index <= 7; ++index)
85*3d8817e4Smiod {
86*3d8817e4Smiod if (load_store)
87*3d8817e4Smiod mask >>= 1;
88*3d8817e4Smiod else
89*3d8817e4Smiod mask <<= 1;
90*3d8817e4Smiod
91*3d8817e4Smiod if (value & mask)
92*3d8817e4Smiod {
93*3d8817e4Smiod (*info->fprintf_func) (info->stream, "%sr%li", comma, index + offset);
94*3d8817e4Smiod comma = ",";
95*3d8817e4Smiod }
96*3d8817e4Smiod }
97*3d8817e4Smiod }
98*3d8817e4Smiod
99*3d8817e4Smiod static void
print_hi_register_list_ld(CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,void * dis_info,long value,unsigned int attrs ATTRIBUTE_UNUSED,bfd_vma pc ATTRIBUTE_UNUSED,int length ATTRIBUTE_UNUSED)100*3d8817e4Smiod print_hi_register_list_ld (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
101*3d8817e4Smiod void * dis_info,
102*3d8817e4Smiod long value,
103*3d8817e4Smiod unsigned int attrs ATTRIBUTE_UNUSED,
104*3d8817e4Smiod bfd_vma pc ATTRIBUTE_UNUSED,
105*3d8817e4Smiod int length ATTRIBUTE_UNUSED)
106*3d8817e4Smiod {
107*3d8817e4Smiod print_register_list (dis_info, value, 8, 0 /* Load. */);
108*3d8817e4Smiod }
109*3d8817e4Smiod
110*3d8817e4Smiod static void
print_low_register_list_ld(CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,void * dis_info,long value,unsigned int attrs ATTRIBUTE_UNUSED,bfd_vma pc ATTRIBUTE_UNUSED,int length ATTRIBUTE_UNUSED)111*3d8817e4Smiod print_low_register_list_ld (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
112*3d8817e4Smiod void * dis_info,
113*3d8817e4Smiod long value,
114*3d8817e4Smiod unsigned int attrs ATTRIBUTE_UNUSED,
115*3d8817e4Smiod bfd_vma pc ATTRIBUTE_UNUSED,
116*3d8817e4Smiod int length ATTRIBUTE_UNUSED)
117*3d8817e4Smiod {
118*3d8817e4Smiod print_register_list (dis_info, value, 0, 0 /* Load. */);
119*3d8817e4Smiod }
120*3d8817e4Smiod
121*3d8817e4Smiod static void
print_hi_register_list_st(CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,void * dis_info,long value,unsigned int attrs ATTRIBUTE_UNUSED,bfd_vma pc ATTRIBUTE_UNUSED,int length ATTRIBUTE_UNUSED)122*3d8817e4Smiod print_hi_register_list_st (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
123*3d8817e4Smiod void * dis_info,
124*3d8817e4Smiod long value,
125*3d8817e4Smiod unsigned int attrs ATTRIBUTE_UNUSED,
126*3d8817e4Smiod bfd_vma pc ATTRIBUTE_UNUSED,
127*3d8817e4Smiod int length ATTRIBUTE_UNUSED)
128*3d8817e4Smiod {
129*3d8817e4Smiod print_register_list (dis_info, value, 8, 1 /* Store. */);
130*3d8817e4Smiod }
131*3d8817e4Smiod
132*3d8817e4Smiod static void
print_low_register_list_st(CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,void * dis_info,long value,unsigned int attrs ATTRIBUTE_UNUSED,bfd_vma pc ATTRIBUTE_UNUSED,int length ATTRIBUTE_UNUSED)133*3d8817e4Smiod print_low_register_list_st (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
134*3d8817e4Smiod void * dis_info,
135*3d8817e4Smiod long value,
136*3d8817e4Smiod unsigned int attrs ATTRIBUTE_UNUSED,
137*3d8817e4Smiod bfd_vma pc ATTRIBUTE_UNUSED,
138*3d8817e4Smiod int length ATTRIBUTE_UNUSED)
139*3d8817e4Smiod {
140*3d8817e4Smiod print_register_list (dis_info, value, 0, 1 /* Store. */);
141*3d8817e4Smiod }
142*3d8817e4Smiod
143*3d8817e4Smiod static void
print_m4(CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,void * dis_info,long value,unsigned int attrs ATTRIBUTE_UNUSED,bfd_vma pc ATTRIBUTE_UNUSED,int length ATTRIBUTE_UNUSED)144*3d8817e4Smiod print_m4 (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
145*3d8817e4Smiod void * dis_info,
146*3d8817e4Smiod long value,
147*3d8817e4Smiod unsigned int attrs ATTRIBUTE_UNUSED,
148*3d8817e4Smiod bfd_vma pc ATTRIBUTE_UNUSED,
149*3d8817e4Smiod int length ATTRIBUTE_UNUSED)
150*3d8817e4Smiod {
151*3d8817e4Smiod disassemble_info *info = (disassemble_info *) dis_info;
152*3d8817e4Smiod
153*3d8817e4Smiod (*info->fprintf_func) (info->stream, "%ld", value);
154*3d8817e4Smiod }
155*3d8817e4Smiod /* -- */
156*3d8817e4Smiod
157*3d8817e4Smiod void fr30_cgen_print_operand
158*3d8817e4Smiod (CGEN_CPU_DESC, int, PTR, CGEN_FIELDS *, void const *, bfd_vma, int);
159*3d8817e4Smiod
160*3d8817e4Smiod /* Main entry point for printing operands.
161*3d8817e4Smiod XINFO is a `void *' and not a `disassemble_info *' to not put a requirement
162*3d8817e4Smiod of dis-asm.h on cgen.h.
163*3d8817e4Smiod
164*3d8817e4Smiod This function is basically just a big switch statement. Earlier versions
165*3d8817e4Smiod used tables to look up the function to use, but
166*3d8817e4Smiod - if the table contains both assembler and disassembler functions then
167*3d8817e4Smiod the disassembler contains much of the assembler and vice-versa,
168*3d8817e4Smiod - there's a lot of inlining possibilities as things grow,
169*3d8817e4Smiod - using a switch statement avoids the function call overhead.
170*3d8817e4Smiod
171*3d8817e4Smiod This function could be moved into `print_insn_normal', but keeping it
172*3d8817e4Smiod separate makes clear the interface between `print_insn_normal' and each of
173*3d8817e4Smiod the handlers. */
174*3d8817e4Smiod
175*3d8817e4Smiod void
fr30_cgen_print_operand(CGEN_CPU_DESC cd,int opindex,void * xinfo,CGEN_FIELDS * fields,void const * attrs ATTRIBUTE_UNUSED,bfd_vma pc,int length)176*3d8817e4Smiod fr30_cgen_print_operand (CGEN_CPU_DESC cd,
177*3d8817e4Smiod int opindex,
178*3d8817e4Smiod void * xinfo,
179*3d8817e4Smiod CGEN_FIELDS *fields,
180*3d8817e4Smiod void const *attrs ATTRIBUTE_UNUSED,
181*3d8817e4Smiod bfd_vma pc,
182*3d8817e4Smiod int length)
183*3d8817e4Smiod {
184*3d8817e4Smiod disassemble_info *info = (disassemble_info *) xinfo;
185*3d8817e4Smiod
186*3d8817e4Smiod switch (opindex)
187*3d8817e4Smiod {
188*3d8817e4Smiod case FR30_OPERAND_CRI :
189*3d8817e4Smiod print_keyword (cd, info, & fr30_cgen_opval_cr_names, fields->f_CRi, 0);
190*3d8817e4Smiod break;
191*3d8817e4Smiod case FR30_OPERAND_CRJ :
192*3d8817e4Smiod print_keyword (cd, info, & fr30_cgen_opval_cr_names, fields->f_CRj, 0);
193*3d8817e4Smiod break;
194*3d8817e4Smiod case FR30_OPERAND_R13 :
195*3d8817e4Smiod print_keyword (cd, info, & fr30_cgen_opval_h_r13, 0, 0);
196*3d8817e4Smiod break;
197*3d8817e4Smiod case FR30_OPERAND_R14 :
198*3d8817e4Smiod print_keyword (cd, info, & fr30_cgen_opval_h_r14, 0, 0);
199*3d8817e4Smiod break;
200*3d8817e4Smiod case FR30_OPERAND_R15 :
201*3d8817e4Smiod print_keyword (cd, info, & fr30_cgen_opval_h_r15, 0, 0);
202*3d8817e4Smiod break;
203*3d8817e4Smiod case FR30_OPERAND_RI :
204*3d8817e4Smiod print_keyword (cd, info, & fr30_cgen_opval_gr_names, fields->f_Ri, 0);
205*3d8817e4Smiod break;
206*3d8817e4Smiod case FR30_OPERAND_RIC :
207*3d8817e4Smiod print_keyword (cd, info, & fr30_cgen_opval_gr_names, fields->f_Ric, 0);
208*3d8817e4Smiod break;
209*3d8817e4Smiod case FR30_OPERAND_RJ :
210*3d8817e4Smiod print_keyword (cd, info, & fr30_cgen_opval_gr_names, fields->f_Rj, 0);
211*3d8817e4Smiod break;
212*3d8817e4Smiod case FR30_OPERAND_RJC :
213*3d8817e4Smiod print_keyword (cd, info, & fr30_cgen_opval_gr_names, fields->f_Rjc, 0);
214*3d8817e4Smiod break;
215*3d8817e4Smiod case FR30_OPERAND_RS1 :
216*3d8817e4Smiod print_keyword (cd, info, & fr30_cgen_opval_dr_names, fields->f_Rs1, 0);
217*3d8817e4Smiod break;
218*3d8817e4Smiod case FR30_OPERAND_RS2 :
219*3d8817e4Smiod print_keyword (cd, info, & fr30_cgen_opval_dr_names, fields->f_Rs2, 0);
220*3d8817e4Smiod break;
221*3d8817e4Smiod case FR30_OPERAND_CC :
222*3d8817e4Smiod print_normal (cd, info, fields->f_cc, 0, pc, length);
223*3d8817e4Smiod break;
224*3d8817e4Smiod case FR30_OPERAND_CCC :
225*3d8817e4Smiod print_normal (cd, info, fields->f_ccc, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
226*3d8817e4Smiod break;
227*3d8817e4Smiod case FR30_OPERAND_DIR10 :
228*3d8817e4Smiod print_normal (cd, info, fields->f_dir10, 0, pc, length);
229*3d8817e4Smiod break;
230*3d8817e4Smiod case FR30_OPERAND_DIR8 :
231*3d8817e4Smiod print_normal (cd, info, fields->f_dir8, 0, pc, length);
232*3d8817e4Smiod break;
233*3d8817e4Smiod case FR30_OPERAND_DIR9 :
234*3d8817e4Smiod print_normal (cd, info, fields->f_dir9, 0, pc, length);
235*3d8817e4Smiod break;
236*3d8817e4Smiod case FR30_OPERAND_DISP10 :
237*3d8817e4Smiod print_normal (cd, info, fields->f_disp10, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
238*3d8817e4Smiod break;
239*3d8817e4Smiod case FR30_OPERAND_DISP8 :
240*3d8817e4Smiod print_normal (cd, info, fields->f_disp8, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
241*3d8817e4Smiod break;
242*3d8817e4Smiod case FR30_OPERAND_DISP9 :
243*3d8817e4Smiod print_normal (cd, info, fields->f_disp9, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
244*3d8817e4Smiod break;
245*3d8817e4Smiod case FR30_OPERAND_I20 :
246*3d8817e4Smiod print_normal (cd, info, fields->f_i20, 0|(1<<CGEN_OPERAND_HASH_PREFIX)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
247*3d8817e4Smiod break;
248*3d8817e4Smiod case FR30_OPERAND_I32 :
249*3d8817e4Smiod print_normal (cd, info, fields->f_i32, 0|(1<<CGEN_OPERAND_HASH_PREFIX)|(1<<CGEN_OPERAND_SIGN_OPT), pc, length);
250*3d8817e4Smiod break;
251*3d8817e4Smiod case FR30_OPERAND_I8 :
252*3d8817e4Smiod print_normal (cd, info, fields->f_i8, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
253*3d8817e4Smiod break;
254*3d8817e4Smiod case FR30_OPERAND_LABEL12 :
255*3d8817e4Smiod print_address (cd, info, fields->f_rel12, 0|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
256*3d8817e4Smiod break;
257*3d8817e4Smiod case FR30_OPERAND_LABEL9 :
258*3d8817e4Smiod print_address (cd, info, fields->f_rel9, 0|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
259*3d8817e4Smiod break;
260*3d8817e4Smiod case FR30_OPERAND_M4 :
261*3d8817e4Smiod print_m4 (cd, info, fields->f_m4, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
262*3d8817e4Smiod break;
263*3d8817e4Smiod case FR30_OPERAND_PS :
264*3d8817e4Smiod print_keyword (cd, info, & fr30_cgen_opval_h_ps, 0, 0);
265*3d8817e4Smiod break;
266*3d8817e4Smiod case FR30_OPERAND_REGLIST_HI_LD :
267*3d8817e4Smiod print_hi_register_list_ld (cd, info, fields->f_reglist_hi_ld, 0, pc, length);
268*3d8817e4Smiod break;
269*3d8817e4Smiod case FR30_OPERAND_REGLIST_HI_ST :
270*3d8817e4Smiod print_hi_register_list_st (cd, info, fields->f_reglist_hi_st, 0, pc, length);
271*3d8817e4Smiod break;
272*3d8817e4Smiod case FR30_OPERAND_REGLIST_LOW_LD :
273*3d8817e4Smiod print_low_register_list_ld (cd, info, fields->f_reglist_low_ld, 0, pc, length);
274*3d8817e4Smiod break;
275*3d8817e4Smiod case FR30_OPERAND_REGLIST_LOW_ST :
276*3d8817e4Smiod print_low_register_list_st (cd, info, fields->f_reglist_low_st, 0, pc, length);
277*3d8817e4Smiod break;
278*3d8817e4Smiod case FR30_OPERAND_S10 :
279*3d8817e4Smiod print_normal (cd, info, fields->f_s10, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
280*3d8817e4Smiod break;
281*3d8817e4Smiod case FR30_OPERAND_U10 :
282*3d8817e4Smiod print_normal (cd, info, fields->f_u10, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
283*3d8817e4Smiod break;
284*3d8817e4Smiod case FR30_OPERAND_U4 :
285*3d8817e4Smiod print_normal (cd, info, fields->f_u4, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
286*3d8817e4Smiod break;
287*3d8817e4Smiod case FR30_OPERAND_U4C :
288*3d8817e4Smiod print_normal (cd, info, fields->f_u4c, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
289*3d8817e4Smiod break;
290*3d8817e4Smiod case FR30_OPERAND_U8 :
291*3d8817e4Smiod print_normal (cd, info, fields->f_u8, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
292*3d8817e4Smiod break;
293*3d8817e4Smiod case FR30_OPERAND_UDISP6 :
294*3d8817e4Smiod print_normal (cd, info, fields->f_udisp6, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
295*3d8817e4Smiod break;
296*3d8817e4Smiod
297*3d8817e4Smiod default :
298*3d8817e4Smiod /* xgettext:c-format */
299*3d8817e4Smiod fprintf (stderr, _("Unrecognized field %d while printing insn.\n"),
300*3d8817e4Smiod opindex);
301*3d8817e4Smiod abort ();
302*3d8817e4Smiod }
303*3d8817e4Smiod }
304*3d8817e4Smiod
305*3d8817e4Smiod cgen_print_fn * const fr30_cgen_print_handlers[] =
306*3d8817e4Smiod {
307*3d8817e4Smiod print_insn_normal,
308*3d8817e4Smiod };
309*3d8817e4Smiod
310*3d8817e4Smiod
311*3d8817e4Smiod void
fr30_cgen_init_dis(CGEN_CPU_DESC cd)312*3d8817e4Smiod fr30_cgen_init_dis (CGEN_CPU_DESC cd)
313*3d8817e4Smiod {
314*3d8817e4Smiod fr30_cgen_init_opcode_table (cd);
315*3d8817e4Smiod fr30_cgen_init_ibld_table (cd);
316*3d8817e4Smiod cd->print_handlers = & fr30_cgen_print_handlers[0];
317*3d8817e4Smiod cd->print_operand = fr30_cgen_print_operand;
318*3d8817e4Smiod }
319*3d8817e4Smiod
320*3d8817e4Smiod
321*3d8817e4Smiod /* Default print handler. */
322*3d8817e4Smiod
323*3d8817e4Smiod static void
print_normal(CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,void * dis_info,long value,unsigned int attrs,bfd_vma pc ATTRIBUTE_UNUSED,int length ATTRIBUTE_UNUSED)324*3d8817e4Smiod print_normal (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
325*3d8817e4Smiod void *dis_info,
326*3d8817e4Smiod long value,
327*3d8817e4Smiod unsigned int attrs,
328*3d8817e4Smiod bfd_vma pc ATTRIBUTE_UNUSED,
329*3d8817e4Smiod int length ATTRIBUTE_UNUSED)
330*3d8817e4Smiod {
331*3d8817e4Smiod disassemble_info *info = (disassemble_info *) dis_info;
332*3d8817e4Smiod
333*3d8817e4Smiod #ifdef CGEN_PRINT_NORMAL
334*3d8817e4Smiod CGEN_PRINT_NORMAL (cd, info, value, attrs, pc, length);
335*3d8817e4Smiod #endif
336*3d8817e4Smiod
337*3d8817e4Smiod /* Print the operand as directed by the attributes. */
338*3d8817e4Smiod if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY))
339*3d8817e4Smiod ; /* nothing to do */
340*3d8817e4Smiod else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED))
341*3d8817e4Smiod (*info->fprintf_func) (info->stream, "%ld", value);
342*3d8817e4Smiod else
343*3d8817e4Smiod (*info->fprintf_func) (info->stream, "0x%lx", value);
344*3d8817e4Smiod }
345*3d8817e4Smiod
346*3d8817e4Smiod /* Default address handler. */
347*3d8817e4Smiod
348*3d8817e4Smiod static void
print_address(CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,void * dis_info,bfd_vma value,unsigned int attrs,bfd_vma pc ATTRIBUTE_UNUSED,int length ATTRIBUTE_UNUSED)349*3d8817e4Smiod print_address (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
350*3d8817e4Smiod void *dis_info,
351*3d8817e4Smiod bfd_vma value,
352*3d8817e4Smiod unsigned int attrs,
353*3d8817e4Smiod bfd_vma pc ATTRIBUTE_UNUSED,
354*3d8817e4Smiod int length ATTRIBUTE_UNUSED)
355*3d8817e4Smiod {
356*3d8817e4Smiod disassemble_info *info = (disassemble_info *) dis_info;
357*3d8817e4Smiod
358*3d8817e4Smiod #ifdef CGEN_PRINT_ADDRESS
359*3d8817e4Smiod CGEN_PRINT_ADDRESS (cd, info, value, attrs, pc, length);
360*3d8817e4Smiod #endif
361*3d8817e4Smiod
362*3d8817e4Smiod /* Print the operand as directed by the attributes. */
363*3d8817e4Smiod if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY))
364*3d8817e4Smiod ; /* Nothing to do. */
365*3d8817e4Smiod else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_PCREL_ADDR))
366*3d8817e4Smiod (*info->print_address_func) (value, info);
367*3d8817e4Smiod else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_ABS_ADDR))
368*3d8817e4Smiod (*info->print_address_func) (value, info);
369*3d8817e4Smiod else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED))
370*3d8817e4Smiod (*info->fprintf_func) (info->stream, "%ld", (long) value);
371*3d8817e4Smiod else
372*3d8817e4Smiod (*info->fprintf_func) (info->stream, "0x%lx", (long) value);
373*3d8817e4Smiod }
374*3d8817e4Smiod
375*3d8817e4Smiod /* Keyword print handler. */
376*3d8817e4Smiod
377*3d8817e4Smiod static void
print_keyword(CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,void * dis_info,CGEN_KEYWORD * keyword_table,long value,unsigned int attrs ATTRIBUTE_UNUSED)378*3d8817e4Smiod print_keyword (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
379*3d8817e4Smiod void *dis_info,
380*3d8817e4Smiod CGEN_KEYWORD *keyword_table,
381*3d8817e4Smiod long value,
382*3d8817e4Smiod unsigned int attrs ATTRIBUTE_UNUSED)
383*3d8817e4Smiod {
384*3d8817e4Smiod disassemble_info *info = (disassemble_info *) dis_info;
385*3d8817e4Smiod const CGEN_KEYWORD_ENTRY *ke;
386*3d8817e4Smiod
387*3d8817e4Smiod ke = cgen_keyword_lookup_value (keyword_table, value);
388*3d8817e4Smiod if (ke != NULL)
389*3d8817e4Smiod (*info->fprintf_func) (info->stream, "%s", ke->name);
390*3d8817e4Smiod else
391*3d8817e4Smiod (*info->fprintf_func) (info->stream, "???");
392*3d8817e4Smiod }
393*3d8817e4Smiod
394*3d8817e4Smiod /* Default insn printer.
395*3d8817e4Smiod
396*3d8817e4Smiod DIS_INFO is defined as `void *' so the disassembler needn't know anything
397*3d8817e4Smiod about disassemble_info. */
398*3d8817e4Smiod
399*3d8817e4Smiod static void
print_insn_normal(CGEN_CPU_DESC cd,void * dis_info,const CGEN_INSN * insn,CGEN_FIELDS * fields,bfd_vma pc,int length)400*3d8817e4Smiod print_insn_normal (CGEN_CPU_DESC cd,
401*3d8817e4Smiod void *dis_info,
402*3d8817e4Smiod const CGEN_INSN *insn,
403*3d8817e4Smiod CGEN_FIELDS *fields,
404*3d8817e4Smiod bfd_vma pc,
405*3d8817e4Smiod int length)
406*3d8817e4Smiod {
407*3d8817e4Smiod const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
408*3d8817e4Smiod disassemble_info *info = (disassemble_info *) dis_info;
409*3d8817e4Smiod const CGEN_SYNTAX_CHAR_TYPE *syn;
410*3d8817e4Smiod
411*3d8817e4Smiod CGEN_INIT_PRINT (cd);
412*3d8817e4Smiod
413*3d8817e4Smiod for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
414*3d8817e4Smiod {
415*3d8817e4Smiod if (CGEN_SYNTAX_MNEMONIC_P (*syn))
416*3d8817e4Smiod {
417*3d8817e4Smiod (*info->fprintf_func) (info->stream, "%s", CGEN_INSN_MNEMONIC (insn));
418*3d8817e4Smiod continue;
419*3d8817e4Smiod }
420*3d8817e4Smiod if (CGEN_SYNTAX_CHAR_P (*syn))
421*3d8817e4Smiod {
422*3d8817e4Smiod (*info->fprintf_func) (info->stream, "%c", CGEN_SYNTAX_CHAR (*syn));
423*3d8817e4Smiod continue;
424*3d8817e4Smiod }
425*3d8817e4Smiod
426*3d8817e4Smiod /* We have an operand. */
427*3d8817e4Smiod fr30_cgen_print_operand (cd, CGEN_SYNTAX_FIELD (*syn), info,
428*3d8817e4Smiod fields, CGEN_INSN_ATTRS (insn), pc, length);
429*3d8817e4Smiod }
430*3d8817e4Smiod }
431*3d8817e4Smiod
432*3d8817e4Smiod /* Subroutine of print_insn. Reads an insn into the given buffers and updates
433*3d8817e4Smiod the extract info.
434*3d8817e4Smiod Returns 0 if all is well, non-zero otherwise. */
435*3d8817e4Smiod
436*3d8817e4Smiod static int
read_insn(CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,bfd_vma pc,disassemble_info * info,bfd_byte * buf,int buflen,CGEN_EXTRACT_INFO * ex_info,unsigned long * insn_value)437*3d8817e4Smiod read_insn (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
438*3d8817e4Smiod bfd_vma pc,
439*3d8817e4Smiod disassemble_info *info,
440*3d8817e4Smiod bfd_byte *buf,
441*3d8817e4Smiod int buflen,
442*3d8817e4Smiod CGEN_EXTRACT_INFO *ex_info,
443*3d8817e4Smiod unsigned long *insn_value)
444*3d8817e4Smiod {
445*3d8817e4Smiod int status = (*info->read_memory_func) (pc, buf, buflen, info);
446*3d8817e4Smiod
447*3d8817e4Smiod if (status != 0)
448*3d8817e4Smiod {
449*3d8817e4Smiod (*info->memory_error_func) (status, pc, info);
450*3d8817e4Smiod return -1;
451*3d8817e4Smiod }
452*3d8817e4Smiod
453*3d8817e4Smiod ex_info->dis_info = info;
454*3d8817e4Smiod ex_info->valid = (1 << buflen) - 1;
455*3d8817e4Smiod ex_info->insn_bytes = buf;
456*3d8817e4Smiod
457*3d8817e4Smiod *insn_value = bfd_get_bits (buf, buflen * 8, info->endian == BFD_ENDIAN_BIG);
458*3d8817e4Smiod return 0;
459*3d8817e4Smiod }
460*3d8817e4Smiod
461*3d8817e4Smiod /* Utility to print an insn.
462*3d8817e4Smiod BUF is the base part of the insn, target byte order, BUFLEN bytes long.
463*3d8817e4Smiod The result is the size of the insn in bytes or zero for an unknown insn
464*3d8817e4Smiod or -1 if an error occurs fetching data (memory_error_func will have
465*3d8817e4Smiod been called). */
466*3d8817e4Smiod
467*3d8817e4Smiod static int
print_insn(CGEN_CPU_DESC cd,bfd_vma pc,disassemble_info * info,bfd_byte * buf,unsigned int buflen)468*3d8817e4Smiod print_insn (CGEN_CPU_DESC cd,
469*3d8817e4Smiod bfd_vma pc,
470*3d8817e4Smiod disassemble_info *info,
471*3d8817e4Smiod bfd_byte *buf,
472*3d8817e4Smiod unsigned int buflen)
473*3d8817e4Smiod {
474*3d8817e4Smiod CGEN_INSN_INT insn_value;
475*3d8817e4Smiod const CGEN_INSN_LIST *insn_list;
476*3d8817e4Smiod CGEN_EXTRACT_INFO ex_info;
477*3d8817e4Smiod int basesize;
478*3d8817e4Smiod
479*3d8817e4Smiod /* Extract base part of instruction, just in case CGEN_DIS_* uses it. */
480*3d8817e4Smiod basesize = cd->base_insn_bitsize < buflen * 8 ?
481*3d8817e4Smiod cd->base_insn_bitsize : buflen * 8;
482*3d8817e4Smiod insn_value = cgen_get_insn_value (cd, buf, basesize);
483*3d8817e4Smiod
484*3d8817e4Smiod
485*3d8817e4Smiod /* Fill in ex_info fields like read_insn would. Don't actually call
486*3d8817e4Smiod read_insn, since the incoming buffer is already read (and possibly
487*3d8817e4Smiod modified a la m32r). */
488*3d8817e4Smiod ex_info.valid = (1 << buflen) - 1;
489*3d8817e4Smiod ex_info.dis_info = info;
490*3d8817e4Smiod ex_info.insn_bytes = buf;
491*3d8817e4Smiod
492*3d8817e4Smiod /* The instructions are stored in hash lists.
493*3d8817e4Smiod Pick the first one and keep trying until we find the right one. */
494*3d8817e4Smiod
495*3d8817e4Smiod insn_list = CGEN_DIS_LOOKUP_INSN (cd, (char *) buf, insn_value);
496*3d8817e4Smiod while (insn_list != NULL)
497*3d8817e4Smiod {
498*3d8817e4Smiod const CGEN_INSN *insn = insn_list->insn;
499*3d8817e4Smiod CGEN_FIELDS fields;
500*3d8817e4Smiod int length;
501*3d8817e4Smiod unsigned long insn_value_cropped;
502*3d8817e4Smiod
503*3d8817e4Smiod #ifdef CGEN_VALIDATE_INSN_SUPPORTED
504*3d8817e4Smiod /* Not needed as insn shouldn't be in hash lists if not supported. */
505*3d8817e4Smiod /* Supported by this cpu? */
506*3d8817e4Smiod if (! fr30_cgen_insn_supported (cd, insn))
507*3d8817e4Smiod {
508*3d8817e4Smiod insn_list = CGEN_DIS_NEXT_INSN (insn_list);
509*3d8817e4Smiod continue;
510*3d8817e4Smiod }
511*3d8817e4Smiod #endif
512*3d8817e4Smiod
513*3d8817e4Smiod /* Basic bit mask must be correct. */
514*3d8817e4Smiod /* ??? May wish to allow target to defer this check until the extract
515*3d8817e4Smiod handler. */
516*3d8817e4Smiod
517*3d8817e4Smiod /* Base size may exceed this instruction's size. Extract the
518*3d8817e4Smiod relevant part from the buffer. */
519*3d8817e4Smiod if ((unsigned) (CGEN_INSN_BITSIZE (insn) / 8) < buflen &&
520*3d8817e4Smiod (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long))
521*3d8817e4Smiod insn_value_cropped = bfd_get_bits (buf, CGEN_INSN_BITSIZE (insn),
522*3d8817e4Smiod info->endian == BFD_ENDIAN_BIG);
523*3d8817e4Smiod else
524*3d8817e4Smiod insn_value_cropped = insn_value;
525*3d8817e4Smiod
526*3d8817e4Smiod if ((insn_value_cropped & CGEN_INSN_BASE_MASK (insn))
527*3d8817e4Smiod == CGEN_INSN_BASE_VALUE (insn))
528*3d8817e4Smiod {
529*3d8817e4Smiod /* Printing is handled in two passes. The first pass parses the
530*3d8817e4Smiod machine insn and extracts the fields. The second pass prints
531*3d8817e4Smiod them. */
532*3d8817e4Smiod
533*3d8817e4Smiod /* Make sure the entire insn is loaded into insn_value, if it
534*3d8817e4Smiod can fit. */
535*3d8817e4Smiod if (((unsigned) CGEN_INSN_BITSIZE (insn) > cd->base_insn_bitsize) &&
536*3d8817e4Smiod (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long))
537*3d8817e4Smiod {
538*3d8817e4Smiod unsigned long full_insn_value;
539*3d8817e4Smiod int rc = read_insn (cd, pc, info, buf,
540*3d8817e4Smiod CGEN_INSN_BITSIZE (insn) / 8,
541*3d8817e4Smiod & ex_info, & full_insn_value);
542*3d8817e4Smiod if (rc != 0)
543*3d8817e4Smiod return rc;
544*3d8817e4Smiod length = CGEN_EXTRACT_FN (cd, insn)
545*3d8817e4Smiod (cd, insn, &ex_info, full_insn_value, &fields, pc);
546*3d8817e4Smiod }
547*3d8817e4Smiod else
548*3d8817e4Smiod length = CGEN_EXTRACT_FN (cd, insn)
549*3d8817e4Smiod (cd, insn, &ex_info, insn_value_cropped, &fields, pc);
550*3d8817e4Smiod
551*3d8817e4Smiod /* Length < 0 -> error. */
552*3d8817e4Smiod if (length < 0)
553*3d8817e4Smiod return length;
554*3d8817e4Smiod if (length > 0)
555*3d8817e4Smiod {
556*3d8817e4Smiod CGEN_PRINT_FN (cd, insn) (cd, info, insn, &fields, pc, length);
557*3d8817e4Smiod /* Length is in bits, result is in bytes. */
558*3d8817e4Smiod return length / 8;
559*3d8817e4Smiod }
560*3d8817e4Smiod }
561*3d8817e4Smiod
562*3d8817e4Smiod insn_list = CGEN_DIS_NEXT_INSN (insn_list);
563*3d8817e4Smiod }
564*3d8817e4Smiod
565*3d8817e4Smiod return 0;
566*3d8817e4Smiod }
567*3d8817e4Smiod
568*3d8817e4Smiod /* Default value for CGEN_PRINT_INSN.
569*3d8817e4Smiod The result is the size of the insn in bytes or zero for an unknown insn
570*3d8817e4Smiod or -1 if an error occured fetching bytes. */
571*3d8817e4Smiod
572*3d8817e4Smiod #ifndef CGEN_PRINT_INSN
573*3d8817e4Smiod #define CGEN_PRINT_INSN default_print_insn
574*3d8817e4Smiod #endif
575*3d8817e4Smiod
576*3d8817e4Smiod static int
default_print_insn(CGEN_CPU_DESC cd,bfd_vma pc,disassemble_info * info)577*3d8817e4Smiod default_print_insn (CGEN_CPU_DESC cd, bfd_vma pc, disassemble_info *info)
578*3d8817e4Smiod {
579*3d8817e4Smiod bfd_byte buf[CGEN_MAX_INSN_SIZE];
580*3d8817e4Smiod int buflen;
581*3d8817e4Smiod int status;
582*3d8817e4Smiod
583*3d8817e4Smiod /* Attempt to read the base part of the insn. */
584*3d8817e4Smiod buflen = cd->base_insn_bitsize / 8;
585*3d8817e4Smiod status = (*info->read_memory_func) (pc, buf, buflen, info);
586*3d8817e4Smiod
587*3d8817e4Smiod /* Try again with the minimum part, if min < base. */
588*3d8817e4Smiod if (status != 0 && (cd->min_insn_bitsize < cd->base_insn_bitsize))
589*3d8817e4Smiod {
590*3d8817e4Smiod buflen = cd->min_insn_bitsize / 8;
591*3d8817e4Smiod status = (*info->read_memory_func) (pc, buf, buflen, info);
592*3d8817e4Smiod }
593*3d8817e4Smiod
594*3d8817e4Smiod if (status != 0)
595*3d8817e4Smiod {
596*3d8817e4Smiod (*info->memory_error_func) (status, pc, info);
597*3d8817e4Smiod return -1;
598*3d8817e4Smiod }
599*3d8817e4Smiod
600*3d8817e4Smiod return print_insn (cd, pc, info, buf, buflen);
601*3d8817e4Smiod }
602*3d8817e4Smiod
603*3d8817e4Smiod /* Main entry point.
604*3d8817e4Smiod Print one instruction from PC on INFO->STREAM.
605*3d8817e4Smiod Return the size of the instruction (in bytes). */
606*3d8817e4Smiod
607*3d8817e4Smiod typedef struct cpu_desc_list
608*3d8817e4Smiod {
609*3d8817e4Smiod struct cpu_desc_list *next;
610*3d8817e4Smiod CGEN_BITSET *isa;
611*3d8817e4Smiod int mach;
612*3d8817e4Smiod int endian;
613*3d8817e4Smiod CGEN_CPU_DESC cd;
614*3d8817e4Smiod } cpu_desc_list;
615*3d8817e4Smiod
616*3d8817e4Smiod int
print_insn_fr30(bfd_vma pc,disassemble_info * info)617*3d8817e4Smiod print_insn_fr30 (bfd_vma pc, disassemble_info *info)
618*3d8817e4Smiod {
619*3d8817e4Smiod static cpu_desc_list *cd_list = 0;
620*3d8817e4Smiod cpu_desc_list *cl = 0;
621*3d8817e4Smiod static CGEN_CPU_DESC cd = 0;
622*3d8817e4Smiod static CGEN_BITSET *prev_isa;
623*3d8817e4Smiod static int prev_mach;
624*3d8817e4Smiod static int prev_endian;
625*3d8817e4Smiod int length;
626*3d8817e4Smiod CGEN_BITSET *isa;
627*3d8817e4Smiod int mach;
628*3d8817e4Smiod int endian = (info->endian == BFD_ENDIAN_BIG
629*3d8817e4Smiod ? CGEN_ENDIAN_BIG
630*3d8817e4Smiod : CGEN_ENDIAN_LITTLE);
631*3d8817e4Smiod enum bfd_architecture arch;
632*3d8817e4Smiod
633*3d8817e4Smiod /* ??? gdb will set mach but leave the architecture as "unknown" */
634*3d8817e4Smiod #ifndef CGEN_BFD_ARCH
635*3d8817e4Smiod #define CGEN_BFD_ARCH bfd_arch_fr30
636*3d8817e4Smiod #endif
637*3d8817e4Smiod arch = info->arch;
638*3d8817e4Smiod if (arch == bfd_arch_unknown)
639*3d8817e4Smiod arch = CGEN_BFD_ARCH;
640*3d8817e4Smiod
641*3d8817e4Smiod /* There's no standard way to compute the machine or isa number
642*3d8817e4Smiod so we leave it to the target. */
643*3d8817e4Smiod #ifdef CGEN_COMPUTE_MACH
644*3d8817e4Smiod mach = CGEN_COMPUTE_MACH (info);
645*3d8817e4Smiod #else
646*3d8817e4Smiod mach = info->mach;
647*3d8817e4Smiod #endif
648*3d8817e4Smiod
649*3d8817e4Smiod #ifdef CGEN_COMPUTE_ISA
650*3d8817e4Smiod {
651*3d8817e4Smiod static CGEN_BITSET *permanent_isa;
652*3d8817e4Smiod
653*3d8817e4Smiod if (!permanent_isa)
654*3d8817e4Smiod permanent_isa = cgen_bitset_create (MAX_ISAS);
655*3d8817e4Smiod isa = permanent_isa;
656*3d8817e4Smiod cgen_bitset_clear (isa);
657*3d8817e4Smiod cgen_bitset_add (isa, CGEN_COMPUTE_ISA (info));
658*3d8817e4Smiod }
659*3d8817e4Smiod #else
660*3d8817e4Smiod isa = info->insn_sets;
661*3d8817e4Smiod #endif
662*3d8817e4Smiod
663*3d8817e4Smiod /* If we've switched cpu's, try to find a handle we've used before */
664*3d8817e4Smiod if (cd
665*3d8817e4Smiod && (cgen_bitset_compare (isa, prev_isa) != 0
666*3d8817e4Smiod || mach != prev_mach
667*3d8817e4Smiod || endian != prev_endian))
668*3d8817e4Smiod {
669*3d8817e4Smiod cd = 0;
670*3d8817e4Smiod for (cl = cd_list; cl; cl = cl->next)
671*3d8817e4Smiod {
672*3d8817e4Smiod if (cgen_bitset_compare (cl->isa, isa) == 0 &&
673*3d8817e4Smiod cl->mach == mach &&
674*3d8817e4Smiod cl->endian == endian)
675*3d8817e4Smiod {
676*3d8817e4Smiod cd = cl->cd;
677*3d8817e4Smiod prev_isa = cd->isas;
678*3d8817e4Smiod break;
679*3d8817e4Smiod }
680*3d8817e4Smiod }
681*3d8817e4Smiod }
682*3d8817e4Smiod
683*3d8817e4Smiod /* If we haven't initialized yet, initialize the opcode table. */
684*3d8817e4Smiod if (! cd)
685*3d8817e4Smiod {
686*3d8817e4Smiod const bfd_arch_info_type *arch_type = bfd_lookup_arch (arch, mach);
687*3d8817e4Smiod const char *mach_name;
688*3d8817e4Smiod
689*3d8817e4Smiod if (!arch_type)
690*3d8817e4Smiod abort ();
691*3d8817e4Smiod mach_name = arch_type->printable_name;
692*3d8817e4Smiod
693*3d8817e4Smiod prev_isa = cgen_bitset_copy (isa);
694*3d8817e4Smiod prev_mach = mach;
695*3d8817e4Smiod prev_endian = endian;
696*3d8817e4Smiod cd = fr30_cgen_cpu_open (CGEN_CPU_OPEN_ISAS, prev_isa,
697*3d8817e4Smiod CGEN_CPU_OPEN_BFDMACH, mach_name,
698*3d8817e4Smiod CGEN_CPU_OPEN_ENDIAN, prev_endian,
699*3d8817e4Smiod CGEN_CPU_OPEN_END);
700*3d8817e4Smiod if (!cd)
701*3d8817e4Smiod abort ();
702*3d8817e4Smiod
703*3d8817e4Smiod /* Save this away for future reference. */
704*3d8817e4Smiod cl = xmalloc (sizeof (struct cpu_desc_list));
705*3d8817e4Smiod cl->cd = cd;
706*3d8817e4Smiod cl->isa = prev_isa;
707*3d8817e4Smiod cl->mach = mach;
708*3d8817e4Smiod cl->endian = endian;
709*3d8817e4Smiod cl->next = cd_list;
710*3d8817e4Smiod cd_list = cl;
711*3d8817e4Smiod
712*3d8817e4Smiod fr30_cgen_init_dis (cd);
713*3d8817e4Smiod }
714*3d8817e4Smiod
715*3d8817e4Smiod /* We try to have as much common code as possible.
716*3d8817e4Smiod But at this point some targets need to take over. */
717*3d8817e4Smiod /* ??? Some targets may need a hook elsewhere. Try to avoid this,
718*3d8817e4Smiod but if not possible try to move this hook elsewhere rather than
719*3d8817e4Smiod have two hooks. */
720*3d8817e4Smiod length = CGEN_PRINT_INSN (cd, pc, info);
721*3d8817e4Smiod if (length > 0)
722*3d8817e4Smiod return length;
723*3d8817e4Smiod if (length < 0)
724*3d8817e4Smiod return -1;
725*3d8817e4Smiod
726*3d8817e4Smiod (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG);
727*3d8817e4Smiod return cd->default_insn_bitsize / 8;
728*3d8817e4Smiod }
729