| 1 | // Adapted from the coregex project, https://github.com/coregx/coregex |
| 2 | // (package simd), Copyright (c) 2025 Andrey Kolkov and contributors, |
| 3 | // MIT License. See the LICENSE file in this directory for the full text. |
| 4 | |
| 5 | //go:build amd64 |
| 6 | |
| 7 | package simdscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/simd`/ |
| 8 | |
| 9 | // Assembly kernels implemented in memchr_class_amd64.s. Class membership |
| 10 | // is computed with a pair of VPSHUFB nibble lookups instead of one |
| 11 | // clamp-and-compare per range, and four 32-byte vectors are classified per |
| 12 | // iteration. |
| 13 | // |
| 14 | //go:noescape |
| 15 | func memchrWordAVX2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/simd`/memchrWordAVX2().(haystack []byte) int |
| 16 | |
| 17 | //go:noescape |
| 18 | func memchrNotWordAVX2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/simd`/memchrNotWordAVX2().(haystack []byte) int |
| 19 | |
| 20 | // memchrWordImpl dispatches to the AVX2 kernel for inputs large enough to |
| 21 | // amortize the vector setup. The caller guarantees a non-empty haystack. |
| 22 | func memchrWordImplscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/simd`/memchrWordImpl().(haystack []byte) int { |
| 23 | if hasAVX2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/simd`/hasAVX2. && len(haystack) >= MinLenscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/simd`/MinLen. { |
| 24 | return memchrWordAVX2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/simd`/memchrWordAVX2().(haystack) |
| 25 | } |
| 26 | return memchrWordGenericscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/simd`/memchrWordGeneric().(haystack) |
| 27 | } |
| 28 | |
| 29 | // memchrNotWordImpl dispatches like memchrWordImpl. |
| 30 | func memchrNotWordImplscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/simd`/memchrNotWordImpl().(haystack []byte) int { |
| 31 | if hasAVX2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/simd`/hasAVX2. && len(haystack) >= MinLenscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/simd`/MinLen. { |
| 32 | return memchrNotWordAVX2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/simd`/memchrNotWordAVX2().(haystack) |
| 33 | } |
| 34 | return memchrNotWordGenericscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/simd`/memchrNotWordGeneric().(haystack) |
| 35 | } |