Changeset 609 for branches/GNU/src/binutils/opcodes/fr30-dis.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/opcodes/fr30-dis.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 5 5 - the resultant file is machine generated, cgen-dis.in isn't 6 6 7 Copyright 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. 7 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 8 Free Software Foundation, Inc. 8 9 9 10 This file is part of the GNU Binutils and GDB, the GNU debugger. … … 32 33 #include "bfd.h" 33 34 #include "symcat.h" 35 #include "libiberty.h" 34 36 #include "fr30-desc.h" 35 37 #include "fr30-opc.h" … … 48 50 PARAMS ((CGEN_CPU_DESC, PTR, const CGEN_INSN *, CGEN_FIELDS *, 49 51 bfd_vma, int)); 50 static int print_insn PARAMS ((CGEN_CPU_DESC, bfd_vma,51 disassemble_info *, char *, int));52 static int print_insn 53 PARAMS ((CGEN_CPU_DESC, bfd_vma, disassemble_info *, char *, unsigned)); 52 54 static int default_print_insn 53 55 PARAMS ((CGEN_CPU_DESC, bfd_vma, disassemble_info *)); 56 static int read_insn 57 PARAMS ((CGEN_CPU_DESC, bfd_vma, disassemble_info *, char *, int, 58 CGEN_EXTRACT_INFO *, unsigned long *)); 54 59 55 60 … … 57 62 58 63 /* -- dis.c */ 64 static void print_register_list 65 PARAMS ((PTR, long, long, int)); 66 static void print_hi_register_list_ld 67 PARAMS ((CGEN_CPU_DESC, PTR, long, unsigned, bfd_vma, int)); 68 static void print_low_register_list_ld 69 PARAMS ((CGEN_CPU_DESC, PTR, long, unsigned, bfd_vma, int)); 70 static void print_hi_register_list_st 71 PARAMS ((CGEN_CPU_DESC, PTR, long, unsigned, bfd_vma, int)); 72 static void print_low_register_list_st 73 PARAMS ((CGEN_CPU_DESC, PTR, long, unsigned, bfd_vma, int)); 74 static void print_m4 75 PARAMS ((CGEN_CPU_DESC, PTR, long, unsigned, bfd_vma, int)); 59 76 60 77 static void … … 158 175 /* -- */ 159 176 177 void fr30_cgen_print_operand 178 PARAMS ((CGEN_CPU_DESC, int, PTR, CGEN_FIELDS *, 179 void const *, bfd_vma, int)); 180 160 181 /* Main entry point for printing operands. 161 182 XINFO is a `void *' and not a `disassemble_info *' to not put a requirement … … 171 192 This function could be moved into `print_insn_normal', but keeping it 172 193 separate makes clear the interface between `print_insn_normal' and each of 173 the handlers. 174 */ 194 the handlers. */ 175 195 176 196 void … … 327 347 static void 328 348 print_normal (cd, dis_info, value, attrs, pc, length) 329 #ifdef CGEN_PRINT_NORMAL 330 CGEN_CPU_DESC cd; 331 #else 332 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED; 333 #endif 349 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED; 334 350 PTR dis_info; 335 351 long value; 336 352 unsigned int attrs; 337 #ifdef CGEN_PRINT_NORMAL338 bfd_vma pc;339 int length;340 #else341 353 bfd_vma pc ATTRIBUTE_UNUSED; 342 354 int length ATTRIBUTE_UNUSED; 343 #endif344 355 { 345 356 disassemble_info *info = (disassemble_info *) dis_info; … … 362 373 static void 363 374 print_address (cd, dis_info, value, attrs, pc, length) 364 #ifdef CGEN_PRINT_NORMAL 365 CGEN_CPU_DESC cd; 366 #else 367 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED; 368 #endif 375 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED; 369 376 PTR dis_info; 370 377 bfd_vma value; 371 378 unsigned int attrs; 372 #ifdef CGEN_PRINT_NORMAL373 bfd_vma pc;374 int length;375 #else376 379 bfd_vma pc ATTRIBUTE_UNUSED; 377 380 int length ATTRIBUTE_UNUSED; 378 #endif379 381 { 380 382 disassemble_info *info = (disassemble_info *) dis_info; … … 434 436 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); 435 437 disassemble_info *info = (disassemble_info *) dis_info; 436 const unsigned char*syn;438 const CGEN_SYNTAX_CHAR_TYPE *syn; 437 439 438 440 CGEN_INIT_PRINT (cd); … … 461 463 the extract info. 462 464 Returns 0 if all is well, non-zero otherwise. */ 465 463 466 static int 464 467 read_insn (cd, pc, info, buf, buflen, ex_info, insn_value) … … 482 485 ex_info->insn_bytes = buf; 483 486 484 switch (buflen) 485 { 486 case 1: 487 *insn_value = buf[0]; 488 break; 489 case 2: 490 *insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb16 (buf) : bfd_getl16 (buf); 491 break; 492 case 4: 493 *insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb32 (buf) : bfd_getl32 (buf); 494 break; 495 default: 496 abort (); 497 } 498 487 *insn_value = bfd_get_bits (buf, buflen * 8, info->endian == BFD_ENDIAN_BIG); 499 488 return 0; 500 489 } … … 512 501 disassemble_info *info; 513 502 char *buf; 514 int buflen;515 { 516 unsigned longinsn_value;503 unsigned int buflen; 504 { 505 CGEN_INSN_INT insn_value; 517 506 const CGEN_INSN_LIST *insn_list; 518 507 CGEN_EXTRACT_INFO ex_info; 519 520 int rc = read_insn (cd, pc, info, buf, buflen, & ex_info, & insn_value); 521 if (rc != 0) 522 return rc; 508 int basesize; 509 510 /* Extract base part of instruction, just in case CGEN_DIS_* uses it. */ 511 basesize = cd->base_insn_bitsize < buflen * 8 ? 512 cd->base_insn_bitsize : buflen * 8; 513 insn_value = cgen_get_insn_value (cd, buf, basesize); 514 515 516 /* Fill in ex_info fields like read_insn would. Don't actually call 517 read_insn, since the incoming buffer is already read (and possibly 518 modified a la m32r). */ 519 ex_info.valid = (1 << buflen) - 1; 520 ex_info.dis_info = info; 521 ex_info.insn_bytes = buf; 523 522 524 523 /* The instructions are stored in hash lists. … … 531 530 CGEN_FIELDS fields; 532 531 int length; 532 unsigned long insn_value_cropped; 533 533 534 534 #ifdef CGEN_VALIDATE_INSN_SUPPORTED 535 /* not needed as insn shouldn't be in hash lists if not supported*/535 /* Not needed as insn shouldn't be in hash lists if not supported. */ 536 536 /* Supported by this cpu? */ 537 537 if (! fr30_cgen_insn_supported (cd, insn)) … … 545 545 /* ??? May wish to allow target to defer this check until the extract 546 546 handler. */ 547 if ((insn_value & CGEN_INSN_BASE_MASK (insn)) 547 548 /* Base size may exceed this instruction's size. Extract the 549 relevant part from the buffer. */ 550 if ((unsigned) (CGEN_INSN_BITSIZE (insn) / 8) < buflen && 551 (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long)) 552 insn_value_cropped = bfd_get_bits (buf, CGEN_INSN_BITSIZE (insn), 553 info->endian == BFD_ENDIAN_BIG); 554 else 555 insn_value_cropped = insn_value; 556 557 if ((insn_value_cropped & CGEN_INSN_BASE_MASK (insn)) 548 558 == CGEN_INSN_BASE_VALUE (insn)) 549 559 { … … 554 564 /* Make sure the entire insn is loaded into insn_value, if it 555 565 can fit. */ 556 if (( unsigned) CGEN_INSN_BITSIZE (insn) > cd->base_insn_bitsize&&566 if (((unsigned) CGEN_INSN_BITSIZE (insn) > cd->base_insn_bitsize) && 557 567 (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long)) 558 568 { … … 568 578 else 569 579 length = CGEN_EXTRACT_FN (cd, insn) 570 (cd, insn, &ex_info, insn_value , &fields, pc);580 (cd, insn, &ex_info, insn_value_cropped, &fields, pc); 571 581 572 582 /* length < 0 -> error */ … … 602 612 { 603 613 char buf[CGEN_MAX_INSN_SIZE]; 614 int buflen; 604 615 int status; 605 616 606 /* Read the base part of the insn. */ 607 608 status = (*info->read_memory_func) (pc, buf, cd->base_insn_bitsize / 8, info); 617 /* Attempt to read the base part of the insn. */ 618 buflen = cd->base_insn_bitsize / 8; 619 status = (*info->read_memory_func) (pc, buf, buflen, info); 620 621 /* Try again with the minimum part, if min < base. */ 622 if (status != 0 && (cd->min_insn_bitsize < cd->base_insn_bitsize)) 623 { 624 buflen = cd->min_insn_bitsize / 8; 625 status = (*info->read_memory_func) (pc, buf, buflen, info); 626 } 627 609 628 if (status != 0) 610 629 { … … 613 632 } 614 633 615 return print_insn (cd, pc, info, buf, cd->base_insn_bitsize / 8);634 return print_insn (cd, pc, info, buf, buflen); 616 635 } 617 636 … … 619 638 Print one instruction from PC on INFO->STREAM. 620 639 Return the size of the instruction (in bytes). */ 640 641 typedef struct cpu_desc_list { 642 struct cpu_desc_list *next; 643 int isa; 644 int mach; 645 int endian; 646 CGEN_CPU_DESC cd; 647 } cpu_desc_list; 621 648 622 649 int … … 625 652 disassemble_info *info; 626 653 { 654 static cpu_desc_list *cd_list = 0; 655 cpu_desc_list *cl = 0; 627 656 static CGEN_CPU_DESC cd = 0; 628 657 static int prev_isa; … … 643 672 if (arch == bfd_arch_unknown) 644 673 arch = CGEN_BFD_ARCH; 645 646 /* There's no standard way to compute the isa number (e.g. for arm thumb)674 675 /* There's no standard way to compute the machine or isa number 647 676 so we leave it to the target. */ 677 #ifdef CGEN_COMPUTE_MACH 678 mach = CGEN_COMPUTE_MACH (info); 679 #else 680 mach = info->mach; 681 #endif 682 648 683 #ifdef CGEN_COMPUTE_ISA 649 684 isa = CGEN_COMPUTE_ISA (info); 650 685 #else 651 isa = 0;686 isa = info->insn_sets; 652 687 #endif 653 688 654 mach = info->mach; 655 656 /* If we've switched cpu's, close the current table and open a new one. */ 689 /* If we've switched cpu's, try to find a handle we've used before */ 657 690 if (cd 658 691 && (isa != prev_isa … … 660 693 || endian != prev_endian)) 661 694 { 662 fr30_cgen_cpu_close (cd);663 695 cd = 0; 664 } 696 for (cl = cd_list; cl; cl = cl->next) 697 { 698 if (cl->isa == isa && 699 cl->mach == mach && 700 cl->endian == endian) 701 { 702 cd = cl->cd; 703 break; 704 } 705 } 706 } 665 707 666 708 /* If we haven't initialized yet, initialize the opcode table. */ … … 683 725 if (!cd) 684 726 abort (); 727 728 /* save this away for future reference */ 729 cl = xmalloc (sizeof (struct cpu_desc_list)); 730 cl->cd = cd; 731 cl->isa = isa; 732 cl->mach = mach; 733 cl->endian = endian; 734 cl->next = cd_list; 735 cd_list = cl; 736 685 737 fr30_cgen_init_dis (cd); 686 738 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.