Changeset 609 for branches/GNU/src/binutils/opcodes/cgen-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/cgen-dis.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* CGEN generic disassembler support code. 2 2 3 Copyright 1996, 1997, 1998, 1999, 2000, 2001 3 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 4 4 Free Software Foundation, Inc. 5 5 … … 28 28 #include "opcode/cgen.h" 29 29 30 static CGEN_INSN_LIST * hash_insn_array PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *, int, int, CGEN_INSN_LIST **, CGEN_INSN_LIST *)); 31 static CGEN_INSN_LIST * hash_insn_list PARAMS ((CGEN_CPU_DESC, const CGEN_INSN_LIST *, CGEN_INSN_LIST **, CGEN_INSN_LIST *)); 32 static void build_dis_hash_table PARAMS ((CGEN_CPU_DESC)); 33 static int count_decodable_bits PARAMS ((const CGEN_INSN *)); 34 static void add_insn_to_hash_chain PARAMS ((CGEN_INSN_LIST *, 35 const CGEN_INSN *, 36 CGEN_INSN_LIST **, 37 unsigned int)); 38 39 /* Return the number of decodable bits in this insn. */ 40 static int 41 count_decodable_bits (insn) 42 const CGEN_INSN *insn; 43 { 44 unsigned mask = CGEN_INSN_BASE_MASK (insn); 45 int bits = 0; 46 int m; 47 for (m = 1; m != 0; m <<= 1) 48 { 49 if (mask & m) 50 ++bits; 51 } 52 return bits; 53 } 54 55 /* Add an instruction to the hash chain. */ 56 static void 57 add_insn_to_hash_chain (hentbuf, insn, htable, hash) 58 CGEN_INSN_LIST *hentbuf; 59 const CGEN_INSN *insn; 60 CGEN_INSN_LIST **htable; 61 unsigned int hash; 62 { 63 CGEN_INSN_LIST *current_buf; 64 CGEN_INSN_LIST *previous_buf; 65 int insn_decodable_bits; 66 67 /* Add insns sorted by the number of decodable bits, in decreasing order. 68 This ensures that any insn which is a special case of another will be 69 checked first. */ 70 insn_decodable_bits = count_decodable_bits (insn); 71 previous_buf = NULL; 72 for (current_buf = htable[hash]; current_buf != NULL; 73 current_buf = current_buf->next) 74 { 75 int current_decodable_bits = count_decodable_bits (current_buf->insn); 76 if (insn_decodable_bits >= current_decodable_bits) 77 break; 78 previous_buf = current_buf; 79 } 80 81 /* Now insert the new insn. */ 82 hentbuf->insn = insn; 83 hentbuf->next = current_buf; 84 if (previous_buf == NULL) 85 htable[hash] = hentbuf; 86 else 87 previous_buf->next = hentbuf; 88 } 89 30 90 /* Subroutine of build_dis_hash_table to add INSNS to the hash table. 31 91 … … 71 131 big_p); 72 132 hash = (* cd->dis_hash) (buf, value); 73 hentbuf->next = htable[hash]; 74 hentbuf->insn = insn; 75 htable[hash] = hentbuf; 133 add_insn_to_hash_chain (hentbuf, insn, htable, hash); 76 134 } 77 135 … … 111 169 big_p); 112 170 hash = (* cd->dis_hash) (buf, value); 113 hentbuf->next = htable [hash]; 114 hentbuf->insn = ilist->insn; 115 htable [hash] = hentbuf; 171 add_insn_to_hash_chain (hentbuf, ilist->insn, htable, hash); 116 172 } 117 173 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.