Skip to content

Commit

Permalink
add SHA x64 runtime check
Browse files Browse the repository at this point in the history
  • Loading branch information
guzba committed Dec 18, 2022
1 parent e56b059 commit 548e57c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nimsimd.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "1.2.1"
version = "1.2.2"
author = "Ryan Oldenburg"
description = "Pleasant Nim bindings for SIMD instruction sets."
license = "MIT"
Expand Down
6 changes: 5 additions & 1 deletion src/nimsimd/runtimecheck.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
when defined(amd64):
## https://www.felixcloutier.com/x86/cpuid

type
InstructionSet* = enum
SSE3
Expand All @@ -8,6 +10,7 @@ when defined(amd64):
AVX
AVX2
PCLMULQDQ
SHA

InstructionSetCheckInfo = object
leaf, register, bit: int
Expand All @@ -19,7 +22,8 @@ when defined(amd64):
InstructionSetCheckInfo(leaf: 1, register: 2, bit: 20), # SSE42
InstructionSetCheckInfo(leaf: 1, register: 2, bit: 28), # AVX
InstructionSetCheckInfo(leaf: 7, register: 1, bit: 5), # AVX2
InstructionSetCheckInfo(leaf: 1, register: 2, bit: 1) # PCLMULQDQ
InstructionSetCheckInfo(leaf: 1, register: 2, bit: 1), # PCLMULQDQ
InstructionSetCheckInfo(leaf: 7, register: 1, bit: 29) # SHA
]

proc cpuid(eaxi, ecxi: int32): array[4, int32] = # eax, ebx, ecx, edx
Expand Down

0 comments on commit 548e57c

Please sign in to comment.