mirror of
https://github.com/fumiama/blake2b-simd.git
synced 2026-06-08 20:10:33 +08:00
asm: Add new defines
- Add UNDIAGONALIZE define - Add DIAGONALIZE define - Add G1 define - Add G2 define - Add LOAD_SHUFFLE define Additionally check for AVX support.
This commit is contained in:
@@ -53,7 +53,7 @@ func compressSSE(d *digest, p []uint8) {
|
||||
}
|
||||
|
||||
func compress(d *digest, p []uint8) {
|
||||
if sse {
|
||||
if avx {
|
||||
compressSSE(d, p)
|
||||
return
|
||||
}
|
||||
|
||||
1469
compress_amd64.s
1469
compress_amd64.s
File diff suppressed because it is too large
Load Diff
16
cpuid.go
16
cpuid.go
@@ -18,12 +18,20 @@
|
||||
package blake2b
|
||||
|
||||
func cpuid(op uint32) (eax, ebx, ecx, edx uint32)
|
||||
func xgetbv(index uint32) (eax, edx uint32)
|
||||
|
||||
// True when SIMD instructions are available.
|
||||
var sse = haveSSE()
|
||||
var avx = haveAVX()
|
||||
|
||||
// haveSSE returns true if we have streaming SIMD instructions.
|
||||
func haveSSE() bool {
|
||||
_, _, _, d := cpuid(1)
|
||||
return (d & (1 << 25)) != 0
|
||||
func haveAVX() bool {
|
||||
_, _, c, _ := cpuid(1)
|
||||
|
||||
// Check XGETBV, OXSAVE and AVX bits
|
||||
if c&(1<<26) != 0 && c&(1<<27) != 0 && c&(1<<28) != 0 {
|
||||
// Check for OS support
|
||||
eax, _ := xgetbv(0)
|
||||
return (eax & 0x6) == 0x6
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -13,3 +13,10 @@ TEXT ·cpuid(SB), 7, $0
|
||||
MOVL DX, edx+16(FP)
|
||||
RET
|
||||
|
||||
// func xgetbv(index uint32) (eax, edx uint32)
|
||||
TEXT ·xgetbv(SB), 7, $0
|
||||
MOVL index+0(FP), CX
|
||||
BYTE $0x0f; BYTE $0x01; BYTE $0xd0 // XGETBV
|
||||
MOVL AX, eax+4(FP)
|
||||
MOVL DX, edx+8(FP)
|
||||
RET
|
||||
|
||||
@@ -12,3 +12,11 @@ TEXT ·cpuid(SB), 7, $0
|
||||
MOVL CX, ecx+16(FP)
|
||||
MOVL DX, edx+20(FP)
|
||||
RET
|
||||
|
||||
// func xgetbv(index uint32) (eax, edx uint32)
|
||||
TEXT ·xgetbv(SB), 7, $0
|
||||
MOVL index+0(FP), CX
|
||||
BYTE $0x0f; BYTE $0x01; BYTE $0xd0 // XGETBV
|
||||
MOVL AX, eax+8(FP)
|
||||
MOVL DX, edx+12(FP)
|
||||
RET
|
||||
|
||||
Reference in New Issue
Block a user