public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] opcodes/loongarch: Remove unused code
@ 2022-07-19  3:03 WANG Xuerui
  2022-07-19  3:03 ` [PATCH 2/2] opcodes/loongarch: Implement style support in the disassembler WANG Xuerui
  2022-08-01  7:07 ` [PATCH 1/2] opcodes/loongarch: Remove unused code WANG Xuerui
  0 siblings, 2 replies; 6+ messages in thread
From: WANG Xuerui @ 2022-07-19  3:03 UTC (permalink / raw)
  To: binutils; +Cc: Chenghua Xu, Zhensong Liu, Xi Ruoyao, WANG Xuerui

From: WANG Xuerui <git@xen0n.name>

include/ChangeLog
	* opcode/loongarch.h (loongarch_parse_dis_options): Remove
	unused declarations.
	(loongarch_disassemble_one): Likewise.

opcodes/ChangeLog
	* loongarch-dis.c (loongarch_parse_dis_options): Remove
	unused code.
	(my_print_address_func): Likewise.
	(loongarch_disassemble_one): Likewise.

Signed-off-by: WANG Xuerui <git@xen0n.name>
---
 include/ChangeLog          |  6 ++++++
 include/opcode/loongarch.h |  5 -----
 opcodes/ChangeLog          |  7 +++++++
 opcodes/loongarch-dis.c    | 35 -----------------------------------
 4 files changed, 13 insertions(+), 40 deletions(-)

diff --git a/include/ChangeLog b/include/ChangeLog
index f8f7747640e..40cb717906c 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,9 @@
+2022-07-19  WANG Xuerui  <git@xen0n.name>
+
+	* opcode/loongarch.h (loongarch_parse_dis_options): Remove
+	unused declarations.
+	(loongarch_disassemble_one): Likewise.
+
 2022-07-08  Nick Clifton  <nickc@redhat.com>
 
 	* 2.39 branch created.
diff --git a/include/opcode/loongarch.h b/include/opcode/loongarch.h
index c3922348a56..448e5e0bbc4 100644
--- a/include/opcode/loongarch.h
+++ b/include/opcode/loongarch.h
@@ -172,11 +172,6 @@ dec2 : [1-9][0-9]?
 
   extern void loongarch_eliminate_adjacent_repeat_char (char *dest, char c);
 
-  extern int loongarch_parse_dis_options (const char *opts_in);
-  extern void loongarch_disassemble_one (
-    int64_t pc, insn_t insn,
-    int (*fprintf_func) (void *stream, const char *format, ...), void *stream);
-
   extern const char *const loongarch_r_normal_name[32];
   extern const char *const loongarch_r_lp64_name[32];
   extern const char *const loongarch_r_lp64_name1[32];
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 3889a80f427..0ad9b5a53f8 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,10 @@
+2022-07-19  WANG Xuerui  <git@xen0n.name>
+
+	* loongarch-dis.c (loongarch_parse_dis_options): Remove
+	unused code.
+	(my_print_address_func): Likewise.
+	(loongarch_disassemble_one): Likewise.
+
 2022-07-18  Claudiu Zissulescu  <claziss@synopsys.com>
 
 	* disassemble.c (disassemble_init_for_target): Set
diff --git a/opcodes/loongarch-dis.c b/opcodes/loongarch-dis.c
index 9dcf989d0df..c7c95e9e90f 100644
--- a/opcodes/loongarch-dis.c
+++ b/opcodes/loongarch-dis.c
@@ -305,38 +305,3 @@ with the -M switch (multiple options should be separated by commas):\n"));
     numeric       Print numeric register names, rather than ABI names.\n"));
   fprintf (stream, _("\n"));
 }
