Message ID | 20221118021223.348112-1-christoph.muellner@vrull.eu |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 18CDA388D25B for <patchwork@sourceware.org>; Fri, 18 Nov 2022 02:12:46 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id 9284C3842313 for <gcc-patches@gcc.gnu.org>; Fri, 18 Nov 2022 02:12:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9284C3842313 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu Received: by mail-ed1-x530.google.com with SMTP id a5so5189724edb.11 for <gcc-patches@gcc.gnu.org>; Thu, 17 Nov 2022 18:12:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; 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=1puhCWYYlcNH+J4Sp9bR4gxPCDxxAPLygIQgBStlxLc=; b=o/3RD8N3knU250g2Td1J9irOu6gONEKlVUEZR0n0RKO2OQjdX2POSK0KG6gub3zTi2 zoxAZe9HOCdlu6/alUl/vFigRRO0hDdkL+FKOYipMxmUTJITNpCe9lRwUx6dzOpcVx8M fpj4OOi3ZgYP6MAF+HaklmEvWqNwWJFs08amj0WDl2izPbhnYejzxs6NZanNw7t2B1gN hfiZr4JBFwUtKXxuHOg7sWccd86X72wyDc+acOO3DKlaH/XN/C8I7FgA++zNH9KUCWf9 BrHDViovM4/rdyQPjyPuuXmTGkqEZglja9SOiE+g4ddSdBL2lAftwtz4Or/qA2MeA3ib xH+w== 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=1puhCWYYlcNH+J4Sp9bR4gxPCDxxAPLygIQgBStlxLc=; b=73QtTdBxwRIZwKmgTGv88fRoCmnRkp/dbe/t3Fhbxil6qdAPmQ3gb9BLt36DTNSjt1 9RMQBRnPFhAAca28XboZ81wMlRrVUJQzYInlt16XwofC2Q4bpJA1PQKCYIb4sSelfljj 8mbfAke7ph8XyXYyA1koeJ2NxyYMC2VLG0Fwah45EQkRbNXLHTvpQfCvyRSHUirZ6BRl 4aHZlfHT+VVAMYXaNPruLq7/XgQGFMjqO4oL/UzxReujiFRJnWZCrhHUiGnRFhwnmCy+ uZSifOhWV5KrclL0MXZryWk0MOp2Hx6gNpBV+7jNSL4SiaNMIfQTAVa7Gzu/S7K2T/zQ 5atw== X-Gm-Message-State: ANoB5plSNc96SKgPH9cjtAfz4L0qzG2rxkFr0Jsh6CpxGx5NGsxw67sk xKiNfyUGLTNGkxT9NJmRqY7BLub9ZfjvdFJj X-Google-Smtp-Source: AA0mqf7+4CRYSOy/bl7Ajga6Zo0cxlw+LL4d7Pl6e62rVLBbEI5CYEJAz9OIbxMqwp7B1uGspTPgQA== X-Received: by 2002:aa7:c3c2:0:b0:457:791d:8348 with SMTP id l2-20020aa7c3c2000000b00457791d8348mr4417192edr.306.1668737547194; Thu, 17 Nov 2022 18:12:27 -0800 (PST) Received: from beast.fritz.box (62-178-148-172.cable.dynamic.surfer.at. [62.178.148.172]) by smtp.gmail.com with ESMTPSA id ew5-20020a056402538500b004619f024864sm1186079edb.81.2022.11.17.18.12.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 18:12:26 -0800 (PST) From: Christoph Muellner <christoph.muellner@vrull.eu> To: gcc-patches@gcc.gnu.org, Kito Cheng <kito.cheng@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Philipp Tomsich <philipp.tomsich@vrull.eu>, Jeff Law <jeffreyalaw@gmail.com> Cc: =?utf-8?q?Christoph_M=C3=BCllner?= <christoph.muellner@vrull.eu> Subject: [PATCH] RISC-V: Add support for AIA ISA extensions (Ssaia and Smaia) Date: Fri, 18 Nov 2022 03:12:23 +0100 Message-Id: <20221118021223.348112-1-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
RISC-V: Add support for AIA ISA extensions (Ssaia and Smaia)
|
|
Commit Message
Christoph Muellner
Nov. 18, 2022, 2:12 a.m. UTC
From: Christoph Müllner <christoph.muellner@vrull.eu> This patch adds support for the two AIA ISA extensions Ssaia and Smaia. They are not relelvant for the compiler, but the assembler might want to validate the CSRs. Therefore, all this patch does is recognize the extension name, emit a feature macro (incl. a test). Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu> --- gcc/common/config/riscv/riscv-common.cc | 2 ++ gcc/testsuite/gcc.target/riscv/smaia.c | 13 +++++++++++++ gcc/testsuite/gcc.target/riscv/ssaia.c | 13 +++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/smaia.c create mode 100644 gcc/testsuite/gcc.target/riscv/ssaia.c
Comments
On Thu, 17 Nov 2022 18:12:23 PST (-0800), christoph.muellner@vrull.eu wrote: > From: Christoph Müllner <christoph.muellner@vrull.eu> > > This patch adds support for the two AIA ISA extensions Ssaia and Smaia. > They are not relelvant for the compiler, but the assembler might want > to validate the CSRs. Therefore, all this patch does is recognize the > extension name, emit a feature macro (incl. a test). This is pretty far in the weeds, but the AIA PDF says extension Smaia encompasses all added CSRs and all modifications to interrupt response behavior that the AIA specifies for a hart, over all privilege levels but only a subset of AIA has been frozen. I think that's fine, assuming we're decoupling ourselves from the ISA strings (and thus extension names). We just need to document it somewhere -- presumably invoke, but that doesn't document anything else yet so we don't really have a pattern to match. > Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu> > --- > gcc/common/config/riscv/riscv-common.cc | 2 ++ > gcc/testsuite/gcc.target/riscv/smaia.c | 13 +++++++++++++ > gcc/testsuite/gcc.target/riscv/ssaia.c | 13 +++++++++++++ > 3 files changed, 28 insertions(+) > create mode 100644 gcc/testsuite/gcc.target/riscv/smaia.c > create mode 100644 gcc/testsuite/gcc.target/riscv/ssaia.c > > diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc > index 4b7f777c103..674eded07b7 100644 > --- a/gcc/common/config/riscv/riscv-common.cc > +++ b/gcc/common/config/riscv/riscv-common.cc > @@ -219,6 +219,8 @@ static const struct riscv_ext_version riscv_ext_version_table[] = > > {"zmmul", ISA_SPEC_CLASS_NONE, 1, 0}, > > + {"smaia", ISA_SPEC_CLASS_NONE, 1, 0}, > + {"ssaia", ISA_SPEC_CLASS_NONE, 1, 0}, > {"svinval", ISA_SPEC_CLASS_NONE, 1, 0}, > {"svnapot", ISA_SPEC_CLASS_NONE, 1, 0}, > > diff --git a/gcc/testsuite/gcc.target/riscv/smaia.c b/gcc/testsuite/gcc.target/riscv/smaia.c > new file mode 100644 > index 00000000000..9ca80236245 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/riscv/smaia.c > @@ -0,0 +1,13 @@ > +/* { dg-do compile } */ > +/* { dg-options "-march=rv64gc_smaia" { target { rv64 } } } */ > +/* { dg-options "-march=rv32gc_smaia" { target { rv32 } } } */ > + > +#ifndef __riscv_smaia > +#error Feature macro not defined > +#endif > + > +int > +foo (int a) > +{ > + return a; > +} > diff --git a/gcc/testsuite/gcc.target/riscv/ssaia.c b/gcc/testsuite/gcc.target/riscv/ssaia.c > new file mode 100644 > index 00000000000..b20e0eb10f5 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/riscv/ssaia.c > @@ -0,0 +1,13 @@ > +/* { dg-do compile } */ > +/* { dg-options "-march=rv64gc_ssaia" { target { rv64 } } } */ > +/* { dg-options "-march=rv32gc_ssaia" { target { rv32 } } } */ > + > +#ifndef __riscv_ssaia > +#error Feature macro not defined > +#endif > + > +int > +foo (int a) > +{ > + return a; > +}
On Fri, Nov 18, 2022 at 6:09 AM Palmer Dabbelt <palmer@dabbelt.com> wrote: > On Thu, 17 Nov 2022 18:12:23 PST (-0800), christoph.muellner@vrull.eu > wrote: > > From: Christoph Müllner <christoph.muellner@vrull.eu> > > > > This patch adds support for the two AIA ISA extensions Ssaia and Smaia. > > They are not relelvant for the compiler, but the assembler might want > > to validate the CSRs. Therefore, all this patch does is recognize the > > extension name, emit a feature macro (incl. a test). > > This is pretty far in the weeds, but the AIA PDF says > > extension Smaia encompasses all added CSRs and all modifications to > interrupt response behavior that the AIA specifies for a hart, over > all privilege levels > > but only a subset of AIA has been frozen. I think that's fine, assuming > we're decoupling ourselves from the ISA strings (and thus extension > names). We just need to document it somewhere -- presumably invoke, but > that doesn't document anything else yet so we don't really have a > pattern to match. > Thanks for highlighting this! We could model this such that Smaia implies Ssaia. Since the tool's interpretation of these extensions is "availability of extension's CSRs", this should work. But it is mostly irrelevant for GCC, as Binutils does the CSR checking, and we need to model it there. I see what you mean with the "subset of AIA has been frozen". I would expect that the draft chapters ("Duo-PLIC" and "IOMMU Support") will introduce new CSRs in the future. They might get included in separate extensions, be available only if another extension is enabled (like the hypervisor CSRs), or they will be put into the existing Smaia and Ssaia extensions. The last case is problematic, as it would change the behavior of the CSR checker. We could therefore document that the CSR checker strictly follows the latest specs and that changing behavior is possible for that reason. Not perfect, but reasonable and a method to permanently solve the recurring CSR discussions. > > > Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu> > > --- > > gcc/common/config/riscv/riscv-common.cc | 2 ++ > > gcc/testsuite/gcc.target/riscv/smaia.c | 13 +++++++++++++ > > gcc/testsuite/gcc.target/riscv/ssaia.c | 13 +++++++++++++ > > 3 files changed, 28 insertions(+) > > create mode 100644 gcc/testsuite/gcc.target/riscv/smaia.c > > create mode 100644 gcc/testsuite/gcc.target/riscv/ssaia.c > > > > diff --git a/gcc/common/config/riscv/riscv-common.cc > b/gcc/common/config/riscv/riscv-common.cc > > index 4b7f777c103..674eded07b7 100644 > > --- a/gcc/common/config/riscv/riscv-common.cc > > +++ b/gcc/common/config/riscv/riscv-common.cc > > @@ -219,6 +219,8 @@ static const struct riscv_ext_version > riscv_ext_version_table[] = > > > > {"zmmul", ISA_SPEC_CLASS_NONE, 1, 0}, > > > > + {"smaia", ISA_SPEC_CLASS_NONE, 1, 0}, > > + {"ssaia", ISA_SPEC_CLASS_NONE, 1, 0}, > > {"svinval", ISA_SPEC_CLASS_NONE, 1, 0}, > > {"svnapot", ISA_SPEC_CLASS_NONE, 1, 0}, > > > > diff --git a/gcc/testsuite/gcc.target/riscv/smaia.c > b/gcc/testsuite/gcc.target/riscv/smaia.c > > new file mode 100644 > > index 00000000000..9ca80236245 > > --- /dev/null > > +++ b/gcc/testsuite/gcc.target/riscv/smaia.c > > @@ -0,0 +1,13 @@ > > +/* { dg-do compile } */ > > +/* { dg-options "-march=rv64gc_smaia" { target { rv64 } } } */ > > +/* { dg-options "-march=rv32gc_smaia" { target { rv32 } } } */ > > + > > +#ifndef __riscv_smaia > > +#error Feature macro not defined > > +#endif > > + > > +int > > +foo (int a) > > +{ > > + return a; > > +} > > diff --git a/gcc/testsuite/gcc.target/riscv/ssaia.c > b/gcc/testsuite/gcc.target/riscv/ssaia.c > > new file mode 100644 > > index 00000000000..b20e0eb10f5 > > --- /dev/null > > +++ b/gcc/testsuite/gcc.target/riscv/ssaia.c > > @@ -0,0 +1,13 @@ > > +/* { dg-do compile } */ > > +/* { dg-options "-march=rv64gc_ssaia" { target { rv64 } } } */ > > +/* { dg-options "-march=rv32gc_ssaia" { target { rv32 } } } */ > > + > > +#ifndef __riscv_ssaia > > +#error Feature macro not defined > > +#endif > > + > > +int > > +foo (int a) > > +{ > > + return a; > > +} >
On Fri, Nov 18, 2022 at 10:08 AM Christoph Müllner <christoph.muellner@vrull.eu> wrote: > > > > On Fri, Nov 18, 2022 at 6:09 AM Palmer Dabbelt <palmer@dabbelt.com> wrote: >> >> On Thu, 17 Nov 2022 18:12:23 PST (-0800), christoph.muellner@vrull.eu wrote: >> > From: Christoph Müllner <christoph.muellner@vrull.eu> >> > >> > This patch adds support for the two AIA ISA extensions Ssaia and Smaia. >> > They are not relelvant for the compiler, but the assembler might want >> > to validate the CSRs. Therefore, all this patch does is recognize the >> > extension name, emit a feature macro (incl. a test). >> >> This is pretty far in the weeds, but the AIA PDF says >> >> extension Smaia encompasses all added CSRs and all modifications to >> interrupt response behavior that the AIA specifies for a hart, over >> all privilege levels >> >> but only a subset of AIA has been frozen. I think that's fine, assuming >> we're decoupling ourselves from the ISA strings (and thus extension >> names). We just need to document it somewhere -- presumably invoke, but >> that doesn't document anything else yet so we don't really have a >> pattern to match. > > > Thanks for highlighting this! > We could model this such that Smaia implies Ssaia. > Since the tool's interpretation of these extensions is "availability of extension's CSRs", > this should work. > But it is mostly irrelevant for GCC, as Binutils does the CSR checking, and we need > to model it there. > > I see what you mean with the "subset of AIA has been frozen". > I would expect that the draft chapters ("Duo-PLIC" and "IOMMU Support") will > introduce new CSRs in the future. They might get included in separate extensions, > be available only if another extension is enabled (like the hypervisor CSRs), or > they will be put into the existing Smaia and Ssaia extensions. > The last case is problematic, as it would change the behavior of the CSR checker. > We could therefore document that the CSR checker strictly follows the latest > specs and that changing behavior is possible for that reason. > Not perfect, but reasonable and a method to permanently solve the recurring > CSR discussions. Palmer, since you did not respond since 9 days, I tried to guess what you want to have documented and made a change in invoke.texi: https://gcc.gnu.org/pipermail/gcc-patches/2022-November/607326.html The Binutils patch landed already: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ac8df5a1921904b3928429e696ad8b40c612f829 > > > > >> >> >> > Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu> >> > --- >> > gcc/common/config/riscv/riscv-common.cc | 2 ++ >> > gcc/testsuite/gcc.target/riscv/smaia.c | 13 +++++++++++++ >> > gcc/testsuite/gcc.target/riscv/ssaia.c | 13 +++++++++++++ >> > 3 files changed, 28 insertions(+) >> > create mode 100644 gcc/testsuite/gcc.target/riscv/smaia.c >> > create mode 100644 gcc/testsuite/gcc.target/riscv/ssaia.c >> > >> > diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc >> > index 4b7f777c103..674eded07b7 100644 >> > --- a/gcc/common/config/riscv/riscv-common.cc >> > +++ b/gcc/common/config/riscv/riscv-common.cc >> > @@ -219,6 +219,8 @@ static const struct riscv_ext_version riscv_ext_version_table[] = >> > >> > {"zmmul", ISA_SPEC_CLASS_NONE, 1, 0}, >> > >> > + {"smaia", ISA_SPEC_CLASS_NONE, 1, 0}, >> > + {"ssaia", ISA_SPEC_CLASS_NONE, 1, 0}, >> > {"svinval", ISA_SPEC_CLASS_NONE, 1, 0}, >> > {"svnapot", ISA_SPEC_CLASS_NONE, 1, 0}, >> > >> > diff --git a/gcc/testsuite/gcc.target/riscv/smaia.c b/gcc/testsuite/gcc.target/riscv/smaia.c >> > new file mode 100644 >> > index 00000000000..9ca80236245 >> > --- /dev/null >> > +++ b/gcc/testsuite/gcc.target/riscv/smaia.c >> > @@ -0,0 +1,13 @@ >> > +/* { dg-do compile } */ >> > +/* { dg-options "-march=rv64gc_smaia" { target { rv64 } } } */ >> > +/* { dg-options "-march=rv32gc_smaia" { target { rv32 } } } */ >> > + >> > +#ifndef __riscv_smaia >> > +#error Feature macro not defined >> > +#endif >> > + >> > +int >> > +foo (int a) >> > +{ >> > + return a; >> > +} >> > diff --git a/gcc/testsuite/gcc.target/riscv/ssaia.c b/gcc/testsuite/gcc.target/riscv/ssaia.c >> > new file mode 100644 >> > index 00000000000..b20e0eb10f5 >> > --- /dev/null >> > +++ b/gcc/testsuite/gcc.target/riscv/ssaia.c >> > @@ -0,0 +1,13 @@ >> > +/* { dg-do compile } */ >> > +/* { dg-options "-march=rv64gc_ssaia" { target { rv64 } } } */ >> > +/* { dg-options "-march=rv32gc_ssaia" { target { rv32 } } } */ >> > + >> > +#ifndef __riscv_ssaia >> > +#error Feature macro not defined >> > +#endif >> > + >> > +int >> > +foo (int a) >> > +{ >> > + return a; >> > +}
diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 4b7f777c103..674eded07b7 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -219,6 +219,8 @@ static const struct riscv_ext_version riscv_ext_version_table[] = {"zmmul", ISA_SPEC_CLASS_NONE, 1, 0}, + {"smaia", ISA_SPEC_CLASS_NONE, 1, 0}, + {"ssaia", ISA_SPEC_CLASS_NONE, 1, 0}, {"svinval", ISA_SPEC_CLASS_NONE, 1, 0}, {"svnapot", ISA_SPEC_CLASS_NONE, 1, 0}, diff --git a/gcc/testsuite/gcc.target/riscv/smaia.c b/gcc/testsuite/gcc.target/riscv/smaia.c new file mode 100644 index 00000000000..9ca80236245 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/smaia.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_smaia" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_smaia" { target { rv32 } } } */ + +#ifndef __riscv_smaia +#error Feature macro not defined +#endif + +int +foo (int a) +{ + return a; +} diff --git a/gcc/testsuite/gcc.target/riscv/ssaia.c b/gcc/testsuite/gcc.target/riscv/ssaia.c new file mode 100644 index 00000000000..b20e0eb10f5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/ssaia.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_ssaia" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_ssaia" { target { rv32 } } } */ + +#ifndef __riscv_ssaia +#error Feature macro not defined +#endif + +int +foo (int a) +{ + return a; +}