public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Max Filippov <jcmvbkbc@gmail.com>
To: binutils@sourceware.org
Cc: Max Filippov <jcmvbkbc@gmail.com>
Subject: [COMMITTED] opcodes: xtensa: implement styled disassembly
Date: Tue,  3 Jan 2023 13:57:22 -0800	[thread overview]
Message-ID: <20230103215722.616744-1-jcmvbkbc@gmail.com> (raw)

opcodes/
	* xtensa-dis.c (print_xtensa_operand)
	(print_insn_xtensa): Replace fprintf_func with
	fprintf_styled_func.
---
 opcodes/xtensa-dis.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/opcodes/xtensa-dis.c b/opcodes/xtensa-dis.c
index 8a26fd7c1239..3631f7fad715 100644
--- a/opcodes/xtensa-dis.c
+++ b/opcodes/xtensa-dis.c
@@ -238,24 +238,28 @@ print_xtensa_operand (bfd_vma memaddr,
       else
 	{
 	  if ((signed_operand_val > -256) && (signed_operand_val < 256))
-	    (*info->fprintf_func) (info->stream, "%d", signed_operand_val);
+	    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
+					  "%d", signed_operand_val);
 	  else
-	    (*info->fprintf_func) (info->stream, "0x%x", signed_operand_val);
+	    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
+					  "0x%x", signed_operand_val);
 	}
     }
   else
     {
       int i = 1;
       xtensa_regfile opnd_rf = xtensa_operand_regfile (isa, opc, opnd);
-      (*info->fprintf_func) (info->stream, "%s%u",
-			     xtensa_regfile_shortname (isa, opnd_rf),
-			     operand_val);
+      (*info->fprintf_styled_func) (info->stream, dis_style_register,
+				    "%s%u",
+				    xtensa_regfile_shortname (isa, opnd_rf),
+				    operand_val);
       while (i < xtensa_operand_num_regs (isa, opc, opnd))
 	{
 	  operand_val++;
-	  (*info->fprintf_func) (info->stream, ":%s%u",
-				 xtensa_regfile_shortname (isa, opnd_rf),
-				 operand_val);
+	  (*info->fprintf_styled_func) (info->stream, dis_style_register,
+					":%s%u",
+					xtensa_regfile_shortname (isa, opnd_rf),
+					operand_val);
 	  i++;
 	}
     }
@@ -404,7 +408,13 @@ print_insn_xtensa (bfd_vma memaddr, struct disassemble_info *info)
 	}
       else
 	{
-	  (*info->fprintf_func) (info->stream, ".byte %#02x", priv.byte_buf[0]);
+	  (*info->fprintf_styled_func) (info->stream,
+					dis_style_assembler_directive,
+					".byte");
+	  (*info->fprintf_func) (info->stream, "\t");
+	  (*info->fprintf_styled_func) (info->stream,
+					dis_style_immediate,
+					"%#02x", priv.byte_buf[0]);
 	  return 1;
 	}
     }
@@ -425,8 +435,9 @@ print_insn_xtensa (bfd_vma memaddr, struct disassemble_info *info)
 
       xtensa_format_get_slot (isa, fmt, n, insn_buffer, slot_buffer);
       opc = xtensa_opcode_decode (isa, fmt, n, slot_buffer);
-      (*info->fprintf_func) (info->stream, "%s",
-			     xtensa_opcode_name (isa, opc));
+      (*info->fprintf_styled_func) (info->stream,
+				    dis_style_mnemonic, "%s",
+				    xtensa_opcode_name (isa, opc));
 
       if (xtensa_opcode_is_branch (isa, opc))
 	info->insn_type = dis_condbranch;
-- 
2.30.2


                 reply	other threads:[~2023-01-03 21:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230103215722.616744-1-jcmvbkbc@gmail.com \
    --to=jcmvbkbc@gmail.com \
    --cc=binutils@sourceware.org \
    /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).