Don't use TARGET unless the target options are *not* specified
This eliminates the possibility of inlining target failures for ondemand Also makes it so we always compile common architectures needed by simdjson.cpp in simdjson.h, since amalgamation has no way to reason about whether to include / exclude it.
This commit is contained in:
parent
633161fe86
commit
985dfab2c4
|
@ -27,10 +27,6 @@ namespace arm64 {
|
||||||
#include "simdjson/generic/atomparsing.h"
|
#include "simdjson/generic/atomparsing.h"
|
||||||
#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"
|
|
||||||
|
|
||||||
// Inline definitions
|
|
||||||
#include "simdjson/generic/implementation_simdjson_result_base-inl.h"
|
|
||||||
#include "simdjson/arm64/end.h"
|
#include "simdjson/arm64/end.h"
|
||||||
|
|
||||||
#endif // SIMDJSON_IMPLEMENTATION_ARM64
|
#endif // SIMDJSON_IMPLEMENTATION_ARM64
|
||||||
|
|
|
@ -3,6 +3,37 @@
|
||||||
|
|
||||||
#include "simdjson/implementations.h"
|
#include "simdjson/implementations.h"
|
||||||
|
|
||||||
|
// Determine the best builtin implementation
|
||||||
|
#ifndef SIMDJSON_BUILTIN_IMPLEMENTATION
|
||||||
|
#if SIMDJSON_CAN_ALWAYS_RUN_HASWELL
|
||||||
|
#define SIMDJSON_BUILTIN_IMPLEMENTATION haswell
|
||||||
|
#elif SIMDJSON_CAN_ALWAYS_RUN_WESTMERE
|
||||||
|
#define SIMDJSON_BUILTIN_IMPLEMENTATION westmere
|
||||||
|
#elif SIMDJSON_CAN_ALWAYS_RUN_ARM64
|
||||||
|
#define SIMDJSON_BUILTIN_IMPLEMENTATION arm64
|
||||||
|
#elif SIMDJSON_CAN_ALWAYS_RUN_PPC64
|
||||||
|
#define SIMDJSON_BUILTIN_IMPLEMENTATION ppc64
|
||||||
|
#elif SIMDJSON_CAN_ALWAYS_RUN_FALLBACK
|
||||||
|
#define SIMDJSON_BUILTIN_IMPLEMENTATION fallback
|
||||||
|
#else
|
||||||
|
#error "All possible implementations (including fallback) have been disabled! simdjson will not run."
|
||||||
|
#endif
|
||||||
|
#endif // SIMDJSON_BUILTIN_IMPLEMENTATION
|
||||||
|
|
||||||
|
#define SIMDJSON_IMPLEMENTATION SIMDJSON_BUILTIN_IMPLEMENTATION
|
||||||
|
|
||||||
|
// ondemand is only compiled as part of the builtin implementation at present
|
||||||
|
|
||||||
|
// Interface declarations
|
||||||
|
#include "simdjson/generic/implementation_simdjson_result_base.h"
|
||||||
|
#include "simdjson/generic/ondemand.h"
|
||||||
|
|
||||||
|
// Inline definitions
|
||||||
|
#include "simdjson/generic/implementation_simdjson_result_base-inl.h"
|
||||||
|
#include "simdjson/generic/ondemand-inl.h"
|
||||||
|
|
||||||
|
#undef SIMDJSON_IMPLEMENTATION
|
||||||
|
|
||||||
namespace simdjson {
|
namespace simdjson {
|
||||||
/**
|
/**
|
||||||
* Represents the best statically linked simdjson implementation that can be used by the compiling
|
* Represents the best statically linked simdjson implementation that can be used by the compiling
|
||||||
|
|
|
@ -24,13 +24,6 @@ namespace fallback {
|
||||||
#include "simdjson/generic/atomparsing.h"
|
#include "simdjson/generic/atomparsing.h"
|
||||||
#include "simdjson/fallback/stringparsing.h"
|
#include "simdjson/fallback/stringparsing.h"
|
||||||
#include "simdjson/fallback/numberparsing.h"
|
#include "simdjson/fallback/numberparsing.h"
|
||||||
#include "simdjson/generic/implementation_simdjson_result_base.h"
|
|
||||||
#include "simdjson/generic/ondemand.h"
|
|
||||||
|
|
||||||
// Inline definitions
|
|
||||||
#include "simdjson/generic/implementation_simdjson_result_base-inl.h"
|
|
||||||
#include "simdjson/generic/ondemand-inl.h"
|
|
||||||
|
|
||||||
#include "simdjson/fallback/end.h"
|
#include "simdjson/fallback/end.h"
|
||||||
|
|
||||||
#endif // SIMDJSON_IMPLEMENTATION_FALLBACK
|
#endif // SIMDJSON_IMPLEMENTATION_FALLBACK
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
|
|
||||||
#if SIMDJSON_IMPLEMENTATION_HASWELL
|
#if SIMDJSON_IMPLEMENTATION_HASWELL
|
||||||
|
|
||||||
#ifndef SIMDJSON_CAN_ALWAYS_RUN_HASWELL
|
#if SIMDJSON_CAN_ALWAYS_RUN_HASWELL
|
||||||
#define SIMDJSON_TARGET_HASWELL SIMDJSON_TARGET_REGION("avx2,bmi,pclmul,lzcnt")
|
|
||||||
#define SIMDJSON_UNTARGET_HASWELL SIMDJSON_UNTARGET_REGION
|
|
||||||
#else
|
|
||||||
#define SIMDJSON_TARGET_HASWELL
|
#define SIMDJSON_TARGET_HASWELL
|
||||||
#define SIMDJSON_UNTARGET_HASWELL
|
#define SIMDJSON_UNTARGET_HASWELL
|
||||||
|
#else
|
||||||
|
#define SIMDJSON_TARGET_HASWELL SIMDJSON_TARGET_REGION("avx2,bmi,pclmul,lzcnt")
|
||||||
|
#define SIMDJSON_UNTARGET_HASWELL SIMDJSON_UNTARGET_REGION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace simdjson {
|
namespace simdjson {
|
||||||
|
@ -41,13 +41,6 @@ namespace haswell {
|
||||||
#include "simdjson/generic/atomparsing.h"
|
#include "simdjson/generic/atomparsing.h"
|
||||||
#include "simdjson/haswell/stringparsing.h"
|
#include "simdjson/haswell/stringparsing.h"
|
||||||
#include "simdjson/haswell/numberparsing.h"
|
#include "simdjson/haswell/numberparsing.h"
|
||||||
#include "simdjson/generic/implementation_simdjson_result_base.h"
|
|
||||||
#include "simdjson/generic/ondemand.h"
|
|
||||||
|
|
||||||
// Inline definitions
|
|
||||||
#include "simdjson/generic/implementation_simdjson_result_base-inl.h"
|
|
||||||
#include "simdjson/generic/ondemand-inl.h"
|
|
||||||
|
|
||||||
#include "simdjson/haswell/end.h"
|
#include "simdjson/haswell/end.h"
|
||||||
|
|
||||||
#endif // SIMDJSON_IMPLEMENTATION_HASWELL
|
#endif // SIMDJSON_IMPLEMENTATION_HASWELL
|
||||||
|
|
|
@ -51,21 +51,4 @@
|
||||||
#endif
|
#endif
|
||||||
#define SIMDJSON_CAN_ALWAYS_RUN_FALLBACK SIMDJSON_IMPLEMENTATION_FALLBACK
|
#define SIMDJSON_CAN_ALWAYS_RUN_FALLBACK SIMDJSON_IMPLEMENTATION_FALLBACK
|
||||||
|
|
||||||
// Determine the best builtin implementation
|
|
||||||
#ifndef SIMDJSON_BUILTIN_IMPLEMENTATION
|
|
||||||
#if SIMDJSON_CAN_ALWAYS_RUN_HASWELL
|
|
||||||
#define SIMDJSON_BUILTIN_IMPLEMENTATION haswell
|
|
||||||
#elif SIMDJSON_CAN_ALWAYS_RUN_WESTMERE
|
|
||||||
#define SIMDJSON_BUILTIN_IMPLEMENTATION westmere
|
|
||||||
#elif SIMDJSON_CAN_ALWAYS_RUN_ARM64
|
|
||||||
#define SIMDJSON_BUILTIN_IMPLEMENTATION arm64
|
|
||||||
#elif SIMDJSON_CAN_ALWAYS_RUN_PPC64
|
|
||||||
#define SIMDJSON_BUILTIN_IMPLEMENTATION ppc64
|
|
||||||
#elif SIMDJSON_CAN_ALWAYS_RUN_FALLBACK
|
|
||||||
#define SIMDJSON_BUILTIN_IMPLEMENTATION fallback
|
|
||||||
#else
|
|
||||||
#error "All possible implementations (including fallback) have been disabled! simdjson will not run."
|
|
||||||
#endif
|
|
||||||
#endif // SIMDJSON_BUILTIN_IMPLEMENTATION
|
|
||||||
|
|
||||||
#endif // SIMDJSON_IMPLEMENTATION_BASE_H
|
#endif // SIMDJSON_IMPLEMENTATION_BASE_H
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef SIMDJSON_IMPLEMENTATIONS_H
|
#ifndef SIMDJSON_IMPLEMENTATIONS_H
|
||||||
#define SIMDJSON_IMPLEMENTATIONS_H
|
#define SIMDJSON_IMPLEMENTATIONS_H
|
||||||
|
|
||||||
|
#include "simdjson/implementation-base.h"
|
||||||
|
|
||||||
SIMDJSON_PUSH_DISABLE_WARNINGS
|
SIMDJSON_PUSH_DISABLE_WARNINGS
|
||||||
SIMDJSON_DISABLE_UNDESIRED_WARNINGS
|
SIMDJSON_DISABLE_UNDESIRED_WARNINGS
|
||||||
|
|
||||||
|
@ -10,6 +12,7 @@ SIMDJSON_DISABLE_UNDESIRED_WARNINGS
|
||||||
#include "simdjson/westmere.h"
|
#include "simdjson/westmere.h"
|
||||||
#include "simdjson/ppc64.h"
|
#include "simdjson/ppc64.h"
|
||||||
#include "simdjson/fallback.h"
|
#include "simdjson/fallback.h"
|
||||||
|
#include "simdjson/builtin.h"
|
||||||
|
|
||||||
SIMDJSON_POP_DISABLE_WARNINGS
|
SIMDJSON_POP_DISABLE_WARNINGS
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,6 @@ namespace ppc64 {
|
||||||
#include "simdjson/generic/atomparsing.h"
|
#include "simdjson/generic/atomparsing.h"
|
||||||
#include "simdjson/ppc64/stringparsing.h"
|
#include "simdjson/ppc64/stringparsing.h"
|
||||||
#include "simdjson/ppc64/numberparsing.h"
|
#include "simdjson/ppc64/numberparsing.h"
|
||||||
#include "simdjson/generic/implementation_simdjson_result_base.h"
|
|
||||||
#include "simdjson/generic/ondemand.h"
|
|
||||||
|
|
||||||
// Inline definitions
|
|
||||||
#include "simdjson/generic/implementation_simdjson_result_base-inl.h"
|
|
||||||
#include "simdjson/generic/ondemand-inl.h"
|
|
||||||
#include "simdjson/ppc64/end.h"
|
#include "simdjson/ppc64/end.h"
|
||||||
|
|
||||||
#endif // SIMDJSON_IMPLEMENTATION_PPC64
|
#endif // SIMDJSON_IMPLEMENTATION_PPC64
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
|
|
||||||
#if SIMDJSON_IMPLEMENTATION_WESTMERE
|
#if SIMDJSON_IMPLEMENTATION_WESTMERE
|
||||||
|
|
||||||
#ifndef SIMDJSON_CAN_ALWAYS_RUN_WESTMERE
|
#if SIMDJSON_CAN_ALWAYS_RUN_WESTMERE
|
||||||
#define SIMDJSON_TARGET_WESTMERE SIMDJSON_TARGET_REGION("sse4.2,pclmul")
|
|
||||||
#define SIMDJSON_UNTARGET_WESTMERE SIMDJSON_UNTARGET_REGION
|
|
||||||
#else
|
|
||||||
#define SIMDJSON_TARGET_WESTMERE
|
#define SIMDJSON_TARGET_WESTMERE
|
||||||
#define SIMDJSON_UNTARGET_WESTMERE
|
#define SIMDJSON_UNTARGET_WESTMERE
|
||||||
|
#else
|
||||||
|
#define SIMDJSON_TARGET_WESTMERE SIMDJSON_TARGET_REGION("sse4.2,pclmul")
|
||||||
|
#define SIMDJSON_UNTARGET_WESTMERE SIMDJSON_UNTARGET_REGION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace simdjson {
|
namespace simdjson {
|
||||||
|
@ -41,13 +41,6 @@ namespace westmere {
|
||||||
#include "simdjson/generic/atomparsing.h"
|
#include "simdjson/generic/atomparsing.h"
|
||||||
#include "simdjson/westmere/stringparsing.h"
|
#include "simdjson/westmere/stringparsing.h"
|
||||||
#include "simdjson/westmere/numberparsing.h"
|
#include "simdjson/westmere/numberparsing.h"
|
||||||
#include "simdjson/generic/implementation_simdjson_result_base.h"
|
|
||||||
#include "simdjson/generic/ondemand.h"
|
|
||||||
|
|
||||||
// Inline definitions
|
|
||||||
#include "simdjson/generic/implementation_simdjson_result_base-inl.h"
|
|
||||||
#include "simdjson/generic/ondemand-inl.h"
|
|
||||||
|
|
||||||
#include "simdjson/westmere/end.h"
|
#include "simdjson/westmere/end.h"
|
||||||
|
|
||||||
#endif // SIMDJSON_IMPLEMENTATION_WESTMERE
|
#endif // SIMDJSON_IMPLEMENTATION_WESTMERE
|
||||||
|
|
|
@ -83,7 +83,8 @@ def dofile(fid, prepath, filename):
|
||||||
# Last lines are always ignored. Files should end by an empty lines.
|
# Last lines are always ignored. Files should end by an empty lines.
|
||||||
print(f"/* begin file {RELFILE} */", file=fid)
|
print(f"/* begin file {RELFILE} */", file=fid)
|
||||||
includepattern = re.compile('^#include "(.*)"')
|
includepattern = re.compile('^#include "(.*)"')
|
||||||
redefines_simdjson_implementation = re.compile('^#define SIMDJSON_IMPLEMENTATION (.*)')
|
redefines_simdjson_implementation = re.compile('^#define\s+SIMDJSON_IMPLEMENTATION\s+(.*)')
|
||||||
|
undefines_simdjson_implementation = re.compile('^#undef\s+SIMDJSON_IMPLEMENTATION\s*$')
|
||||||
uses_simdjson_implementation = re.compile('SIMDJSON_IMPLEMENTATION([^_a-zA-Z0-9]|$)')
|
uses_simdjson_implementation = re.compile('SIMDJSON_IMPLEMENTATION([^_a-zA-Z0-9]|$)')
|
||||||
with open(file, 'r') as fid2:
|
with open(file, 'r') as fid2:
|
||||||
for line in fid2:
|
for line in fid2:
|
||||||
|
@ -106,6 +107,9 @@ def dofile(fid, prepath, filename):
|
||||||
if s:
|
if s:
|
||||||
current_implementation=s.group(1)
|
current_implementation=s.group(1)
|
||||||
print(f"// redefining SIMDJSON_IMPLEMENTATION to \"{current_implementation}\"\n// {line}", file=fid)
|
print(f"// redefining SIMDJSON_IMPLEMENTATION to \"{current_implementation}\"\n// {line}", file=fid)
|
||||||
|
elif undefines_simdjson_implementation.search(line):
|
||||||
|
# Don't include #undef SIMDJSON_IMPLEMENTATION since we're handling it ourselves
|
||||||
|
print(f"// {line}")
|
||||||
else:
|
else:
|
||||||
# copy the line, with SIMDJSON_IMPLEMENTATION replace to what it is currently defined to
|
# copy the line, with SIMDJSON_IMPLEMENTATION replace to what it is currently defined to
|
||||||
print(uses_simdjson_implementation.sub(current_implementation+"\\1",line), file=fid)
|
print(uses_simdjson_implementation.sub(current_implementation+"\\1",line), file=fid)
|
||||||
|
|
|
@ -155,6 +155,7 @@ simdjson_warn_unused bool validate_utf8(const char *buf, size_t len) noexcept {
|
||||||
|
|
||||||
const implementation * builtin_implementation() {
|
const implementation * builtin_implementation() {
|
||||||
static const implementation * builtin_impl = available_implementations[STRINGIFY(SIMDJSON_BUILTIN_IMPLEMENTATION)];
|
static const implementation * builtin_impl = available_implementations[STRINGIFY(SIMDJSON_BUILTIN_IMPLEMENTATION)];
|
||||||
|
assert(builtin_impl);
|
||||||
return builtin_impl;
|
return builtin_impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue