m14509.nim 415 B

1234567891011121314151617
  1. import macros
  2. type float32x4 = array[4, float32]
  3. type float32x8 = array[8, float32]
  4. {.experimental: "dynamicBindSym".}
  5. macro dispatch(N: static int, T: type SomeNumber): untyped =
  6. let BaseT = getTypeInst(T)[1]
  7. result = bindSym($BaseT & "x" & $N)
  8. type
  9. VecIntrin*[N: static int, T: SomeNumber] = dispatch(N, T)
  10. func `$`*[N, T](vec: VecIntrin[N, T]): string =
  11. ## Display a vector
  12. $cast[array[N, T]](vec)