-
-int
-loongarch_parse_dis_options (const char *opts_in)
-{
-  return parse_loongarch_dis_options (opts_in);
-}
-
-static void
-my_print_address_func (bfd_vma addr, struct disassemble_info *dinfo)
-{
-  dinfo->fprintf_func (dinfo->stream, "0x%llx", (long long) addr);
-}
-
-void
-loongarch_disassemble_one (int64_t pc, insn_t insn,
-			   int (*fprintf_func) (void *stream,
-						const char *format, ...),
-			   void *stream)
-{
-  static struct disassemble_info my_disinfo =
-  {
-    .print_address_func = my_print_address_func,
-  };
-  static int not_init_yet = 1;
-  if (not_init_yet)
-    {
-      loongarch_parse_dis_options (NULL);
-      not_init_yet = 0;
-    }
-
-  my_disinfo.fprintf_func = fprintf_func;
-  my_disinfo.stream = stream;
-  my_disinfo.target = pc;
-  disassemble_one (insn, &my_disinfo);
-}
-- 
2.35.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/2] opcodes/loongarch: Implement style support in the disassembler
  2022-07-19  3:03 [PATCH 1/2] opcodes/loongarch: Remove unused code WANG Xuerui
@ 2022-07-19  3:03 ` WANG Xuerui
  2022-08-01  7:07 ` [PATCH 1/2] opcodes/loongarch: Remove unused code WANG Xuerui
  1 sibling, 0 replies; 6+ messages in thread
From: WANG Xuerui @ 2022-07-19  3:03 UTC (permalink / raw)
  To: binutils; +Cc: Chenghua Xu, Zhensong Liu, Xi Ruoyao, WANG Xuerui

From: WANG Xuerui <git@xen0n.name>

Update the LoongArch disassembler to supply style information to the
disassembler output. The output formatting remains unchanged.

opcodes/ChangeLog:
	* disassemble.c (disassemble_init_for_target): Set
	created_styled_output for LoongArch targets.
	* loongarch-dis.c (dis_one_arg): Use fprintf_styled_func
	instead of fprintf_func throughout.
	(disassemble_one): Likewise.

Signed-off-by: WANG Xuerui <git@xen0n.name>
---
 opcodes/ChangeLog       |  8 ++++++++
 opcodes/disassemble.c   |  5 +++++
 opcodes/loongarch-dis.c | 41 ++++++++++++++++++++++-------------------
 3 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 0ad9b5a53f8..41fd5a7f6ec 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,11 @@
+2022-07-19  WANG Xuerui  <git@xen0n.name>
+
+	* disassemble.c (disassemble_init_for_target): Set
+	created_styled_output for LoongArch targets.
+	* loongarch-dis.c (dis_one_arg): Use fprintf_styled_func
+	instead of fprintf_func throughout.
+	(disassemble_one): Likewise.
+
 2022-07-19  WANG Xuerui  <git@xen0n.name>
 
 	* loongarch-dis.c (loongarch_parse_dis_options): Remove
diff --git a/opcodes/disassemble.c b/opcodes/disassemble.c
index e2e5a2608d6..b12b12f24f1 100644
--- a/opcodes/disassemble.c
+++ b/opcodes/disassemble.c
@@ -645,6 +645,11 @@ disassemble_init_for_target (struct disassemble_info * info)
       info->skip_zeroes = 16;
       break;
 #endif
+#ifdef ARCH_loongarch
+    case bfd_arch_loongarch:
+      info->created_styled_output = true;
+      break;
+#endif
 #ifdef ARCH_tic4x
     case bfd_arch_tic4x:
       info->skip_zeroes = 32;
