From patchwork Tue Oct 25 06:17:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Monk Chiang X-Patchwork-Id: 10510 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp835192wru; Mon, 24 Oct 2022 23:18:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7M5RR+yKaQUmIPaz0ub5eaagZskoXRtZ7sF9trhrwercPDZyeCYyx03IsorOWmLFxadOD3 X-Received: by 2002:a05:6402:4443:b0:45f:ca04:719b with SMTP id o3-20020a056402444300b0045fca04719bmr25977498edb.171.1666678693805; Mon, 24 Oct 2022 23:18:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666678693; cv=none; d=google.com; s=arc-20160816; b=N+5au9ri05niERBwoyaO4ZGxoDGrhuJwgVNWnqjgNn45fDk0vlN/bL/eCLLhyJyy4G LQyXZ8zZGFXdnGhmpCPBQoh0FBC36ejIZlkE6qrbRyWMyFFDT94OVC0dsn2yfaFiXwqE fOiDC1cpyksXo2GrNrPRmA6AoqH4YIKt9Tfann7vHoHUrstqQMNZhZWDzxTQ5ZAyCzID aDx/J6kvNxYC7QJE0f6gOJ3pzNKyTYbw4umoU1UREnb2uYOHAoCQttYcXNlak2naPk3R HLd92KYkxTxTnDm7tRHiJtmuUqPShg4wQkgh3vYT3EeiXQKelLNcIM0LxgsWG0uq/Ox/ Yg9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :dmarc-filter:delivered-to; bh=xUacltzbscYBk1l4D5Yu280ZMf2F8y4z5RHuyR96nuE=; b=aZIKsSiShUyRfjCVWGilZR/oaRPF4rpiHcBHNPrwG2Iy953hbgJVM4OeApzEqfDdpQ dStpFxE4wGlANtihFe7qIhnk16XR+FXXBRf+ozDXzfhLpW34ZvKk+b0fcvoqYhlkKm6W zuhXwDhsWqTHCfD/MEJ1INuR/Ca9p1czfpP6/rWXhFyAHA+9ZTcWROjXTjR5r8K3BXEK ozY8ACpkkBrmLqcnVvbvm3+G1+gEtKairmAz2/b8N0s+dXzKgFXk0BnKfAM0IL6cUACD 9x8SzR/pzczDYyJPKR/f6MQExP94H/yixvnkiLsU2o9NxeRImfTFNt8YaT0wHsrsUdY6 i99g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b="mo/3Qd49"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id hd34-20020a17090796a200b00741a16e8562si2213086ejc.826.2022.10.24.23.18.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 23:18:13 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.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=@sifive.com header.s=google header.b="mo/3Qd49"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 24A73385841F for ; Tue, 25 Oct 2022 06:18:09 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 757B83858401 for ; Tue, 25 Oct 2022 06:17:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 757B83858401 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-pf1-x42e.google.com with SMTP id b185so4741307pfb.9 for ; Mon, 24 Oct 2022 23:17:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xUacltzbscYBk1l4D5Yu280ZMf2F8y4z5RHuyR96nuE=; b=mo/3Qd490i1E/c4GLyk1I6En6gx3Jpp0VIZcG3z+B9q8bqvg35GZS0Jj3zfIO5Kl1n epUqRCj8um8Oil9I01FhoXlgKqwFQC8TyPfg8RVH3oMKTG1jW/N9QpR9BUKZKnJLxmRU 9Wm9yQpWDuTEGLihs7CmDf1ZJtPVAgIhCtJtH0YSXFeWPUL1a2wgpAO1f7EtwbiFNPpM n14Kd1EuWFQwMdpYnk16VqKpKCURQw1t0tp5m/AOKXk7Nx8xifyi9FGZ3sLEexFlbOkb jACOEOUmFjEEMe5QvVAekrskpChC06gQGr8zF4mSK4JKpkuHt8ESuR/HBAL+LAWU1zFM rDfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=xUacltzbscYBk1l4D5Yu280ZMf2F8y4z5RHuyR96nuE=; b=VU/X6oJY9IuC6uYQGbJjIK1mD8UC7UXMUGa+aypHO96LYx3KCOo0Irmsfqjt9k1roY LxTLy8NEO4iECeaCgkytyQOWI7uXRU+TRnIsZXwWOSQRhjgcRfCqQQ+lUNfQ+qZ88TX0 aKJqvhm/RUsns491aXhWrqE6/m+fwxq+MsxxJpwbv+eIx/h1lIiE94T0iSD/74CZa1W7 0c9cYe+36YT4wo378e8SZ0ADVFg0Ts3dod3AwUIRNJrx6XKjFa80Z1fVhC/LIv9001gv S7VVA3m+6sY4VLOy+TpI5hZGGiBea5Lkjj2uzByWQohfTI1EA0rbVlkXaVxUKvzLS7i5 T5qQ== X-Gm-Message-State: ACrzQf0bjjNWnMqQF6m9qdxGTw8JS3GK8QoO+A/U9pL4un8QmHMaZ12+ PwnfTZboCwnXM29c70F91QV5DIVfs4XvJThsZykqtfioPCbhm5JPYM9oRhw5jHgz7IW3JWJMfr8 yZjX6OaQ7Dnfs5Q04kAZ3xVd/reqzvEkGWLes18eeOB8UNiRtHK63bw4YJC2g6szH/JKdIaro9h o= X-Received: by 2002:a63:2f45:0:b0:457:dc63:68b4 with SMTP id v66-20020a632f45000000b00457dc6368b4mr31259012pgv.228.1666678663033; Mon, 24 Oct 2022 23:17:43 -0700 (PDT) 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 g9-20020aa79f09000000b00535da15a252sm726377pfr.165.2022.10.24.23.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 23:17:42 -0700 (PDT) From: Monk Chiang To: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com Subject: [PATCH] RISC-V: Recognized Svinval and Svnapot extensions Date: Tue, 25 Oct 2022 14:17:33 +0800 Message-Id: <20221025061733.41146-1-monk.chiang@sifive.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Monk Chiang Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747639277625331718?= X-GMAIL-MSGID: =?utf-8?q?1747639277625331718?= gcc/ChangeLog: * common/config/riscv/riscv-common.cc (riscv_ext_version_table): Add svinval and svnapot extension. (riscv_ext_flag_table): Ditto. * config/riscv/riscv-opts.h (MASK_SVINVAL): New. (MASK_SVNAPOT): Ditto. (TARGET_SVINVAL): Ditto. (TARGET_SVNAPOT): Ditto. * config/riscv/riscv.opt (riscv_sv_subext): New. gcc/testsuite/ChangeLog: * gcc.target/riscv/predef-23.c:New. * gcc.target/riscv/predef-24.c:Ditto. --- gcc/common/config/riscv/riscv-common.cc | 6 +++ gcc/config/riscv/riscv-opts.h | 6 +++ gcc/config/riscv/riscv.opt | 3 ++ gcc/testsuite/gcc.target/riscv/predef-23.c | 47 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/predef-24.c | 47 ++++++++++++++++++++++ 5 files changed, 109 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/predef-23.c create mode 100644 gcc/testsuite/gcc.target/riscv/predef-24.c diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index dead3802f83..a5fe782bb61 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -202,6 +202,9 @@ static const struct riscv_ext_version riscv_ext_version_table[] = {"zmmul", ISA_SPEC_CLASS_NONE, 1, 0}, + {"svinval", ISA_SPEC_CLASS_NONE, 1, 0}, + {"svnapot", ISA_SPEC_CLASS_NONE, 1, 0}, + /* Terminate the list. */ {NULL, ISA_SPEC_CLASS_NONE, 0, 0} }; @@ -1226,6 +1229,9 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] = {"zmmul", &gcc_options::x_riscv_zm_subext, MASK_ZMMUL}, + {"svinval", &gcc_options::x_riscv_sv_subext, MASK_SVINVAL}, + {"svnapot", &gcc_options::x_riscv_sv_subext, MASK_SVNAPOT}, + {NULL, NULL, 0} }; diff --git a/gcc/config/riscv/riscv-opts.h b/gcc/config/riscv/riscv-opts.h index 55e0bc0a0e9..63ac56a8ca0 100644 --- a/gcc/config/riscv/riscv-opts.h +++ b/gcc/config/riscv/riscv-opts.h @@ -162,6 +162,12 @@ enum stack_protector_guard { #define MASK_ZMMUL (1 << 0) #define TARGET_ZMMUL ((riscv_zm_subext & MASK_ZMMUL) != 0) +#define MASK_SVINVAL (1 << 0) +#define MASK_SVNAPOT (1 << 1) + +#define TARGET_SVINVAL ((riscv_sv_subext & MASK_SVINVAL) != 0) +#define TARGET_SVNAPOT ((riscv_sv_subext & MASK_SVNAPOT) != 0) + /* Bit of riscv_zvl_flags will set contintuly, N-1 bit will set if N-bit is set, e.g. MASK_ZVL64B has set then MASK_ZVL32B is set, so we can use popcount to caclulate the minimal VLEN. */ diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt index 8923a11a97d..949311775c1 100644 --- a/gcc/config/riscv/riscv.opt +++ b/gcc/config/riscv/riscv.opt @@ -224,6 +224,9 @@ int riscv_zf_subext TargetVariable int riscv_zm_subext +TargetVariable +int riscv_sv_subext + Enum Name(isa_spec_class) Type(enum riscv_isa_spec_class) Supported ISA specs (for use with the -misa-spec= option): diff --git a/gcc/testsuite/gcc.target/riscv/predef-23.c b/gcc/testsuite/gcc.target/riscv/predef-23.c new file mode 100644 index 00000000000..64bde17efa9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/predef-23.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_svinval -mabi=lp64 -mcmodel=medlow -misa-spec=20191213" } */ + +int main () { + +#ifndef __riscv_arch_test +#error "__riscv_arch_test" +#endif + +#if __riscv_xlen != 64 +#error "__riscv_xlen" +#endif + +#if !defined(__riscv_i) || (__riscv_i != (2 * 1000 * 1000 + 1 * 1000)) +#error "__riscv_i" +#endif + +#if !defined(__riscv_c) || (__riscv_c != (2 * 1000 * 1000)) +#error "__riscv_c" +#endif + +#if defined(__riscv_e) +#error "__riscv_e" +#endif + +#if !defined(__riscv_a) || (__riscv_a != (2 * 1000 * 1000 + 1 * 1000)) +#error "__riscv_a" +#endif + +#if !defined(__riscv_m) || (__riscv_m != (2 * 1000 * 1000)) +#error "__riscv_m" +#endif + +#if !defined(__riscv_f) || (__riscv_f != (2 * 1000 * 1000 + 2 * 1000)) +#error "__riscv_f" +#endif + +#if !defined(__riscv_d) || (__riscv_d != (2 * 1000 * 1000 + 2 * 1000)) +#error "__riscv_d" +#endif + +#if !defined(__riscv_svinval) +#error "__riscv_svinval" +#endif + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/predef-24.c b/gcc/testsuite/gcc.target/riscv/predef-24.c new file mode 100644 index 00000000000..2b51a19eacd --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/predef-24.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_svnapot -mabi=lp64 -mcmodel=medlow -misa-spec=20191213" } */ + +int main () { + +#ifndef __riscv_arch_test +#error "__riscv_arch_test" +#endif + +#if __riscv_xlen != 64 +#error "__riscv_xlen" +#endif + +#if !defined(__riscv_i) || (__riscv_i != (2 * 1000 * 1000 + 1 * 1000)) +#error "__riscv_i" +#endif + +#if !defined(__riscv_c) || (__riscv_c != (2 * 1000 * 1000)) +#error "__riscv_c" +#endif + +#if defined(__riscv_e) +#error "__riscv_e" +#endif + +#if !defined(__riscv_a) || (__riscv_a != (2 * 1000 * 1000 + 1 * 1000)) +#error "__riscv_a" +#endif + +#if !defined(__riscv_m) || (__riscv_m != (2 * 1000 * 1000)) +#error "__riscv_m" +#endif + +#if !defined(__riscv_f) || (__riscv_f != (2 * 1000 * 1000 + 2 * 1000)) +#error "__riscv_f" +#endif + +#if !defined(__riscv_d) || (__riscv_d != (2 * 1000 * 1000 + 2 * 1000)) +#error "__riscv_d" +#endif + +#if !defined(__riscv_svnapot) +#error "__riscv_svnapot" +#endif + + return 0; +}