From 0bd47d8457a0abfb38009655cb2e61bbcc9be65a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 27 Jan 2024 12:07:45 +0530 Subject: [PATCH] Cleanup KITTY_NO_SIMD compilation --- kitty/simd-string-impl.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/kitty/simd-string-impl.h b/kitty/simd-string-impl.h index 7139e1010..52142043f 100644 --- a/kitty/simd-string-impl.h +++ b/kitty/simd-string-impl.h @@ -5,17 +5,23 @@ */ #pragma once -#ifdef KITTY_NO_SIMD -bool utf8_decode_to_esc_128(UTF8Decoder *d, const uint8_t *src, size_t src_sz) { fatal("No SIMD implementations for this CPU"); } -bool utf8_decode_to_esc_256(UTF8Decoder *d, const uint8_t *src, size_t src_sz) { fatal("No SIMD implementations for this CPU"); } -const uint8_t* find_either_of_two_bytes_128(const uint8_t *haystack, const size_t sz, const uint8_t a, const uint8_t b) { fatal("No SIMD implementations for this CPU"); } -const uint8_t* find_either_of_two_bytes_256(const uint8_t *haystack, const size_t sz, const uint8_t a, const uint8_t b) { fatal("No SIMD implementations for this CPU"); } -#else +#include "data-types.h" +#include "simd-string.h" + #ifndef KITTY_SIMD_LEVEL #define KITTY_SIMD_LEVEL 128 #endif +#define CONCAT(A, B) A##B +#define CONCAT_EXPAND(A, B) CONCAT(A,B) +#define FUNC(name) CONCAT_EXPAND(name##_, KITTY_SIMD_LEVEL) + +#ifdef KITTY_NO_SIMD +#define NOSIMD { fatal("No SIMD implementations for this CPU"); } +bool FUNC(utf8_decode_to_esc)(UTF8Decoder *d UNUSED, const uint8_t *src UNUSED, size_t src_sz UNUSED) NOSIMD +const uint8_t* FUNC(find_either_of_two_bytes)(const uint8_t *haystack UNUSED, const size_t sz UNUSED, const uint8_t a UNUSED, const uint8_t b UNUSED) NOSIMD +#undef NOSIMD +#else -#include "simd-string.h" #include "charsets.h" // Boilerplate {{{ @@ -32,9 +38,6 @@ _Pragma("clang diagnostic pop") #ifndef _MM_SHUFFLE #define _MM_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w)) #endif -#define CONCAT(A, B) A##B -#define CONCAT_EXPAND(A, B) CONCAT(A,B) -#define FUNC(name) CONCAT_EXPAND(name##_, KITTY_SIMD_LEVEL) #define integer_t CONCAT_EXPAND(CONCAT_EXPAND(simde__m, KITTY_SIMD_LEVEL), i) #define shift_right_by_bytes128 simde_mm_srli_si128 #define zero_last_n_bytes FUNC(zero_last_n_bytes)