22//!
33//! In this module, a "vector" is any `repr(simd)` type.
44
5+ use crate :: marker:: ConstParamTy ;
6+
57/// Inserts an element into a vector, returning the updated vector.
68///
79/// `T` must be a vector with element type `U`, and `idx` must be `const`.
@@ -377,6 +379,19 @@ pub unsafe fn simd_gather<T, U, V>(val: T, ptr: U, mask: V) -> T;
377379#[ rustc_nounwind]
378380pub unsafe fn simd_scatter < T , U , V > ( val : T , ptr : U , mask : V ) ;
379381
382+ /// A type for alignment options for SIMD masked load/store intrinsics.
383+ #[ derive( Debug , ConstParamTy , PartialEq , Eq ) ]
384+ pub enum SimdAlign {
385+ // These values must match the compiler's `SimdAlign` defined in
386+ // `rustc_middle/src/ty/consts/int.rs`!
387+ /// No alignment requirements on the pointer
388+ Unaligned = 0 ,
389+ /// The pointer must be aligned to the element type of the SIMD vector
390+ Element = 1 ,
391+ /// The pointer must be aligned to the SIMD vector type
392+ Vector = 2 ,
393+ }
394+
380395/// Reads a vector of pointers.
381396///
382397/// `T` must be a vector.
@@ -392,13 +407,12 @@ pub unsafe fn simd_scatter<T, U, V>(val: T, ptr: U, mask: V);
392407/// `val`.
393408///
394409/// # Safety
395- /// Unmasked values in `T` must be readable as if by `<ptr>::read` (e.g. aligned to the element
396- /// type).
410+ /// `ptr` must be aligned according to the `ALIGN` parameter, see [`SimdAlign`] for details.
397411///
398412/// `mask` must only contain `0` or `!0` values.
399413#[ rustc_intrinsic]
400414#[ rustc_nounwind]
401- pub unsafe fn simd_masked_load < V , U , T > ( mask : V , ptr : U , val : T ) -> T ;
415+ pub unsafe fn simd_masked_load < V , U , T , const ALIGN : SimdAlign > ( mask : V , ptr : U , val : T ) -> T ;
402416
403417/// Writes to a vector of pointers.
404418///
@@ -414,13 +428,12 @@ pub unsafe fn simd_masked_load<V, U, T>(mask: V, ptr: U, val: T) -> T;
414428/// Otherwise if the corresponding value in `mask` is `0`, do nothing.
415429///
416430/// # Safety
417- /// Unmasked values in `T` must be writeable as if by `<ptr>::write` (e.g. aligned to the element
418- /// type).
431+ /// `ptr` must be aligned according to the `ALIGN` parameter, see [`SimdAlign`] for details.
419432///
420433/// `mask` must only contain `0` or `!0` values.
421434#[ rustc_intrinsic]
422435#[ rustc_nounwind]
423- pub unsafe fn simd_masked_store < V , U , T > ( mask : V , ptr : U , val : T ) ;
436+ pub unsafe fn simd_masked_store < V , U , T , const ALIGN : SimdAlign > ( mask : V , ptr : U , val : T ) ;
424437
425438/// Adds two simd vectors elementwise, with saturation.
426439///
0 commit comments