public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Tsukasa OI <research_trasio@irq.a4lg.com>
To: "Tsukasa OI" <research_trasio@irq.a4lg.com>,
	"Christoph Müllner" <christoph.muellner@vrull.eu>,
	"Nelson Chu" <nelson@rivosinc.com>,
	"Kito Cheng" <kito.cheng@sifive.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Andrew Burgess" <aburgess@redhat.com>
Cc: binutils@sourceware.org
Subject: [PATCH v3 4/6] RISC-V: Print comma and tabs as the "text" style
Date: Mon,  3 Oct 2022 10:44:02 +0000	[thread overview]
Message-ID: <c65fc3e9aa58965d6768a28c9fd7467fea9897a5.1664793840.git.research_trasio@irq.a4lg.com> (raw)
In-Reply-To: <cover.1664793840.git.research_trasio@irq.a4lg.com>

On the RISC-V disassembler, some separators have non-text style when
printed with another word with another style.

This commit splits those, making sure that those comma and tabs are printed
with the "text" style.

opcodes/ChangeLog:

	* riscv-dis.c (print_insn_args): Split and print the comma as
	text.  (riscv_disassemble_insn): Split and print tabs as text.
	(riscv_disassemble_data): Likewise.
---
 opcodes/riscv-dis.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index 70f484189f5..7f5ca4dcb85 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -382,9 +382,12 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info
 		     (int)EXTRACT_RVV_OFFSET (l));
 	      break;
 	    case 'm':
-	      if (! EXTRACT_OPERAND (VMASK, l))
-		print (info->stream, dis_style_register, ",%s",
-		       riscv_vecm_names_numeric[0]);
+	      if (!EXTRACT_OPERAND (VMASK, l))
+		{
+		  print (info->stream, dis_style_text, ",");
+		  print (info->stream, dis_style_register, "%s",
+			 riscv_vecm_names_numeric[0]);
+		}
 	      break;
 	    }
 	  break;
@@ -765,7 +768,8 @@ riscv_disassemble_insn (bfd_vma memaddr, insn_t word, disassemble_info *info)
     case 4:
     case 8:
       (*info->fprintf_styled_func)
