MIPS: Optimize uasm insn lookup.
Instead of doing a linear search through the insn_table for each instruction, use the opcode as direct index into the table. This will give constant time lookup performance as the number of supported opcodes increases. Make the tables const as they are only ever read. For uasm-mips.c sort the table alphabetically, and remove duplicate entries, uasm-micromips.c was already sorted and duplicate free. There is a small savings in object size as struct insn loses a field: $ size arch/mips/mm/uasm-mips.o arch/mips/mm/uasm-mips.o.save text data bss dec hex filename 10040 0 0 10040 2738 arch/mips/mm/uasm-mips.o 9240 1120 0 10360 2878 arch/mips/mm/uasm-mips.o.save Signed-off-by: David Daney <david.daney@cavium.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Matt Redfearn <matt.redfearn@imgtec.com> Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/16365/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:

committed by
Ralf Baechle

parent
430d0b8894
commit
ce807d5f67
@@ -46,7 +46,6 @@ enum fields {
|
||||
#define SIMM9_MASK 0x1ff
|
||||
|
||||
enum opcode {
|
||||
insn_invalid,
|
||||
insn_addiu, insn_addu, insn_and, insn_andi, insn_bbit0, insn_bbit1,
|
||||
insn_beq, insn_beql, insn_bgez, insn_bgezl, insn_bltz, insn_bltzl,
|
||||
insn_bne, insn_cache, insn_cfc1, insn_cfcmsa, insn_ctc1, insn_ctcmsa,
|
||||
@@ -62,10 +61,10 @@ enum opcode {
|
||||
insn_srlv, insn_subu, insn_sw, insn_sync, insn_syscall, insn_tlbp,
|
||||
insn_tlbr, insn_tlbwi, insn_tlbwr, insn_wait, insn_wsbh, insn_xor,
|
||||
insn_xori, insn_yield, insn_lddir, insn_ldpte, insn_lhu,
|
||||
insn_invalid /* insn_invalid must be last */
|
||||
};
|
||||
|
||||
struct insn {
|
||||
enum opcode opcode;
|
||||
u32 match;
|
||||
enum fields fields;
|
||||
};
|
||||
|
Reference in New Issue
Block a user