"Bruno Larsen (billionai)" <bruno.lar...@eldorado.org.br> writes:
> code motion to remove opcode callback table from > translate_init.c.inc to translate.c in preparation > to remove #include <translate_init.c.inc> from > translate.c I'd mention the creation of destroy_ppc_opcodes since this patch is not strictly just moving code. > > Signed-off-by: Bruno Larsen (billionai) <bruno.lar...@eldorado.org.br> > --- > target/ppc/internal.h | 6 + > target/ppc/translate.c | 394 ++++++++++++++++++++++++++++++++ > target/ppc/translate_init.c.inc | 390 +------------------------------ > 3 files changed, 401 insertions(+), 389 deletions(-) <snip> > +void destroy_ppc_opcodes(PowerPCCPU *cpu) > +{ > + opc_handler_t **table, **table_2; > + int i, j, k; > + > + for (i = 0; i < PPC_CPU_OPCODES_LEN; i++) { > + if (cpu->opcodes[i] == &invalid_handler) { > + continue; > + } > + if (is_indirect_opcode(cpu->opcodes[i])) { > + table = ind_table(cpu->opcodes[i]); > + for (j = 0; j < PPC_CPU_INDIRECT_OPCODES_LEN; j++) { > + if (table[j] == &invalid_handler) { > + continue; > + } > + if (is_indirect_opcode(table[j])) { > + table_2 = ind_table(table[j]); > + for (k = 0; k < PPC_CPU_INDIRECT_OPCODES_LEN; k++) { > + if (table_2[k] != &invalid_handler && > + is_indirect_opcode(table_2[k])) { > + g_free((opc_handler_t *)((uintptr_t)table_2[k] & > + ~PPC_INDIRECT)); > + } > + } > + g_free((opc_handler_t *)((uintptr_t)table[j] & > + ~PPC_INDIRECT)); > + } > + } > + g_free((opc_handler_t *)((uintptr_t)cpu->opcodes[i] & > + ~PPC_INDIRECT)); > + } > + } > +} > + > +#if defined(PPC_DUMP_CPU) The commented out define for this was left behind. > +static void dump_ppc_insns(CPUPPCState *env) > +{ > + opc_handler_t **table, *handler; > + const char *p, *q; > + uint8_t opc1, opc2, opc3, opc4; > + > + printf("Instructions set:\n"); > + /* opc1 is 6 bits long */ > + for (opc1 = 0x00; opc1 < PPC_CPU_OPCODES_LEN; opc1++) { > + table = env->opcodes; > + handler = table[opc1]; > + if (is_indirect_opcode(handler)) { > + /* opc2 is 5 bits long */ > + for (opc2 = 0; opc2 < PPC_CPU_INDIRECT_OPCODES_LEN; opc2++) { > + table = env->opcodes; > + handler = env->opcodes[opc1]; > + table = ind_table(handler); > + handler = table[opc2]; > + if (is_indirect_opcode(handler)) { > + table = ind_table(handler); > + /* opc3 is 5 bits long */ > + for (opc3 = 0; opc3 < PPC_CPU_INDIRECT_OPCODES_LEN; > + opc3++) { > + handler = table[opc3]; > + if (is_indirect_opcode(handler)) { > + table = ind_table(handler); > + /* opc4 is 5 bits long */ > + for (opc4 = 0; opc4 < > PPC_CPU_INDIRECT_OPCODES_LEN; > + opc4++) { > + handler = table[opc4]; > + if (handler->handler != &gen_invalid) { > + printf("INSN: %02x %02x %02x %02x -- " > + "(%02d %04d %02d) : %s\n", > + opc1, opc2, opc3, opc4, > + opc1, (opc3 << 5) | opc2, opc4, > + handler->oname); > + } > + } > + } else { > + if (handler->handler != &gen_invalid) { > + /* Special hack to properly dump SPE insns */ > + p = strchr(handler->oname, '_'); > + if (p == NULL) { > + printf("INSN: %02x %02x %02x (%02d %04d) > : " > + "%s\n", > + opc1, opc2, opc3, opc1, > + (opc3 << 5) | opc2, > + handler->oname); > + } else { > + q = "speundef"; > + if ((p - handler->oname) != strlen(q) > + || (memcmp(handler->oname, q, > strlen(q)) > + != 0)) { > + /* First instruction */ > + printf("INSN: %02x %02x %02x" > + "(%02d %04d) : %.*s\n", > + opc1, opc2 << 1, opc3, opc1, > + (opc3 << 6) | (opc2 << 1), > + (int)(p - handler->oname), > + handler->oname); > + } > + if (strcmp(p + 1, q) != 0) { > + /* Second instruction */ > + printf("INSN: %02x %02x %02x " > + "(%02d %04d) : %s\n", opc1, > + (opc2 << 1) | 1, opc3, opc1, > + (opc3 << 6) | (opc2 << 1) | 1, > + p + 1); > + } > + } > + } > + } > + } > + } else { > + if (handler->handler != &gen_invalid) { > + printf("INSN: %02x %02x -- (%02d %04d) : %s\n", > + opc1, opc2, opc1, opc2, handler->oname); > + } > + } > + } > + } else { > + if (handler->handler != &gen_invalid) { > + printf("INSN: %02x -- -- (%02d ----) : %s\n", > + opc1, opc1, handler->oname); > + } > + } > + } > +} > +#endif