-	(info->stream, dis_style_assembler_directive, ".%dbyte\t", insnlen);
+	(info->stream, dis_style_assembler_directive, ".%dbyte", insnlen);
+      (*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
       (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
 				    "0x%llx", (unsigned long long) word);
       break;
@@ -773,7 +777,8 @@ riscv_disassemble_insn (bfd_vma memaddr, insn_t word, disassemble_info *info)
       {
         int i;
 	(*info->fprintf_styled_func)
-	  (info->stream, dis_style_assembler_directive, ".byte\t");
+	  (info->stream, dis_style_assembler_directive, ".byte");
+	(*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
         for (i = 0; i < insnlen; ++i)
           {
             if (i > 0)
@@ -961,21 +966,24 @@ riscv_disassemble_data (bfd_vma memaddr ATTRIBUTE_UNUSED,
     case 1:
       info->bytes_per_line = 6;
       (*info->fprintf_styled_func)
-	(info->stream, dis_style_assembler_directive, ".byte\t");
-      (*info->fprintf_styled_func)
-	(info->stream, dis_style_immediate, "0x%02x", (unsigned) data);
+	(info->stream, dis_style_assembler_directive, ".byte");
+      (*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
+      (*info->fprintf_styled_func) (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->stream, dis_style_assembler_directive, ".short");
+      (*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
       (*info->fprintf_styled_func)
 	(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->stream, dis_style_assembler_directive, ".word");
+      (*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
       (*info->fprintf_styled_func)
 	(info->stream, dis_style_immediate, "0x%08lx",
 	 (unsigned long) data);
@@ -983,7 +991,8 @@ riscv_disassemble_data (bfd_vma memaddr ATTRIBUTE_UNUSED,
     case 8:
       info->bytes_per_line = 8;
       (*info->fprintf_styled_func)
-	(info->stream, dis_style_assembler_directive, ".dword\t");
+	(info->stream, dis_style_assembler_directive, ".dword");
+      (*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
       (*info->fprintf_styled_func)
 	(info->stream, dis_style_immediate, "0x%016llx",
 	 (unsigned long long) data);
-- 
2.34.1


  parent reply	other threads:[~2022-10-03 10:45 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-13 13:40 [PATCH] RISC-V: fix printf types on riscv-dis.c Tsukasa OI
2022-08-03  4:27 ` [PATCH 0/4] RISC-V: Fix disassembler types and styles Tsukasa OI
2022-08-03  4:27   ` [PATCH 1/4] RISC-V: Fix immediates to have `immediate' style Tsukasa OI
2022-08-10 11:16     ` Andrew Burgess
2022-08-10 13:48       ` Tsukasa OI
2022-08-03  4:27   ` [PATCH 2/4] RISC-V: Fix printf argument types corresponding %x Tsukasa OI
2022-08-03  4:27   ` [PATCH 3/4] RISC-V: Optimize riscv_disassemble_data printf Tsukasa OI
2022-08-03  4:27   ` [PATCH 4/4] RISC-V: Print comma and tabs as the `text' style Tsukasa OI
2022-08-10 11:20     ` Andrew Burgess
2022-08-10 13:54       ` Tsukasa OI
2022-09-26 12:26   ` [PATCH v2 0/6] RISC-V: Fix disassembler types and styles Tsukasa OI
2022-09-26 12:26     ` [PATCH v2 1/6] RISC-V: Fix immediates to have "immediate" style Tsukasa OI
2022-09-26 12:26     ` [PATCH v2 2/6] RISC-V: Fix printf argument types corresponding %x Tsukasa OI
2022-09-26 12:26     ` [PATCH v2 3/6] RISC-V: Optimize riscv_disassemble_data printf Tsukasa OI
2022-09-26 12:26     ` [PATCH v2 4/6] RISC-V: Print comma and tabs as the "text" style Tsukasa OI
2022-09-26 12:26     ` [PATCH v2 5/6] RISC-V: Fix T-Head immediate types on printing Tsukasa OI
2022-10-03  9:57       ` Andrew Burgess
2022-10-03 11:06       ` Christoph Müllner
2022-09-26 12:26     ` [PATCH v2 6/6] RISC-V: Print XTheadMemPair literal as "immediate" Tsukasa OI
2022-10-03 11:06       ` Christoph Müllner
2022-10-03  9:59     ` [PATCH v2 0/6] RISC-V: Fix disassembler types and styles Andrew Burgess
2022-10-03 17:40       ` Palmer Dabbelt
2022-10-04  1:34         ` Tsukasa OI
2022-10-04  1:41         ` Nelson Chu
2022-10-04  8:46         ` Andrew Burgess
2022-10-05 22:37           ` Palmer Dabbelt
2022-10-05 21:52         ` Jeff Law
2022-10-03 10:43     ` [PATCH v3 " Tsukasa OI
2022-10-03 10:43       ` [PATCH v3 1/6] RISC-V: Fix immediates to have "immediate" style Tsukasa OI
2022-10-03 10:44       ` [PATCH v3 2/6] RISC-V: Fix printf argument types corresponding %x Tsukasa OI
2022-10-03 10:44       ` [PATCH v3 3/6] RISC-V: Optimize riscv_disassemble_data printf Tsukasa OI
2022-10-03 10:44       ` Tsukasa OI [this message]
2022-10-03 10:44       ` [PATCH v3 5/6] RISC-V: Fix T-Head immediate types on printing Tsukasa OI
2022-10-03 10:44       ` [PATCH v3 6/6] RISC-V: Print XTheadMemPair literal as "immediate" Tsukasa OI

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c65fc3e9aa58965d6768a28c9fd7467fea9897a5.1664793840.git.research_trasio@irq.a4lg.com \
    --to=research_trasio@irq.a4lg.com \
    --cc=aburgess@redhat.com \
    --cc=binutils@sourceware.org \
    --cc=christoph.muellner@vrull.eu \
    --cc=kito.cheng@sifive.com \
    --cc=nelson@rivosinc.com \
    --cc=palmer@dabbelt.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).