diff options
author | Peter Bergner <bergner@vnet.ibm.com> | 2018-05-07 09:40:59 -0500 |
---|---|---|
committer | Peter Bergner <bergner@vnet.ibm.com> | 2018-05-07 09:40:59 -0500 |
commit | 2ceb7719f763b9e541a379d8ac7d53a72794fdd4 (patch) | |
tree | c8670b17f7f33270471dd6dbf6e750485b96e6e0 /opcodes | |
parent | ce4ec1a9b6c442a9feefa18dd8734372a718665c (diff) | |
download | gdb-2ceb7719f763b9e541a379d8ac7d53a72794fdd4.zip gdb-2ceb7719f763b9e541a379d8ac7d53a72794fdd4.tar.gz gdb-2ceb7719f763b9e541a379d8ac7d53a72794fdd4.tar.bz2 |
Cleanup ppc code dealing with opcode dumps.
include/
* opcode/ppc.h (powerpc_num_opcodes): Change type to unsigned.
(vle_num_opcodes): Likewise.
(spe2_num_opcodes): Likewise.
opcodes/
* ppc-opc.c (powerpc_num_opcodes): Likewise.
(vle_num_opcodes): Likewise.
(spe2_num_opcodes): Likewise.
* ppc-dis.c (disassemble_init_powerpc) <powerpc_opcd_indices>: Rewrite
initialization loop.
(disassemble_init_powerpc) <vle_opcd_indices>: Likewise.
(disassemble_init_powerpc) <spe2_opcd_indices>: Likewise. Initialize
only once.
gas/
* config/tc-ppc.c (ppc_setup_opcodes) <powerpc_opcodes>: Rewrite code
to dump the entire opcode table.
(ppc_setup_opcodes) <spe2_opcodes>: Likewise.
(ppc_setup_opcodes) <vle_opcodes>: Likewise. Fix calculation of
opcode index.
Diffstat (limited to 'opcodes')
-rw-r--r-- | opcodes/ChangeLog | 11 | ||||
-rw-r--r-- | opcodes/ppc-dis.c | 66 | ||||
-rw-r--r-- | opcodes/ppc-opc.c | 6 |
3 files changed, 39 insertions, 44 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 3c2cf16..4bf8685 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,14 @@ +2018-05-07 Peter Bergner <bergner@vnet.ibm.com.com> + + * ppc-opc.c (powerpc_num_opcodes): Change type to unsigned. + (vle_num_opcodes): Likewise. + (spe2_num_opcodes): Likewise. + * ppc-dis.c (disassemble_init_powerpc) <powerpc_opcd_indices>: Rewrite + initialization loop. + (disassemble_init_powerpc) <vle_opcd_indices>: Likewise. + (disassemble_init_powerpc) <spe2_opcd_indices>: Likewise. Initialize + only once. + 2018-05-01 Tamar Christina <tamar.christina@arm.com> * aarch64-dis.c (aarch64_opcode_decode): Moved memory clear code. diff --git a/opcodes/ppc-dis.c b/opcodes/ppc-dis.c index efa7898..f8b0292 100644 --- a/opcodes/ppc-dis.c +++ b/opcodes/ppc-dis.c @@ -380,60 +380,44 @@ static unsigned short spe2_opcd_indices[SPE2_OPCD_SEGS+1]; void disassemble_init_powerpc (struct disassemble_info *info) { - int i; - unsigned short last; - if (powerpc_opcd_indices[PPC_OPCD_SEGS] == 0) { - i = powerpc_num_opcodes; - while (--i >= 0) - { - unsigned op = PPC_OP (powerpc_opcodes[i].opcode); - powerpc_opcd_indices[op] = i; - } + unsigned seg, idx, op; - last = powerpc_num_opcodes; - for (i = PPC_OPCD_SEGS; i > 0; --i) + /* PPC opcodes */ + for (seg = 0, idx = 0; seg <= PPC_OPCD_SEGS; seg++) { - if (powerpc_opcd_indices[i] == 0) - powerpc_opcd_indices[i] = last; - last = powerpc_opcd_indices[i]; + powerpc_opcd_indices[seg] = idx; + for (; idx < powerpc_num_opcodes; idx++) + if (seg < PPC_OP (powerpc_opcodes[idx].opcode)) + break; } - i = vle_num_opcodes; - while (--i >= 0) + /* VLE opcodes */ + for (seg = 0, idx = 0; seg <= VLE_OPCD_SEGS; seg++) { - unsigned op = VLE_OP (vle_opcodes[i].opcode, vle_opcodes[i].mask); - unsigned seg = VLE_OP_TO_SEG (op); - vle_opcd_indices[seg] = i; + vle_opcd_indices[seg] = idx; + for (; idx < vle_num_opcodes; idx++) + { + op = VLE_OP (vle_opcodes[idx].opcode, vle_opcodes[idx].mask); + if (seg < VLE_OP_TO_SEG (op)) + break; + } } - last = vle_num_opcodes; - for (i = VLE_OPCD_SEGS; i > 0; --i) + /* SPE2 opcodes */ + for (seg = 0, idx = 0; seg <= SPE2_OPCD_SEGS; seg++) { - if (vle_opcd_indices[i] == 0) - vle_opcd_indices[i] = last; - last = vle_opcd_indices[i]; + spe2_opcd_indices[seg] = idx; + for (; idx < spe2_num_opcodes; idx++) + { + op = SPE2_XOP (spe2_opcodes[idx].opcode); + if (seg < SPE2_XOP_TO_SEG (op)) + break; + } } } - /* SPE2 opcodes */ - i = spe2_num_opcodes; - while (--i >= 0) - { - unsigned xop = SPE2_XOP (spe2_opcodes[i].opcode); - unsigned seg = SPE2_XOP_TO_SEG (xop); - spe2_opcd_indices[seg] = i; - } - - last = spe2_num_opcodes; - for (i = SPE2_OPCD_SEGS; i > 1; --i) - { - if (spe2_opcd_indices[i] == 0) - spe2_opcd_indices[i] = last; - last = spe2_opcd_indices[i]; - } - powerpc_init_dialect (info); } diff --git a/opcodes/ppc-opc.c b/opcodes/ppc-opc.c index bb17f26..1527aa5 100644 --- a/opcodes/ppc-opc.c +++ b/opcodes/ppc-opc.c @@ -7551,7 +7551,7 @@ const struct powerpc_opcode powerpc_opcodes[] = { {"fcfidu.", XRC(63,974,1), XRA_MASK, POWER7|PPCA2, PPCVLE, {FRT, FRB}}, }; -const int powerpc_num_opcodes = +const unsigned int powerpc_num_opcodes = sizeof (powerpc_opcodes) / sizeof (powerpc_opcodes[0]); /* The VLE opcode table. @@ -8479,7 +8479,7 @@ const struct powerpc_opcode vle_opcodes[] = { {"se_bl", BD8(58,0,1), BD8_MASK, PPCVLE, 0, {B8}}, }; -const int vle_num_opcodes = +const unsigned int vle_num_opcodes = sizeof (vle_opcodes) / sizeof (vle_opcodes[0]); /* The macro table. This is only used by the assembler. */ @@ -9370,5 +9370,5 @@ const struct powerpc_opcode spe2_opcodes[] = { {"evavgdsr", VX (4, 1663), VX_MASK, PPCSPE2, 0, {RD, RA, RB}}, }; -const int spe2_num_opcodes = +const unsigned int spe2_num_opcodes = sizeof (spe2_opcodes) / sizeof (spe2_opcodes[0]); |