blob: b070ae3b6dda96eb1dfc96af0b2b2e02fbb4a396 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Generates code for every target that this compiler can support.
#undef HWY_TARGET_INCLUDE
#define HWY_TARGET_INCLUDE "simd/index_of.cpp" // this file
#include <hwy/foreach_target.h> // must come before highway.h
#include <hwy/highway.h>
#include <simd/index_of.h>
#include <optional>
HWY_BEFORE_NAMESPACE();
namespace ghostty {
namespace HWY_NAMESPACE {
namespace hn = hwy::HWY_NAMESPACE;
size_t IndexOf(const uint8_t needle,
const uint8_t* HWY_RESTRICT input,
size_t count) {
const hn::ScalableTag<uint8_t> d;
return IndexOfImpl(d, needle, input, count);
}
} // namespace HWY_NAMESPACE
} // namespace ghostty
HWY_AFTER_NAMESPACE();
// HWY_ONCE is true for only one of the target passes
#if HWY_ONCE
namespace ghostty {
// This macro declares a static array used for dynamic dispatch.
HWY_EXPORT(IndexOf);
size_t IndexOf(const uint8_t needle,
const uint8_t* HWY_RESTRICT input,
size_t count) {
return HWY_DYNAMIC_DISPATCH(IndexOf)(needle, input, count);
}
} // namespace ghostty
extern "C" {
size_t ghostty_simd_index_of(const uint8_t needle,
const uint8_t* HWY_RESTRICT input,
size_t count) {
return ghostty::IndexOf(needle, input, count);
}
}
#endif // HWY_ONCE
|