Function safe_arch::search_explicit_str_for_index

source ·
pub fn search_explicit_str_for_index<const IMM: i32>(
    needle: m128i,
    needle_len: i32,
    haystack: m128i,
    haystack_len: i32,
) -> i32
Available with target feature sse4.2 only.
Expand description

Search for needle in `haystack, with explicit string length.

In the constant you need to provide (combine with |):

  • A comparison unit: STR_CMP_U8, STR_CMP_U16, STR_CMP_I8, or STR_CMP_I16.
  • A comparison op: STR_CMP_EQ_ANY, STR_CMP_RANGES, STR_CMP_EQ_EACH, or STR_CMP_EQ_ORDERED.
  • The desired output: STR_CMP_FIRST_MATCH or STR_CMP_LAST_MATCH.

If there’s no match the output is the length of the haystack.

  • Intrinsic: _mm_cmpestri
  • Assembly: pcmpestri xmm, xmm, imm8