From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sender-0.a4lg.com (mail-sender.a4lg.com [153.120.152.154]) by sourceware.org (Postfix) with ESMTPS id 6296C3954472 for ; Mon, 28 Nov 2022 04:47:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6296C3954472 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=irq.a4lg.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=irq.a4lg.com Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id BD3B6300089; Mon, 28 Nov 2022 04:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irq.a4lg.com; s=2017s01; t=1669610868; bh=H4mY4QML7dLGw+wtpeSyNYu/RzVXrRkrjBDz+0jyEGM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Mime-Version:Content-Transfer-Encoding; b=RWMMy7bWH0GU6V+1BswaOC7RS77lMdtGdV6ST6JDojoKkRXCT5cdR2EB2WSpGssgc CDniJpYgm4NVuV5/fifR7Df7b+thtfIvmPr8aRuPc2aDxG7/Immw1i0nw2EjURJRT8 TXwTDYAXw8FbGjynV8jW+kJcJbgS73y0A2pdpTG4= From: Tsukasa OI To: Tsukasa OI , Nelson Chu , Kito Cheng , Palmer Dabbelt Cc: binutils@sourceware.org Subject: [PATCH v2 2/3] RISC-V: Per-section private data initialization Date: Mon, 28 Nov 2022 04:47:22 +0000 Message-Id: <4b8fcca24b8897f382b6e32fd29337f0b6972e2f.1669610841.git.research_trasio@irq.a4lg.com> In-Reply-To: References: Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Tsukasa OI 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 bb7c03ad5fbf..ba9b16afeb46 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 @@ -1312,7 +1323,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