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 <taking@google.com>
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Mark D Ryan 2024-08-23 08:17:25 +00:00 committed by Gopher Robot
parent 5d06d165ff
commit 26aa8d6eb8
2 changed files with 14 additions and 0 deletions

View File

@ -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.

12
src/runtime/asm_riscv64.h Normal file
View File

@ -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