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>,
	Nelson Chu <nelson@rivosinc.com>,
	Kito Cheng <kito.cheng@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>
Cc: binutils@sourceware.org
Subject: [PATCH 2/3] RISC-V: Per-section private data initialization
Date: Sun, 20 Nov 2022 01:10:08 +0000	[thread overview]
Message-ID: <55a36e28e1cb3983c637b3019d48717278574591.1668906599.git.research_trasio@irq.a4lg.com> (raw)
In-Reply-To: <cover.1668906599.git.research_trasio@irq.a4lg.com>

From: Tsukasa OI <research_trasio@irq.a4lg.com>

This is one more preparation for mapping symbol optimization.  It adds a
separate function that is called when the section to disassemble is changed.

This commit enables tracking per-section state management required for the
next optimization ("RISC-V: Optimized search on mapping symbols").

opcodes/ChangeLog:

	* riscv-dis.c (struct riscv_private_data): Add last_section.
	(init_riscv_dis_private_data): Initialize last_section.
	(init_riscv_dis_private_data_for_section): New function. update
	last_section here.
	(print_insn_riscv): Track section changes.
---
 opcodes/riscv-dis.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index 9ea4da9b219b..1a7ca74b8020 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -89,6 +89,7 @@ struct riscv_private_data
   bfd_vma gp;
   bfd_vma print_addr;
   bfd_vma hi_addr[NGPR];
+  void* last_section;
   bool to_print_addr;
   bool has_gp;
 };
@@ -245,6 +246,7 @@ init_riscv_dis_private_data (struct disassemble_info *info)
   pd->print_addr = 0;
   for (int i = 0; i < (int)ARRAY_SIZE (pd->hi_addr); i++)
     pd->hi_addr[i] = -1;
+  pd->last_section = NULL;
   pd->to_print_addr = false;
   pd->has_gp = false;
 
@@ -256,6 +258,15 @@ init_riscv_dis_private_data (struct disassemble_info *info)
       }
 }
 
+/* Initialize private data when the section to disassemble is changed.  */
+
+static void
+init_riscv_dis_private_data_for_section (struct disassemble_info *info)
+{
+  struct riscv_private_data *pd = info->private_data;
+  pd->last_section = info->section;
+}
+
 /* Update architecture for disassembler with its context.
    Call initialization functions if either:
    -  the architecture for current context is changed or
@@ -1308,7 +1319,13 @@ print_insn_riscv (bfd_vma memaddr, struct disassemble_info *info)
 
   /* Initialize the private data.  */
   if (info->private_data == NULL)
-    init_riscv_dis_private_data (info);
+    {
+      init_riscv_dis_private_data (info);
+      init_riscv_dis_private_data_for_section (info);
+    }
+  struct riscv_private_data *pd = info->private_data;
+  if (info->section != pd->last_section)
+    init_riscv_dis_private_data_for_section (info);
 
   /* Guess and update XLEN if we haven't determined it yet.  */
   if (xlen == 0)
-- 
2.38.1


  parent reply	other threads:[~2022-11-20  1:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-20  1:10 [PATCH 0/3] RISC-V: Disassembler Core Optimization 1-2 (Mapping symbols) Tsukasa OI
2022-11-20  1:10 ` [PATCH 1/3] RISC-V: Easy optimization on riscv_search_mapping_symbol Tsukasa OI
2022-11-20  1:10 ` Tsukasa OI [this message]
2022-11-20  1:10 ` [PATCH 3/3] RISC-V: Optimized search on mapping symbols Tsukasa OI
2022-11-28  4:47 ` [PATCH v2 0/3] RISC-V: Disassembler Core Optimization 1-2 (Mapping symbols) Tsukasa OI
2022-11-28  4:47   ` [PATCH v2 1/3] RISC-V: Easy optimization on riscv_search_mapping_symbol Tsukasa OI
2022-11-28  4:47   ` [PATCH v2 2/3] RISC-V: Per-section private data initialization Tsukasa OI
2022-11-28  4:47   ` [PATCH v2 3/3] RISC-V: Optimized search on mapping symbols 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=55a36e28e1cb3983c637b3019d48717278574591.1668906599.git.research_trasio@irq.a4lg.com \
    --to=research_trasio@irq.a4lg.com \
    --cc=binutils@sourceware.org \
    --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).