1
0
mirror of https://github.com/fumiama/blake2b-simd.git synced 2026-06-23 12:40:27 +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:
frankw
2016-06-28 12:15:46 +02:00
committed by Harshavardhana
parent 3a46db1cb4
commit f41b7a312a
5 changed files with 202 additions and 1300 deletions

View File

@@ -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
}