From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id 9065C384F6C1 for ; Fri, 18 Nov 2022 04:29:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9065C384F6C1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pj1-x102e.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso3716648pjt.0 for ; Thu, 17 Nov 2022 20:29:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:from:to:cc:subject:date:message-id :reply-to; bh=YhQh452kU72YQDXZlxszELYUpF5Pd1sCiFI5yzw/iDw=; b=dM0eDXlM9FQ4ZthQGilz5dtJXxp8xbOuDMPN/RiM0DMqVn19U6lcq0uPH5NRuobwsG dZEAWVRzUZEgXv98Od/EX3a96hKobNTcHUoFwubNAjaIQE7DSaCg/y3dS3Qmlx8qwABe gPt4IIvywsJG1KlTUwrmCv1ELR2dcwdseP4Q1f8K2iml5P6knpqsiedoJ95svzqaWfR8 +QQZgvtgP6wE+KNxKBWg2BIqhTrY+rO0S57JC3puEQtDkkdk17KscVZ2437drq5USZRb XYtk4MrdW7/3VcPgbQGvs7AhBSwr2M7mBdO0zqoMhrsdRJbUwI1w6pv2nyPvVEY9HsEr Urlg== 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:to:from:cc :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YhQh452kU72YQDXZlxszELYUpF5Pd1sCiFI5yzw/iDw=; b=B/GX4dgFRkAfjp6O644XpsXhUkLEuY5o08flNgms5KkbVrGvJcg69vx0MWAWxAbTuL FYIwHPxgvCem6KN3RKNvY34PFUf5qTIeh+bLeOKObnjg5bxNVsptngJ3VnMCyg8apQf9 0Kt15N0G4xaTkJ+smDgzf/EacRwgGsBGXSwejHlAuS1em0p6C5vxWoKgYQ/EtyNXKmtM rZRA4HwJ01LYUFp1+1HW8T49Y2Df/6Kbu1KTA5aS5svxJnMlX3kvOJcF3ialec7jtsYw Yk6NC3QF9YzwJd9hYGnZE+LvCH69WKeQfsHbIROLBkUZ8Azbr1kq1EQYxDdgZQs21IOQ zBEQ== X-Gm-Message-State: ANoB5pnmmE1TKXt0PxrSeSXCKC6c7VZefqQPN8Oos+ngpIyDGswTSUDq 5fLjMxAkcrLuDWfRrHbwzN4Pb3h5EfDKfg== X-Google-Smtp-Source: AA0mqf5AVc6XoDFVcCoxby16BQ2COieDI81ApV0dVCdzxbiKFXNVxGN8O7W2bvALm2S5SZWmhL4vuw== X-Received: by 2002:a17:903:4284:b0:187:edc:82f3 with SMTP id ju4-20020a170903428400b001870edc82f3mr5747829plb.161.1668745750341; Thu, 17 Nov 2022 20:29:10 -0800 (PST) Received: from localhost ([50.221.140.188]) by smtp.gmail.com with ESMTPSA id s1-20020a170902c64100b00188f0c641easm2249961pls.225.2022.11.17.20.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 20:29:09 -0800 (PST) Date: Thu, 17 Nov 2022 20:29:09 -0800 (PST) X-Google-Original-Date: Thu, 17 Nov 2022 20:27:59 PST (-0800) Subject: Re: [PATCH] RISC-V: Add the Zihpm and Zicntr extensions In-Reply-To: CC: gcc-patches@gcc.gnu.org, philipp.tomsich@vrull.eu, kito.cheng@sifive.com, Vedvyas Shanbhogue , nelson@rivosinc.com, jeffreyalaw@gmail.com From: Palmer Dabbelt To: christoph.muellner@vrull.eu Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,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 List-Id: On Thu, 17 Nov 2022 18:14:18 PST (-0800), christoph.muellner@vrull.eu wrote: > On Wed, Nov 9, 2022 at 4:01 AM Palmer Dabbelt wrote: > >> These extensions were recently frozen [1]. As per Andrew's post [2] >> we're meant to ignore these in software, this just adds them to the list >> of allowed extensions and otherwise ignores them. I added these under >> SPEC_CLASS_NONE even though the PDF lists them as 20190614 because it >> seems pointless to add another spec class just to accept two extensions >> we then ignore. >> >> 1: >> https://groups.google.com/a/groups.riscv.org/g/isa-dev/c/HZGoqP1eyps/m/GTNKRLJoAQAJ >> 2: >> https://groups.google.com/a/groups.riscv.org/g/sw-dev/c/QKjQhChrq9Q/m/7gqdkctgAgAJ >> >> gcc/ChangeLog >> >> * common/config/riscv/riscv-common.cc: Add Zihpm and Zicnttr >> extensions. >> >> --- >> >> These deserves documentation, a test case, and a NEWS entry. I didn't >> write those yet because it's not super clear this is the way we wanted >> to go, though: just flat out ignoring the ISA feels like the wrong thing >> to do, but the guidance here is pretty clear. Still feels odd, though. >> > > > We already have the infrastructure in GAS to check the CSR numbers. > It is an optional feature, but it is here and working. > We follow the guidance in the default configuration (CSR checking needs to > be turned on). > As long as we want to keep this infrastructure, there is no question if we > should continue > to support new extensions as required by this feature: > We have to because everything else will lead to a broken feature. > > The question if CSR checking in GAS should be removed or not does not have > to be > answered right now if there is doubt about making the wrong decision. > > Additionally, I fully agree that we can not ignore unknown extensions. > We must report an unknown extension in the march string to the user. > And even without CSR checking, GCC needs to be aware of all extensions > (e.g. for possible future support of -march=native). > > So I think this patch should go in (together with a test). > > That's why I also sent something similar for Smaia and Ssaia: > https://gcc.gnu.org/pipermail/gcc-patches/2022-November/606640.html That's a different problem: with Zihpm and Zicntr we're ignoring known extensions, so we can pretend the ISA didn't make a backwards incompatible change. That requires explicitly ignoring words in the ISA manual, which is something we've tried very hard to do in the past -- maybe less so these days, but IMO it's still worth calling out (see the __builtin_riscv_pause() doc patch, for example). > BR > Christoph > > > > > >> We've also still got an open discussion on how we want to handle -march >> going forwards that's pretty relevant here, so I figured it'd be best to >> send this out sooner rather than later as it's sort of related. >> --- >> gcc/common/config/riscv/riscv-common.cc | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/gcc/common/config/riscv/riscv-common.cc >> b/gcc/common/config/riscv/riscv-common.cc >> index 4b7f777c103..72981f05ac7 100644 >> --- a/gcc/common/config/riscv/riscv-common.cc >> +++ b/gcc/common/config/riscv/riscv-common.cc >> @@ -190,6 +190,9 @@ static const struct riscv_ext_version >> riscv_ext_version_table[] = >> {"zicbom",ISA_SPEC_CLASS_NONE, 1, 0}, >> {"zicbop",ISA_SPEC_CLASS_NONE, 1, 0}, >> >> + {"zicntr", ISA_SPEC_CLASS_NONE, 2, 0}, >> + {"zihpm", ISA_SPEC_CLASS_NONE, 2, 0}, >> + >> {"zk", ISA_SPEC_CLASS_NONE, 1, 0}, >> {"zkn", ISA_SPEC_CLASS_NONE, 1, 0}, >> {"zks", ISA_SPEC_CLASS_NONE, 1, 0}, >> -- >> 2.38.1 >> >>