From patchwork Mon Jan 24 09:50:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kito Cheng X-Patchwork-Id: 1583359 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=Qt2kYFGL; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jj4xj2c9Qz9t56 for ; Mon, 24 Jan 2022 20:51:21 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C37EF3858017 for ; Mon, 24 Jan 2022 09:51:18 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id 1BD7C3858425 for ; Mon, 24 Jan 2022 09:51:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1BD7C3858425 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pl1-x62a.google.com with SMTP id x11so9163133plg.6 for ; Mon, 24 Jan 2022 01:51:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XPsQYScgGjRkgxQHjvtTdHIoMrwgeqXHUFNk9Ix/95k=; b=Qt2kYFGL6V9MqLbvmoNWD7rKOvXObhASDwmhy+UAuGJFVEmkTkglSCp5zV735RZqHj nZDF7BjcJZk2NxiiUeWrbprzabSNY+LQjZv0mJk4bZpb+ePn9TgW03HjE9IeLQPTApAx IgMkAJxHLTZs7Y38YGsw6IbVYTxYWgMie8xEdp4jYmOn+5asiHKW5jPvWwVwyV+WF/2o /iSywlHasVhPF2LQRRNBVAanZn3F/Qpu/cJWw5sDitC0it1eawLtJJivcPQf51D10NHM QKWvDR6AG+5ePTRLrCNJ2biB87i7V5fw3EVCS1cqP+3xyCSZQVTIb726/9YIMWEyVRop deBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XPsQYScgGjRkgxQHjvtTdHIoMrwgeqXHUFNk9Ix/95k=; b=D/UooeBV/F+8bLfzyZwFc/7oxJ5LK16vshm60NA1zMY81oUPtqNQDcM2XcQuBrvCIh Vsowyj48Kx0AwEgXbPi2cjxhtxSAG9GZOsWpQPYpstJpB5W0VoGBw2CrwvyIJbIdtCKn fQXUC04b0xfguJJJYGOz19HFgII0Qe0sYy/lJMR/bOqEWF8O1Mu4Co5+O+cTvGPq5bDe Dz7/vK7/blYxAXSjQHcexEwze5G191bxWnPbJ/Mrq5Hr6Z/mcEMI0ARTBdeois12kDOr DXjqfzUSpRdSj428OQW/my5riBGbencIdHAxJeV7DFp62NrGTZOfCGxswn8X/34WpacU d3GA== X-Gm-Message-State: AOAM532DkBkGxDpxkz0jJSfbWhKR9WH/sD1efhBw1dqto3TXxEwlclhM uOj3R8pJbppx1+XO22tAofqjuqPpV5Povw== X-Google-Smtp-Source: ABdhPJwbkNqUILlBE5VSpke6q5gAaO+MaA7i+whfPcNuiQAn1ZVxTIvJD/PCTGkSIFREJxXvTN9Ycw== X-Received: by 2002:a17:902:b08b:b0:149:88bb:b477 with SMTP id p11-20020a170902b08b00b0014988bbb477mr14069019plr.137.1643017861933; Mon, 24 Jan 2022 01:51:01 -0800 (PST) Received: from hsinchu02.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id i11sm11341107pgm.92.2022.01.24.01.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 01:51:01 -0800 (PST) From: Kito Cheng To: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com, jim.wilson.gcc@gmail.com, palmer@dabbelt.com, andrew@sifive.com Subject: [committed] RISC-V: Do not emit zcisr and zifencei if i-ext is 2.0 Date: Mon, 24 Jan 2022 17:50:50 +0800 Message-Id: <20220124095050.8787-1-kito.cheng@sifive.com> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kito Cheng Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" I-ext 2.0 already included zicsr and zifencei, skip that prevent confusing binutils. gcc/ChangeLog * common/config/riscv/riscv-common.cc (riscv_subset_list::to_string): Skip zicsr and zifencei if I-ext is 2.0. --- gcc/common/config/riscv/riscv-common.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 25f56707d94..a904893b9ed 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -488,6 +488,7 @@ riscv_subset_list::to_string (bool version_p) const bool skip_zifencei = false; bool skip_zicsr = false; + bool i2p0 = false; /* For RISC-V ISA version 2.2 or earlier version, zicsr and zifencei is included in the base ISA. */ @@ -497,6 +498,13 @@ riscv_subset_list::to_string (bool version_p) const skip_zicsr = true; } + for (subset = m_head; subset != NULL; subset = subset->next) + if (subset->name == "i") + { + i2p0 = subset->major_version == 2 && subset->minor_version == 0; + break; + } + #ifndef HAVE_AS_MISA_SPEC /* Skip since older binutils doesn't recognize zicsr. */ skip_zicsr = true; @@ -509,10 +517,12 @@ riscv_subset_list::to_string (bool version_p) const for (subset = m_head; subset != NULL; subset = subset->next) { - if (subset->implied_p && skip_zifencei && subset->name == "zifencei") + if (((subset->implied_p && skip_zifencei) || i2p0) && + subset->name == "zifencei") continue; - if (subset->implied_p && skip_zicsr && subset->name == "zicsr") + if (((subset->implied_p && skip_zicsr) || i2p0) && + subset->name == "zicsr") continue; /* For !version_p, we only separate extension with underline for