diff --git a/opcodes/loongarch-dis.c b/opcodes/loongarch-dis.c
index c7c95e9e90f..1624313d25a 100644
--- a/opcodes/loongarch-dis.c
+++ b/opcodes/loongarch-dis.c
@@ -130,7 +130,7 @@ dis_one_arg (char esc1, char esc2, const char *bit_field,
   if (esc1)
     {
       if (need_comma)
-	info->fprintf_func (info->stream, ", ");
+	info->fprintf_styled_func (info->stream, dis_style_text, ", ");
       need_comma = 1;
       imm = loongarch_decode_imm (bit_field, insn, 1);
       u_imm = loongarch_decode_imm (bit_field, insn, 0);
@@ -139,35 +139,38 @@ dis_one_arg (char esc1, char esc2, const char *bit_field,
   switch (esc1)
     {
     case 'r':
-      info->fprintf_func (info->stream, "%s", loongarch_r_disname[u_imm]);
+      info->fprintf_styled_func (info->stream, dis_style_register, "%s", loongarch_r_disname[u_imm]);
       break;
     case 'f':
-      info->fprintf_func (info->stream, "%s", loongarch_f_disname[u_imm]);
+      info->fprintf_styled_func (info->stream, dis_style_register, "%s", loongarch_f_disname[u_imm]);
       break;
     case 'c':
       switch (esc2)
 	{
 	case 'r':
-	  info->fprintf_func (info->stream, "%s", loongarch_cr_disname[u_imm]);
+	  info->fprintf_styled_func (info->stream, dis_style_register, "%s", loongarch_cr_disname[u_imm]);
 	  break;
 	default:
-	  info->fprintf_func (info->stream, "%s", loongarch_c_disname[u_imm]);
+	  info->fprintf_styled_func (info->stream, dis_style_register, "%s", loongarch_c_disname[u_imm]);
 	}
       break;
     case 'v':
-      info->fprintf_func (info->stream, "%s", loongarch_v_disname[u_imm]);
+      info->fprintf_styled_func (info->stream, dis_style_register, "%s", loongarch_v_disname[u_imm]);
       break;
     case 'x':
-      info->fprintf_func (info->stream, "%s", loongarch_x_disname[u_imm]);
+      info->fprintf_styled_func (info->stream, dis_style_register, "%s", loongarch_x_disname[u_imm]);
       break;
     case 'u':
-      info->fprintf_func (info->stream, "0x%x", u_imm);
+      info->fprintf_styled_func (info->stream, dis_style_immediate, "0x%x", u_imm);
       break;
     case 's':
       if (imm == 0)
-	info->fprintf_func (info->stream, "%d", imm);
+	info->fprintf_styled_func (info->stream, dis_style_immediate, "%d", imm);
       else
-	info->fprintf_func (info->stream, "%d(0x%x)", imm, u_imm);
+	{
+	  info->fprintf_styled_func (info->stream, dis_style_immediate, "%d", imm);
+	  info->fprintf_styled_func (info->stream, dis_style_text, "(0x%x)", u_imm);
+	}
       switch (esc2)
 	{
 	case 'b':
@@ -221,32 +224,32 @@ disassemble_one (insn_t insn, struct disassemble_info *info)
   for (i = 31; 0 <= i; i--)
     {
       if (t & insn)
-	info->fprintf_func (info->stream, "1");
+	info->fprintf_styled_func (info->stream, dis_style_text, "1");
       else
-	info->fprintf_func (info->stream, "0");
+	info->fprintf_styled_func (info->stream, dis_style_text, "0");
       if (have_space[i])
-	info->fprintf_func (info->stream, " ");
+	info->fprintf_styled_func (info->stream, dis_style_text, " ");
       t = t >> 1;
     }
-  info->fprintf_func (info->stream, "\t");
+  info->fprintf_styled_func (info->stream, dis_style_text, "\t");
 #endif
 
   if (!opc)
     {
       info->insn_type = dis_noninsn;
-      info->fprintf_func (info->stream, "0x%08x", insn);
+      info->fprintf_styled_func (info->stream, dis_style_immediate, "0x%08x", insn);
       return;
     }
 
   info->insn_type = dis_nonbranch;
-  info->fprintf_func (info->stream, "%-12s", opc->name);
+  info->fprintf_styled_func (info->stream, dis_style_mnemonic, "%-12s", opc->name);
 
   {
     char *fake_args = xmalloc (strlen (opc->format) + 1);
     const char *fake_arg_strs[MAX_ARG_NUM_PLUS_2];
     strcpy (fake_args, opc->format);
     if (0 < loongarch_split_args_by_comma (fake_args, fake_arg_strs))
-      info->fprintf_func (info->stream, "\t");
+      info->fprintf_styled_func (info->stream, dis_style_text, "\t");
     info->private_data = &insn;
     loongarch_foreach_args (opc->format, fake_arg_strs, dis_one_arg, info);
     free (fake_args);
@@ -254,11 +257,11 @@ disassemble_one (insn_t insn, struct disassemble_info *info)
 
   if (info->insn_type == dis_branch || info->insn_type == dis_condbranch
       /* Someother if we have extra info to print.  */)
-    info->fprintf_func (info->stream, "\t#");
+    info->fprintf_styled_func (info->stream, dis_style_text, "\t#");
 
   if (info->insn_type == dis_branch || info->insn_type == dis_condbranch)
     {
-      info->fprintf_func (info->stream, " ");
+      info->fprintf_styled_func (info->stream, dis_style_text, " ");
       info->print_address_func (info->target, info);
     }
 }
-- 
2.35.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] opcodes/loongarch: Remove unused code
  2022-07-19  3:03 [PATCH 1/2] opcodes/loongarch: Remove unused code WANG Xuerui
  2022-07-19  3:03 ` [PATCH 2/2] opcodes/loongarch: Implement style support in the disassembler WANG Xuerui
@ 2022-08-01  7:07 ` WANG Xuerui
  2022-08-02  7:02   ` liuzhensong
  1 sibling, 1 reply; 6+ messages in thread
From: WANG Xuerui @ 2022-08-01  7:07 UTC (permalink / raw)
  To: WANG Xuerui, binutils; +Cc: Chenghua Xu, Zhensong Liu, Xi Ruoyao, WANG Xuerui

On 2022/7/19 11:03, WANG Xuerui wrote:
> From: WANG Xuerui <git@xen0n.name>
>
> include/ChangeLog
> 	* opcode/loongarch.h (loongarch_parse_dis_options): Remove
> 	unused declarations.
> 	(loongarch_disassemble_one): Likewise.
>
> opcodes/ChangeLog
> 	* loongarch-dis.c (loongarch_parse_dis_options): Remove
> 	unused code.
> 	(my_print_address_func): Likewise.
> 	(loongarch_disassemble_one): Likewise.
>
> Signed-off-by: WANG Xuerui <git@xen0n.name>
> ---
>   include/ChangeLog          |  6 ++++++
>   include/opcode/loongarch.h |  5 -----
>   opcodes/ChangeLog          |  7 +++++++
>   opcodes/loongarch-dis.c    | 35 -----------------------------------
>   4 files changed, 13 insertions(+), 40 deletions(-)

A gentle ping for this patchset.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] opcodes/loongarch: Remove unused code
  2022-08-01  7:07 ` [PATCH 1/2] opcodes/loongarch: Remove unused code WANG Xuerui
@ 2022-08-02  7:02   ` liuzhensong
  2022-08-02  7:11     ` WANG Xuerui
  0 siblings, 1 reply; 6+ messages in thread
From: liuzhensong @ 2022-08-02  7:02 UTC (permalink / raw)
  To: WANG Xuerui, binutils; +Cc: Chenghua Xu, Xi Ruoyao, WANG Xuerui


在 2022/8/1 下午3:07, WANG Xuerui 写道:
> On 2022/7/19 11:03, WANG Xuerui wrote:
>> From: WANG Xuerui <git@xen0n.name>
>>
>> include/ChangeLog
>>     * opcode/loongarch.h (loongarch_parse_dis_options): Remove
>>     unused declarations.
>>     (loongarch_disassemble_one): Likewise.
>>
>> opcodes/ChangeLog
>>     * loongarch-dis.c (loongarch_parse_dis_options): Remove
>>     unused code.
>>     (my_print_address_func): Likewise.
>>     (loongarch_disassemble_one): Likewise.
>>
>> Signed-off-by: WANG Xuerui <git@xen0n.name>
>> ---
>>   include/ChangeLog          |  6 ++++++
>>   include/opcode/loongarch.h |  5 -----
>>   opcodes/ChangeLog          |  7 +++++++
>>   opcodes/loongarch-dis.c    | 35 -----------------------------------
>>   4 files changed, 13 insertions(+), 40 deletions(-)
>
> A gentle ping for this patchset.

This patchsethas been verified that there is no problem but cannot be 
directly patched.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] opcodes/loongarch: Remove unused code
  2022-08-02  7:02   ` liuzhensong
@ 2022-08-02  7:11     ` WANG Xuerui
  2022-08-02  7:33       ` liuzhensong
  0 siblings, 1 reply; 6+ messages in thread
From: WANG Xuerui @ 2022-08-02  7:11 UTC (permalink / raw)
  To: liuzhensong, WANG Xuerui, binutils; +Cc: Chenghua Xu, Xi Ruoyao, WANG Xuerui

On 2022/8/2 15:02, liuzhensong wrote:
>
>
> 在 2022/8/1 下午3:07, WANG Xuerui 写道:
>> On 2022/7/19 11:03, WANG Xuerui wrote:
>>> From: WANG Xuerui <git@xen0n.name>
>>>
>>> include/ChangeLog
>>>     * opcode/loongarch.h (loongarch_parse_dis_options): Remove
>>>     unused declarations.
>>>     (loongarch_disassemble_one): Likewise.
>>>
>>> opcodes/ChangeLog
>>>     * loongarch-dis.c (loongarch_parse_dis_options): Remove
>>>     unused code.
>>>     (my_print_address_func): Likewise.
>>>     (loongarch_disassemble_one): Likewise.
>>>
>>> Signed-off-by: WANG Xuerui <git@xen0n.name>
>>> ---
>>>   include/ChangeLog          |  6 ++++++
>>>   include/opcode/loongarch.h |  5 -----
>>>   opcodes/ChangeLog          |  7 +++++++
>>>   opcodes/loongarch-dis.c    | 35 -----------------------------------
>>>   4 files changed, 13 insertions(+), 40 deletions(-)
>>
>> A gentle ping for this patchset.
>
> This patchsethas been verified that there is no problem but cannot be 
> directly patched.
Do you mean I should rebase it by "cannot be directly patched"? Or is 
there any other places that I have missed (e.g. testsuite)?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] opcodes/loongarch: Remove unused code
  2022-08-02  7:11     ` WANG Xuerui
@ 2022-08-02  7:33       ` liuzhensong
  0 siblings, 0 replies; 6+ messages in thread
From: liuzhensong @ 2022-08-02  7:33 UTC (permalink / raw)
  To: WANG Xuerui, binutils; +Cc: Chenghua Xu, Xi Ruoyao, WANG Xuerui


在 2022/8/2 下午3:11, WANG Xuerui 写道:
> On 2022/8/2 15:02, liuzhensong wrote:
>>
>>
>> 在 2022/8/1 下午3:07, WANG Xuerui 写道:
>>> On 2022/7/19 11:03, WANG Xuerui wrote:
>>>> From: WANG Xuerui <git@xen0n.name>
>>>>
>>>> include/ChangeLog
>>>>     * opcode/loongarch.h (loongarch_parse_dis_options): Remove
>>>>     unused declarations.
>>>>     (loongarch_disassemble_one): Likewise.
>>>>
>>>> opcodes/ChangeLog
>>>>     * loongarch-dis.c (loongarch_parse_dis_options): Remove
>>>>     unused code.
>>>>     (my_print_address_func): Likewise.
>>>>     (loongarch_disassemble_one): Likewise.
>>>>
>>>> Signed-off-by: WANG Xuerui <git@xen0n.name>
>>>> ---
>>>>   include/ChangeLog          |  6 ++++++
>>>>   include/opcode/loongarch.h |  5 -----
>>>>   opcodes/ChangeLog          |  7 +++++++
>>>>   opcodes/loongarch-dis.c    | 35 -----------------------------------
>>>>   4 files changed, 13 insertions(+), 40 deletions(-)
>>>
>>> A gentle ping for this patchset.
>>
>> This patchsethas been verified that there is no problem but cannot be 
>> directly patched.
> Do you mean I should rebase it by "cannot be directly patched"? Or is 
> there any other places that I have missed (e.g. testsuite)?
May be rebased only. (Some errors caused by non-conflicting issues.)

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-02  7:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19  3:03 [PATCH 1/2] opcodes/loongarch: Remove unused code WANG Xuerui
2022-07-19  3:03 ` [PATCH 2/2] opcodes/loongarch: Implement style support in the disassembler WANG Xuerui
2022-08-01  7:07 ` [PATCH 1/2] opcodes/loongarch: Remove unused code WANG Xuerui
2022-08-02  7:02   ` liuzhensong
2022-08-02  7:11     ` WANG Xuerui
2022-08-02  7:33       ` liuzhensong

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).