From patchwork Mon Nov 28 04:47:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsukasa OI X-Patchwork-Id: 26509 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5434898wrr; Sun, 27 Nov 2022 20:54:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf4HyKaBCIOnzJYXEyZnMu1IT2crjPMO0zdVJwi2hitgE6cd+03UanZgdIxT3N7rJt/UHIJE X-Received: by 2002:aa7:c6da:0:b0:469:172:1f38 with SMTP id b26-20020aa7c6da000000b0046901721f38mr43811977eds.195.1669611285613; Sun, 27 Nov 2022 20:54:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669611285; cv=none; d=google.com; s=arc-20160816; b=Rwixn7PWcbd6yTInV6qEUMXNSXUwttXL/C/xUMiN6AL+Whc5D5ZeJExl7PFAQ1XE6i n3Yer7Q4i8ju4lkj0FlW94zoRfe29Sxj5TbomdgZnScUuGV7XwyNTtXJxUkD4eUSqpMr J2gBWdhhY3C+AjyY2/MIx3uAE5WxLzC5nm8Pk1/5wiv+BVtIu4/AsBVKdy7UTrO9WtDf POi1e+lFZGCayMVeSYUPMpPdFutWncLhfzTNm4+2LONP63lLnS954IYcw9MkjITpDzZV uglpnmA+Cj5Nys9OwPpPKfERgYf5nH7UDSVi1+0eZCp0UynRIJHGT4faXthDa4T/PrL3 du+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=H4mY4QML7dLGw+wtpeSyNYu/RzVXrRkrjBDz+0jyEGM=; b=KdUWmUzzYQFjWv+2YTmIaAhoadhsXrChd+aBtCwWR8lklqBOSN7v38UECungYF/lzx svnNopiq0Ku1jJA8N49mrFfK2NycJOxNakzFLEnJ2szhPJdAIvaHfoRJ9aM91x0UQkHr PPdpGY1nnVn+5R8YA7xmCd0CQ4eAfWk1tUDxv2HYRsmHU/qgOoSuuzd/CRnlLmB8iFPU hDcGnE/TwRrDMiuUckDOwiy9c6jP6VVbbBedbTN8v16QdC3opUMzvGGYtHT9yBHRt/3H gBsyi8vsu2meL5uQtslUoCGQb+frJ9nynRvocALG7q7DjN4RBAPpvanxJySzQyB7x/eP SfVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=oxK7UjD+; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id hz1-20020a1709072ce100b007316ac034acsi9280289ejc.834.2022.11.27.20.54.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Nov 2022 20:54:45 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=oxK7UjD+; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 967133947434 for ; Mon, 28 Nov 2022 04:49:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 967133947434 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669610986; bh=H4mY4QML7dLGw+wtpeSyNYu/RzVXrRkrjBDz+0jyEGM=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=oxK7UjD+vi9xIDrUCnN0x98l+96hgmGXvgwvBMeRBd6ig01jPpr3JePCt5Kg6dnM3 Gu7gEk9D0wgr3b2EU39JvRSjVS+FGWjjtcZkrBLP0HSNkrP+OznJ+PFaTs88FPs9YW 0IOimdVEJeJtyvZdYVKO3uPpi4KObrVnSEzNTafA= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org 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 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) 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 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tsukasa OI via Binutils From: Tsukasa OI Reply-To: Tsukasa OI Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749975582135560699?= X-GMAIL-MSGID: =?utf-8?q?1750714323618004241?= 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)