@@ -4,7 +4,7 @@ use stdsimd_test::assert_instr;
4
4
use v128:: * ;
5
5
use x86:: __m128i;
6
6
7
- /// String contains unsigned 8-bit characters
7
+ /// String contains unsigned 8-bit characters *(Default)*
8
8
pub const _SIDD_UBYTE_OPS: i8 = 0b00000000 ;
9
9
/// String contains unsigned 16-bit characters
10
10
pub const _SIDD_UWORD_OPS: i8 = 0b00000001 ;
@@ -13,16 +13,16 @@ pub const _SIDD_SBYTE_OPS: i8 = 0b00000010;
13
13
/// String contains unsigned 16-bit characters
14
14
pub const _SIDD_SWORD_OPS: i8 = 0b00000011 ;
15
15
16
- /// For each character in `a`, find if it is in `b`
16
+ /// For each character in `a`, find if it is in `b` *(Default)*
17
17
pub const _SIDD_CMP_EQUAL_ANY: i8 = 0b00000000 ;
18
18
/// For each character in `a`, determine if `b[0] <= c <= b[1] or b[1] <= c <= b[2]...`
19
19
pub const _SIDD_CMP_RANGES: i8 = 0b00000100 ;
20
- /// String equality
20
+ /// The strings defined by `a` and `b` are equal
21
21
pub const _SIDD_CMP_EQUAL_EACH: i8 = 0b00001000 ;
22
- /// Substring search
22
+ /// Search for the defined substring in the target
23
23
pub const _SIDD_CMP_EQUAL_ORDERED: i8 = 0b00001100 ;
24
24
25
- /// Do not negate results
25
+ /// Do not negate results *(Default)*
26
26
pub const _SIDD_POSITIVE_POLARITY: i8 = 0b00000000 ;
27
27
/// Negate results
28
28
pub const _SIDD_NEGATIVE_POLARITY: i8 = 0b00010000 ;
@@ -31,14 +31,14 @@ pub const _SIDD_MASKED_POSITIVE_POLARITY: i8 = 0b00100000;
31
31
/// Negate results only before the end of the string
32
32
pub const _SIDD_MASKED_NEGATIVE_POLARITY: i8 = 0b00110000 ;
33
33
34
- /// Index only: return the least significant bit
34
+ /// ** Index only** : return the least significant bit *(Default)*
35
35
pub const _SIDD_LEAST_SIGNIFICANT: i8 = 0b00000000 ;
36
- /// Index only: return the most significant bit
36
+ /// ** Index only** : return the most significant bit
37
37
pub const _SIDD_MOST_SIGNIFICANT: i8 = 0b01000000 ;
38
38
39
- /// Mask only: return the bit mask
39
+ /// ** Mask only** : return the bit mask
40
40
pub const _SIDD_BIT_MASK: i8 = 0b00000000 ;
41
- /// Mask only: return the byte mask
41
+ /// ** Mask only** : return the byte mask
42
42
pub const _SIDD_UNIT_MASK: i8 = 0b01000000 ;
43
43
44
44
/// Compare packed strings with implicit lengths in `a` and `b` using the
@@ -59,6 +59,85 @@ pub unsafe fn _mm_cmpistrm(
59
59
60
60
/// Compare packed strings with implicit lengths in `a` and `b` using the
61
61
/// control in `imm8`, and return the generated index.
62
+ ///
63
+ /// # Control modes
64
+ ///
65
+ /// The control specified by `imm8` may be one or more of the following.
66
+ ///
67
+ /// ## Data size and signedness
68
+ ///
69
+ /// - [`_SIDD_UBYTE_OPS`] - Default
70
+ /// - [`_SIDD_UWORD_OPS`]
71
+ /// - [`_SIDD_SBYTE_OPS`]
72
+ /// - [`_SIDD_SWORD_OPS`]
73
+ ///
74
+ /// ## Comparison options
75
+ /// - [`_SIDD_CMP_EQUAL_ANY`] - Default
76
+ /// - [`_SIDD_CMP_RANGES`]
77
+ /// - [`_SIDD_CMP_EQUAL_EACH`]
78
+ /// - [`_SIDD_CMP_EQUAL_ORDERED`]
79
+ ///
80
+ /// ## Result polarity
81
+ /// - [`_SIDD_POSITIVE_POLARITY`] - Default
82
+ /// - [`_SIDD_NEGATIVE_POLARITY`]
83
+ ///
84
+ /// ## Bit returned
85
+ /// - [`_SIDD_LEAST_SIGNIFICANT`] - Default
86
+ /// - [`_SIDD_MOST_SIGNIFICANT`]
87
+ ///
88
+ /// # Examples
89
+ ///
90
+ /// ```
91
+ /// # #![feature(cfg_target_feature)]
92
+ /// # #![feature(target_feature)]
93
+ /// #
94
+ /// # #[macro_use] extern crate stdsimd;
95
+ /// #
96
+ /// # fn main() {
97
+ /// # if cfg_feature_enabled!("sse4.2") {
98
+ /// # #[target_feature = "+sse4.2"]
99
+ /// # fn worker() {
100
+ ///
101
+ /// use stdsimd::simd::u8x16;
102
+ /// use stdsimd::vendor::{__m128i, _mm_cmpistri, _SIDD_CMP_EQUAL_ORDERED};
103
+ ///
104
+ /// let haystack = b"This is a long string of text data\r\n\tthat extends multiple lines";
105
+ /// let needle = b"\r\n\t\0\0\0\0\0\0\0\0\0\0\0\0\0";
106
+ ///
107
+ /// let a = __m128i::from(u8x16::load(needle, 0));
108
+ /// let hop = 16;
109
+ /// let mut indexes = Vec::new();
110
+ ///
111
+ /// // Chunk the haystack into 16 byte chunks and find
112
+ /// // the first "\r\n\t" in the chunk.
113
+ /// for (i, chunk) in haystack.chunks(hop).enumerate() {
114
+ /// let b = __m128i::from(u8x16::load(chunk, 0));
115
+ /// let idx = unsafe {
116
+ /// _mm_cmpistri(a, b, _SIDD_CMP_EQUAL_ORDERED)
117
+ /// };
118
+ /// if idx != 16 {
119
+ /// indexes.push((idx as usize) + (i * hop));
120
+ /// }
121
+ /// }
122
+ /// assert_eq!(indexes, vec![34]);
123
+ /// # }
124
+ /// # worker();
125
+ /// # }
126
+ /// # }
127
+ /// ```
128
+ ///
129
+ /// [`_SIDD_UBYTE_OPS`]: constant._SIDD_UBYTE_OPS.html
130
+ /// [`_SIDD_UWORD_OPS`]: constant._SIDD_UWORD_OPS.html
131
+ /// [`_SIDD_SBYTE_OPS`]: constant._SIDD_SBYTE_OPS.html
132
+ /// [`_SIDD_SWORD_OPS`]: constant._SIDD_SWORD_OPS.html
133
+ /// [`_SIDD_CMP_EQUAL_ANY`]: constant._SIDD_CMP_EQUAL_ANY.html
134
+ /// [`_SIDD_CMP_RANGES`]: constant._SIDD_CMP_RANGES.html
135
+ /// [`_SIDD_CMP_EQUAL_EACH`]: constant._SIDD_CMP_EQUAL_EACH.html
136
+ /// [`_SIDD_CMP_EQUAL_ORDERED`]: constant._SIDD_CMP_EQUAL_ORDERED.html
137
+ /// [`_SIDD_POSITIVE_POLARITY`]: constant._SIDD_POSITIVE_POLARITY.html
138
+ /// [`_SIDD_NEGATIVE_POLARITY`]: constant._SIDD_NEGATIVE_POLARITY.html
139
+ /// [`_SIDD_LEAST_SIGNIFICANT`]: constant._SIDD_LEAST_SIGNIFICANT.html
140
+ /// [`_SIDD_MOST_SIGNIFICANT`]: constant._SIDD_MOST_SIGNIFICANT.html
62
141
#[ inline( always) ]
63
142
#[ target_feature = "+sse4.2" ]
64
143
#[ cfg_attr( test, assert_instr( pcmpistri, imm8 = 0 ) ) ]
0 commit comments