The stuff in
|
const __m128i = NTuple{2, VecElement{UInt64}} |
|
Base.convert(::Type{__m128i}, x::UInt128) = unsafe_load(Ptr{__m128i}(pointer_from_objref(Ref(x)))) |
|
Base.convert(::Type{UInt128}, x::__m128i) = unsafe_load(Ptr{UInt128}(pointer_from_objref(Ref(x)))) |
|
UInt128(x::__m128i) = convert(UInt128, x) |
|
__m128i(x::UInt128) = convert(__m128i, x) |
|
Base.convert(::Type{__m128i}, x::Union{Signed, Unsigned}) = convert(__m128i, UInt128(x)) |
|
Base.convert(::Type{T}, x::__m128i) where T <: Union{Signed, Unsigned} = convert(T, UInt128(x)) |
|
|
|
const LITTLE_ENDIAN = ENDIAN_BOM ≡ 0x04030201 |
|
__m128i(hi::UInt64, lo::UInt64) = LITTLE_ENDIAN ? (VecElement(lo), VecElement(hi)) : (VecElement(hi), VecElement(lo)) |
is type piracy and changes how basic Julia types behave.
You should in general do something like
struct __m128i
data:: NTuple{2, VecElement{UInt64}}
end
and define functions on that (similar as to how e.g. SIMD.jl does it, https://github.com/eschnett/SIMD.jl/blob/863e12ffd3fc36c4d9257f5332525948d55c9a70/src/simdvec.jl#L1-L3)
The stuff in
Random123.jl/src/aesni_common.jl
Lines 7 to 16 in 195d1ee
You should in general do something like
and define functions on that (similar as to how e.g. SIMD.jl does it, https://github.com/eschnett/SIMD.jl/blob/863e12ffd3fc36c4d9257f5332525948d55c9a70/src/simdvec.jl#L1-L3)