@@ -192,6 +192,19 @@ ada_really_inline int trailing_zeroes(uint32_t input_num) noexcept {
192192// :, /, \\, ? or [. If none is found, view.size() is returned.
193193// For use within get_host_delimiter_location.
194194#if ADA_NEON
195+ // The ada_make_uint8x16_t macro is necessary because Visual Studio does not
196+ // support direct initialization of uint8x16_t. See
197+ // https://developercommunity.visualstudio.com/t/error-C2078:-too-many-initializers-whe/402911?q=backend+neon
198+ #ifndef ada_make_uint8x16_t
199+ #define ada_make_uint8x16_t (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, \
200+ x13, x14, x15, x16) \
201+ ([=]() { \
202+ static uint8_t array[16 ] = {x1, x2, x3, x4, x5, x6, x7, x8, \
203+ x9, x10, x11, x12, x13, x14, x15, x16}; \
204+ return vld1q_u8 (array); \
205+ }())
206+ #endif
207+
195208ada_really_inline size_t find_next_host_delimiter_special (
196209 std::string_view view, size_t location) noexcept {
197210 // first check for short strings in which case we do it naively.
@@ -205,8 +218,9 @@ ada_really_inline size_t find_next_host_delimiter_special(
205218 return size_t (view.size ());
206219 }
207220 auto to_bitmask = [](uint8x16_t input) -> uint16_t {
208- uint8x16_t bit_mask = {0x01 , 0x02 , 0x4 , 0x8 , 0x10 , 0x20 , 0x40 , 0x80 ,
209- 0x01 , 0x02 , 0x4 , 0x8 , 0x10 , 0x20 , 0x40 , 0x80 };
221+ uint8x16_t bit_mask =
222+ ada_make_uint8x16_t (0x01 , 0x02 , 0x4 , 0x8 , 0x10 , 0x20 , 0x40 , 0x80 , 0x01 ,
223+ 0x02 , 0x4 , 0x8 , 0x10 , 0x20 , 0x40 , 0x80 );
210224 uint8x16_t minput = vandq_u8 (input, bit_mask);
211225 uint8x16_t tmp = vpaddq_u8 (minput, minput);
212226 tmp = vpaddq_u8 (tmp, tmp);
@@ -216,10 +230,12 @@ ada_really_inline size_t find_next_host_delimiter_special(
216230
217231 // fast path for long strings (expected to be common)
218232 size_t i = location;
219- uint8x16_t low_mask = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
220- 0x00 , 0x00 , 0x01 , 0x04 , 0x04 , 0x00 , 0x00 , 0x03 };
221- uint8x16_t high_mask = {0x00 , 0x00 , 0x02 , 0x01 , 0x00 , 0x04 , 0x00 , 0x00 ,
222- 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
233+ uint8x16_t low_mask =
234+ ada_make_uint8x16_t (0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
235+ 0x00 , 0x01 , 0x04 , 0x04 , 0x00 , 0x00 , 0x03 );
236+ uint8x16_t high_mask =
237+ ada_make_uint8x16_t (0x00 , 0x00 , 0x02 , 0x01 , 0x00 , 0x04 , 0x00 , 0x00 , 0x00 ,
238+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 );
223239 uint8x16_t fmask = vmovq_n_u8 (0xf );
224240 uint8x16_t zero{0 };
225241 for (; i + 15 < view.size (); i += 16 ) {
@@ -340,8 +356,9 @@ ada_really_inline size_t find_next_host_delimiter(std::string_view view,
340356 return size_t (view.size ());
341357 }
342358 auto to_bitmask = [](uint8x16_t input) -> uint16_t {
343- uint8x16_t bit_mask = {0x01 , 0x02 , 0x4 , 0x8 , 0x10 , 0x20 , 0x40 , 0x80 ,
344- 0x01 , 0x02 , 0x4 , 0x8 , 0x10 , 0x20 , 0x40 , 0x80 };
359+ uint8x16_t bit_mask =
360+ ada_make_uint8x16_t (0x01 , 0x02 , 0x4 , 0x8 , 0x10 , 0x20 , 0x40 , 0x80 , 0x01 ,
361+ 0x02 , 0x4 , 0x8 , 0x10 , 0x20 , 0x40 , 0x80 );
345362 uint8x16_t minput = vandq_u8 (input, bit_mask);
346363 uint8x16_t tmp = vpaddq_u8 (minput, minput);
347364 tmp = vpaddq_u8 (tmp, tmp);
@@ -351,10 +368,12 @@ ada_really_inline size_t find_next_host_delimiter(std::string_view view,
351368
352369 // fast path for long strings (expected to be common)
353370 size_t i = location;
354- uint8x16_t low_mask = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
355- 0x00 , 0x00 , 0x01 , 0x04 , 0x00 , 0x00 , 0x00 , 0x03 };
356- uint8x16_t high_mask = {0x00 , 0x00 , 0x02 , 0x01 , 0x00 , 0x04 , 0x00 , 0x00 ,
357- 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
371+ uint8x16_t low_mask =
372+ ada_make_uint8x16_t (0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
373+ 0x00 , 0x01 , 0x04 , 0x00 , 0x00 , 0x00 , 0x03 );
374+ uint8x16_t high_mask =
375+ ada_make_uint8x16_t (0x00 , 0x00 , 0x02 , 0x01 , 0x00 , 0x04 , 0x00 , 0x00 , 0x00 ,
376+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 );
358377 uint8x16_t fmask = vmovq_n_u8 (0xf );
359378 uint8x16_t zero{0 };
360379 for (; i + 15 < view.size (); i += 16 ) {
@@ -774,4 +793,5 @@ namespace ada {
774793ada_warn_unused std::string to_string (ada::state state) {
775794 return ada::helpers::get_state (state);
776795}
796+ #undef ada_make_uint8x16_t
777797} // namespace ada
0 commit comments