From 26aa8d6eb8faf05bbbb87a4f531e3e0fe4feed44 Mon Sep 17 00:00:00 2001 From: Mark D Ryan Date: Fri, 23 Aug 2024 08:17:25 +0000 Subject: [PATCH] runtime: add asm_riscv64.h asm_riscv64.h will be used to define macros for each riscv64 extension that is not part of the rva20u64 base profile but that the _riscv64.s assembly files are allowed to use because the user has specified a more capable profile in the GORISCV64 variable. This will allow us, for example, to test for the hasZba macro in those assembly files instead of the GORISCV64_rva22u64 macro before using a Zba instruction. This is important as it means that in the future when we add support for new profiles that support Zba, e.g., rva23u64, we only need to update asm_riscv64.h to indicate rva23u64 supports Zba. We will not need to update every assembly language file that already uses Zba instructions. Updates #61476 Change-Id: I83abfeb20d08a87ac8ea88f4d8a93437f0631353 Reviewed-on: https://go-review.googlesource.com/c/go/+/608255 Auto-Submit: Tim King Reviewed-by: Tim King Reviewed-by: Dmitri Shuralyov Reviewed-by: Meng Zhuo Reviewed-by: Joel Sing LUCI-TryBot-Result: Go LUCI --- src/cmd/dist/build.go | 2 ++ src/runtime/asm_riscv64.h | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 src/runtime/asm_riscv64.h diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index cd76446881..2c9ecdfa58 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -845,6 +845,8 @@ func runInstall(pkg string, ch chan struct{}) { pathf("%s/src/runtime/asm_ppc64x.h", goroot), 0) copyfile(pathf("%s/pkg/include/asm_amd64.h", goroot), pathf("%s/src/runtime/asm_amd64.h", goroot), 0) + copyfile(pathf("%s/pkg/include/asm_riscv64.h", goroot), + pathf("%s/src/runtime/asm_riscv64.h", goroot), 0) } // Generate any missing files; regenerate existing ones. diff --git a/src/runtime/asm_riscv64.h b/src/runtime/asm_riscv64.h new file mode 100644 index 0000000000..d4deb093a6 --- /dev/null +++ b/src/runtime/asm_riscv64.h @@ -0,0 +1,12 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Define features that are guaranteed to be supported by setting the GORISCV64 variable. +// If a feature is supported, there's no need to check it at runtime every time. + +#ifdef GORISCV64_rva22u64 +#define hasZba +#define hasZbb +#define hasZbs +#endif -- 2.48.1