RISC-V: Optimize riscv_disassemble_data printf
authorTsukasa OI <research_trasio@irq.a4lg.com>
Tue, 2 Aug 2022 08:18:33 +0000 (17:18 +0900)
committerTsukasa OI <research_trasio@irq.a4lg.com>
Thu, 6 Oct 2022 02:23:31 +0000 (02:23 +0000)
This commit makes types of printf arguments on riscv_disassemble_data
as small as possible (as long as we can preserve the portability) to reduce
the cost of printf (especially on 32-bit host).

opcodes/ChangeLog:

* riscv-dis.c (riscv_disassemble_data): Use smallest possible type
to printing data.

opcodes/riscv-dis.c

index ae35790d43b3ffa0dbda4acf3d53f78c1081ebc0..bbeee3feda1e7f04db73ed3974d524b3926e1a93 100644 (file)
@@ -964,24 +964,22 @@ riscv_disassemble_data (bfd_vma memaddr ATTRIBUTE_UNUSED,
       (*info->fprintf_styled_func)
        (info->stream, dis_style_assembler_directive, ".byte\t");
       (*info->fprintf_styled_func)
-       (info->stream, dis_style_immediate, "0x%02llx",
-        (unsigned long long) data);
+       (info->stream, dis_style_immediate, "0x%02x", (unsigned) data);
       break;
     case 2:
       info->bytes_per_line = 8;
       (*info->fprintf_styled_func)
        (info->stream, dis_style_assembler_directive, ".short\t");
       (*info->fprintf_styled_func)
-       (info->stream, dis_style_immediate, "0x%04llx",
-        (unsigned long long) data);
+       (info->stream, dis_style_immediate, "0x%04x", (unsigned) data);
       break;
     case 4:
       info->bytes_per_line = 8;
       (*info->fprintf_styled_func)
        (info->stream, dis_style_assembler_directive, ".word\t");
       (*info->fprintf_styled_func)
-       (info->stream, dis_style_immediate, "0x%08llx",
-        (unsigned long long) data);
+       (info->stream, dis_style_immediate, "0x%08lx",
+        (unsigned long) data);
       break;
     case 8:
       info->bytes_per_line = 8;