diff options
author | Philippe Mathieu-Daudé | 2021-08-07 13:09:39 +0200 |
---|---|---|
committer | Laurent Vivier | 2021-10-22 18:07:30 +0200 |
commit | dcc99bd833840c6c4e909d391df17b71e47dea62 (patch) | |
tree | a385519b42958f0ceffa2695b516e287e7d500ca | |
parent | disas/nios2: Fix style in print_insn_nios2() (diff) | |
download | qemu-dcc99bd833840c6c4e909d391df17b71e47dea62.tar.gz qemu-dcc99bd833840c6c4e909d391df17b71e47dea62.tar.xz qemu-dcc99bd833840c6c4e909d391df17b71e47dea62.zip |
disas/nios2: Simplify endianess conversion
Since commit 12b6e9b27d4 ("disas: Clean up CPUDebug initialization")
the disassemble_info->bfd_endian enum is set for all targets in
target_disas(). We can directly call print_insn_nios2() and simplify.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20210807110939.95853-3-f4bug@amsat.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
-rw-r--r-- | disas/nios2.c | 22 | ||||
-rw-r--r-- | include/disas/dis-asm.h | 3 | ||||
-rw-r--r-- | target/nios2/cpu.c | 6 |
3 files changed, 5 insertions, 26 deletions
diff --git a/disas/nios2.c b/disas/nios2.c index d124902ae3..98ac07d72e 100644 --- a/disas/nios2.c +++ b/disas/nios2.c @@ -3478,9 +3478,7 @@ nios2_disassemble (bfd_vma address, unsigned long opcode, instruction word at the address given, and prints the disassembled instruction on the stream info->stream using info->fprintf_func. */ -static int -print_insn_nios2 (bfd_vma address, disassemble_info *info, - enum bfd_endian endianness) +int print_insn_nios2(bfd_vma address, disassemble_info *info) { bfd_byte buffer[INSNLEN]; int status; @@ -3488,7 +3486,7 @@ print_insn_nios2 (bfd_vma address, disassemble_info *info, status = (*info->read_memory_func)(address, buffer, INSNLEN, info); if (status == 0) { unsigned long insn; - if (endianness == BFD_ENDIAN_BIG) { + if (info->endian == BFD_ENDIAN_BIG) { insn = (unsigned long) bfd_getb32(buffer); } else { insn = (unsigned long) bfd_getl32(buffer); @@ -3501,7 +3499,7 @@ print_insn_nios2 (bfd_vma address, disassemble_info *info, status = (*info->read_memory_func)(address, buffer, 2, info); if (status == 0) { unsigned long insn; - if (endianness == BFD_ENDIAN_BIG) { + if (info->endian == BFD_ENDIAN_BIG) { insn = (unsigned long) bfd_getb16(buffer); } else { insn = (unsigned long) bfd_getl16(buffer); @@ -3514,17 +3512,3 @@ print_insn_nios2 (bfd_vma address, disassemble_info *info, (*info->memory_error_func)(status, address, info); return -1; } - -/* These two functions are the main entry points, accessed from - disassemble.c. */ -int -print_insn_big_nios2 (bfd_vma address, disassemble_info *info) -{ - return print_insn_nios2 (address, info, BFD_ENDIAN_BIG); -} - -int -print_insn_little_nios2 (bfd_vma address, disassemble_info *info) -{ - return print_insn_nios2 (address, info, BFD_ENDIAN_LITTLE); -} diff --git a/include/disas/dis-asm.h b/include/disas/dis-asm.h index 524f29196d..08e1beec85 100644 --- a/include/disas/dis-asm.h +++ b/include/disas/dis-asm.h @@ -455,8 +455,7 @@ int print_insn_crisv32 (bfd_vma, disassemble_info*); int print_insn_crisv10 (bfd_vma, disassemble_info*); int print_insn_microblaze (bfd_vma, disassemble_info*); int print_insn_ia64 (bfd_vma, disassemble_info*); -int print_insn_big_nios2 (bfd_vma, disassemble_info*); -int print_insn_little_nios2 (bfd_vma, disassemble_info*); +int print_insn_nios2(bfd_vma, disassemble_info*); int print_insn_xtensa (bfd_vma, disassemble_info*); int print_insn_riscv32 (bfd_vma, disassemble_info*); int print_insn_riscv64 (bfd_vma, disassemble_info*); diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 947bb09bc1..58ecd27d75 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -147,11 +147,7 @@ static void nios2_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) { /* NOTE: NiosII R2 is not supported yet. */ info->mach = bfd_arch_nios2; -#ifdef TARGET_WORDS_BIGENDIAN - info->print_insn = print_insn_big_nios2; -#else - info->print_insn = print_insn_little_nios2; -#endif + info->print_insn = print_insn_nios2; } static int nios2_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) |