From patchwork Sun Nov 20 01:10:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsukasa OI X-Patchwork-Id: 23365 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp928587wrr; Sat, 19 Nov 2022 17:12:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf6hsck1n2VZEJKaWxXsPmTcy728wqqlYJxa0nyGMiO2e4wSVsRWkbFu73bD+3tPTMZEN1uQ X-Received: by 2002:a17:906:4cc1:b0:7ae:50c6:fd0a with SMTP id q1-20020a1709064cc100b007ae50c6fd0amr10604195ejt.184.1668906767208; Sat, 19 Nov 2022 17:12:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668906767; cv=none; d=google.com; s=arc-20160816; b=TBO7foW/YAJngmrWF32Ioq7VB+OQ5AS3MRTl9D2c2aPoRdRXqhOJDku7OejRg3b/CF qhxoGgDm8ueBot6u0X72IwoGIwzStZLddhnBL4ulUZpbWxCXuPyeyI0/aFgvFVqQPaX+ Jj+h4WhlIDG3WqS85zaumLEM6JfJYcsYAZ4UlJ93AM1QYof5UwStyfi82Xrd52CwxKpC fLYacSOZaE0imsb2ctrf72KGmhLOc8+wUC9PtZg0EWCrRdSgWB7pdVEBTOVo2unN/TJD K3/8CPbyDWBD9kS1jQZUQzuYBbqbv5n1F/YUVqkp600zrP0qpNCkGtXljXABMEQR+aLC RCMg== 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=vXscySyGZMDSkpsZWAKnb8C1uRhj8KSzMhJf/OpVLq8=; b=iXDQfNPKmXJ5SqoEh1l9yDxEGzDMfdtq/zY9BuzJ1xxNwqCccGWlyudEzAhrvS+9nj 8d1fHh2WG8PPasEcTLtVpFmog5NhgSV+9NY1KGW8RtBB7iF0JLPkcciP8AydRehZKkXR YJhFmnArx4cqTkStK+YnD+3G7JbAuBlMptvdWoDrBwQDRhy/bThTD2U/LLrV95qA8bSF 6PWG0Iot8S/wyFM3IQZPY8zuoeRCiCwJIK9CbJ63f/uf3Z8SfWyhiNck3TmTInUz/S9X JN51QRSBrbwMyC1F4+MVspdwMONICD8wkZruMufmvmKpJ3/ajXz2LiTztYGEF0Sa4kqq EX2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=CjGVTnFz; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id d7-20020a056402400700b004676b9092e0si6142452eda.408.2022.11.19.17.12.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Nov 2022 17:12:47 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=CjGVTnFz; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 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 1373B3894C3B for ; Sun, 20 Nov 2022 01:12:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1373B3894C3B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668906725; bh=vXscySyGZMDSkpsZWAKnb8C1uRhj8KSzMhJf/OpVLq8=; 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=CjGVTnFzCVsL83AKZfITrcO7MpVfHOLZRf7B9R6sHaQIMEGybcfHoSrQlvtZFxy7Y 5qtbBy3zldqvA66rxpLarJZGphH4+NHprGJ3Fr8r6KF5Zk5Uo50HlTaSHdE4cPXZ5f cxaeIwkOtl0XtRkk9YxyV4qjNEWW3yoltiYfs+a0= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-sender-0.a4lg.com (mail-sender-0.a4lg.com [IPv6:2401:2500:203:30b:4000:6bfe:4757:0]) by sourceware.org (Postfix) with ESMTPS id 7CFD23889E1C for ; Sun, 20 Nov 2022 01:10:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7CFD23889E1C Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id CC814300089; Sun, 20 Nov 2022 01:10:31 +0000 (UTC) To: Tsukasa OI , Nelson Chu , Kito Cheng , Palmer Dabbelt Cc: binutils@sourceware.org Subject: [PATCH 2/3] RISC-V: Per-section private data initialization Date: Sun, 20 Nov 2022 01:10:08 +0000 Message-Id: <55a36e28e1cb3983c637b3019d48717278574591.1668906599.git.research_trasio@irq.a4lg.com> In-Reply-To: References: Mime-Version: 1.0 X-Spam-Status: No, score=-12.2 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?1749975582135560699?= 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 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)