File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -5,3 +5,6 @@ mod uint;
55pub use float:: * ;
66pub use int:: * ;
77pub use uint:: * ;
8+
9+ // Vectors of pointers are not for public use at the current time.
10+ pub ( crate ) mod ptr;
Original file line number Diff line number Diff line change 1+ //! Private implementation details of public gather/scatter APIs.
2+ use crate :: SimdUsize ;
3+ use core:: mem;
4+
5+ /// A vector of *const T.
6+ #[ derive( Debug , Copy , Clone ) ]
7+ #[ repr( simd) ]
8+ pub ( crate ) struct SimdConstPtr < T , const LANES : usize > ( [ * const T ; LANES ] ) ;
9+
10+ impl < T , const LANES : usize > SimdConstPtr < T , LANES >
11+ where
12+ SimdUsize < LANES > : crate :: LanesAtMost32 ,
13+ T : Sized ,
14+ {
15+ #[ inline]
16+ #[ must_use]
17+ pub fn splat ( ptr : * const T ) -> Self {
18+ Self ( [ ptr; LANES ] )
19+ }
20+
21+ #[ inline]
22+ #[ must_use]
23+ pub fn wrapping_add ( self , addend : SimdUsize < LANES > ) -> Self {
24+ unsafe {
25+ let x: SimdUsize < LANES > = mem:: transmute_copy ( & self ) ;
26+ mem:: transmute_copy ( & { x + ( addend * mem:: size_of :: < T > ( ) ) } )
27+ }
28+ }
29+ }
30+
31+ /// A vector of *mut T. Be very careful around potential aliasing.
32+ #[ derive( Debug , Copy , Clone ) ]
33+ #[ repr( simd) ]
34+ pub ( crate ) struct SimdMutPtr < T , const LANES : usize > ( [ * mut T ; LANES ] ) ;
35+
36+ impl < T , const LANES : usize > SimdMutPtr < T , LANES >
37+ where
38+ SimdUsize < LANES > : crate :: LanesAtMost32 ,
39+ T : Sized ,
40+ {
41+ #[ inline]
42+ #[ must_use]
43+ pub fn splat ( ptr : * mut T ) -> Self {
44+ Self ( [ ptr; LANES ] )
45+ }
46+
47+ #[ inline]
48+ #[ must_use]
49+ pub fn wrapping_add ( self , addend : SimdUsize < LANES > ) -> Self {
50+ unsafe {
51+ let x: SimdUsize < LANES > = mem:: transmute_copy ( & self ) ;
52+ mem:: transmute_copy ( & { x + ( addend * mem:: size_of :: < T > ( ) ) } )
53+ }
54+ }
55+ }
You can’t perform that action at this time.
0 commit comments