aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJoel Sing <joel@sing.id.au>2024-02-08 13:54:10 +1100
committerJoel Sing <joel@sing.id.au>2024-03-07 14:57:07 +0000
commit997636760e2d981bb2f5ba486e0702e60a07ba16 (patch)
treef4272eb6f8f4bd67d8b8c73e857f09233419a412 /test
parent58052fe8e707cc0285cffb239bc7a5343243e316 (diff)
downloadgo-997636760e2d981bb2f5ba486e0702e60a07ba16.tar.gz
go-997636760e2d981bb2f5ba486e0702e60a07ba16.zip
cmd/compile,cmd/internal/obj: provide rotation pseudo-instructions for riscv64
Provide and use rotation pseudo-instructions for riscv64. The RISC-V bitmanip extension adds support for hardware rotation instructions in the form of ROL, ROLW, ROR, RORI, RORIW and RORW. These are easily implemented in the assembler as pseudo-instructions for CPUs that do not support the bitmanip extension. This approach provides a number of advantages, including reducing the rewrite rules needed in the compiler, simplifying codegen tests and most importantly, allowing these instructions to be used in assembly (for example, riscv64 optimised versions of SHA-256 and SHA-512). When bitmanip support is added, these instruction sequences can simply be replaced with a single instruction if permitted by the GORISCV64 profile. Change-Id: Ia23402e1a82f211ac760690deb063386056ae1fa Reviewed-on: https://go-review.googlesource.com/c/go/+/565015 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: M Zhuo <mengzhuo1203@gmail.com> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Joel Sing <joel@sing.id.au>
Diffstat (limited to 'test')
-rw-r--r--test/codegen/rotate.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/test/codegen/rotate.go b/test/codegen/rotate.go
index 109e55763c..121ce4cc0a 100644
--- a/test/codegen/rotate.go
+++ b/test/codegen/rotate.go
@@ -18,7 +18,7 @@ func rot64(x uint64) uint64 {
// amd64:"ROLQ\t[$]7"
// ppc64x:"ROTL\t[$]7"
// loong64: "ROTRV\t[$]57"
- // riscv64: "OR","SLLI","SRLI",-"AND"
+ // riscv64: "RORI\t[$]57"
a += x<<7 | x>>57
// amd64:"ROLQ\t[$]8"
@@ -26,7 +26,7 @@ func rot64(x uint64) uint64 {
// s390x:"RISBGZ\t[$]0, [$]63, [$]8, "
// ppc64x:"ROTL\t[$]8"
// loong64: "ROTRV\t[$]56"
- // riscv64: "OR","SLLI","SRLI",-"AND"
+ // riscv64: "RORI\t[$]56"
a += x<<8 + x>>56
// amd64:"ROLQ\t[$]9"
@@ -34,7 +34,7 @@ func rot64(x uint64) uint64 {
// s390x:"RISBGZ\t[$]0, [$]63, [$]9, "
// ppc64x:"ROTL\t[$]9"
// loong64: "ROTRV\t[$]55"
- // riscv64: "OR","SLLI","SRLI",-"AND"
+ // riscv64: "RORI\t[$]55"
a += x<<9 ^ x>>55
// amd64:"ROLQ\t[$]10"
@@ -44,7 +44,7 @@ func rot64(x uint64) uint64 {
// arm64:"ROR\t[$]54"
// s390x:"RISBGZ\t[$]0, [$]63, [$]10, "
// loong64: "ROTRV\t[$]54"
- // riscv64: "OR","SLLI","SRLI",-"AND"
+ // riscv64: "RORI\t[$]54"
a += bits.RotateLeft64(x, 10)
return a
@@ -57,7 +57,7 @@ func rot32(x uint32) uint32 {
// arm:"MOVW\tR\\d+@>25"
// ppc64x:"ROTLW\t[$]7"
// loong64: "ROTR\t[$]25"
- // riscv64: "OR","SLLIW","SRLIW",-"AND"
+ // riscv64: "RORIW\t[$]25"
a += x<<7 | x>>25
// amd64:`ROLL\t[$]8`
@@ -66,7 +66,7 @@ func rot32(x uint32) uint32 {
// s390x:"RLL\t[$]8"
// ppc64x:"ROTLW\t[$]8"
// loong64: "ROTR\t[$]24"
- // riscv64: "OR","SLLIW","SRLIW",-"AND"
+ // riscv64: "RORIW\t[$]24"
a += x<<8 + x>>24
// amd64:"ROLL\t[$]9"
@@ -75,7 +75,7 @@ func rot32(x uint32) uint32 {
// s390x:"RLL\t[$]9"
// ppc64x:"ROTLW\t[$]9"
// loong64: "ROTR\t[$]23"
- // riscv64: "OR","SLLIW","SRLIW",-"AND"
+ // riscv64: "RORIW\t[$]23"
a += x<<9 ^ x>>23
// amd64:"ROLL\t[$]10"
@@ -86,7 +86,7 @@ func rot32(x uint32) uint32 {
// arm64:"RORW\t[$]22"
// s390x:"RLL\t[$]10"
// loong64: "ROTR\t[$]22"
- // riscv64: "OR","SLLIW","SRLIW",-"AND"
+ // riscv64: "RORIW\t[$]22"
a += bits.RotateLeft32(x, 10)
return a
@@ -141,14 +141,14 @@ func rot64nc(x uint64, z uint) uint64 {
// arm64:"ROR","NEG",-"AND"
// ppc64x:"ROTL",-"NEG",-"AND"
// loong64: "ROTRV", -"AND"
- // riscv64: "OR","SLL","SRL",-"AND"
+ // riscv64: "ROL",-"AND"
a += x<<z | x>>(64-z)
// amd64:"RORQ",-"AND"
// arm64:"ROR",-"NEG",-"AND"
// ppc64x:"ROTL","NEG",-"AND"
// loong64: "ROTRV", -"AND"
- // riscv64: "OR","SLL","SRL",-"AND"
+ // riscv64: "ROR",-"AND"
a += x>>z | x<<(64-z)
return a
@@ -163,14 +163,14 @@ func rot32nc(x uint32, z uint) uint32 {
// arm64:"ROR","NEG",-"AND"
// ppc64x:"ROTLW",-"NEG",-"AND"
// loong64: "ROTR", -"AND"
- // riscv64: "OR","SLLW","SRLW",-"AND"
+ // riscv64: "ROLW",-"AND"
a += x<<z | x>>(32-z)
// amd64:"RORL",-"AND"
// arm64:"ROR",-"NEG",-"AND"
// ppc64x:"ROTLW","NEG",-"AND"
// loong64: "ROTR", -"AND"
- // riscv64: "OR","SLLW","SRLW",-"AND"
+ // riscv64: "RORW",-"AND"
a += x>>z | x<<(32-z)
return a