sm3: s390x copyResultsBy4

This commit is contained in:
Sun Yimin 2024-09-04 07:58:07 +08:00 committed by GitHub
parent 75d3974162
commit a3fa174e71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 39 additions and 0 deletions

View File

@ -8,3 +8,6 @@ package sm3
//go:noescape //go:noescape
func transposeMatrix(dig **[8]uint32) func transposeMatrix(dig **[8]uint32)
//go:noescape
func copyResultsBy4(dig *uint32, p *byte)

View File

@ -56,3 +56,16 @@ TEXT ·transposeMatrix(SB),NOSPLIT,$0
VSTM V6, V7, (R2) VSTM V6, V7, (R2)
RET RET
// func copyResultsBy4(dig *uint32, dst *byte)
TEXT ·copyResultsBy4(SB),NOSPLIT,$0
#define digPtr R1
#define dstPtr R2
MOVD dig+0(FP), digPtr
MOVD dst+8(FP), dstPtr
// load state
VLM (digPtr), V0, V7
VSTM V0, V7, (dstPtr)
RET

View File

@ -29,3 +29,26 @@ func TestTransposeMatrix(t *testing.T) {
fmt.Println() fmt.Println()
} }
} }
func TestCopyResultsBy4(t *testing.T) {
var m [4][8]uint32
var k uint32 = 0
for i := 0; i < 4; i++ {
for j := 0; j < 8; j++ {
m[i][j] = k << 24
k++
fmt.Printf("%04x ", m[i][j])
}
fmt.Println()
}
var p [32]byte
copyResultsBy4(&m[0][0], &p[0])
fmt.Println()
fmt.Println()
for i := 0; i < 32; i++ {
fmt.Printf("%04x ", p[i])
if i%8 == 7 {
fmt.Println()
}
}
}