From: Junyang Shao Date: Mon, 17 Nov 2025 21:34:18 +0000 (+0000) Subject: [dev.simd] cmd/compile, simd: change SHA ops names and types X-Git-Tag: go1.26rc1~147^2~20 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=be9c50c6a0;p=gostls13.git [dev.simd] cmd/compile, simd: change SHA ops names and types This CL addressed some naming changes decided in API audit. Before After SHA1Msg1 SHA1Message1, Remove signed SHA1Msg2 SHA1Message2, Remove signed SHA1NextE SHA1NextE, Remove signed SHA1Round4 SHA1FourRounds, Remove signed SHA256Msg1 SHA256Message1, Remove signed SHA256Msg2 SHA256Message2, Remove signed SHA256Rounds2 SHA256TwoRounds, Remove signed Change-Id: If2cead113f37a9044bc5c65e78fa9d124e318005 Reviewed-on: https://go-review.googlesource.com/c/go/+/721003 Reviewed-by: David Chase LUCI-TryBot-Result: Go LUCI --- diff --git a/src/cmd/compile/internal/ssa/_gen/simdAMD64.rules b/src/cmd/compile/internal/ssa/_gen/simdAMD64.rules index ea1094b805..5169bf24d9 100644 --- a/src/cmd/compile/internal/ssa/_gen/simdAMD64.rules +++ b/src/cmd/compile/internal/ssa/_gen/simdAMD64.rules @@ -946,20 +946,13 @@ (RoundToEvenScaledResidueFloat64x2 [a] x) => (VREDUCEPD128 [a+0] x) (RoundToEvenScaledResidueFloat64x4 [a] x) => (VREDUCEPD256 [a+0] x) (RoundToEvenScaledResidueFloat64x8 [a] x) => (VREDUCEPD512 [a+0] x) -(SHA1Msg1Int32x4 ...) => (SHA1MSG1128 ...) -(SHA1Msg1Uint32x4 ...) => (SHA1MSG1128 ...) -(SHA1Msg2Int32x4 ...) => (SHA1MSG2128 ...) -(SHA1Msg2Uint32x4 ...) => (SHA1MSG2128 ...) -(SHA1NextEInt32x4 ...) => (SHA1NEXTE128 ...) +(SHA1FourRoundsUint32x4 ...) => (SHA1RNDS4128 ...) +(SHA1Message1Uint32x4 ...) => (SHA1MSG1128 ...) +(SHA1Message2Uint32x4 ...) => (SHA1MSG2128 ...) (SHA1NextEUint32x4 ...) => (SHA1NEXTE128 ...) -(SHA1Round4Int32x4 ...) => (SHA1RNDS4128 ...) -(SHA1Round4Uint32x4 ...) => (SHA1RNDS4128 ...) -(SHA256Msg1Int32x4 ...) => (SHA256MSG1128 ...) -(SHA256Msg1Uint32x4 ...) => (SHA256MSG1128 ...) -(SHA256Msg2Int32x4 ...) => (SHA256MSG1128 ...) -(SHA256Msg2Uint32x4 ...) => (SHA256MSG1128 ...) -(SHA256Rounds2Int32x4 ...) => (SHA256RNDS2128 ...) -(SHA256Rounds2Uint32x4 ...) => (SHA256RNDS2128 ...) +(SHA256Message1Uint32x4 ...) => (SHA256MSG1128 ...) +(SHA256Message2Uint32x4 ...) => (SHA256MSG1128 ...) +(SHA256TwoRoundsUint32x4 ...) => (SHA256RNDS2128 ...) (ScaleFloat32x4 ...) => (VSCALEFPS128 ...) (ScaleFloat32x8 ...) => (VSCALEFPS256 ...) (ScaleFloat32x16 ...) => (VSCALEFPS512 ...) diff --git a/src/cmd/compile/internal/ssa/_gen/simdgenericOps.go b/src/cmd/compile/internal/ssa/_gen/simdgenericOps.go index b97e5f4f14..dca366f0f9 100644 --- a/src/cmd/compile/internal/ssa/_gen/simdgenericOps.go +++ b/src/cmd/compile/internal/ssa/_gen/simdgenericOps.go @@ -848,18 +848,12 @@ func simdGenericOps() []opData { {name: "RoundToEvenFloat32x8", argLength: 1, commutative: false}, {name: "RoundToEvenFloat64x2", argLength: 1, commutative: false}, {name: "RoundToEvenFloat64x4", argLength: 1, commutative: false}, - {name: "SHA1Msg1Int32x4", argLength: 2, commutative: false}, - {name: "SHA1Msg1Uint32x4", argLength: 2, commutative: false}, - {name: "SHA1Msg2Int32x4", argLength: 2, commutative: false}, - {name: "SHA1Msg2Uint32x4", argLength: 2, commutative: false}, - {name: "SHA1NextEInt32x4", argLength: 2, commutative: false}, + {name: "SHA1Message1Uint32x4", argLength: 2, commutative: false}, + {name: "SHA1Message2Uint32x4", argLength: 2, commutative: false}, {name: "SHA1NextEUint32x4", argLength: 2, commutative: false}, - {name: "SHA256Msg1Int32x4", argLength: 2, commutative: false}, - {name: "SHA256Msg1Uint32x4", argLength: 2, commutative: false}, - {name: "SHA256Msg2Int32x4", argLength: 2, commutative: false}, - {name: "SHA256Msg2Uint32x4", argLength: 2, commutative: false}, - {name: "SHA256Rounds2Int32x4", argLength: 3, commutative: false}, - {name: "SHA256Rounds2Uint32x4", argLength: 3, commutative: false}, + {name: "SHA256Message1Uint32x4", argLength: 2, commutative: false}, + {name: "SHA256Message2Uint32x4", argLength: 2, commutative: false}, + {name: "SHA256TwoRoundsUint32x4", argLength: 3, commutative: false}, {name: "ScaleFloat32x4", argLength: 2, commutative: false}, {name: "ScaleFloat32x8", argLength: 2, commutative: false}, {name: "ScaleFloat32x16", argLength: 2, commutative: false}, @@ -1215,8 +1209,7 @@ func simdGenericOps() []opData { {name: "RoundToEvenScaledResidueFloat64x2", argLength: 1, commutative: false, aux: "UInt8"}, {name: "RoundToEvenScaledResidueFloat64x4", argLength: 1, commutative: false, aux: "UInt8"}, {name: "RoundToEvenScaledResidueFloat64x8", argLength: 1, commutative: false, aux: "UInt8"}, - {name: "SHA1Round4Int32x4", argLength: 2, commutative: false, aux: "UInt8"}, - {name: "SHA1Round4Uint32x4", argLength: 2, commutative: false, aux: "UInt8"}, + {name: "SHA1FourRoundsUint32x4", argLength: 2, commutative: false, aux: "UInt8"}, {name: "Select128FromPairFloat32x8", argLength: 2, commutative: false, aux: "UInt8"}, {name: "Select128FromPairFloat64x4", argLength: 2, commutative: false, aux: "UInt8"}, {name: "Select128FromPairInt32x8", argLength: 2, commutative: false, aux: "UInt8"}, diff --git a/src/cmd/compile/internal/ssa/opGen.go b/src/cmd/compile/internal/ssa/opGen.go index bd94b4d576..d0482743d1 100644 --- a/src/cmd/compile/internal/ssa/opGen.go +++ b/src/cmd/compile/internal/ssa/opGen.go @@ -6796,18 +6796,12 @@ const ( OpRoundToEvenFloat32x8 OpRoundToEvenFloat64x2 OpRoundToEvenFloat64x4 - OpSHA1Msg1Int32x4 - OpSHA1Msg1Uint32x4 - OpSHA1Msg2Int32x4 - OpSHA1Msg2Uint32x4 - OpSHA1NextEInt32x4 + OpSHA1Message1Uint32x4 + OpSHA1Message2Uint32x4 OpSHA1NextEUint32x4 - OpSHA256Msg1Int32x4 - OpSHA256Msg1Uint32x4 - OpSHA256Msg2Int32x4 - OpSHA256Msg2Uint32x4 - OpSHA256Rounds2Int32x4 - OpSHA256Rounds2Uint32x4 + OpSHA256Message1Uint32x4 + OpSHA256Message2Uint32x4 + OpSHA256TwoRoundsUint32x4 OpScaleFloat32x4 OpScaleFloat32x8 OpScaleFloat32x16 @@ -7163,8 +7157,7 @@ const ( OpRoundToEvenScaledResidueFloat64x2 OpRoundToEvenScaledResidueFloat64x4 OpRoundToEvenScaledResidueFloat64x8 - OpSHA1Round4Int32x4 - OpSHA1Round4Uint32x4 + OpSHA1FourRoundsUint32x4 OpSelect128FromPairFloat32x8 OpSelect128FromPairFloat64x4 OpSelect128FromPairInt32x8 @@ -90254,27 +90247,12 @@ var opcodeTable = [...]opInfo{ generic: true, }, { - name: "SHA1Msg1Int32x4", + name: "SHA1Message1Uint32x4", argLen: 2, generic: true, }, { - name: "SHA1Msg1Uint32x4", - argLen: 2, - generic: true, - }, - { - name: "SHA1Msg2Int32x4", - argLen: 2, - generic: true, - }, - { - name: "SHA1Msg2Uint32x4", - argLen: 2, - generic: true, - }, - { - name: "SHA1NextEInt32x4", + name: "SHA1Message2Uint32x4", argLen: 2, generic: true, }, @@ -90284,32 +90262,17 @@ var opcodeTable = [...]opInfo{ generic: true, }, { - name: "SHA256Msg1Int32x4", + name: "SHA256Message1Uint32x4", argLen: 2, generic: true, }, { - name: "SHA256Msg1Uint32x4", + name: "SHA256Message2Uint32x4", argLen: 2, generic: true, }, { - name: "SHA256Msg2Int32x4", - argLen: 2, - generic: true, - }, - { - name: "SHA256Msg2Uint32x4", - argLen: 2, - generic: true, - }, - { - name: "SHA256Rounds2Int32x4", - argLen: 3, - generic: true, - }, - { - name: "SHA256Rounds2Uint32x4", + name: "SHA256TwoRoundsUint32x4", argLen: 3, generic: true, }, @@ -92215,13 +92178,7 @@ var opcodeTable = [...]opInfo{ generic: true, }, { - name: "SHA1Round4Int32x4", - auxType: auxUInt8, - argLen: 2, - generic: true, - }, - { - name: "SHA1Round4Uint32x4", + name: "SHA1FourRoundsUint32x4", auxType: auxUInt8, argLen: 2, generic: true, diff --git a/src/cmd/compile/internal/ssa/rewriteAMD64.go b/src/cmd/compile/internal/ssa/rewriteAMD64.go index 042649f256..5f564000d9 100644 --- a/src/cmd/compile/internal/ssa/rewriteAMD64.go +++ b/src/cmd/compile/internal/ssa/rewriteAMD64.go @@ -5024,46 +5024,25 @@ func rewriteValueAMD64(v *Value) bool { return rewriteValueAMD64_OpRsh8x64(v) case OpRsh8x8: return rewriteValueAMD64_OpRsh8x8(v) - case OpSHA1Msg1Int32x4: - v.Op = OpAMD64SHA1MSG1128 + case OpSHA1FourRoundsUint32x4: + v.Op = OpAMD64SHA1RNDS4128 return true - case OpSHA1Msg1Uint32x4: + case OpSHA1Message1Uint32x4: v.Op = OpAMD64SHA1MSG1128 return true - case OpSHA1Msg2Int32x4: - v.Op = OpAMD64SHA1MSG2128 - return true - case OpSHA1Msg2Uint32x4: + case OpSHA1Message2Uint32x4: v.Op = OpAMD64SHA1MSG2128 return true - case OpSHA1NextEInt32x4: - v.Op = OpAMD64SHA1NEXTE128 - return true case OpSHA1NextEUint32x4: v.Op = OpAMD64SHA1NEXTE128 return true - case OpSHA1Round4Int32x4: - v.Op = OpAMD64SHA1RNDS4128 - return true - case OpSHA1Round4Uint32x4: - v.Op = OpAMD64SHA1RNDS4128 - return true - case OpSHA256Msg1Int32x4: - v.Op = OpAMD64SHA256MSG1128 - return true - case OpSHA256Msg1Uint32x4: + case OpSHA256Message1Uint32x4: v.Op = OpAMD64SHA256MSG1128 return true - case OpSHA256Msg2Int32x4: + case OpSHA256Message2Uint32x4: v.Op = OpAMD64SHA256MSG1128 return true - case OpSHA256Msg2Uint32x4: - v.Op = OpAMD64SHA256MSG1128 - return true - case OpSHA256Rounds2Int32x4: - v.Op = OpAMD64SHA256RNDS2128 - return true - case OpSHA256Rounds2Uint32x4: + case OpSHA256TwoRoundsUint32x4: v.Op = OpAMD64SHA256RNDS2128 return true case OpScaleFloat32x16: diff --git a/src/cmd/compile/internal/ssagen/simdintrinsics.go b/src/cmd/compile/internal/ssagen/simdintrinsics.go index f3aa904f6c..492f581781 100644 --- a/src/cmd/compile/internal/ssagen/simdintrinsics.go +++ b/src/cmd/compile/internal/ssagen/simdintrinsics.go @@ -958,20 +958,13 @@ func simdIntrinsics(addF func(pkg, fn string, b intrinsicBuilder, archFamilies . addF(simdPackage, "Float64x2.RoundToEvenScaledResidue", opLen1Imm8(ssa.OpRoundToEvenScaledResidueFloat64x2, types.TypeVec128, 4), sys.AMD64) addF(simdPackage, "Float64x4.RoundToEvenScaledResidue", opLen1Imm8(ssa.OpRoundToEvenScaledResidueFloat64x4, types.TypeVec256, 4), sys.AMD64) addF(simdPackage, "Float64x8.RoundToEvenScaledResidue", opLen1Imm8(ssa.OpRoundToEvenScaledResidueFloat64x8, types.TypeVec512, 4), sys.AMD64) - addF(simdPackage, "Int32x4.SHA1Msg1", opLen2(ssa.OpSHA1Msg1Int32x4, types.TypeVec128), sys.AMD64) - addF(simdPackage, "Uint32x4.SHA1Msg1", opLen2(ssa.OpSHA1Msg1Uint32x4, types.TypeVec128), sys.AMD64) - addF(simdPackage, "Int32x4.SHA1Msg2", opLen2(ssa.OpSHA1Msg2Int32x4, types.TypeVec128), sys.AMD64) - addF(simdPackage, "Uint32x4.SHA1Msg2", opLen2(ssa.OpSHA1Msg2Uint32x4, types.TypeVec128), sys.AMD64) - addF(simdPackage, "Int32x4.SHA1NextE", opLen2(ssa.OpSHA1NextEInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.SHA1FourRounds", opLen2Imm8_SHA1RNDS4(ssa.OpSHA1FourRoundsUint32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint32x4.SHA1Message1", opLen2(ssa.OpSHA1Message1Uint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.SHA1Message2", opLen2(ssa.OpSHA1Message2Uint32x4, types.TypeVec128), sys.AMD64) addF(simdPackage, "Uint32x4.SHA1NextE", opLen2(ssa.OpSHA1NextEUint32x4, types.TypeVec128), sys.AMD64) - addF(simdPackage, "Int32x4.SHA1Round4", opLen2Imm8_SHA1RNDS4(ssa.OpSHA1Round4Int32x4, types.TypeVec128, 0), sys.AMD64) - addF(simdPackage, "Uint32x4.SHA1Round4", opLen2Imm8_SHA1RNDS4(ssa.OpSHA1Round4Uint32x4, types.TypeVec128, 0), sys.AMD64) - addF(simdPackage, "Int32x4.SHA256Msg1", opLen2(ssa.OpSHA256Msg1Int32x4, types.TypeVec128), sys.AMD64) - addF(simdPackage, "Uint32x4.SHA256Msg1", opLen2(ssa.OpSHA256Msg1Uint32x4, types.TypeVec128), sys.AMD64) - addF(simdPackage, "Int32x4.SHA256Msg2", opLen2(ssa.OpSHA256Msg2Int32x4, types.TypeVec128), sys.AMD64) - addF(simdPackage, "Uint32x4.SHA256Msg2", opLen2(ssa.OpSHA256Msg2Uint32x4, types.TypeVec128), sys.AMD64) - addF(simdPackage, "Int32x4.SHA256Rounds2", opLen3(ssa.OpSHA256Rounds2Int32x4, types.TypeVec128), sys.AMD64) - addF(simdPackage, "Uint32x4.SHA256Rounds2", opLen3(ssa.OpSHA256Rounds2Uint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.SHA256Message1", opLen2(ssa.OpSHA256Message1Uint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.SHA256Message2", opLen2(ssa.OpSHA256Message2Uint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.SHA256TwoRounds", opLen3(ssa.OpSHA256TwoRoundsUint32x4, types.TypeVec128), sys.AMD64) addF(simdPackage, "Float32x4.Scale", opLen2(ssa.OpScaleFloat32x4, types.TypeVec128), sys.AMD64) addF(simdPackage, "Float32x8.Scale", opLen2(ssa.OpScaleFloat32x8, types.TypeVec256), sys.AMD64) addF(simdPackage, "Float32x16.Scale", opLen2(ssa.OpScaleFloat32x16, types.TypeVec512), sys.AMD64) diff --git a/src/simd/_gen/simdgen/ops/Others/categories.yaml b/src/simd/_gen/simdgen/ops/Others/categories.yaml index 8ecf066e80..64a9544bc8 100644 --- a/src/simd/_gen/simdgen/ops/Others/categories.yaml +++ b/src/simd/_gen/simdgen/ops/Others/categories.yaml @@ -47,7 +47,7 @@ // NAME performs the InvMixColumns operation in AES cipher algorithm defined in FIPS 197. // x is the chunk of w array in use. // result = InvMixColumns(x) -- go: SHA1Round4 +- go: SHA1FourRounds commutative: false documentation: !string |- // NAME performs 4 rounds of B loop in SHA1 algorithm defined in FIPS 180-4. @@ -66,21 +66,21 @@ // For the last round of the loop, you can specify zero for y to obtain the e' value itself, or better off specifying H4:0:0:0 // for y to get e' added to H4. (Note that the value of e' is computed only from x, and values of y don't affect the // computation of the value of e'.) -- go: SHA1Msg1 +- go: SHA1Message1 commutative: false documentation: !string |- // NAME does the XORing of 1 in SHA1 algorithm defined in FIPS 180-4. // x = {W3, W2, W1, W0} // y = {0, 0, W5, W4} // result = {W3^W5, W2^W4, W1^W3, W0^W2}. -- go: SHA1Msg2 +- go: SHA1Message2 commutative: false documentation: !string |- // NAME does the calculation of 3 and 4 in SHA1 algorithm defined in FIPS 180-4. // x = result of 2. // y = {W15, W14, W13} // result = {W19, W18, W17, W16} -- go: SHA256Rounds2 +- go: SHA256TwoRounds commutative: false documentation: !string |- // NAME does 2 rounds of B loop to calculate updated state variables in SHA1 algorithm defined in FIPS 180-4. @@ -92,14 +92,14 @@ // the corresponding element of the W array to make the input data z. // The updated state variables c', d', g', h' are not returned by this instruction, because they are equal to the input data // y (the state variables a, b, e, f before the 2 rounds). -- go: SHA256Msg1 +- go: SHA256Message1 commutative: false documentation: !string |- // NAME does the sigma and addtion of 1 in SHA1 algorithm defined in FIPS 180-4. // x = {W0, W1, W2, W3} // y = {W4, 0, 0, 0} // result = {W0+σ(W1), W1+σ(W2), W2+σ(W3), W3+σ(W4)} -- go: SHA256Msg2 +- go: SHA256Message2 commutative: false documentation: !string |- // NAME does the sigma and addition of 3 in SHA1 algorithm defined in FIPS 180-4. diff --git a/src/simd/_gen/simdgen/ops/Others/go.yaml b/src/simd/_gen/simdgen/ops/Others/go.yaml index f89d7ef82d..c098d28968 100644 --- a/src/simd/_gen/simdgen/ops/Others/go.yaml +++ b/src/simd/_gen/simdgen/ops/Others/go.yaml @@ -53,44 +53,46 @@ - *uint32s out: - *uint32s -- go: SHA1Round4 +- go: SHA1FourRounds asm: SHA1RNDS4 operandOrder: "SHA1RNDS4" - in: &2any1imm - - *any - - *any + in: &2uint1imm + - &uint + go: $t + base: uint + - *uint - class: immediate immOffset: 0 - out: &1any - - *any + out: &1uint + - *uint - go: SHA1NextE asm: SHA1NEXTE - in: &2any - - *any - - *any - out: *1any -- go: SHA1Msg1 + in: &2uint + - *uint + - *uint + out: *1uint +- go: SHA1Message1 asm: SHA1MSG1 - in: *2any - out: *1any -- go: SHA1Msg2 + in: *2uint + out: *1uint +- go: SHA1Message2 asm: SHA1MSG2 - in: *2any - out: *1any -- go: SHA256Rounds2 + in: *2uint + out: *1uint +- go: SHA256TwoRounds asm: SHA256RNDS2 in: - - base: $t - - base: $t - - base: $t + - base: uint + - base: uint + - base: uint overwriteElementBits: 32 out: - - base: $t -- go: SHA256Msg1 + - base: uint +- go: SHA256Message1 asm: SHA256MSG1 - in: *2any - out: *1any -- go: SHA256Msg2 + in: *2uint + out: *1uint +- go: SHA256Message2 asm: SHA256MSG1 - in: *2any - out: *1any \ No newline at end of file + in: *2uint + out: *1uint \ No newline at end of file diff --git a/src/simd/ops_amd64.go b/src/simd/ops_amd64.go index 88b951990c..29c9387d78 100644 --- a/src/simd/ops_amd64.go +++ b/src/simd/ops_amd64.go @@ -5685,56 +5685,41 @@ func (x Float64x4) RoundToEvenScaledResidue(prec uint8) Float64x4 // Asm: VREDUCEPD, CPU Feature: AVX512 func (x Float64x8) RoundToEvenScaledResidue(prec uint8) Float64x8 -/* SHA1Msg1 */ +/* SHA1FourRounds */ -// SHA1Msg1 does the XORing of 1 in SHA1 algorithm defined in FIPS 180-4. -// x = {W3, W2, W1, W0} -// y = {0, 0, W5, W4} -// result = {W3^W5, W2^W4, W1^W3, W0^W2}. +// SHA1FourRounds performs 4 rounds of B loop in SHA1 algorithm defined in FIPS 180-4. +// x contains the state variables a, b, c and d from upper to lower order. +// y contains the W array elements (with the state variable e added to the upper element) from upper to lower order. +// result = the state variables a', b', c', d' updated after 4 rounds. +// constant = 0 for the first 20 rounds of the loop, 1 for the next 20 rounds of the loop..., 3 for the last 20 rounds of the loop. // -// Asm: SHA1MSG1, CPU Feature: SHA -func (x Int32x4) SHA1Msg1(y Int32x4) Int32x4 +// constant results in better performance when it's a constant, a non-constant value will be translated into a jump table. +// +// Asm: SHA1RNDS4, CPU Feature: SHA +func (x Uint32x4) SHA1FourRounds(constant uint8, y Uint32x4) Uint32x4 + +/* SHA1Message1 */ -// SHA1Msg1 does the XORing of 1 in SHA1 algorithm defined in FIPS 180-4. +// SHA1Message1 does the XORing of 1 in SHA1 algorithm defined in FIPS 180-4. // x = {W3, W2, W1, W0} // y = {0, 0, W5, W4} // result = {W3^W5, W2^W4, W1^W3, W0^W2}. // // Asm: SHA1MSG1, CPU Feature: SHA -func (x Uint32x4) SHA1Msg1(y Uint32x4) Uint32x4 +func (x Uint32x4) SHA1Message1(y Uint32x4) Uint32x4 -/* SHA1Msg2 */ - -// SHA1Msg2 does the calculation of 3 and 4 in SHA1 algorithm defined in FIPS 180-4. -// x = result of 2. -// y = {W15, W14, W13} -// result = {W19, W18, W17, W16} -// -// Asm: SHA1MSG2, CPU Feature: SHA -func (x Int32x4) SHA1Msg2(y Int32x4) Int32x4 +/* SHA1Message2 */ -// SHA1Msg2 does the calculation of 3 and 4 in SHA1 algorithm defined in FIPS 180-4. +// SHA1Message2 does the calculation of 3 and 4 in SHA1 algorithm defined in FIPS 180-4. // x = result of 2. // y = {W15, W14, W13} // result = {W19, W18, W17, W16} // // Asm: SHA1MSG2, CPU Feature: SHA -func (x Uint32x4) SHA1Msg2(y Uint32x4) Uint32x4 +func (x Uint32x4) SHA1Message2(y Uint32x4) Uint32x4 /* SHA1NextE */ -// SHA1NextE calculates the state variable e' updated after 4 rounds in SHA1 algorithm defined in FIPS 180-4. -// x contains the state variable a (before the 4 rounds), placed in the upper element. -// y is the elements of W array for next 4 rounds from upper to lower order. -// result = the elements of the W array for the next 4 rounds, with the updated state variable e' added to the upper element, -// from upper to lower order. -// For the last round of the loop, you can specify zero for y to obtain the e' value itself, or better off specifying H4:0:0:0 -// for y to get e' added to H4. (Note that the value of e' is computed only from x, and values of y don't affect the -// computation of the value of e'.) -// -// Asm: SHA1NEXTE, CPU Feature: SHA -func (x Int32x4) SHA1NextE(y Int32x4) Int32x4 - // SHA1NextE calculates the state variable e' updated after 4 rounds in SHA1 algorithm defined in FIPS 180-4. // x contains the state variable a (before the 4 rounds), placed in the upper element. // y is the elements of W array for next 4 rounds from upper to lower order. @@ -5747,82 +5732,29 @@ func (x Int32x4) SHA1NextE(y Int32x4) Int32x4 // Asm: SHA1NEXTE, CPU Feature: SHA func (x Uint32x4) SHA1NextE(y Uint32x4) Uint32x4 -/* SHA1Round4 */ +/* SHA256Message1 */ -// SHA1Round4 performs 4 rounds of B loop in SHA1 algorithm defined in FIPS 180-4. -// x contains the state variables a, b, c and d from upper to lower order. -// y contains the W array elements (with the state variable e added to the upper element) from upper to lower order. -// result = the state variables a', b', c', d' updated after 4 rounds. -// constant = 0 for the first 20 rounds of the loop, 1 for the next 20 rounds of the loop..., 3 for the last 20 rounds of the loop. -// -// constant results in better performance when it's a constant, a non-constant value will be translated into a jump table. -// -// Asm: SHA1RNDS4, CPU Feature: SHA -func (x Int32x4) SHA1Round4(constant uint8, y Int32x4) Int32x4 - -// SHA1Round4 performs 4 rounds of B loop in SHA1 algorithm defined in FIPS 180-4. -// x contains the state variables a, b, c and d from upper to lower order. -// y contains the W array elements (with the state variable e added to the upper element) from upper to lower order. -// result = the state variables a', b', c', d' updated after 4 rounds. -// constant = 0 for the first 20 rounds of the loop, 1 for the next 20 rounds of the loop..., 3 for the last 20 rounds of the loop. -// -// constant results in better performance when it's a constant, a non-constant value will be translated into a jump table. -// -// Asm: SHA1RNDS4, CPU Feature: SHA -func (x Uint32x4) SHA1Round4(constant uint8, y Uint32x4) Uint32x4 - -/* SHA256Msg1 */ - -// SHA256Msg1 does the sigma and addtion of 1 in SHA1 algorithm defined in FIPS 180-4. -// x = {W0, W1, W2, W3} -// y = {W4, 0, 0, 0} -// result = {W0+σ(W1), W1+σ(W2), W2+σ(W3), W3+σ(W4)} -// -// Asm: SHA256MSG1, CPU Feature: SHA -func (x Int32x4) SHA256Msg1(y Int32x4) Int32x4 - -// SHA256Msg1 does the sigma and addtion of 1 in SHA1 algorithm defined in FIPS 180-4. +// SHA256Message1 does the sigma and addtion of 1 in SHA1 algorithm defined in FIPS 180-4. // x = {W0, W1, W2, W3} // y = {W4, 0, 0, 0} // result = {W0+σ(W1), W1+σ(W2), W2+σ(W3), W3+σ(W4)} // // Asm: SHA256MSG1, CPU Feature: SHA -func (x Uint32x4) SHA256Msg1(y Uint32x4) Uint32x4 +func (x Uint32x4) SHA256Message1(y Uint32x4) Uint32x4 -/* SHA256Msg2 */ +/* SHA256Message2 */ -// SHA256Msg2 does the sigma and addition of 3 in SHA1 algorithm defined in FIPS 180-4. +// SHA256Message2 does the sigma and addition of 3 in SHA1 algorithm defined in FIPS 180-4. // x = result of 2 // y = {0, 0, W14, W15} // result = {W16, W17, W18, W19} // // Asm: SHA256MSG1, CPU Feature: SHA -func (x Int32x4) SHA256Msg2(y Int32x4) Int32x4 +func (x Uint32x4) SHA256Message2(y Uint32x4) Uint32x4 -// SHA256Msg2 does the sigma and addition of 3 in SHA1 algorithm defined in FIPS 180-4. -// x = result of 2 -// y = {0, 0, W14, W15} -// result = {W16, W17, W18, W19} -// -// Asm: SHA256MSG1, CPU Feature: SHA -func (x Uint32x4) SHA256Msg2(y Uint32x4) Uint32x4 - -/* SHA256Rounds2 */ - -// SHA256Rounds2 does 2 rounds of B loop to calculate updated state variables in SHA1 algorithm defined in FIPS 180-4. -// x = {h, g, d, c} -// y = {f, e, b, a} -// z = {W0+K0, W1+K1} -// result = {f', e', b', a'} -// The K array is a 64-DWORD constant array defined in page 11 of FIPS 180-4. Each element of the K array is to be added to -// the corresponding element of the W array to make the input data z. -// The updated state variables c', d', g', h' are not returned by this instruction, because they are equal to the input data -// y (the state variables a, b, e, f before the 2 rounds). -// -// Asm: SHA256RNDS2, CPU Feature: SHA -func (x Int32x4) SHA256Rounds2(y Int32x4, z Int32x4) Int32x4 +/* SHA256TwoRounds */ -// SHA256Rounds2 does 2 rounds of B loop to calculate updated state variables in SHA1 algorithm defined in FIPS 180-4. +// SHA256TwoRounds does 2 rounds of B loop to calculate updated state variables in SHA1 algorithm defined in FIPS 180-4. // x = {h, g, d, c} // y = {f, e, b, a} // z = {W0+K0, W1+K1} @@ -5833,7 +5765,7 @@ func (x Int32x4) SHA256Rounds2(y Int32x4, z Int32x4) Int32x4 // y (the state variables a, b, e, f before the 2 rounds). // // Asm: SHA256RNDS2, CPU Feature: SHA -func (x Uint32x4) SHA256Rounds2(y Uint32x4, z Uint32x4) Uint32x4 +func (x Uint32x4) SHA256TwoRounds(y Uint32x4, z Uint32x4) Uint32x4 /* Scale */