sicontrol(8): Add few fallthrough.
[dragonfly.git] / contrib / gdb-7 / opcodes / disassemble.c
blob55a44ec83fd2168d1f109d2ff2d20fbde949f10a
1 /* Select disassembly routine for specified architecture.
2 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 Free Software Foundation, Inc.
6 This file is part of the GNU opcodes library.
8 This library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
23 #include "sysdep.h"
24 #include "dis-asm.h"
26 #ifdef ARCH_all
27 #define ARCH_aarch64
28 #define ARCH_alpha
29 #define ARCH_arc
30 #define ARCH_arm
31 #define ARCH_avr
32 #define ARCH_bfin
33 #define ARCH_cr16
34 #define ARCH_cris
35 #define ARCH_crx
36 #define ARCH_d10v
37 #define ARCH_d30v
38 #define ARCH_dlx
39 #define ARCH_epiphany
40 #define ARCH_fr30
41 #define ARCH_frv
42 #define ARCH_h8300
43 #define ARCH_h8500
44 #define ARCH_hppa
45 #define ARCH_i370
46 #define ARCH_i386
47 #define ARCH_i860
48 #define ARCH_i960
49 #define ARCH_ia64
50 #define ARCH_ip2k
51 #define ARCH_iq2000
52 #define ARCH_lm32
53 #define ARCH_m32c
54 #define ARCH_m32r
55 #define ARCH_m68hc11
56 #define ARCH_m68hc12
57 #define ARCH_m68k
58 #define ARCH_m88k
59 #define ARCH_mcore
60 #define ARCH_mep
61 #define ARCH_metag
62 #define ARCH_microblaze
63 #define ARCH_mips
64 #define ARCH_mmix
65 #define ARCH_mn10200
66 #define ARCH_mn10300
67 #define ARCH_moxie
68 #define ARCH_mt
69 #define ARCH_msp430
70 #define ARCH_nios2
71 #define ARCH_ns32k
72 #define ARCH_openrisc
73 #define ARCH_or32
74 #define ARCH_pdp11
75 #define ARCH_pj
76 #define ARCH_powerpc
77 #define ARCH_rs6000
78 #define ARCH_rl78
79 #define ARCH_rx
80 #define ARCH_s390
81 #define ARCH_score
82 #define ARCH_sh
83 #define ARCH_sparc
84 #define ARCH_spu
85 #define ARCH_tic30
86 #define ARCH_tic4x
87 #define ARCH_tic54x
88 #define ARCH_tic6x
89 #define ARCH_tic80
90 #define ARCH_tilegx
91 #define ARCH_tilepro
92 #define ARCH_v850
93 #define ARCH_vax
94 #define ARCH_w65
95 #define ARCH_xstormy16
96 #define ARCH_xc16x
97 #define ARCH_xgate
98 #define ARCH_xtensa
99 #define ARCH_z80
100 #define ARCH_z8k
101 #define INCLUDE_SHMEDIA
102 #endif
104 #ifdef ARCH_m32c
105 #include "m32c-desc.h"
106 #endif
108 disassembler_ftype
109 disassembler (abfd)
110 bfd *abfd;
112 enum bfd_architecture a = bfd_get_arch (abfd);
113 disassembler_ftype disassemble;
115 switch (a)
117 /* If you add a case to this table, also add it to the
118 ARCH_all definition right above this function. */
119 #ifdef ARCH_aarch64
120 case bfd_arch_aarch64:
121 disassemble = print_insn_aarch64;
122 break;
123 #endif
124 #ifdef ARCH_alpha
125 case bfd_arch_alpha:
126 disassemble = print_insn_alpha;
127 break;
128 #endif
129 #ifdef ARCH_arc
130 case bfd_arch_arc:
131 disassemble = arc_get_disassembler (abfd);
132 break;
133 #endif
134 #ifdef ARCH_arm
135 case bfd_arch_arm:
136 if (bfd_big_endian (abfd))
137 disassemble = print_insn_big_arm;
138 else
139 disassemble = print_insn_little_arm;
140 break;
141 #endif
142 #ifdef ARCH_avr
143 case bfd_arch_avr:
144 disassemble = print_insn_avr;
145 break;
146 #endif
147 #ifdef ARCH_bfin
148 case bfd_arch_bfin:
149 disassemble = print_insn_bfin;
150 break;
151 #endif
152 #ifdef ARCH_cr16
153 case bfd_arch_cr16:
154 disassemble = print_insn_cr16;
155 break;
156 #endif
157 #ifdef ARCH_cris
158 case bfd_arch_cris:
159 disassemble = cris_get_disassembler (abfd);
160 break;
161 #endif
162 #ifdef ARCH_crx
163 case bfd_arch_crx:
164 disassemble = print_insn_crx;
165 break;
166 #endif
167 #ifdef ARCH_d10v
168 case bfd_arch_d10v:
169 disassemble = print_insn_d10v;
170 break;
171 #endif
172 #ifdef ARCH_d30v
173 case bfd_arch_d30v:
174 disassemble = print_insn_d30v;
175 break;
176 #endif
177 #ifdef ARCH_dlx
178 case bfd_arch_dlx:
179 /* As far as I know we only handle big-endian DLX objects. */
180 disassemble = print_insn_dlx;
181 break;
182 #endif
183 #ifdef ARCH_h8300
184 case bfd_arch_h8300:
185 if (bfd_get_mach (abfd) == bfd_mach_h8300h
186 || bfd_get_mach (abfd) == bfd_mach_h8300hn)
187 disassemble = print_insn_h8300h;
188 else if (bfd_get_mach (abfd) == bfd_mach_h8300s
189 || bfd_get_mach (abfd) == bfd_mach_h8300sn
190 || bfd_get_mach (abfd) == bfd_mach_h8300sx
191 || bfd_get_mach (abfd) == bfd_mach_h8300sxn)
192 disassemble = print_insn_h8300s;
193 else
194 disassemble = print_insn_h8300;
195 break;
196 #endif
197 #ifdef ARCH_h8500
198 case bfd_arch_h8500:
199 disassemble = print_insn_h8500;
200 break;
201 #endif
202 #ifdef ARCH_hppa
203 case bfd_arch_hppa:
204 disassemble = print_insn_hppa;
205 break;
206 #endif
207 #ifdef ARCH_i370
208 case bfd_arch_i370:
209 disassemble = print_insn_i370;
210 break;
211 #endif
212 #ifdef ARCH_i386
213 case bfd_arch_i386:
214 case bfd_arch_l1om:
215 case bfd_arch_k1om:
216 disassemble = print_insn_i386;
217 break;
218 #endif
219 #ifdef ARCH_i860
220 case bfd_arch_i860:
221 disassemble = print_insn_i860;
222 break;
223 #endif
224 #ifdef ARCH_i960
225 case bfd_arch_i960:
226 disassemble = print_insn_i960;
227 break;
228 #endif
229 #ifdef ARCH_ia64
230 case bfd_arch_ia64:
231 disassemble = print_insn_ia64;
232 break;
233 #endif
234 #ifdef ARCH_ip2k
235 case bfd_arch_ip2k:
236 disassemble = print_insn_ip2k;
237 break;
238 #endif
239 #ifdef ARCH_epiphany
240 case bfd_arch_epiphany:
241 disassemble = print_insn_epiphany;
242 break;
243 #endif
244 #ifdef ARCH_fr30
245 case bfd_arch_fr30:
246 disassemble = print_insn_fr30;
247 break;
248 #endif
249 #ifdef ARCH_lm32
250 case bfd_arch_lm32:
251 disassemble = print_insn_lm32;
252 break;
253 #endif
254 #ifdef ARCH_m32r
255 case bfd_arch_m32r:
256 disassemble = print_insn_m32r;
257 break;
258 #endif
259 #if defined(ARCH_m68hc11) || defined(ARCH_m68hc12) \
260 || defined(ARCH_9s12x) || defined(ARCH_m9s12xg)
261 case bfd_arch_m68hc11:
262 disassemble = print_insn_m68hc11;
263 break;
264 case bfd_arch_m68hc12:
265 disassemble = print_insn_m68hc12;
266 break;
267 case bfd_arch_m9s12x:
268 disassemble = print_insn_m9s12x;
269 break;
270 case bfd_arch_m9s12xg:
271 disassemble = print_insn_m9s12xg;
272 break;
273 #endif
274 #ifdef ARCH_m68k
275 case bfd_arch_m68k:
276 disassemble = print_insn_m68k;
277 break;
278 #endif
279 #ifdef ARCH_m88k
280 case bfd_arch_m88k:
281 disassemble = print_insn_m88k;
282 break;
283 #endif
284 #ifdef ARCH_mt
285 case bfd_arch_mt:
286 disassemble = print_insn_mt;
287 break;
288 #endif
289 #ifdef ARCH_microblaze
290 case bfd_arch_microblaze:
291 disassemble = print_insn_microblaze;
292 break;
293 #endif
294 #ifdef ARCH_msp430
295 case bfd_arch_msp430:
296 disassemble = print_insn_msp430;
297 break;
298 #endif
299 #ifdef ARCH_ns32k
300 case bfd_arch_ns32k:
301 disassemble = print_insn_ns32k;
302 break;
303 #endif
304 #ifdef ARCH_mcore
305 case bfd_arch_mcore:
306 disassemble = print_insn_mcore;
307 break;
308 #endif
309 #ifdef ARCH_mep
310 case bfd_arch_mep:
311 disassemble = print_insn_mep;
312 break;
313 #endif
314 #ifdef ARCH_metag
315 case bfd_arch_metag:
316 disassemble = print_insn_metag;
317 break;
318 #endif
319 #ifdef ARCH_mips
320 case bfd_arch_mips:
321 if (bfd_big_endian (abfd))
322 disassemble = print_insn_big_mips;
323 else
324 disassemble = print_insn_little_mips;
325 break;
326 #endif
327 #ifdef ARCH_mmix
328 case bfd_arch_mmix:
329 disassemble = print_insn_mmix;
330 break;
331 #endif
332 #ifdef ARCH_mn10200
333 case bfd_arch_mn10200:
334 disassemble = print_insn_mn10200;
335 break;
336 #endif
337 #ifdef ARCH_mn10300
338 case bfd_arch_mn10300:
339 disassemble = print_insn_mn10300;
340 break;
341 #endif
342 #ifdef ARCH_nios2
343 case bfd_arch_nios2:
344 if (bfd_big_endian (abfd))
345 disassemble = print_insn_big_nios2;
346 else
347 disassemble = print_insn_little_nios2;
348 break;
349 #endif
350 #ifdef ARCH_openrisc
351 case bfd_arch_openrisc:
352 disassemble = print_insn_openrisc;
353 break;
354 #endif
355 #ifdef ARCH_or32
356 case bfd_arch_or32:
357 if (bfd_big_endian (abfd))
358 disassemble = print_insn_big_or32;
359 else
360 disassemble = print_insn_little_or32;
361 break;
362 #endif
363 #ifdef ARCH_pdp11
364 case bfd_arch_pdp11:
365 disassemble = print_insn_pdp11;
366 break;
367 #endif
368 #ifdef ARCH_pj
369 case bfd_arch_pj:
370 disassemble = print_insn_pj;
371 break;
372 #endif
373 #ifdef ARCH_powerpc
374 case bfd_arch_powerpc:
375 if (bfd_big_endian (abfd))
376 disassemble = print_insn_big_powerpc;
377 else
378 disassemble = print_insn_little_powerpc;
379 break;
380 #endif
381 #ifdef ARCH_rs6000
382 case bfd_arch_rs6000:
383 if (bfd_get_mach (abfd) == bfd_mach_ppc_620)
384 disassemble = print_insn_big_powerpc;
385 else
386 disassemble = print_insn_rs6000;
387 break;
388 #endif
389 #ifdef ARCH_rl78
390 case bfd_arch_rl78:
391 disassemble = print_insn_rl78;
392 break;
393 #endif
394 #ifdef ARCH_rx
395 case bfd_arch_rx:
396 disassemble = print_insn_rx;
397 break;
398 #endif
399 #ifdef ARCH_s390
400 case bfd_arch_s390:
401 disassemble = print_insn_s390;
402 break;
403 #endif
404 #ifdef ARCH_score
405 case bfd_arch_score:
406 if (bfd_big_endian (abfd))
407 disassemble = print_insn_big_score;
408 else
409 disassemble = print_insn_little_score;
410 break;
411 #endif
412 #ifdef ARCH_sh
413 case bfd_arch_sh:
414 disassemble = print_insn_sh;
415 break;
416 #endif
417 #ifdef ARCH_sparc
418 case bfd_arch_sparc:
419 disassemble = print_insn_sparc;
420 break;
421 #endif
422 #ifdef ARCH_spu
423 case bfd_arch_spu:
424 disassemble = print_insn_spu;
425 break;
426 #endif
427 #ifdef ARCH_tic30
428 case bfd_arch_tic30:
429 disassemble = print_insn_tic30;
430 break;
431 #endif
432 #ifdef ARCH_tic4x
433 case bfd_arch_tic4x:
434 disassemble = print_insn_tic4x;
435 break;
436 #endif
437 #ifdef ARCH_tic54x
438 case bfd_arch_tic54x:
439 disassemble = print_insn_tic54x;
440 break;
441 #endif
442 #ifdef ARCH_tic6x
443 case bfd_arch_tic6x:
444 disassemble = print_insn_tic6x;
445 break;
446 #endif
447 #ifdef ARCH_tic80
448 case bfd_arch_tic80:
449 disassemble = print_insn_tic80;
450 break;
451 #endif
452 #ifdef ARCH_v850
453 case bfd_arch_v850:
454 case bfd_arch_v850_rh850:
455 disassemble = print_insn_v850;
456 break;
457 #endif
458 #ifdef ARCH_w65
459 case bfd_arch_w65:
460 disassemble = print_insn_w65;
461 break;
462 #endif
463 #ifdef ARCH_xgate
464 case bfd_arch_xgate:
465 disassemble = print_insn_xgate;
466 break;
467 #endif
468 #ifdef ARCH_xstormy16
469 case bfd_arch_xstormy16:
470 disassemble = print_insn_xstormy16;
471 break;
472 #endif
473 #ifdef ARCH_xc16x
474 case bfd_arch_xc16x:
475 disassemble = print_insn_xc16x;
476 break;
477 #endif
478 #ifdef ARCH_xtensa
479 case bfd_arch_xtensa:
480 disassemble = print_insn_xtensa;
481 break;
482 #endif
483 #ifdef ARCH_z80
484 case bfd_arch_z80:
485 disassemble = print_insn_z80;
486 break;
487 #endif
488 #ifdef ARCH_z8k
489 case bfd_arch_z8k:
490 if (bfd_get_mach(abfd) == bfd_mach_z8001)
491 disassemble = print_insn_z8001;
492 else
493 disassemble = print_insn_z8002;
494 break;
495 #endif
496 #ifdef ARCH_vax
497 case bfd_arch_vax:
498 disassemble = print_insn_vax;
499 break;
500 #endif
501 #ifdef ARCH_frv
502 case bfd_arch_frv:
503 disassemble = print_insn_frv;
504 break;
505 #endif
506 #ifdef ARCH_moxie
507 case bfd_arch_moxie:
508 disassemble = print_insn_moxie;
509 break;
510 #endif
511 #ifdef ARCH_iq2000
512 case bfd_arch_iq2000:
513 disassemble = print_insn_iq2000;
514 break;
515 #endif
516 #ifdef ARCH_m32c
517 case bfd_arch_m32c:
518 disassemble = print_insn_m32c;
519 break;
520 #endif
521 #ifdef ARCH_tilegx
522 case bfd_arch_tilegx:
523 disassemble = print_insn_tilegx;
524 break;
525 #endif
526 #ifdef ARCH_tilepro
527 case bfd_arch_tilepro:
528 disassemble = print_insn_tilepro;
529 break;
530 #endif
531 default:
532 return 0;
534 return disassemble;
537 void
538 disassembler_usage (stream)
539 FILE * stream ATTRIBUTE_UNUSED;
541 #ifdef ARCH_aarch64
542 print_aarch64_disassembler_options (stream);
543 #endif
544 #ifdef ARCH_arm
545 print_arm_disassembler_options (stream);
546 #endif
547 #ifdef ARCH_mips
548 print_mips_disassembler_options (stream);
549 #endif
550 #ifdef ARCH_powerpc
551 print_ppc_disassembler_options (stream);
552 #endif
553 #ifdef ARCH_i386
554 print_i386_disassembler_options (stream);
555 #endif
556 #ifdef ARCH_s390
557 print_s390_disassembler_options (stream);
558 #endif
560 return;
563 void
564 disassemble_init_for_target (struct disassemble_info * info)
566 if (info == NULL)
567 return;
569 switch (info->arch)
571 #ifdef ARCH_aarch64
572 case bfd_arch_aarch64:
573 info->symbol_is_valid = aarch64_symbol_is_valid;
574 info->disassembler_needs_relocs = TRUE;
575 break;
576 #endif
577 #ifdef ARCH_arm
578 case bfd_arch_arm:
579 info->symbol_is_valid = arm_symbol_is_valid;
580 info->disassembler_needs_relocs = TRUE;
581 break;
582 #endif
583 #ifdef ARCH_ia64
584 case bfd_arch_ia64:
585 info->skip_zeroes = 16;
586 break;
587 #endif
588 #ifdef ARCH_tic4x
589 case bfd_arch_tic4x:
590 info->skip_zeroes = 32;
591 break;
592 #endif
593 #ifdef ARCH_mep
594 case bfd_arch_mep:
595 info->skip_zeroes = 256;
596 info->skip_zeroes_at_end = 0;
597 break;
598 #endif
599 #ifdef ARCH_metag
600 case bfd_arch_metag:
601 info->disassembler_needs_relocs = TRUE;
602 break;
603 #endif
604 #ifdef ARCH_m32c
605 case bfd_arch_m32c:
606 /* This processor in fact is little endian. The value set here
607 reflects the way opcodes are written in the cgen description. */
608 info->endian = BFD_ENDIAN_BIG;
609 if (! info->insn_sets)
611 info->insn_sets = cgen_bitset_create (ISA_MAX);
612 if (info->mach == bfd_mach_m16c)
613 cgen_bitset_set (info->insn_sets, ISA_M16C);
614 else
615 cgen_bitset_set (info->insn_sets, ISA_M32C);
617 break;
618 #endif
619 #ifdef ARCH_powerpc
620 case bfd_arch_powerpc:
621 #endif
622 #ifdef ARCH_rs6000
623 case bfd_arch_rs6000:
624 #endif
625 #if defined (ARCH_powerpc) || defined (ARCH_rs6000)
626 disassemble_init_powerpc (info);
627 break;
628 #endif
629 default:
630 break;