From patchwork Mon Nov 28 04:43:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsukasa OI X-Patchwork-Id: 26496 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5432973wrr; Sun, 27 Nov 2022 20:46:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf7JYIz1+gNCV64pjUKGep/qcWGRRWtJ3C1+mKrKMNbaUPGAoNX53xqRJ5HVfab0cClO7Un1 X-Received: by 2002:a05:6402:360b:b0:468:f365:dca with SMTP id el11-20020a056402360b00b00468f3650dcamr9307366edb.41.1669610806819; Sun, 27 Nov 2022 20:46:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669610806; cv=none; d=google.com; s=arc-20160816; b=My/efEzYdKXuY8lPM+kJPWyE/JbT4qnhLaq7Q69V17a+4hLH/qMR1F8dqViTwslIfd w/6o2TDjVbZqWq4W93fCyJAr+v1xxH6lAR1QfGdDPxWmwPJARKqa2x6ArxUSJgv9UZiq VopAlHvuL6+pntlTketKL/Xe2+Ife3gYNCf/83VLsRWclzmTyNR+QjncSxCzRqCqIvYj P5nE9Hune/4BewnGiC8/Apl0qy72SbIq+cMu0chgZOrkyjSoP5b2kU+FwHLHuAKpHmLh qR0JFwKt5Y/1WjMiwF2/nAfqSUHi8VU3ob700NWP95WJeyqd85LPA8pds0vE7IX63h14 mPNw== 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=zxufoScZ45JUF/v53XFfZpJIolVsqNg1wUdR4KqVktQ=; b=SZSQgpX8Hwg/Eu4xOuME/kjblIN4KN5mypp3rYLMWxsZhRcN1M11uENw4nvs2eby69 lx5Lxtyz45iw+eG19kOz378k2Z1FbaI1lLsTkWCkTMB3+EGNDkibfgyoQRzfKKDWSMbJ EA4N0i0rEhqFOckpfRhUyvOHTZveys2al4NLnpKTV0yDa91srJZrC5xwqGfHbidTk9EH JM0hctQ2WeiC/ww8ulzgiQUlXj52dT1Yt5KZm9uF9ZcjuyUrNEqf0DxPz/dfH+ySBhAY kZ4+kB5Flclco4Uvq3ocqVfZ+1Osfu6c6biD8MvE9eyqxVGHP+Kcm60ZGPORhPYRRda1 R7RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=xil6NfGg; 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 nb24-20020a1709071c9800b007bfacfbd8b6si1628544ejc.155.2022.11.27.20.46.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Nov 2022 20:46:46 -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=xil6NfGg; 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 C6B2B38362F2 for ; Mon, 28 Nov 2022 04:45:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6B2B38362F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669610730; bh=zxufoScZ45JUF/v53XFfZpJIolVsqNg1wUdR4KqVktQ=; 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=xil6NfGgrEP9yg6NouTfLfjHjb1tzC8RgxQGOcklYj8oUe4qoEysHyHLd28T+bp9J HesRFqsV5YUPdfieyEeEL3ZMglVMTgTYYsAbXAO2lyP3//K9+pZc0bGJuNenEjY7uc Wm5wsg9ATTCO2SkebO6AZYniW4Wcb5NizeA5X6N0= 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 2F1563854572 for ; Mon, 28 Nov 2022 04:44:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2F1563854572 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 7C2DC300089; Mon, 28 Nov 2022 04:44:57 +0000 (UTC) To: Tsukasa OI , Nelson Chu , Kito Cheng , Palmer Dabbelt Cc: binutils@sourceware.org Subject: [PATCH v2 05/11] RISC-V: One time CSR hash table initialization Date: Mon, 28 Nov 2022 04:43:40 +0000 Message-Id: <72c8e56861fccff6720a9b6ccefcecfd80e1adba.1669610611.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?1749537067859008886?= X-GMAIL-MSGID: =?utf-8?q?1750713821334506215?= From: Tsukasa OI The current disassembler intends to initialize the CSR hash table when CSR name parsing is required at the first time. This is managed by a function- scope static variable init_csr but... there's a problem. It's never set to true. Because of this issue, current disassembler actually initializes the CSR hash table every time when CSR name parsing is required. This commit sets init_csr to true once the CSR hash table is initialized. It is expected to have about 30% performance improvements alone when thousands of only CSR instructions are disassembled (CSR instructions are rare in general so real world performance improvement is not that high). This commit alone will not affect real world performance that much but after the efficient opcode hash is implemented, it will be much effective (sometimes >x10 effect than this commit alone) so that even some regular programs can benefit from it. opcodes/ChangeLog: * riscv-dis.c (print_insn_args): Make sure that CSR hash table initialization occurs only once. --- opcodes/riscv-dis.c | 1 + 1 file changed, 1 insertion(+) diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c index 38eb91349d9a..51a08d847b10 100644 --- a/opcodes/riscv-dis.c +++ b/opcodes/riscv-dis.c @@ -564,6 +564,7 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info DECLARE_CSR (name, num, class, define_version, abort_version) #include "opcode/riscv-opc.h" #undef DECLARE_CSR + init_csr = true; } if (riscv_csr_hash[csr] != NULL)