RISC-V: Fix T-Head immediate types on printing
authorTsukasa OI <research_trasio@irq.a4lg.com>
Mon, 26 Sep 2022 11:13:51 +0000 (11:13 +0000)
committerTsukasa OI <research_trasio@irq.a4lg.com>
Thu, 6 Oct 2022 02:23:31 +0000 (02:23 +0000)
This commit fixes two minor typing-related issues for
T-Head immediate operands.

1.  A signed type must be specified when printing with %i.
2.  unsigned/signed int is not portable enough for max 32-bit immediates.
    Instead, we should use unsigned/signed long.
    The format string is changed accordingly.

opcodes/ChangeLog:

* riscv-dis.c (print_insn_args): Fix T-Head immediate types on
printing.

opcodes/riscv-dis.c

index 50e634ebfdabb32d04278c35931b7f055bc01534..9d7335655496c157eac502f2722c388b0d1eb6a0 100644 (file)
@@ -597,11 +597,11 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info
                  oparg--;
 
                  if (!sign)
-                   print (info->stream, dis_style_immediate, "%u",
-                          (unsigned)EXTRACT_U_IMM (n, s, l));
+                   print (info->stream, dis_style_immediate, "%lu",
+                          (unsigned long)EXTRACT_U_IMM (n, s, l));
                  else
-                   print (info->stream, dis_style_immediate, "%i",
-                          (unsigned)EXTRACT_S_IMM (n, s, l));
+                   print (info->stream, dis_style_immediate, "%li",
+                          (signed long)EXTRACT_S_IMM (n, s, l));
                  break;
                default:
                  goto undefined_modifier;