Only include builtin implementation from header

This commit is contained in:
John Keiser 2021-03-06 12:53:01 -08:00
parent cf4e538536
commit f51d50399c
28 changed files with 54 additions and 74 deletions

View File

@ -35,7 +35,6 @@
*/ */
#include "simdjson/dom.h" #include "simdjson/dom.h"
#include "simdjson/implementations.h"
#include "simdjson/builtin.h" #include "simdjson/builtin.h"
#endif // SIMDJSON_H #endif // SIMDJSON_H

View File

@ -3,15 +3,6 @@
#include "simdjson/implementation-base.h" #include "simdjson/implementation-base.h"
#ifdef SIMDJSON_FALLBACK_H
#error "arm64.h must be included before fallback.h"
#endif
#ifndef SIMDJSON_IMPLEMENTATION_ARM64
#define SIMDJSON_IMPLEMENTATION_ARM64 (SIMDJSON_IS_ARM64)
#endif
#define SIMDJSON_CAN_ALWAYS_RUN_ARM64 SIMDJSON_IMPLEMENTATION_ARM64 && SIMDJSON_IS_ARM64
#if SIMDJSON_IMPLEMENTATION_ARM64 #if SIMDJSON_IMPLEMENTATION_ARM64
namespace simdjson { namespace simdjson {
@ -37,11 +28,9 @@ namespace arm64 {
#include "simdjson/arm64/stringparsing.h" #include "simdjson/arm64/stringparsing.h"
#include "simdjson/arm64/numberparsing.h" #include "simdjson/arm64/numberparsing.h"
#include "simdjson/generic/implementation_simdjson_result_base.h" #include "simdjson/generic/implementation_simdjson_result_base.h"
#include "simdjson/generic/ondemand.h"
// Inline definitions // Inline definitions
#include "simdjson/generic/implementation_simdjson_result_base-inl.h" #include "simdjson/generic/implementation_simdjson_result_base-inl.h"
#include "simdjson/generic/ondemand-inl.h"
#include "simdjson/arm64/end.h" #include "simdjson/arm64/end.h"
#endif // SIMDJSON_IMPLEMENTATION_ARM64 #endif // SIMDJSON_IMPLEMENTATION_ARM64

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_ARM64_IMPLEMENTATION_H #ifndef SIMDJSON_ARM64_IMPLEMENTATION_H
#define SIMDJSON_ARM64_IMPLEMENTATION_H #define SIMDJSON_ARM64_IMPLEMENTATION_H
#include "simdjson.h" #include "simdjson/base.h"
#include "simdjson/internal/isadetection.h" #include "simdjson/internal/isadetection.h"
namespace simdjson { namespace simdjson {

View File

@ -1,8 +1,6 @@
#ifndef SIMDJSON_ARM64_INTRINSICS_H #ifndef SIMDJSON_ARM64_INTRINSICS_H
#define SIMDJSON_ARM64_INTRINSICS_H #define SIMDJSON_ARM64_INTRINSICS_H
#include "simdjson.h"
// This should be the correct header whether // This should be the correct header whether
// you use visual studio or other compilers. // you use visual studio or other compilers.
#include <arm_neon.h> #include <arm_neon.h>

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_ARM64_SIMD_H #ifndef SIMDJSON_ARM64_SIMD_H
#define SIMDJSON_ARM64_SIMD_H #define SIMDJSON_ARM64_SIMD_H
#include "simdjson.h" #include "simdjson/base.h"
#include "simdjson/internal/simdprune_tables.h" #include "simdjson/internal/simdprune_tables.h"
#include "simdjson/arm64/bitmanipulation.h" #include "simdjson/arm64/bitmanipulation.h"
#include <type_traits> #include <type_traits>

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_ARM64_STRINGPARSING_H #ifndef SIMDJSON_ARM64_STRINGPARSING_H
#define SIMDJSON_ARM64_STRINGPARSING_H #define SIMDJSON_ARM64_STRINGPARSING_H
#include "simdjson.h" #include "simdjson/base.h"
#include "simdjson/arm64/simd.h" #include "simdjson/arm64/simd.h"
#include "simdjson/arm64/bitmanipulation.h" #include "simdjson/arm64/bitmanipulation.h"

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_BUILTIN_H #ifndef SIMDJSON_BUILTIN_H
#define SIMDJSON_BUILTIN_H #define SIMDJSON_BUILTIN_H
#include "simdjson/portability.h" #include "simdjson/implementation-base.h"
#ifndef SIMDJSON_BUILTIN_IMPLEMENTATION #ifndef SIMDJSON_BUILTIN_IMPLEMENTATION
#if SIMDJSON_CAN_ALWAYS_RUN_HASWELL #if SIMDJSON_CAN_ALWAYS_RUN_HASWELL

View File

@ -3,12 +3,6 @@
#include "simdjson/implementation-base.h" #include "simdjson/implementation-base.h"
// Default Fallback to on unless a builtin implementation has already been selected.
#ifndef SIMDJSON_IMPLEMENTATION_FALLBACK
#define SIMDJSON_IMPLEMENTATION_FALLBACK 1 // (!SIMDJSON_CAN_ALWAYS_RUN_ARM64 && !SIMDJSON_CAN_ALWAYS_RUN_HASWELL && !SIMDJSON_CAN_ALWAYS_RUN_WESTMERE && !SIMDJSON_CAN_ALWAYS_RUN_PPC64)
#endif
#define SIMDJSON_CAN_ALWAYS_RUN_FALLBACK SIMDJSON_IMPLEMENTATION_FALLBACK
#if SIMDJSON_IMPLEMENTATION_FALLBACK #if SIMDJSON_IMPLEMENTATION_FALLBACK
namespace simdjson { namespace simdjson {

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_FALLBACK_BITMANIPULATION_H #ifndef SIMDJSON_FALLBACK_BITMANIPULATION_H
#define SIMDJSON_FALLBACK_BITMANIPULATION_H #define SIMDJSON_FALLBACK_BITMANIPULATION_H
#include "simdjson.h" #include "simdjson/base.h"
#include <limits> #include <limits>
namespace simdjson { namespace simdjson {

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_FALLBACK_STRINGPARSING_H #ifndef SIMDJSON_FALLBACK_STRINGPARSING_H
#define SIMDJSON_FALLBACK_STRINGPARSING_H #define SIMDJSON_FALLBACK_STRINGPARSING_H
#include "simdjson.h" #include "simdjson/base.h"
namespace simdjson { namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION { namespace SIMDJSON_IMPLEMENTATION {

View File

@ -1,4 +1,4 @@
#include "simdjson.h" #include "simdjson/base.h"
#include "simdjson/internal/isadetection.h" #include "simdjson/internal/isadetection.h"
namespace simdjson { namespace simdjson {

View File

@ -3,22 +3,6 @@
#include "simdjson/implementation-base.h" #include "simdjson/implementation-base.h"
#ifdef SIMDJSON_WESTMERE_H
#error "haswell.h must be included before westmere.h"
#endif
#ifdef SIMDJSON_FALLBACK_H
#error "haswell.h must be included before fallback.h"
#endif
// Default Haswell to on if this is x86-64. Even if we're not compiled for it, it could be selected
// at runtime.
#ifndef SIMDJSON_IMPLEMENTATION_HASWELL
#define SIMDJSON_IMPLEMENTATION_HASWELL (SIMDJSON_IS_X86_64)
#endif
// To see why (__BMI__) && (__PCLMUL__) && (__LZCNT__) are not part of this next line, see
// https://github.com/simdjson/simdjson/issues/1247
#define SIMDJSON_CAN_ALWAYS_RUN_HASWELL ((SIMDJSON_IMPLEMENTATION_HASWELL) && (SIMDJSON_IS_X86_64) && (__AVX2__))
#if SIMDJSON_IMPLEMENTATION_HASWELL #if SIMDJSON_IMPLEMENTATION_HASWELL
#define SIMDJSON_TARGET_HASWELL SIMDJSON_TARGET_REGION("avx2,bmi,pclmul,lzcnt") #define SIMDJSON_TARGET_HASWELL SIMDJSON_TARGET_REGION("avx2,bmi,pclmul,lzcnt")

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_HASWELL_INTRINSICS_H #ifndef SIMDJSON_HASWELL_INTRINSICS_H
#define SIMDJSON_HASWELL_INTRINSICS_H #define SIMDJSON_HASWELL_INTRINSICS_H
#include "simdjson.h" #include "simdjson/base.h"
#ifdef SIMDJSON_VISUAL_STUDIO #ifdef SIMDJSON_VISUAL_STUDIO
// under clang within visual studio, this will include <x86intrin.h> // under clang within visual studio, this will include <x86intrin.h>

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_HASWELL_STRINGPARSING_H #ifndef SIMDJSON_HASWELL_STRINGPARSING_H
#define SIMDJSON_HASWELL_STRINGPARSING_H #define SIMDJSON_HASWELL_STRINGPARSING_H
#include "simdjson.h" #include "simdjson/base.h"
#include "simdjson/haswell/simd.h" #include "simdjson/haswell/simd.h"
#include "simdjson/haswell/bitmanipulation.h" #include "simdjson/haswell/bitmanipulation.h"

View File

@ -20,4 +20,35 @@
#include "simdjson/internal/numberparsing_tables.h" #include "simdjson/internal/numberparsing_tables.h"
#include "simdjson/internal/simdprune_tables.h" #include "simdjson/internal/simdprune_tables.h"
#ifndef SIMDJSON_IMPLEMENTATION_ARM64
#define SIMDJSON_IMPLEMENTATION_ARM64 (SIMDJSON_IS_ARM64)
#endif
#define SIMDJSON_CAN_ALWAYS_RUN_ARM64 SIMDJSON_IMPLEMENTATION_ARM64 && SIMDJSON_IS_ARM64
// Default Haswell to on if this is x86-64. Even if we're not compiled for it, it could be selected
// at runtime.
#ifndef SIMDJSON_IMPLEMENTATION_HASWELL
#define SIMDJSON_IMPLEMENTATION_HASWELL (SIMDJSON_IS_X86_64)
#endif
// To see why (__BMI__) && (__PCLMUL__) && (__LZCNT__) are not part of this next line, see
// https://github.com/simdjson/simdjson/issues/1247
#define SIMDJSON_CAN_ALWAYS_RUN_HASWELL ((SIMDJSON_IMPLEMENTATION_HASWELL) && (SIMDJSON_IS_X86_64) && (__AVX2__))
// Default Westmere to on if this is x86-64, unless we'll always select Haswell.
#ifndef SIMDJSON_IMPLEMENTATION_WESTMERE
#define SIMDJSON_IMPLEMENTATION_WESTMERE (SIMDJSON_IS_X86_64 && !SIMDJSON_REQUIRES_HASWELL)
#endif
#define SIMDJSON_CAN_ALWAYS_RUN_WESTMERE (SIMDJSON_IMPLEMENTATION_WESTMERE && SIMDJSON_IS_X86_64 && __SSE4_2__ && __PCLMUL__)
#ifndef SIMDJSON_IMPLEMENTATION_PPC64
#define SIMDJSON_IMPLEMENTATION_PPC64 (SIMDJSON_IS_PPC64)
#endif
#define SIMDJSON_CAN_ALWAYS_RUN_PPC64 SIMDJSON_IMPLEMENTATION_PPC64 && SIMDJSON_IS_PPC64
// Default Fallback to on unless a builtin implementation has already been selected.
#ifndef SIMDJSON_IMPLEMENTATION_FALLBACK
#define SIMDJSON_IMPLEMENTATION_FALLBACK 1 // (!SIMDJSON_CAN_ALWAYS_RUN_ARM64 && !SIMDJSON_CAN_ALWAYS_RUN_HASWELL && !SIMDJSON_CAN_ALWAYS_RUN_WESTMERE && !SIMDJSON_CAN_ALWAYS_RUN_PPC64)
#endif
#define SIMDJSON_CAN_ALWAYS_RUN_FALLBACK SIMDJSON_IMPLEMENTATION_FALLBACK
#endif // SIMDJSON_IMPLEMENTATION_BASE_H #endif // SIMDJSON_IMPLEMENTATION_BASE_H

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_INTERNAL_JSONCHARUTILS_TABLES_H #ifndef SIMDJSON_INTERNAL_JSONCHARUTILS_TABLES_H
#define SIMDJSON_INTERNAL_JSONCHARUTILS_TABLES_H #define SIMDJSON_INTERNAL_JSONCHARUTILS_TABLES_H
#include "simdjson.h" #include "simdjson/common_defs.h"
#ifdef JSON_TEST_STRINGS #ifdef JSON_TEST_STRINGS
void found_string(const uint8_t *buf, const uint8_t *parsed_begin, void found_string(const uint8_t *buf, const uint8_t *parsed_begin,

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_INTERNAL_NUMBERPARSING_TABLES_H #ifndef SIMDJSON_INTERNAL_NUMBERPARSING_TABLES_H
#define SIMDJSON_INTERNAL_NUMBERPARSING_TABLES_H #define SIMDJSON_INTERNAL_NUMBERPARSING_TABLES_H
#include "simdjson.h" #include "simdjson/base.h"
namespace simdjson { namespace simdjson {
namespace internal { namespace internal {

View File

@ -3,15 +3,6 @@
#include "simdjson/implementation-base.h" #include "simdjson/implementation-base.h"
#ifdef SIMDJSON_FALLBACK_H
#error "ppc64.h must be included before fallback.h"
#endif
#ifndef SIMDJSON_IMPLEMENTATION_PPC64
#define SIMDJSON_IMPLEMENTATION_PPC64 (SIMDJSON_IS_PPC64)
#endif
#define SIMDJSON_CAN_ALWAYS_RUN_PPC64 SIMDJSON_IMPLEMENTATION_PPC64 && SIMDJSON_IS_PPC64
#if SIMDJSON_IMPLEMENTATION_PPC64 #if SIMDJSON_IMPLEMENTATION_PPC64
namespace simdjson { namespace simdjson {

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_PPC64_IMPLEMENTATION_H #ifndef SIMDJSON_PPC64_IMPLEMENTATION_H
#define SIMDJSON_PPC64_IMPLEMENTATION_H #define SIMDJSON_PPC64_IMPLEMENTATION_H
#include "simdjson.h" #include "simdjson/base.h"
#include "simdjson/internal/isadetection.h" #include "simdjson/internal/isadetection.h"
namespace simdjson { namespace simdjson {

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_PPC64_INTRINSICS_H #ifndef SIMDJSON_PPC64_INTRINSICS_H
#define SIMDJSON_PPC64_INTRINSICS_H #define SIMDJSON_PPC64_INTRINSICS_H
#include "simdjson.h" #include "simdjson/base.h"
// This should be the correct header whether // This should be the correct header whether
// you use visual studio or other compilers. // you use visual studio or other compilers.

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_PPC64_SIMD_H #ifndef SIMDJSON_PPC64_SIMD_H
#define SIMDJSON_PPC64_SIMD_H #define SIMDJSON_PPC64_SIMD_H
#include "simdjson.h" #include "simdjson/base.h"
#include "simdjson/internal/simdprune_tables.h" #include "simdjson/internal/simdprune_tables.h"
#include "simdjson/ppc64/bitmanipulation.h" #include "simdjson/ppc64/bitmanipulation.h"
#include <type_traits> #include <type_traits>

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_PPC64_STRINGPARSING_H #ifndef SIMDJSON_PPC64_STRINGPARSING_H
#define SIMDJSON_PPC64_STRINGPARSING_H #define SIMDJSON_PPC64_STRINGPARSING_H
#include "simdjson.h" #include "simdjson/base.h"
#include "simdjson/ppc64/bitmanipulation.h" #include "simdjson/ppc64/bitmanipulation.h"
#include "simdjson/ppc64/simd.h" #include "simdjson/ppc64/simd.h"

View File

@ -3,16 +3,6 @@
#include "simdjson/implementation-base.h" #include "simdjson/implementation-base.h"
#ifdef SIMDJSON_FALLBACK_H
#error "westmere.h must be included before fallback.h"
#endif
// Default Westmere to on if this is x86-64, unless we'll always select Haswell.
#ifndef SIMDJSON_IMPLEMENTATION_WESTMERE
#define SIMDJSON_IMPLEMENTATION_WESTMERE (SIMDJSON_IS_X86_64 && !SIMDJSON_REQUIRES_HASWELL)
#endif
#define SIMDJSON_CAN_ALWAYS_RUN_WESTMERE (SIMDJSON_IMPLEMENTATION_WESTMERE && SIMDJSON_IS_X86_64 && __SSE4_2__ && __PCLMUL__)
#if SIMDJSON_IMPLEMENTATION_WESTMERE #if SIMDJSON_IMPLEMENTATION_WESTMERE
#define SIMDJSON_TARGET_WESTMERE SIMDJSON_TARGET_REGION("sse4.2,pclmul") #define SIMDJSON_TARGET_WESTMERE SIMDJSON_TARGET_REGION("sse4.2,pclmul")

View File

@ -1,4 +1,4 @@
#include "simdjson.h" #include "simdjson/base.h"
#include <initializer_list> #include <initializer_list>
namespace simdjson { namespace simdjson {

View File

@ -1,4 +1,4 @@
#include "simdjson.h" #include "simdjson/base.h"
namespace simdjson { namespace simdjson {
namespace internal { namespace internal {

View File

@ -1,4 +1,4 @@
#include "simdjson.h" #include "simdjson/base.h"
namespace simdjson { namespace simdjson {
namespace internal { namespace internal {

View File

@ -1,4 +1,4 @@
#include "simdjson.h" #include "simdjson/base.h"
namespace simdjson { namespace simdjson {
namespace internal { namespace internal {

View File

@ -1,3 +1,7 @@
// Instead of including simdjson.h, we include the stuff inside so we can get all the
// implementations and not just builtin
#define SIMDJSON_CPP
#include "simdjson.h" #include "simdjson.h"
SIMDJSON_PUSH_DISABLE_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS