|
1 | 1 | # To add support for loading/storing...
|
2 |
| -@inline function load(p::Ptr{UInt}, ::Type{T}) where {T} |
3 |
| - reinterpret(T, vload(p)) |
| 2 | +@inline function load(p::Ptr{UInt}, ::Type{T}) where {T<:Ptr} |
| 3 | + reinterpret(T, __vload(p, False(), register_size())) |
4 | 4 | end
|
5 |
| -@inline function store!(p::Ptr{UInt}, x) |
6 |
| - vstore!(p, reinterpret(UInt, x)) |
| 5 | +@inline function load(p::Ptr{UInt32}, ::Type{T}) where {T<:Union{UInt32,Int32,Float32}} |
| 6 | + reinterpret(T, __vload(p, False(), register_size())) |
7 | 7 | end
|
| 8 | +@inline function load(p::Ptr{UInt64}, ::Type{T}) where {T<:Union{UInt64,Int64,Float64}} |
| 9 | + reinterpret(T, __vload(p, False(), register_size())) |
| 10 | +end |
| 11 | +@inline load(p::Ptr{UInt}, ::Type{T}) where {T} = unsafe_load(Base.unsafe_convert(Ptr{T}, p)) |
| 12 | +@inline function store!(p::Ptr{UInt}, x::T) where {T <: Ptr} |
| 13 | + __vstore!(p, reinterpret(UInt, x), False(), False(), False(), register_size()) |
| 14 | +end |
| 15 | +@inline function store!(p::Ptr{UInt32}, x::T) where {T <: Union{UInt32,Int32,Float32}} |
| 16 | + __vstore!(p, reinterpret(UInt, x), False(), False(), False(), register_size()) |
| 17 | +end |
| 18 | +@inline function store!(p::Ptr{UInt64}, x::T) where {T <: Union{UInt64,Int64,Float64}} |
| 19 | + __vstore!(p, reinterpret(UInt, x), False(), False(), False(), register_size()) |
| 20 | +end |
| 21 | +@inline store!(p::Ptr{UInt}, x::T) where {T} = (unsafe_store!(Base.unsafe_convert(Ptr{T}, p), x); nothing) |
8 | 22 |
|
9 | 23 | @inline load(p::Ptr{UInt}, ::Type{StaticInt{N}}, i) where {N} = i, StaticInt{N}()
|
10 | 24 | @inline store!(p::Ptr{UInt}, ::StaticInt, i) = i
|
|
53 | 67 | end
|
54 | 68 |
|
55 | 69 | @inline function load(p::Ptr{UInt}, ::Type{T}, i) where {T}
|
56 |
| - i += 1 |
57 |
| - i, load(p + i * sizeof(UInt), T) |
| 70 | + i + sizeof(T), load(p + i, T) |
58 | 71 | end
|
59 | 72 | @inline function store!(p::Ptr{UInt}, x, i)
|
60 |
| - store!(p + sizeof(UInt)*(i += 1), x) |
61 |
| - i |
| 73 | + store!(p + i, x) |
| 74 | + i + sizeof(x) |
62 | 75 | end
|
63 | 76 |
|
64 | 77 | @generated function load(p::Ptr{UInt}, ::Type{T}, i) where {T<:Tuple}
|
|
81 | 94 | store!(p, first(tup), i)
|
82 | 95 | end
|
83 | 96 | @inline store!(p::Ptr{UInt}, tup::Tuple{}, i) = i
|
| 97 | +@inline store!(p::Ptr{UInt}, tup::Nothing, i) = i |
84 | 98 |
|
0 commit comments