From patchwork Tue Feb 7 00:16:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_M=C3=BCllner?= X-Patchwork-Id: 64390 Return-Path: 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 BE3733888C43 for ; Tue, 7 Feb 2023 00:18:46 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 3AF933858C60 for ; Tue, 7 Feb 2023 00:16:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3AF933858C60 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-wm1-x32e.google.com with SMTP id j29-20020a05600c1c1d00b003dc52fed235so10240156wms.1 for ; Mon, 06 Feb 2023 16:16:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W4ismAtBWb/CwuQ6RLImTVydg+v9Y4rq5yN1JVec2Bk=; b=YLVwij0Q7JLIECsVQkUkko4BxeUNo92ymCZtwfQIpBcys3hGs0NrkU42hQ5Y+nk8m4 p8LhwDTJKiNLnd9yYtZb5jjcuL2gT4Qm1nEsSw+gyC3EGLfF6ZFcSooubM+/JyVRBJoQ lX0YTMp+AHtKq0zZ2Mzj/DcCmpPQHs63Br7Nl0R1AHCa/QBKGE/kfxTvKPeByVXPaER2 e6knrEUdlV+n3HVCMsPWD4SqU8gjq1H1mYQ3xdfMmpmrwinuzIep/N19upgINPdDMC/+ hWSal+14C3KX/wwFILacba42VLbhqNkTaePdsHfnlOG/e4sDiyJnbQ33tjsvMx0pMKmy Lcmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W4ismAtBWb/CwuQ6RLImTVydg+v9Y4rq5yN1JVec2Bk=; b=hZqOUir+/YonCb/Be9ktW93cZHHRLhiADuYmq7WRRRdfgbT5udxirK/pOUbj2CDFGf mOhl87hDeEZ6qZtpShTk19xNNA9Dsp/Ie+ZDEAVbA9SjZBk6J2igAhLAqObo+U3s4sfF t+8XBDG40s64HyRSDbWC25iIQtHsMqSWD1MGZXP6UD8TMGjvGasbUX2DqQWox+54chWZ v3Wd3JblmRA2yt7yHWDQvSAVjrH375EQfPXzC+48sWp+8RC64oAHaEc07e5PDVdQ82gY x1AzYSKwj7iMSe79T8d5/tFp+rQ5/augGSw+zhF5EiWJ05Gf/7Q+6K61fp0dUyrnxyDt xbAg== X-Gm-Message-State: AO0yUKUnFWN6zAL3V+D7HSuUiBuxmJXvN/ySrr1jouDOYB9Dy6Qv8J/H +5fYFi+szRk9DSVDApNLUy/U9SufnFtwMlcM X-Google-Smtp-Source: AK7set9n2tFF+tVMr/nsI4hlQPWZBXvXEiM5lGcaIIjsA9DluP4Obd9WKuyvQNTu+EHlhBVuJqDLXA== X-Received: by 2002:a05:600c:18a6:b0:3dd:1a8b:7374 with SMTP id x38-20020a05600c18a600b003dd1a8b7374mr1342444wmp.5.1675728997491; Mon, 06 Feb 2023 16:16:37 -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 f1-20020a1cc901000000b003df14531724sm16862050wmb.21.2023.02.06.16.16.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 16:16:37 -0800 (PST) From: Christoph Muellner To: libc-alpha@sourceware.org, Palmer Dabbelt , Darius Rad , Andrew Waterman , DJ Delorie , Vineet Gupta , Kito Cheng , Jeff Law , Philipp Tomsich , Heiko Stuebner Cc: =?utf-8?q?Christoph_M=C3=BCllner?= Subject: [RFC PATCH 05/19] riscv: Introduction of ISA extensions Date: Tue, 7 Feb 2023 01:16:04 +0100 Message-Id: <20230207001618.458947-6-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207001618.458947-1-christoph.muellner@vrull.eu> References: <20230207001618.458947-1-christoph.muellner@vrull.eu> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_MANYTO, 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" From: Christoph Müllner The RISC-V ISA consists of a base ISA and a multitude of optional ISA extensions. This patch introduces some of them, which are expected to be relevant in the near future for ifunc-based optimizations in glibc: * Base (i or e) * M * A * F * D * C * Zicsr * Zifencei * G * Zihintpause * zicbom * zicbop * zicboz * zawrs * zba * zbb * zbc * zbs Given the DSL-like definition it should be trivial to extend the list. Signed-off-by: Christoph Müllner --- sysdeps/unix/sysv/linux/riscv/hart-features.h | 27 +++++++ .../unix/sysv/linux/riscv/isa-extensions.def | 72 +++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/riscv/isa-extensions.def diff --git a/sysdeps/unix/sysv/linux/riscv/hart-features.h b/sysdeps/unix/sysv/linux/riscv/hart-features.h index a417cbc326..dd94685676 100644 --- a/sysdeps/unix/sysv/linux/riscv/hart-features.h +++ b/sysdeps/unix/sysv/linux/riscv/hart-features.h @@ -19,8 +19,35 @@ #ifndef _CPU_FEATURES_RISCV_H #define _CPU_FEATURES_RISCV_H +#define IS_RV32() \ + (GLRO (dl_riscv_hart_features).xlen == 32) + +#define IS_RV64() \ + (GLRO (dl_riscv_hart_features).xlen == 64) + +#define HAVE_RV(E) \ + (GLRO (dl_riscv_hart_features).have_ ## E == 1) + +#define HAVE_CBOM_BLOCKSIZE(n) \ + (GLRO (dl_riscv_hart_features).cbom_blocksize == n) + +#define HAVE_CBOZ_BLOCKSIZE(n) \ + (GLRO (dl_riscv_hart_features).cboz_blocksize == n) + struct hart_features { + const char* rt_march; + unsigned xlen; +#define ISA_EXT(e) \ + unsigned have_##e:1; +#define ISA_EXT_GROUP(g, ...) \ + unsigned have_##g:1; +#include "isa-extensions.def" + + const char* rt_cbom_blocksize; + unsigned cbom_blocksize; + const char* rt_cboz_blocksize; + unsigned cboz_blocksize; }; #endif /* _CPU_FEATURES_RISCV_H */ diff --git a/sysdeps/unix/sysv/linux/riscv/isa-extensions.def b/sysdeps/unix/sysv/linux/riscv/isa-extensions.def new file mode 100644 index 0000000000..eb05823998 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/isa-extensions.def @@ -0,0 +1,72 @@ +/* ISA extensions of RISC-V. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* Define RISC-V ISA extension. */ +#ifndef ISA_EXT +# define ISA_EXT(e) +#endif + +/* Define RISC-V ISA extension group. */ +#ifndef ISA_EXT_GROUP +# define ISA_EXT_GROUP(...) +#endif + +/* + * Here are the ordering rules of extension naming defined by RISC-V + * specification : + * 1. All extensions should be separated from other multi-letter extensions + * by an underscore. + * 2. The first letter following the 'Z' conventionally indicates the most + * closely related alphabetical extension category, IMAFDQLCBKJTPVH. + * If multiple 'Z' extensions are named, they should be ordered first + * by category, then alphabetically within a category. + * 3. Standard supervisor-level extensions (starts with 'S') should be + * listed after standard unprivileged extensions. If multiple + * supervisor-level extensions are listed, they should be ordered + * alphabetically. + * 4. Non-standard extensions (starts with 'X') must be listed after all + * standard extensions. They must be separated from other multi-letter + * extensions by an underscore. + */ + +ISA_EXT (i) +ISA_EXT (e) + +ISA_EXT (m) +ISA_EXT (a) +ISA_EXT (f) +ISA_EXT (d) +ISA_EXT (c) +ISA_EXT (zicsr) +ISA_EXT (zifencei) +ISA_EXT_GROUP (g, i, m, a, f, d, zicsr, zifencei) + +ISA_EXT (zicbom) +ISA_EXT (zicbop) +ISA_EXT (zicboz) +ISA_EXT (zihintpause) + +ISA_EXT (zawrs) + +ISA_EXT (zba) +ISA_EXT (zbb) +ISA_EXT (zbc) +ISA_EXT (zbs) + +#undef ISA_EXT +#undef ISA_EXT_GROUP