Skip to content

Commit 664aeba

Browse files
markdryan4a6f656c
authored andcommitted
cmd/go: add rva23u64 as a valid value for GORISCV64
The RVA23 profile was ratified on the 21st of October 2024. https://riscv.org/announcements/2024/10/risc-v-announces-ratification-of-the-rva23-profile-standard/ Now that it's ratified we can add rva23u64 as a valid value for the GORISCV64 environment variable. This will allow the compiler and assembler to generate instructions made mandatory by the new profile without a runtime check. Examples of such instructions include those introduced by the Vector and Zicond extensions. Setting GORISCV64=rva23u64 defines the riscv64.rva20u64, riscv64.rva22u64 and riscv64.rva23u64 build tags, sets the internal variable buildcfg.GORISCV64 to 23 and defines the macros GORISCV64_rva23u64, hasV, hasZba, hasZbb, hasZbs, hasZfa, and hasZicond for use in assembly language code. Updates #61476 Change-Id: I7641c23084fa52891c9a18df58f4013cb6597d88 Reviewed-on: https://go-review.googlesource.com/c/go/+/633417 Reviewed-by: Carlos Amedee <[email protected]> Reviewed-by: Jorropo <[email protected]> Reviewed-by: Joel Sing <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Meng Zhuo <[email protected]>
1 parent 842e4b5 commit 664aeba

File tree

7 files changed

+34
-9
lines changed

7 files changed

+34
-9
lines changed

src/cmd/go/alldocs.go

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/go/internal/help/helpdoc.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,9 @@ Architecture-specific environment variables:
646646
Valid values are power8 (default), power9, power10.
647647
GORISCV64
648648
For GOARCH=riscv64, the RISC-V user-mode application profile for which
649-
to compile. Valid values are rva20u64 (default), rva22u64.
649+
to compile. Valid values are rva20u64 (default), rva22u64, rva23u64.
650650
See https://github.com/riscv/riscv-profiles/blob/main/src/profiles.adoc
651+
and https://github.com/riscv/riscv-profiles/blob/main/src/rva23-profile.adoc
651652
GOWASM
652653
For GOARCH=wasm, comma-separated list of experimental WebAssembly features to use.
653654
Valid values are satconv, signext.
@@ -951,8 +952,8 @@ The defined architecture feature build tags are:
951952
(or ppc64le.power8, ppc64le.power9, and ppc64le.power10)
952953
feature build tags.
953954
- For GOARCH=riscv64,
954-
GORISCV64=rva20u64 and rva22u64 correspond to the riscv64.rva20u64
955-
and riscv64.rva22u64 build tags.
955+
GORISCV64=rva20u64, rva22u64 and rva23u64 correspond to the riscv64.rva20u64,
956+
riscv64.rva22u64 and riscv64.rva23u64 build tags.
956957
- For GOARCH=wasm, GOWASM=satconv and signext
957958
correspond to the wasm.satconv and wasm.signext feature build tags.
958959

src/cmd/go/testdata/script/tooltags.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,15 @@ env GORISCV64=rva22u64
5050
go list -f '{{context.ToolTags}}'
5151
stdout 'riscv64.rva20u64 riscv64.rva22u64'
5252

53+
env GOARCH=riscv64
54+
env GORISCV64=rva23u64
55+
go list -f '{{context.ToolTags}}'
56+
stdout 'riscv64.rva20u64 riscv64.rva22u64 riscv64.rva23u64'
57+
5358
env GOARCH=riscv64
5459
env GORISCV64=rva22
5560
! go list -f '{{context.ToolTags}}'
56-
stderr 'go: invalid GORISCV64: must be rva20u64, rva22u64'
61+
stderr 'go: invalid GORISCV64: must be rva20u64, rva22u64, rva23u64'
5762

5863
env GOARCH=riscv64
5964
env GORISCV64=

src/cmd/internal/testdir/testdir_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@ var (
14891489
"ppc64x": {}, // A pseudo-arch representing both ppc64 and ppc64le
14901490
"s390x": {},
14911491
"wasm": {},
1492-
"riscv64": {"GORISCV64", "rva20u64", "rva22u64"},
1492+
"riscv64": {"GORISCV64", "rva20u64", "rva22u64", "rva23u64"},
14931493
}
14941494
)
14951495

src/internal/buildcfg/cfg.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,10 @@ func goriscv64() int {
307307
return 20
308308
case "rva22u64":
309309
return 22
310+
case "rva23u64":
311+
return 23
310312
}
311-
Error = fmt.Errorf("invalid GORISCV64: must be rva20u64, rva22u64")
313+
Error = fmt.Errorf("invalid GORISCV64: must be rva20u64, rva22u64, rva23u64")
312314
v := DefaultGORISCV64[len("rva"):]
313315
i := strings.IndexFunc(v, func(r rune) bool {
314316
return r < '0' || r > '9'
@@ -441,6 +443,9 @@ func gogoarchTags() []string {
441443
if GORISCV64 >= 22 {
442444
list = append(list, GOARCH+"."+"rva22u64")
443445
}
446+
if GORISCV64 >= 23 {
447+
list = append(list, GOARCH+"."+"rva23u64")
448+
}
444449
return list
445450
case "wasm":
446451
var list []string

src/internal/buildcfg/cfg_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ func TestConfigFlags(t *testing.T) {
3232
if goriscv64() != 22 {
3333
t.Errorf("Wrong parsing of RISCV64=rva22u64")
3434
}
35+
os.Setenv("GORISCV64", "rva23u64")
36+
if goriscv64() != 23 {
37+
t.Errorf("Wrong parsing of RISCV64=rva23u64")
38+
}
3539
Error = nil
3640
os.Setenv("GORISCV64", "rva22")
3741
if _ = goriscv64(); Error == nil {

src/runtime/asm_riscv64.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,12 @@
1010
#define hasZbb
1111
#define hasZbs
1212
#endif
13+
14+
#ifdef GORISCV64_rva23u64
15+
#define hasV
16+
#define hasZba
17+
#define hasZbb
18+
#define hasZbs
19+
#define hasZfa
20+
#define hasZicond
21+
#endif

0 commit comments

Comments
 (0)