From patchwork Sat Oct 21 00:45:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsukasa OI X-Patchwork-Id: 15709 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp55980vqx; Fri, 20 Oct 2023 17:46:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHT3GqZgX6fX9bD5XDi62toajfdNSTuWizY84/QzmJ+SIzQzqHqX2TU1dI/q1iIDFZlOcHs X-Received: by 2002:ac8:4b73:0:b0:41b:7737:d70f with SMTP id g19-20020ac84b73000000b0041b7737d70fmr2931720qts.0.1697849181280; Fri, 20 Oct 2023 17:46:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697849181; cv=pass; d=google.com; s=arc-20160816; b=doviW0LPIUSdTWuRYpYx+ATJwY3ZyZrgy39omSe3lJmi9COTZdFKSojJDqcpH/wKE4 NU5Ja8rpqys6ST1R+y8xtADrdjR5qpjiK4S0Xeir7d6SiRoMNNkcRRry0alw0DDwK8IN K7CNxQfw2S0Rj6Ae4NcNLiQPC9/bYEo9xXL8Y1OoJgzAH+ez0E23LxicIOkv/jEkw3Sk evP/BteR5NmQYhKequxNd1T0t0GqmIWB/fQ46BC47sLtFW1qlI2N07nYtbhS94aRMNi6 OyZzyArqH8cA2LVn7MasSlBCqBDaSglalYKWoGfev38V3ltTDBWYV0hHRdRlpoGGpvAh p2IA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to: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 :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=Py7vt/+joGkmMwsmXpTHY5BisJWe6yHruyeaQo//bu8=; fh=Q+ZPQdyJDzJx4BfovHNTR1lP4msTSfN6TDra8V1lyf8=; b=cd/ihD94Bc1nO5dLH7IwmmEFpWld9PI0Nbw8dCWLW4i2wn7Ms712NJ0yummmoydSU9 TT6PeAQXYYUiNGMSeCGWTXGRRgPhK4OuNlBrM940ZOOZKq+f4FR3cHsGVoo5J7Hm3GKB BDt8NGx6ssSfyWbHnMX4NDrFfZQWWmWcLYxZhNAGfkuEeTY5flvXpx2J1FaN7HPhDFmo Y5DA2OXmWTmT7Ts97VTNpRiaZgGALm7DwNpE+OEVghZ9aRmQw8wy31z09xovjCC28uV1 RmL7w2X2xb7DyhuW2krGMN6ajwoXSvFvkfsox2Qbie90UQ/1xiRh/DFkwHl2EEGQsxpG CL/Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@irq.a4lg.com header.s=2017s01 header.b="j6Nx/6T2"; arc=pass (i=1); 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=irq.a4lg.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o10-20020ac85a4a000000b0041cd1f7abfdsi2156380qta.472.2023.10.20.17.46.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 17:46:21 -0700 (PDT) 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=@irq.a4lg.com header.s=2017s01 header.b="j6Nx/6T2"; arc=pass (i=1); 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=irq.a4lg.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B1AA43858414 for ; Sat, 21 Oct 2023 00:46:20 +0000 (GMT) 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 EA31A3858D35 for ; Sat, 21 Oct 2023 00:46:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EA31A3858D35 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 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EA31A3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=153.120.152.154 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697849175; cv=none; b=hdODVjZP5CeiLTTUixu6O3xULeG9nIJ8tJxLIeJEsofF1BIHG8owmjkSARnBs0F5+M77ssX+tb8l4T71l4ri7wErIpNlEs2r3dh+C0/mvA7EoaI7Lhgr0oQD1eyFdAEqzfVlkNJzbUrWMDPpZ878l6dLC2orslZ8imjxwvcLIz4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697849175; c=relaxed/simple; bh=w03xX0fC60SAjK7n6TSycCMxh9E3N+5goZf/s9Cx/sY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:Mime-Version; b=jrfMgTn+j6Y972XwQcCwhfrQYQV+l7PZ77BvSrZDnrLpGGm2Oe788lB2e9MjtUK6bNTfoLmdurMi6PNc/+3fimZEZcqwjlno0shAM9Ga1MciMvGb8dVPHW2/Z8DxLNBNHedP0QghcukO6IOwW5jFgAZQ4SKoBV52ogBIVWvj1eo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 60D51300089; Sat, 21 Oct 2023 00:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irq.a4lg.com; s=2017s01; t=1697849162; bh=Py7vt/+joGkmMwsmXpTHY5BisJWe6yHruyeaQo//bu8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Mime-Version:Content-Transfer-Encoding; b=j6Nx/6T2tiWBjJQUyee6VHdJQo0igJRUpJ8Y8nj7DMZu0E8eefoXQT3Ox0DhpxbYo lgw8W0IqVuHtKydcdynQTy4/outDwm16GPRj0VasXkUteF5h34pUiVw0/PlmB5cEXR 6fXaIVNGoTZUm1N4ZxdBsjiv6vF3w6GmQS32QI1I= From: Tsukasa OI To: Tsukasa OI , Palmer Dabbelt , Andrew Waterman , Jim Wilson , Nelson Chu , Kito Cheng Cc: binutils@sourceware.org Subject: [PATCH 0/1] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures Date: Sat, 21 Oct 2023 00:45:58 +0000 Message-ID: In-Reply-To: References: Mime-Version: 1.0 X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KAM_MANYTO, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no 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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773629276894695925 X-GMAIL-MSGID: 1780323903113993126 Hi, This patch adds support for two extensions, split from the RISC-V Unprivileged ISA version 2.2: 1. `Zicntr` Basic hardware performance counters 2. `Zihpm` Platform-specific configurable hardware performance counters but the compatibility is vital. This patch set tries to deal with the compatibility issues as possible. RFC PATCH v1: Unlike RFC PATCH v1, this (PATCH v1) tries to resolve most of compatibility issues by following concepts: 1. Implement 'Zicntr' and 'Zihpm' as in the latest RISC-V ISA Manual documentation (draft) except... 2. even if a 'Zicntr' pseudoinstruction is used without that extension, generate a warning instead of an error. This is much simpler than before (though increases differences in tests) and almost completely ISA specification agnostic. I hope this patch resolves most of concerns raised by Nelson. The hardest part was to move handling of *the ISA version 2.2* to *the 'I' extension version 2.0 (or less)*. If the 'I' extension version is 2.0 or less and its subset (e.g. 'Zicsr' or 'Zicntr') is being added, it disables inferring the default version number. If the ISA is either RV32E or RV64E and 'I' 2.0 subsets (but 'I' itself) are explicitly specified, the default handling is the same as 'I' >= 2.1 because non-draft 'E' extension does not have 'I' 2.0 subsets. Thanks, Tsukasa Tsukasa OI (1): RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures bfd/elfxx-riscv.c | 52 +++- gas/config/tc-riscv.c | 25 ++ .../gas/riscv/csr-insns-pseudo-noalias.d | 2 +- .../gas/riscv/csr-insns-pseudo-nozicntr.d | 37 +++ .../gas/riscv/csr-insns-pseudo-nozicntr.l | 7 + .../gas/riscv/csr-insns-pseudo-zfinx.d | 2 +- gas/testsuite/gas/riscv/csr-insns-pseudo.d | 2 +- gas/testsuite/gas/riscv/csr-insns-pseudo.s | 3 +- gas/testsuite/gas/riscv/csr-insns-read-only.d | 2 +- gas/testsuite/gas/riscv/csr-version-1p10.l | 256 ++++++++++++++++++ gas/testsuite/gas/riscv/csr-version-1p11.l | 256 ++++++++++++++++++ gas/testsuite/gas/riscv/csr-version-1p12.l | 256 ++++++++++++++++++ gas/testsuite/gas/riscv/csr-version-1p9p1.l | 256 ++++++++++++++++++ include/opcode/riscv-opc.h | 128 ++++----- include/opcode/riscv.h | 1 + opcodes/riscv-opc.c | 12 +- 16 files changed, 1217 insertions(+), 80 deletions(-) create mode 100644 gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.d create mode 100644 gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.l base-commit: 4a6daabb94982ccc17ea45ebb6f6e8efa8f86399