From patchwork Wed Jul 24 23:50:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edwin Lu X-Patchwork-Id: 1964575 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=CFPzBjQ0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WTrPt1Vx9z1yY9 for ; Thu, 25 Jul 2024 09:51:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C0031385DDCB for ; Wed, 24 Jul 2024 23:51:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 55B4F385B50B for ; Wed, 24 Jul 2024 23:50:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 55B4F385B50B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 55B4F385B50B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721865045; cv=none; b=jHHL6v6F+Z1csXez7EhYP6YUfSGXLfs75rCNs/mkv4/hxvBK7Jqex7xXxpZXoX5Wd3ra7Gp1xCr5rwSZBXvgedMpIjt97KvjBKrIkX+5m+fF5FANcicun262Pe0NZ/vjdrIpjg+96S1bmu51NvegiyMWfakNDyxlCn9hhXGEKxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721865045; c=relaxed/simple; bh=DTcwfcFlis3mhvx3Kt2Ldk8gN+a//NM/3EieItHlVRw=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=D1kyEzJj/t7N03RaLY+U4vY2676tQhVij42zANayFYu775iSHBMtpSSlzd9waOegjoQslP/SxtDTstyq3PeKCpX9u27ft2yNYkbqR5spRsp7PB8J9DnCskdF3TXlDO9AZ0gAN6jhZyko2TcSnD0aonriE+elfIkDwwyKOTRwYwQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-70d2b921c48so307127b3a.1 for ; Wed, 24 Jul 2024 16:50:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1721865042; x=1722469842; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=zp/rvV23t++DFuufRhySOCV8dj+XZ8pTh0G2GZBBkbU=; b=CFPzBjQ093SqBduKuKK2FRgnokYxOadeg5ACMcY7OkBKVFFtom8pKVnxpRXJE2ug7D vvUJBD8uiDmBSsVlw/7Ejx26VBbHT4gtr7bM/vJzrrL2z4pFYR2QV4oJTsW0yZNio55O ikzSGFYqcUkpEEGuv78C9heVWanjEiZQi97j93FivVCsebWdDDRkyb1OLmbVEAOzfWrU xxT8N2x3RasxJZnO8GPxONphP1auCT8iZJB/CRFwwi0gK/+D18OnriamwdLg/F5q7avj Ffxx5YNTECQaY2oyKzJQR1HU/BouzjhDyLMwulzbNTeFn80DN5wssSmqvbeAYQIz5ffe TAkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721865042; x=1722469842; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zp/rvV23t++DFuufRhySOCV8dj+XZ8pTh0G2GZBBkbU=; b=QPsBOAqGervAtgmP6gBAp/62/Y/BaEEiBp9MCbG7NdMoUPpDsp/U5Bg3t2R2lKLWhQ DoK6kDlib947nx7JK5XfSmQTZn62XRgv2sINQxfZS3zaoyjqB5C74Dxc4pXsxduk4Z1V sylbJMfU/4zI1yACOyfozGpfGuw2WO0/3YwUDLlcKWLjlyYdKX71+K/nI0Nq5Ko2mPpd mNqrzoKMAxGAUehKEtMm6zUtJ0w/gHtTrbNM3h1Db6tyPcb1kxwBMEy/Bp6L/tfkPn9X GPNNAA+G5BYgX8/MOwu1BpX1BoHdt1M3xbkMwY2GkCpHUF5GPPtCh8DIfSCZJ5j34kF5 d5tw== X-Gm-Message-State: AOJu0YxLdIov6zJmYraVw7VhfVFH6ixKCW/8iYoY7e1Xb4uCuZLdwP38 0kn2oPFn+IRFPCSDjh+G3cH9mF6wXFTT1PMgMeZv5NzVgJNiwdWIqVU79cN6MorHPl25WWnsAdn m X-Google-Smtp-Source: AGHT+IGPS92MW4IzKsNSRVa4Il6bwzmmF3On2cugnMJvTm0QGO5LtfuyJnZWeN/cAlwFP34U7p9hVw== X-Received: by 2002:a05:6a20:4315:b0:1c3:a411:dc49 with SMTP id adf61e73a8af0-1c472c602e0mr1640844637.51.1721865041853; Wed, 24 Jul 2024 16:50:41 -0700 (PDT) Received: from ewlu.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead6e0f77sm121024b3a.33.2024.07.24.16.50.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 16:50:41 -0700 (PDT) From: Edwin Lu To: gcc-patches@gcc.gnu.org Cc: gnu-toolchain@rivosinc.com, Edwin Lu Subject: [PATCH] RISC-V: Add configure check for B extention support Date: Wed, 24 Jul 2024 16:50:38 -0700 Message-Id: <20240724235038.3649303-1-ewlu@rivosinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Binutils 2.42 and before don't recognize the B extension in the march strings even though it supports zba_zbb_zbs. Add a configure check to ignore the B in the march string if found. gcc/ChangeLog: * common/config/riscv/riscv-common.cc (riscv_subset_list::to_string): Skip b in march string * config.in: Regenerate. * configure: Regenerate. * configure.ac: Add B assembler check Signed-off-by: Edwin Lu --- gcc/common/config/riscv/riscv-common.cc | 8 +++++++ gcc/config.in | 6 +++++ gcc/configure | 31 +++++++++++++++++++++++++ gcc/configure.ac | 5 ++++ 4 files changed, 50 insertions(+) diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 682826c0e34..200a57e1bc8 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -857,6 +857,7 @@ riscv_subset_list::to_string (bool version_p) const bool skip_zaamo_zalrsc = false; bool skip_zabha = false; bool skip_zicsr = false; + bool skip_b = false; bool i2p0 = false; /* For RISC-V ISA version 2.2 or earlier version, zicsr and zifencei is @@ -891,6 +892,10 @@ riscv_subset_list::to_string (bool version_p) const /* Skip since binutils 2.42 and earlier don't recognize zabha. */ skip_zabha = true; #endif +#ifndef HAVE_AS_MARCH_B + /* Skip since binutils 2.42 and earlier don't recognize b. */ + skip_b = true; +#endif for (subset = m_head; subset != NULL; subset = subset->next) { @@ -911,6 +916,9 @@ riscv_subset_list::to_string (bool version_p) const if (skip_zabha && subset->name == "zabha") continue; + if (skip_b && subset->name == "b") + continue; + /* For !version_p, we only separate extension with underline for multi-letter extension. */ if (!first && diff --git a/gcc/config.in b/gcc/config.in index bc819005bd6..96e829b9c93 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -629,6 +629,12 @@ #endif +/* Define if the assembler understands -march=rv*_b. */ +#ifndef USED_FOR_TARGET +#undef HAVE_AS_MARCH_B +#endif + + /* Define if the assembler understands -march=rv*_zaamo_zalrsc. */ #ifndef USED_FOR_TARGET #undef HAVE_AS_MARCH_ZAAMO_ZALRSC diff --git a/gcc/configure b/gcc/configure index 01acca7fb5c..c5725c4cd44 100755 --- a/gcc/configure +++ b/gcc/configure @@ -30913,6 +30913,37 @@ if test $gcc_cv_as_riscv_march_zabha = yes; then $as_echo "#define HAVE_AS_MARCH_ZABHA 1" >>confdefs.h +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -march=rv32i_b support" >&5 +$as_echo_n "checking assembler for -march=rv32i_b support... " >&6; } +if ${gcc_cv_as_riscv_march_b+:} false; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_riscv_march_b=no + if test x$gcc_cv_as != x; then + $as_echo '' > conftest.s + if { ac_try='$gcc_cv_as $gcc_cv_as_flags -march=rv32i_b -o conftest.o conftest.s >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + gcc_cv_as_riscv_march_b=yes + else + echo "configure: failed program was" >&5 + cat conftest.s >&5 + fi + rm -f conftest.o conftest.s + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_riscv_march_b" >&5 +$as_echo "$gcc_cv_as_riscv_march_b" >&6; } +if test $gcc_cv_as_riscv_march_b = yes; then + +$as_echo "#define HAVE_AS_MARCH_B 1" >>confdefs.h + fi ;; diff --git a/gcc/configure.ac b/gcc/configure.ac index 3f20c107b6a..93d9236ff36 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -5466,6 +5466,11 @@ configured with --enable-newlib-nano-formatted-io.]) [-march=rv32i_zabha],,, [AC_DEFINE(HAVE_AS_MARCH_ZABHA, 1, [Define if the assembler understands -march=rv*_zabha.])]) + gcc_GAS_CHECK_FEATURE([-march=rv32i_b support], + gcc_cv_as_riscv_march_b, + [-march=rv32i_b],,, + [AC_DEFINE(HAVE_AS_MARCH_B, 1, + [Define if the assembler understands -march=rv*_b.])]) ;; loongarch*-*-*) gcc_GAS_CHECK_FEATURE([.dtprelword support],