#ifndef HIGHWAY_HWY_DETECT_COMPILER_ARCH_H_
#define HIGHWAY_HWY_DETECT_COMPILER_ARCH_H_
#if (defined __CDT_PARSER__) || (defined __INTELLISENSE__) || \
(defined Q_CREATOR_RUN) || (defined __CLANGD__) || \
(defined GROK_ELLIPSIS_BUILD)
#define HWY_IDE …
#else
#define HWY_IDE …
#endif
#if defined(_MSC_VER) && !defined(__clang__)
#define HWY_COMPILER_MSVC …
#else
#define HWY_COMPILER_MSVC …
#endif
#if defined(_MSC_VER) && defined(__clang__)
#define HWY_COMPILER_CLANGCL …
#else
#define HWY_COMPILER_CLANGCL …
#endif
#ifdef __INTEL_COMPILER
#define HWY_COMPILER_ICC …
#else
#define HWY_COMPILER_ICC …
#endif
#ifdef __INTEL_LLVM_COMPILER
#define HWY_COMPILER_ICX …
#else
#define HWY_COMPILER_ICX …
#endif
#ifdef __GNUC__
#define HWY_COMPILER_GCC …
#else
#define HWY_COMPILER_GCC …
#endif
#ifdef __clang__
#if defined(__apple_build_version__) || __clang_major__ >= 999
#if __has_warning("-Woverriding-option")
#define HWY_COMPILER_CLANG …
#elif __has_attribute(unsafe_buffer_usage)
#define HWY_COMPILER_CLANG …
#elif __has_attribute(nouwtable)
#define HWY_COMPILER_CLANG …
#elif __has_warning("-Warray-parameter")
#define HWY_COMPILER_CLANG …
#elif __has_warning("-Wbitwise-instead-of-logical")
#define HWY_COMPILER_CLANG …
#elif __has_warning("-Wreserved-identifier")
#define HWY_COMPILER_CLANG …
#elif __has_warning("-Wformat-insufficient-args")
#define HWY_COMPILER_CLANG …
#elif __has_warning("-Wimplicit-const-int-float-conversion")
#define HWY_COMPILER_CLANG …
#elif __has_warning("-Wmisleading-indentation")
#define HWY_COMPILER_CLANG …
#elif defined(__FILE_NAME__)
#define HWY_COMPILER_CLANG …
#elif __has_warning("-Wextra-semi-stmt") || \
__has_builtin(__builtin_rotateleft32)
#define HWY_COMPILER_CLANG …
#elif __has_warning("-Wc++98-compat-extra-semi") || \
(defined(__apple_build_version__) && __apple_build_version__ >= 10010000)
#define HWY_COMPILER_CLANG …
#else
#define HWY_COMPILER_CLANG …
#endif
#define HWY_COMPILER3_CLANG …
#else
#define HWY_COMPILER_CLANG …
#define HWY_COMPILER3_CLANG …
#endif
#else
#define HWY_COMPILER_CLANG …
#define HWY_COMPILER3_CLANG …
#endif
#if HWY_COMPILER_GCC && !HWY_COMPILER_CLANG && !HWY_COMPILER_ICC
#define HWY_COMPILER_GCC_ACTUAL …
#else
#define HWY_COMPILER_GCC_ACTUAL …
#endif
#if 0 == (HWY_COMPILER_MSVC + HWY_COMPILER_CLANGCL + HWY_COMPILER_ICC + \
HWY_COMPILER_GCC + HWY_COMPILER_CLANG)
#error "Unsupported compiler"
#endif
#if 1 < \
(!!HWY_COMPILER_MSVC + !!HWY_COMPILER_ICC + !!HWY_COMPILER_GCC_ACTUAL + \
!!(HWY_COMPILER_CLANGCL | HWY_COMPILER_CLANG))
#error "Detected multiple compilers"
#endif
#ifdef __has_builtin
#define HWY_HAS_BUILTIN(name) …
#else
#define HWY_HAS_BUILTIN …
#endif
#ifdef __has_attribute
#define HWY_HAS_ATTRIBUTE(name) …
#else
#define HWY_HAS_ATTRIBUTE …
#endif
#ifdef __has_cpp_attribute
#define HWY_HAS_CPP_ATTRIBUTE(name) …
#else
#define HWY_HAS_CPP_ATTRIBUTE …
#endif
#ifdef __has_feature
#define HWY_HAS_FEATURE(name) …
#else
#define HWY_HAS_FEATURE …
#endif
#ifdef __has_include
#define HWY_HAS_INCLUDE(header) …
#else
#define HWY_HAS_INCLUDE …
#endif
#if HWY_COMPILER_MSVC && defined(_MSVC_LANG) && _MSVC_LANG > __cplusplus
#define HWY_CXX_LANG …
#else
#define HWY_CXX_LANG …
#endif
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201603L
#define HWY_CXX17_CONSTEXPR …
#else
#define HWY_CXX17_CONSTEXPR
#endif
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201304L
#define HWY_CXX14_CONSTEXPR …
#else
#define HWY_CXX14_CONSTEXPR
#endif
#if HWY_CXX_LANG >= 201703L
#define HWY_IF_CONSTEXPR …
#else
#define HWY_IF_CONSTEXPR …
#endif
#if defined(__i386__) || defined(_M_IX86)
#define HWY_ARCH_X86_32 …
#else
#define HWY_ARCH_X86_32 …
#endif
#if defined(__x86_64__) || defined(_M_X64)
#define HWY_ARCH_X86_64 …
#else
#define HWY_ARCH_X86_64 …
#endif
#if HWY_ARCH_X86_32 && HWY_ARCH_X86_64
#error "Cannot have both x86-32 and x86-64"
#endif
#if HWY_ARCH_X86_32 || HWY_ARCH_X86_64
#define HWY_ARCH_X86 …
#else
#define HWY_ARCH_X86 …
#endif
#if defined(__powerpc64__) || defined(_M_PPC) || defined(__powerpc__)
#define HWY_ARCH_PPC …
#else
#define HWY_ARCH_PPC …
#endif
#if defined(__powerpc64__) || (HWY_ARCH_PPC && defined(__64BIT__))
#define HWY_ARCH_PPC_64 …
#else
#define HWY_ARCH_PPC_64 …
#endif
#if defined(__ARM_ARCH_ISA_A64) || defined(__aarch64__) || defined(_M_ARM64)
#define HWY_ARCH_ARM_A64 …
#else
#define HWY_ARCH_ARM_A64 …
#endif
#if (defined(__ARM_ARCH) && __ARM_ARCH == 7) || (defined(_M_ARM) && _M_ARM == 7)
#define HWY_ARCH_ARM_V7 …
#else
#define HWY_ARCH_ARM_V7 …
#endif
#if HWY_ARCH_ARM_A64 && HWY_ARCH_ARM_V7
#error "Cannot have both A64 and V7"
#endif
#if HWY_ARCH_ARM_A64 || HWY_ARCH_ARM_V7
#define HWY_ARCH_ARM …
#else
#define HWY_ARCH_ARM …
#endif
#if (defined(__arm__) || defined(_M_ARM)) && !HWY_ARCH_ARM
#define HWY_ARCH_ARM_OLD …
#else
#define HWY_ARCH_ARM_OLD …
#endif
#if defined(__EMSCRIPTEN__) || defined(__wasm__) || defined(__WASM__)
#define HWY_ARCH_WASM …
#else
#define HWY_ARCH_WASM …
#endif
#ifdef __riscv
#define HWY_ARCH_RISCV …
#else
#define HWY_ARCH_RISCV …
#endif
#define HWY_ARCH_RVV …
#if HWY_ARCH_RISCV && defined(__riscv_xlen)
#if __riscv_xlen == 32
#define HWY_ARCH_RISCV_32 …
#else
#define HWY_ARCH_RISCV_32 …
#endif
#if __riscv_xlen == 64
#define HWY_ARCH_RISCV_64 …
#else
#define HWY_ARCH_RISCV_64 …
#endif
#else
#define HWY_ARCH_RISCV_32 …
#define HWY_ARCH_RISCV_64 …
#endif
#if HWY_ARCH_RISCV_32 && HWY_ARCH_RISCV_64
#error "Cannot have both RISCV_32 and RISCV_64"
#endif
#if defined(__s390x__)
#define HWY_ARCH_S390X …
#else
#define HWY_ARCH_S390X …
#endif
#if (HWY_ARCH_X86 + HWY_ARCH_PPC + HWY_ARCH_ARM + HWY_ARCH_ARM_OLD + \
HWY_ARCH_WASM + HWY_ARCH_RISCV + HWY_ARCH_S390X) > 1
#error "Must not detect more than one architecture"
#endif
#if defined(_WIN32) || defined(_WIN64)
#define HWY_OS_WIN …
#else
#define HWY_OS_WIN …
#endif
#if defined(linux) || defined(__linux__)
#define HWY_OS_LINUX …
#else
#define HWY_OS_LINUX …
#endif
#if defined(__APPLE__)
#define HWY_OS_APPLE …
#else
#define HWY_OS_APPLE …
#endif
#if defined(__FreeBSD__)
#define HWY_OS_FREEBSD …
#else
#define HWY_OS_FREEBSD …
#endif
#if (HWY_OS_WIN + HWY_OS_LINUX + HWY_OS_APPLE + HWY_OS_FREEBSD) > 1
#error "Must not detect more than one OS"
#endif
#if HWY_COMPILER_MSVC
#if HWY_ARCH_PPC && defined(_XBOX_VER) && _XBOX_VER >= 200
#define HWY_IS_LITTLE_ENDIAN …
#define HWY_IS_BIG_ENDIAN …
#else
#define HWY_IS_LITTLE_ENDIAN …
#define HWY_IS_BIG_ENDIAN …
#endif
#elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define HWY_IS_LITTLE_ENDIAN …
#define HWY_IS_BIG_ENDIAN …
#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define HWY_IS_LITTLE_ENDIAN …
#define HWY_IS_BIG_ENDIAN …
#else
#error "Unable to detect endianness or unsupported byte order"
#endif
#if (HWY_IS_LITTLE_ENDIAN + HWY_IS_BIG_ENDIAN) != 1
#error "Must only detect one byte order"
#endif
#endif