]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: add asm_riscv64.h
authorMark D Ryan <markdryan@rivosinc.com>
Fri, 23 Aug 2024 08:17:25 +0000 (08:17 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 11 Sep 2024 16:49:16 +0000 (16:49 +0000)
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>

src/cmd/dist/build.go
src/runtime/asm_riscv64.h [new file with mode: 0644]

index cd764468813613a81ca5eeae23630f0681727767..2c9ecdfa5817e9ca3553f329a7bf3310ef6e2bf7 100644 (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.
diff --git a/src/runtime/asm_riscv64.h b/src/runtime/asm_riscv64.h
new file mode 100644 (file)
index 0000000..d4deb09
--- /dev/null
@@ -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