@@ -4,7 +4,10 @@ import Base.(+)
44using .. Random123: R123Generator1x, R123Generator4x
55import .. Random123: random123_r, set_counter!
66
7- const __m128i = NTuple{2 , VecElement{UInt64}}
7+ const __m128i_lvec = NTuple{2 , VecElement{UInt64}}
8+ struct __m128i
9+ data:: __m128i_lvec
10+ end
811Base. convert (:: Type{__m128i} , x:: UInt128 ) = unsafe_load (Ptr {__m128i} (pointer_from_objref (Ref (x))))
912Base. convert (:: Type{UInt128} , x:: __m128i ) = unsafe_load (Ptr {UInt128} (pointer_from_objref (Ref (x))))
1013UInt128 (x:: __m128i ) = convert (UInt128, x)
@@ -13,42 +16,42 @@ Base.convert(::Type{__m128i}, x::Union{Signed, Unsigned}) = convert(__m128i, UIn
1316Base. convert (:: Type{T} , x:: __m128i ) where T <: Union{Signed, Unsigned} = convert (T, UInt128 (x))
1417
1518const LITTLE_ENDIAN = ENDIAN_BOM ≡ 0x04030201
16- __m128i (hi:: UInt64 , lo:: UInt64 ) = LITTLE_ENDIAN ? ( VecElement (lo), VecElement (hi)) : ( VecElement (hi), VecElement (lo))
19+ __m128i (hi:: UInt64 , lo:: UInt64 ) = LITTLE_ENDIAN ? __m128i (( VecElement (lo), VecElement (hi))) : __m128i (( VecElement (hi), VecElement (lo) ))
1720
1821Base. zero (:: Type{__m128i} ) = __m128i (zero (UInt64), zero (UInt64))
1922Base. one (:: Type{__m128i} ) = __m128i (zero (UInt64), one (UInt64))
2023Base. xor (a:: __m128i , b:: __m128i ) = llvmcall (
2124 """ %3 = xor <2 x i64> %1, %0
2225 ret <2 x i64> %3""" ,
23- __m128i , Tuple{__m128i, __m128i },
24- a, b
25- )
26+ __m128i_lvec , Tuple{__m128i_lvec, __m128i_lvec },
27+ a. data , b. data
28+ ) |> __m128i
2629(+ )(a:: __m128i , b:: __m128i ) = llvmcall (
2730 """ %3 = add <2 x i64> %1, %0
2831 ret <2 x i64> %3""" ,
29- __m128i , Tuple{__m128i, __m128i },
30- a, b
31- )
32+ __m128i_lvec , Tuple{__m128i_lvec, __m128i_lvec },
33+ a. data , b. data
34+ ) |> __m128i
3235(+ )(a:: __m128i , b:: Integer ) = a + __m128i (UInt128 (b))
3336
3437_aes_enc (a:: __m128i , round_key:: __m128i ) = ccall (
3538 " llvm.x86.aesni.aesenc" ,
3639 llvmcall,
37- __m128i , (__m128i, __m128i ),
38- a, round_key
39- )
40+ __m128i_lvec , (__m128i_lvec, __m128i_lvec ),
41+ a. data , round_key. data
42+ ) |> __m128i
4043_aes_enc_last (a:: __m128i , round_key:: __m128i ) = ccall (
4144 " llvm.x86.aesni.aesenclast" ,
4245 llvmcall,
43- __m128i , (__m128i, __m128i ),
44- a, round_key
45- )
46+ __m128i_lvec , (__m128i_lvec, __m128i_lvec ),
47+ a. data , round_key. data
48+ ) |> __m128i
4649_aes_key_gen_assist (a:: __m128i , :: Val{R} ) where R = ccall (
4750 " llvm.x86.aesni.aeskeygenassist" ,
4851 llvmcall,
49- __m128i , (__m128i , UInt8),
50- a, R
51- )
52+ __m128i_lvec , (__m128i_lvec , UInt8),
53+ a. data , R
54+ ) |> __m128i
5255
5356" Abstract RNG that generates one number at a time and is based on AESNI."
5457abstract type AbstractAESNI1x <: R123Generator1x{UInt128} end
0 commit comments