source: trunk/src/binutils/opcodes/frv-dis.c@ 791

Last change on this file since 791 was 607, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 24.8 KB
Line 
1/* Disassembler interface for targets using CGEN. -*- C -*-
2 CGEN: Cpu tools GENerator
3
4THIS FILE IS MACHINE GENERATED WITH CGEN.
5- the resultant file is machine generated, cgen-dis.in isn't
6
7Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
8Free Software Foundation, Inc.
9
10This file is part of the GNU Binutils and GDB, the GNU debugger.
11
12This program is free software; you can redistribute it and/or modify
13it under the terms of the GNU General Public License as published by
14the Free Software Foundation; either version 2, or (at your option)
15any later version.
16
17This program is distributed in the hope that it will be useful,
18but WITHOUT ANY WARRANTY; without even the implied warranty of
19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License
23along with this program; if not, write to the Free Software Foundation, Inc.,
2459 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25
26/* ??? Eventually more and more of this stuff can go to cpu-independent files.
27 Keep that in mind. */
28
29#include "sysdep.h"
30#include <stdio.h>
31#include "ansidecl.h"
32#include "dis-asm.h"
33#include "bfd.h"
34#include "symcat.h"
35#include "libiberty.h"
36#include "frv-desc.h"
37#include "frv-opc.h"
38#include "opintl.h"
39
40/* Default text to print if an instruction isn't recognized. */
41#define UNKNOWN_INSN_MSG _("*unknown*")
42
43static void print_normal
44 PARAMS ((CGEN_CPU_DESC, PTR, long, unsigned int, bfd_vma, int));
45static void print_address
46 PARAMS ((CGEN_CPU_DESC, PTR, bfd_vma, unsigned int, bfd_vma, int));
47static void print_keyword
48 PARAMS ((CGEN_CPU_DESC, PTR, CGEN_KEYWORD *, long, unsigned int));
49static void print_insn_normal
50 PARAMS ((CGEN_CPU_DESC, PTR, const CGEN_INSN *, CGEN_FIELDS *,
51 bfd_vma, int));
52static int print_insn
53 PARAMS ((CGEN_CPU_DESC, bfd_vma, disassemble_info *, char *, unsigned));
54static int default_print_insn
55 PARAMS ((CGEN_CPU_DESC, bfd_vma, disassemble_info *));
56static int read_insn
57 PARAMS ((CGEN_CPU_DESC, bfd_vma, disassemble_info *, char *, int,
58 CGEN_EXTRACT_INFO *, unsigned long *));
59
60
61/* -- disassembler routines inserted here */
62
63/* -- dis.c */
64static void print_spr
65 PARAMS ((CGEN_CPU_DESC, PTR, CGEN_KEYWORD *, long, unsigned));
66static void print_hi
67 PARAMS ((CGEN_CPU_DESC, PTR, long, unsigned, bfd_vma, int));
68static void print_lo
69 PARAMS ((CGEN_CPU_DESC, PTR, long, unsigned, bfd_vma, int));
70
71static void
72print_spr (cd, dis_info, names, regno, attrs)
73 CGEN_CPU_DESC cd;
74 PTR dis_info;
75 CGEN_KEYWORD *names;
76 long regno;
77 unsigned int attrs;
78{
79 /* Use the register index format for any unnamed registers. */
80 if (cgen_keyword_lookup_value (names, regno) == NULL)
81 {
82 disassemble_info *info = (disassemble_info *) dis_info;
83 (*info->fprintf_func) (info->stream, "spr[%ld]", regno);
84 }
85 else
86 print_keyword (cd, dis_info, names, regno, attrs);
87}
88
89static void
90print_hi (cd, dis_info, value, attrs, pc, length)
91 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
92 PTR dis_info;
93 long value;
94 unsigned int attrs ATTRIBUTE_UNUSED;
95 bfd_vma pc ATTRIBUTE_UNUSED;
96 int length ATTRIBUTE_UNUSED;
97{
98 disassemble_info *info = (disassemble_info *) dis_info;
99 if (value)
100 (*info->fprintf_func) (info->stream, "0x%lx", value);
101 else
102 (*info->fprintf_func) (info->stream, "hi(0x%lx)", value);
103}
104
105static void
106print_lo (cd, dis_info, value, attrs, pc, length)
107 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
108 PTR dis_info;
109 long value;
110 unsigned int attrs ATTRIBUTE_UNUSED;
111 bfd_vma pc ATTRIBUTE_UNUSED;
112 int length ATTRIBUTE_UNUSED;
113{
114 disassemble_info *info = (disassemble_info *) dis_info;
115 if (value)
116 (*info->fprintf_func) (info->stream, "0x%lx", value);
117 else
118 (*info->fprintf_func) (info->stream, "lo(0x%lx)", value);
119}
120
121/* -- */
122
123void frv_cgen_print_operand
124 PARAMS ((CGEN_CPU_DESC, int, PTR, CGEN_FIELDS *,
125 void const *, bfd_vma, int));
126
127/* Main entry point for printing operands.
128 XINFO is a `void *' and not a `disassemble_info *' to not put a requirement
129 of dis-asm.h on cgen.h.
130
131 This function is basically just a big switch statement. Earlier versions
132 used tables to look up the function to use, but
133 - if the table contains both assembler and disassembler functions then
134 the disassembler contains much of the assembler and vice-versa,
135 - there's a lot of inlining possibilities as things grow,
136 - using a switch statement avoids the function call overhead.
137
138 This function could be moved into `print_insn_normal', but keeping it
139 separate makes clear the interface between `print_insn_normal' and each of
140 the handlers. */
141
142void
143frv_cgen_print_operand (cd, opindex, xinfo, fields, attrs, pc, length)
144 CGEN_CPU_DESC cd;
145 int opindex;
146 PTR xinfo;
147 CGEN_FIELDS *fields;
148 void const *attrs ATTRIBUTE_UNUSED;
149 bfd_vma pc;
150 int length;
151{
152 disassemble_info *info = (disassemble_info *) xinfo;
153
154 switch (opindex)
155 {
156 case FRV_OPERAND_A :
157 print_normal (cd, info, fields->f_A, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
158 break;
159 case FRV_OPERAND_ACC40SI :
160 print_keyword (cd, info, & frv_cgen_opval_acc_names, fields->f_ACC40Si, 0);
161 break;
162 case FRV_OPERAND_ACC40SK :
163 print_keyword (cd, info, & frv_cgen_opval_acc_names, fields->f_ACC40Sk, 0);
164 break;
165 case FRV_OPERAND_ACC40UI :
166 print_keyword (cd, info, & frv_cgen_opval_acc_names, fields->f_ACC40Ui, 0);
167 break;
168 case FRV_OPERAND_ACC40UK :
169 print_keyword (cd, info, & frv_cgen_opval_acc_names, fields->f_ACC40Uk, 0);
170 break;
171 case FRV_OPERAND_ACCGI :
172 print_keyword (cd, info, & frv_cgen_opval_accg_names, fields->f_ACCGi, 0);
173 break;
174 case FRV_OPERAND_ACCGK :
175 print_keyword (cd, info, & frv_cgen_opval_accg_names, fields->f_ACCGk, 0);
176 break;
177 case FRV_OPERAND_CCI :
178 print_keyword (cd, info, & frv_cgen_opval_cccr_names, fields->f_CCi, 0);
179 break;
180 case FRV_OPERAND_CPRDOUBLEK :
181 print_keyword (cd, info, & frv_cgen_opval_cpr_names, fields->f_CPRk, 0);
182 break;
183 case FRV_OPERAND_CPRI :
184 print_keyword (cd, info, & frv_cgen_opval_cpr_names, fields->f_CPRi, 0);
185 break;
186 case FRV_OPERAND_CPRJ :
187 print_keyword (cd, info, & frv_cgen_opval_cpr_names, fields->f_CPRj, 0);
188 break;
189 case FRV_OPERAND_CPRK :
190 print_keyword (cd, info, & frv_cgen_opval_cpr_names, fields->f_CPRk, 0);
191 break;
192 case FRV_OPERAND_CRI :
193 print_keyword (cd, info, & frv_cgen_opval_cccr_names, fields->f_CRi, 0);
194 break;
195 case FRV_OPERAND_CRJ :
196 print_keyword (cd, info, & frv_cgen_opval_cccr_names, fields->f_CRj, 0);
197 break;
198 case FRV_OPERAND_CRJ_FLOAT :
199 print_keyword (cd, info, & frv_cgen_opval_cccr_names, fields->f_CRj_float, 0);
200 break;
201 case FRV_OPERAND_CRJ_INT :
202 print_keyword (cd, info, & frv_cgen_opval_cccr_names, fields->f_CRj_int, 0);
203 break;
204 case FRV_OPERAND_CRK :
205 print_keyword (cd, info, & frv_cgen_opval_cccr_names, fields->f_CRk, 0);
206 break;
207 case FRV_OPERAND_FCCI_1 :
208 print_keyword (cd, info, & frv_cgen_opval_fccr_names, fields->f_FCCi_1, 0);
209 break;
210 case FRV_OPERAND_FCCI_2 :
211 print_keyword (cd, info, & frv_cgen_opval_fccr_names, fields->f_FCCi_2, 0);
212 break;
213 case FRV_OPERAND_FCCI_3 :
214 print_keyword (cd, info, & frv_cgen_opval_fccr_names, fields->f_FCCi_3, 0);
215 break;
216 case FRV_OPERAND_FCCK :
217 print_keyword (cd, info, & frv_cgen_opval_fccr_names, fields->f_FCCk, 0);
218 break;
219 case FRV_OPERAND_FRDOUBLEI :
220 print_keyword (cd, info, & frv_cgen_opval_fr_names, fields->f_FRi, 0);
221 break;
222 case FRV_OPERAND_FRDOUBLEJ :
223 print_keyword (cd, info, & frv_cgen_opval_fr_names, fields->f_FRj, 0);
224 break;
225 case FRV_OPERAND_FRDOUBLEK :
226 print_keyword (cd, info, & frv_cgen_opval_fr_names, fields->f_FRk, 0);
227 break;
228 case FRV_OPERAND_FRI :
229 print_keyword (cd, info, & frv_cgen_opval_fr_names, fields->f_FRi, 0);
230 break;
231 case FRV_OPERAND_FRINTI :
232 print_keyword (cd, info, & frv_cgen_opval_fr_names, fields->f_FRi, 0);
233 break;
234 case FRV_OPERAND_FRINTJ :
235 print_keyword (cd, info, & frv_cgen_opval_fr_names, fields->f_FRj, 0);
236 break;
237 case FRV_OPERAND_FRINTK :
238 print_keyword (cd, info, & frv_cgen_opval_fr_names, fields->f_FRk, 0);
239 break;
240 case FRV_OPERAND_FRJ :
241 print_keyword (cd, info, & frv_cgen_opval_fr_names, fields->f_FRj, 0);
242 break;
243 case FRV_OPERAND_FRK :
244 print_keyword (cd, info, & frv_cgen_opval_fr_names, fields->f_FRk, 0);
245 break;
246 case FRV_OPERAND_FRKHI :
247 print_keyword (cd, info, & frv_cgen_opval_fr_names, fields->f_FRk, 0);
248 break;
249 case FRV_OPERAND_FRKLO :
250 print_keyword (cd, info, & frv_cgen_opval_fr_names, fields->f_FRk, 0);
251 break;
252 case FRV_OPERAND_GRDOUBLEK :
253 print_keyword (cd, info, & frv_cgen_opval_gr_names, fields->f_GRk, 0);
254 break;
255 case FRV_OPERAND_GRI :
256 print_keyword (cd, info, & frv_cgen_opval_gr_names, fields->f_GRi, 0);
257 break;
258 case FRV_OPERAND_GRJ :
259 print_keyword (cd, info, & frv_cgen_opval_gr_names, fields->f_GRj, 0);
260 break;
261 case FRV_OPERAND_GRK :
262 print_keyword (cd, info, & frv_cgen_opval_gr_names, fields->f_GRk, 0);
263 break;
264 case FRV_OPERAND_GRKHI :
265 print_keyword (cd, info, & frv_cgen_opval_gr_names, fields->f_GRk, 0);
266 break;
267 case FRV_OPERAND_GRKLO :
268 print_keyword (cd, info, & frv_cgen_opval_gr_names, fields->f_GRk, 0);
269 break;
270 case FRV_OPERAND_ICCI_1 :
271 print_keyword (cd, info, & frv_cgen_opval_iccr_names, fields->f_ICCi_1, 0);
272 break;
273 case FRV_OPERAND_ICCI_2 :
274 print_keyword (cd, info, & frv_cgen_opval_iccr_names, fields->f_ICCi_2, 0);
275 break;
276 case FRV_OPERAND_ICCI_3 :
277 print_keyword (cd, info, & frv_cgen_opval_iccr_names, fields->f_ICCi_3, 0);
278 break;
279 case FRV_OPERAND_LI :
280 print_normal (cd, info, fields->f_LI, 0, pc, length);
281 break;
282 case FRV_OPERAND_AE :
283 print_normal (cd, info, fields->f_ae, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
284 break;
285 case FRV_OPERAND_CCOND :
286 print_normal (cd, info, fields->f_ccond, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
287 break;
288 case FRV_OPERAND_COND :
289 print_normal (cd, info, fields->f_cond, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
290 break;
291 case FRV_OPERAND_D12 :
292 print_normal (cd, info, fields->f_d12, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
293 break;
294 case FRV_OPERAND_DEBUG :
295 print_normal (cd, info, fields->f_debug, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
296 break;
297 case FRV_OPERAND_EIR :
298 print_normal (cd, info, fields->f_eir, 0, pc, length);
299 break;
300 case FRV_OPERAND_HINT :
301 print_normal (cd, info, fields->f_hint, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
302 break;
303 case FRV_OPERAND_HINT_NOT_TAKEN :
304 print_keyword (cd, info, & frv_cgen_opval_h_hint_not_taken, fields->f_hint, 0);
305 break;
306 case FRV_OPERAND_HINT_TAKEN :
307 print_keyword (cd, info, & frv_cgen_opval_h_hint_taken, fields->f_hint, 0);
308 break;
309 case FRV_OPERAND_LABEL16 :
310 print_address (cd, info, fields->f_label16, 0|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
311 break;
312 case FRV_OPERAND_LABEL24 :
313 print_address (cd, info, fields->f_label24, 0|(1<<CGEN_OPERAND_PCREL_ADDR)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
314 break;
315 case FRV_OPERAND_LOCK :
316 print_normal (cd, info, fields->f_lock, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
317 break;
318 case FRV_OPERAND_PACK :
319 print_keyword (cd, info, & frv_cgen_opval_h_pack, fields->f_pack, 0);
320 break;
321 case FRV_OPERAND_S10 :
322 print_normal (cd, info, fields->f_s10, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
323 break;
324 case FRV_OPERAND_S12 :
325 print_normal (cd, info, fields->f_d12, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
326 break;
327 case FRV_OPERAND_S16 :
328 print_normal (cd, info, fields->f_s16, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
329 break;
330 case FRV_OPERAND_S5 :
331 print_normal (cd, info, fields->f_s5, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
332 break;
333 case FRV_OPERAND_S6 :
334 print_normal (cd, info, fields->f_s6, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
335 break;
336 case FRV_OPERAND_S6_1 :
337 print_normal (cd, info, fields->f_s6_1, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
338 break;
339 case FRV_OPERAND_SLO16 :
340 print_lo (cd, info, fields->f_s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
341 break;
342 case FRV_OPERAND_SPR :
343 print_spr (cd, info, & frv_cgen_opval_spr_names, fields->f_spr, 0|(1<<CGEN_OPERAND_VIRTUAL));
344 break;
345 case FRV_OPERAND_U12 :
346 print_normal (cd, info, fields->f_u12, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
347 break;
348 case FRV_OPERAND_U16 :
349 print_normal (cd, info, fields->f_u16, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
350 break;
351 case FRV_OPERAND_U6 :
352 print_normal (cd, info, fields->f_u6, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
353 break;
354 case FRV_OPERAND_UHI16 :
355 print_hi (cd, info, fields->f_u16, 0, pc, length);
356 break;
357 case FRV_OPERAND_ULO16 :
358 print_lo (cd, info, fields->f_u16, 0, pc, length);
359 break;
360
361 default :
362 /* xgettext:c-format */
363 fprintf (stderr, _("Unrecognized field %d while printing insn.\n"),
364 opindex);
365 abort ();
366 }
367}
368
369cgen_print_fn * const frv_cgen_print_handlers[] =
370{
371 print_insn_normal,
372};
373
374
375void
376frv_cgen_init_dis (cd)
377 CGEN_CPU_DESC cd;
378{
379 frv_cgen_init_opcode_table (cd);
380 frv_cgen_init_ibld_table (cd);
381 cd->print_handlers = & frv_cgen_print_handlers[0];
382 cd->print_operand = frv_cgen_print_operand;
383}
384
385
386
387/* Default print handler. */
388
389static void
390print_normal (cd, dis_info, value, attrs, pc, length)