aboutsummaryrefslogtreecommitdiff
path: root/src/simd
diff options
context:
space:
mode:
authorJunyang Shao <shaojunyang@google.com>2025-11-17 20:45:30 +0000
committerJunyang Shao <shaojunyang@google.com>2025-11-17 13:37:42 -0800
commit0978935a99a2293aba75db1d7f925109e10ed0a7 (patch)
treef8cf03ca3a6f5229e779fb61609c57d71270fb3b /src/simd
parent95871e4a0020ea91b9c0177cbeda763c1613d02f (diff)
downloadgo-0978935a99a2293aba75db1d7f925109e10ed0a7.tar.xz
[dev.simd] cmd/compile, simd: change AES op names and add missing size
This CL changed AESEncryptRound and AESDecryptRound to AESEncryptOneRound and AESDecryptOneRound. This CL also adds the 512-bit version of some AES instructions. Change-Id: Ia851a008cce2145b1ff193a89e172862060a725d Reviewed-on: https://go-review.googlesource.com/c/go/+/721280 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/simd')
-rw-r--r--src/simd/_gen/simdgen/ops/Others/categories.yaml4
-rw-r--r--src/simd/_gen/simdgen/ops/Others/go.yaml4
-rw-r--r--src/simd/_gen/simdgen/types.yaml11
-rw-r--r--src/simd/ops_amd64.go52
4 files changed, 57 insertions, 14 deletions
diff --git a/src/simd/_gen/simdgen/ops/Others/categories.yaml b/src/simd/_gen/simdgen/ops/Others/categories.yaml
index 3c8befb826..8ecf066e80 100644
--- a/src/simd/_gen/simdgen/ops/Others/categories.yaml
+++ b/src/simd/_gen/simdgen/ops/Others/categories.yaml
@@ -3,7 +3,7 @@
commutative: false
documentation: !string |-
// NAME counts the leading zeros of each element in x.
-- go: AESEncryptRound
+- go: AESEncryptOneRound
commutative: false
documentation: !string |-
// NAME performs a series of operations in AES cipher algorithm defined in FIPS 197.
@@ -27,7 +27,7 @@
// result[1] = SubWord(x[1])
// result[2] = XOR(SubWord(RotWord(x[2])), r)
// result[3] = SubWord(x[3])
-- go: AESDecryptRound
+- go: AESDecryptOneRound
commutative: false
documentation: !string |-
// NAME performs a series of operations in AES cipher algorithm defined in FIPS 197.
diff --git a/src/simd/_gen/simdgen/ops/Others/go.yaml b/src/simd/_gen/simdgen/ops/Others/go.yaml
index 77b9fc3783..f89d7ef82d 100644
--- a/src/simd/_gen/simdgen/ops/Others/go.yaml
+++ b/src/simd/_gen/simdgen/ops/Others/go.yaml
@@ -6,7 +6,7 @@
go: $t
out:
- *any
-- go: AESEncryptRound
+- go: AESEncryptOneRound
asm: VAESENC
in:
- &uint8s
@@ -33,7 +33,7 @@
name: rconVal
out:
- *uint32s
-- go: AESDecryptRound
+- go: AESDecryptOneRound
asm: VAESDEC
in:
- *uint8s
diff --git a/src/simd/_gen/simdgen/types.yaml b/src/simd/_gen/simdgen/types.yaml
index f7a01cb360..9dccd1e764 100644
--- a/src/simd/_gen/simdgen/types.yaml
+++ b/src/simd/_gen/simdgen/types.yaml
@@ -83,6 +83,17 @@ in: !repeat
- {class: vreg, go: Int64x4, base: "int", elemBits: 128, bits: 256, lanes: 4}
- {class: vreg, go: Uint64x4, base: "uint", elemBits: 128, bits: 256, lanes: 4}
+# Special shapes just to make VAES(ENC|DEC)(LAST)?512 work.
+# The elemBits field of these shapes are wrong, it would be overwritten by overwriteElemBits.
+ - {class: vreg, go: Int8x32, base: "int", elemBits: 128, bits: 512, lanes: 32}
+ - {class: vreg, go: Uint8x32, base: "uint", elemBits: 128, bits: 512, lanes: 32}
+ - {class: vreg, go: Int16x16, base: "int", elemBits: 128, bits: 512, lanes: 16}
+ - {class: vreg, go: Uint16x16, base: "uint", elemBits: 128, bits: 512, lanes: 16}
+ - {class: vreg, go: Int32x8, base: "int", elemBits: 128, bits: 512, lanes: 8}
+ - {class: vreg, go: Uint32x8, base: "uint", elemBits: 128, bits: 512, lanes: 8}
+ - {class: vreg, go: Int64x4, base: "int", elemBits: 128, bits: 512, lanes: 4}
+ - {class: vreg, go: Uint64x4, base: "uint", elemBits: 128, bits: 512, lanes: 4}
+
- {class: immediate, go: Immediate} # TODO: we only support imms that are not used as value -- usually as instruction semantic predicate like VPCMP as of now.
inVariant: !repeat
- *types
diff --git a/src/simd/ops_amd64.go b/src/simd/ops_amd64.go
index ee472d1163..88b951990c 100644
--- a/src/simd/ops_amd64.go
+++ b/src/simd/ops_amd64.go
@@ -22,23 +22,39 @@ func (x Uint8x16) AESDecryptLastRound(y Uint32x4) Uint8x16
// Asm: VAESDECLAST, CPU Feature: AVX512VAES
func (x Uint8x32) AESDecryptLastRound(y Uint32x8) Uint8x32
-/* AESDecryptRound */
+// AESDecryptLastRound performs a series of operations in AES cipher algorithm defined in FIPS 197.
+// x is the state array, starting from low index to high are s00, s10, s20, s30, s01, ..., s33.
+// y is the chunk of dw array in use.
+// result = AddRoundKey(InvShiftRows(InvSubBytes(x)), y)
+//
+// Asm: VAESDECLAST, CPU Feature: AVX512VAES
+func (x Uint8x64) AESDecryptLastRound(y Uint32x16) Uint8x64
+
+/* AESDecryptOneRound */
-// AESDecryptRound performs a series of operations in AES cipher algorithm defined in FIPS 197.
+// AESDecryptOneRound performs a series of operations in AES cipher algorithm defined in FIPS 197.
// x is the state array, starting from low index to high are s00, s10, s20, s30, s01, ..., s33.
// y is the chunk of dw array in use.
// result = AddRoundKey(InvMixColumns(InvShiftRows(InvSubBytes(x))), y)
//
// Asm: VAESDEC, CPU Feature: AVX, AES
-func (x Uint8x16) AESDecryptRound(y Uint32x4) Uint8x16
+func (x Uint8x16) AESDecryptOneRound(y Uint32x4) Uint8x16
+
+// AESDecryptOneRound performs a series of operations in AES cipher algorithm defined in FIPS 197.
+// x is the state array, starting from low index to high are s00, s10, s20, s30, s01, ..., s33.
+// y is the chunk of dw array in use.
+// result = AddRoundKey(InvMixColumns(InvShiftRows(InvSubBytes(x))), y)
+//
+// Asm: VAESDEC, CPU Feature: AVX512VAES
+func (x Uint8x32) AESDecryptOneRound(y Uint32x8) Uint8x32
-// AESDecryptRound performs a series of operations in AES cipher algorithm defined in FIPS 197.
+// AESDecryptOneRound performs a series of operations in AES cipher algorithm defined in FIPS 197.
// x is the state array, starting from low index to high are s00, s10, s20, s30, s01, ..., s33.
// y is the chunk of dw array in use.
// result = AddRoundKey(InvMixColumns(InvShiftRows(InvSubBytes(x))), y)
//
// Asm: VAESDEC, CPU Feature: AVX512VAES
-func (x Uint8x32) AESDecryptRound(y Uint32x8) Uint8x32
+func (x Uint8x64) AESDecryptOneRound(y Uint32x16) Uint8x64
/* AESEncryptLastRound */
@@ -58,23 +74,39 @@ func (x Uint8x16) AESEncryptLastRound(y Uint32x4) Uint8x16
// Asm: VAESENCLAST, CPU Feature: AVX512VAES
func (x Uint8x32) AESEncryptLastRound(y Uint32x8) Uint8x32
-/* AESEncryptRound */
+// AESEncryptLastRound performs a series of operations in AES cipher algorithm defined in FIPS 197.
+// x is the state array, starting from low index to high are s00, s10, s20, s30, s01, ..., s33.
+// y is the chunk of w array in use.
+// result = AddRoundKey((ShiftRows(SubBytes(x))), y)
+//
+// Asm: VAESENCLAST, CPU Feature: AVX512VAES
+func (x Uint8x64) AESEncryptLastRound(y Uint32x16) Uint8x64
+
+/* AESEncryptOneRound */
-// AESEncryptRound performs a series of operations in AES cipher algorithm defined in FIPS 197.
+// AESEncryptOneRound performs a series of operations in AES cipher algorithm defined in FIPS 197.
// x is the state array, starting from low index to high are s00, s10, s20, s30, s01, ..., s33.
// y is the chunk of w array in use.
// result = AddRoundKey(MixColumns(ShiftRows(SubBytes(x))), y)
//
// Asm: VAESENC, CPU Feature: AVX, AES
-func (x Uint8x16) AESEncryptRound(y Uint32x4) Uint8x16
+func (x Uint8x16) AESEncryptOneRound(y Uint32x4) Uint8x16
+
+// AESEncryptOneRound performs a series of operations in AES cipher algorithm defined in FIPS 197.
+// x is the state array, starting from low index to high are s00, s10, s20, s30, s01, ..., s33.
+// y is the chunk of w array in use.
+// result = AddRoundKey(MixColumns(ShiftRows(SubBytes(x))), y)
+//
+// Asm: VAESENC, CPU Feature: AVX512VAES
+func (x Uint8x32) AESEncryptOneRound(y Uint32x8) Uint8x32
-// AESEncryptRound performs a series of operations in AES cipher algorithm defined in FIPS 197.
+// AESEncryptOneRound performs a series of operations in AES cipher algorithm defined in FIPS 197.
// x is the state array, starting from low index to high are s00, s10, s20, s30, s01, ..., s33.
// y is the chunk of w array in use.
// result = AddRoundKey(MixColumns(ShiftRows(SubBytes(x))), y)
//
// Asm: VAESENC, CPU Feature: AVX512VAES
-func (x Uint8x32) AESEncryptRound(y Uint32x8) Uint8x32
+func (x Uint8x64) AESEncryptOneRound(y Uint32x16) Uint8x64
/* AESInvMixColumns */