[v3,5/6] RISC-V: Fix T-Head immediate types on printing

Message ID 5abe1d8a7694417b990e11d8f6cd6789573872e5.1664793840.git.research_trasio@irq.a4lg.com
State Accepted, archived
Headers
Series RISC-V: Fix disassembler types and styles |

Checks

Context Check Description
snail/binutils-gdb-check success Github commit url

Commit Message

Tsukasa OI Oct. 3, 2022, 10:44 a.m. UTC
  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 | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Patch

diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index 7f5ca4dcb85..c0edc4c7d6b 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -596,11 +596,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;