Skip to content

Commit

Permalink
small update to simd types
Browse files Browse the repository at this point in the history
  • Loading branch information
jcosborn committed Nov 23, 2024
1 parent b46d18c commit e5ed8b0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/simd/simdX86Ops.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ template int2mask*(T: typedesc[m512], i: SomeInteger): mmask16 = cvtu32_mask16(u
proc `[]=`*(r:var m128; i:SomeInteger; x:SomeNumber) {.alwaysInline.} =
mixin toArray
var a = toArray(r)
a[i] := x
a[i] = float32 x
assign(r, a)
proc `[]=`*(r:var m128d; i:SomeInteger; x:SomeNumber) {.alwaysInline.} =
mixin toArray
var a = toArray(r)
a[i] := x
a[i] = float x
assign(r, a)
proc `[]=`*(r:var m256; i:SomeInteger; x:SomeNumber) {.alwaysInline.} =
mixin toArray
var a = toArray(r)
a[i] := x
a[i] = float32 x
assign(r, a)
proc `[]=`*(r:var m256d; i:SomeInteger; x:SomeNumber) {.alwaysInline.} =
mixin toArray
var a = toArray(r)
a[i] := x
a[i] = float x
assign(r, a)
#proc `[]=`*(r:var m256d; i:SomeInteger; x:SomeNumber) {.alwaysInline.} =
# var a {.noInit.}: m256d
Expand Down
39 changes: 33 additions & 6 deletions src/simd/simdX86Types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,52 @@ import simdWrap
export simdWrap

{.pragma: imm, header:"immintrin.h".}
{.pragma: imms, header:"immintrin.h", incompleteStruct.}
type
m64* {.importc: "__m64" , imms.} = object
m128* {.importc: "__m128" , imms.} = object
m128d* {.importc: "__m128d", imms.} = object
m128i* {.importc: "__m128i", imms.} = object
m128h* = distinct int64
m256* {.importc: "__m256" , imms.} = object
m256d* {.importc: "__m256d", imms.} = object
m256i* {.importc: "__m256i", imms.} = object
m256h* = distinct m128i
m512* {.importc: "__m512" , imms.} = object
m512d* {.importc: "__m512d", imms.} = object
m512i* {.importc: "__m512i", imms.} = object
m512h* = distinct m256i
mmask8* {.importc: "__mmask8" , imms.} = object
mmask16* {.importc: "__mmask16", imms.} = object
mmask32* {.importc: "__mmask32", imms.} = object
mmask64* {.importc: "__mmask64", imms.} = object
#[
{.pragma: imm, header:"immintrin.h", incompleteStruct.}
type
m64* {.importc: "__m64" , imm.} = object
m128* {.importc: "__m128" , imm.} = object
m128d* {.importc: "__m128d", imm.} = object
a: array[2,float32]
m128* {.importc: "__m128" , imm.} = distinct array[4,float32]
m128d* {.importc: "__m128d", imm.} = distinct array[2,float64]
m128i* {.importc: "__m128i", imm.} = object
a: array[4,int32]
m128h* = distinct int64
m256* {.importc: "__m256" , imm.} = object
m256d* {.importc: "__m256d", imm.} = object
a: array[8,float32]
m256d* {.importc: "__m256d", imm.} = distinct array[4,float64]
m256i* {.importc: "__m256i", imm.} = object
a: array[8,int32]
m256h* = distinct m128i
m512* {.importc: "__m512" , imm.} = object
m512d* {.importc: "__m512d", imm.} = object
m512i* {.importc: "__m512i", imm.} = object
m512* {.importc: "__m512" , imm.} = distinct array[16,float32]
m512d* {.importc: "__m512d", imm.} = distinct array[8,float64]
m512i* {.importc: "__m512i", imm.} = distinct array[16,int32]
m512h* = distinct m256i
mmask8* {.importc: "__mmask8" , imm.} = object
mmask16* {.importc: "__mmask16", imm.} = object
mmask32* {.importc: "__mmask32", imm.} = object
mmask64* {.importc: "__mmask64", imm.} = object
]#

type
SimdX86S* = m64 | m128 | m256 | m512
SimdX86D* = m128d | m256d | m512d
SimdX86* = SimdX86S | SimdX86D
Expand Down

0 comments on commit e5ed8b0

Please sign in to comment.