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 v2 1/3] RISC-V: Easy optimization on riscv_search_mapping_symbol
Date: Mon, 28 Nov 2022 04:47:21 +0000 [thread overview]
Message-ID: <c49e114f7ae383c0e1da452391f19ecf45a3896e.1669610841.git.research_trasio@irq.a4lg.com> (raw)
In-Reply-To: <cover.1669610841.git.research_trasio@irq.a4lg.com>
From: Tsukasa OI <research_trasio@irq.a4lg.com>
Before further optimization, we can optimize the function
riscv_search_mapping_symbol a bit for clarity.
opcodes/ChangeLog:
* riscv-dis.c (riscv_search_mapping_symbol): Make MAP_INSN default
considering major usecases. Remove setting found here as no one
uses the value after setting this. memaddr cannot be negative
so simplify and change comment.
Idea-by: Nelson Chu <nelson@rivosinc.com>
---
opcodes/riscv-dis.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index eb3e64816bf6..bb7c03ad5fbf 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -1134,18 +1134,16 @@ riscv_search_mapping_symbol (bfd_vma memaddr,
/* Decide whether to print the data or instruction by default, in case
we can not find the corresponding mapping symbols. */
- mstate = MAP_DATA;
- if ((info->section
- && info->section->flags & SEC_CODE)
- || !info->section)
- mstate = MAP_INSN;
+ mstate = MAP_INSN;
+ if (info->section && (info->section->flags & SEC_CODE) == 0)
+ mstate = MAP_DATA;
if (info->symtab_size == 0
|| bfd_asymbol_flavour (*info->symtab) != bfd_target_elf_flavour)
return mstate;
- /* Reset the last_map_symbol if we start to dump a new section. */
- if (memaddr <= 0)
+ /* Reset the last_map_symbol if the address is zero. */
+ if (memaddr == 0)
last_map_symbol = -1;
/* If the last stop offset is different from the current one, then
@@ -1197,7 +1195,6 @@ riscv_search_mapping_symbol (bfd_vma memaddr,
if (riscv_get_map_state (n, &mstate, info, true))
{
symbol = n;
- found = true;
break;
}
}
--
2.38.1
next prev parent reply other threads:[~2022-11-28 4:47 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 ` [PATCH 2/3] RISC-V: Per-section private data initialization Tsukasa OI
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 ` Tsukasa OI [this message]
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=c49e114f7ae383c0e1da452391f19ecf45a3896e.1669610841.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).