Don't include target flags if the compiler already has them on

This commit is contained in:
John Keiser 2021-03-08 08:52:47 -08:00
parent f51d50399c
commit 633161fe86
9 changed files with 37 additions and 29 deletions

View File

@ -1,28 +1,7 @@
#ifndef SIMDJSON_BUILTIN_H
#define SIMDJSON_BUILTIN_H
#include "simdjson/implementation-base.h"
#ifndef SIMDJSON_BUILTIN_IMPLEMENTATION
#if SIMDJSON_CAN_ALWAYS_RUN_HASWELL
#define SIMDJSON_BUILTIN_IMPLEMENTATION haswell
#include "simdjson/haswell.h"
#elif SIMDJSON_CAN_ALWAYS_RUN_WESTMERE
#define SIMDJSON_BUILTIN_IMPLEMENTATION westmere
#include "simdjson/westmere.h"
#elif SIMDJSON_CAN_ALWAYS_RUN_ARM64
#define SIMDJSON_BUILTIN_IMPLEMENTATION arm64
#include "simdjson/arm64.h"
#elif SIMDJSON_CAN_ALWAYS_RUN_PPC64
#define SIMDJSON_BUILTIN_IMPLEMENTATION ppc64
#include "simdjson/ppc64.h"
#elif SIMDJSON_CAN_ALWAYS_RUN_FALLBACK
#define SIMDJSON_BUILTIN_IMPLEMENTATION fallback
#include "simdjson/fallback.h"
#else
#error "All possible implementations (including fallback) have been disabled! simdjson will not run."
#endif
#endif // SIMDJSON_BUILTIN_IMPLEMENTATION
#include "simdjson/implementations.h"
namespace simdjson {
/**

View File

@ -5,7 +5,13 @@
#if SIMDJSON_IMPLEMENTATION_HASWELL
#ifndef 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_UNTARGET_HASWELL
#endif
namespace simdjson {
/**
@ -16,7 +22,7 @@ namespace haswell {
} // namespace simdjson
//
// These two need to be included outside SIMDJSON_TARGET_REGION
// These two need to be included outside SIMDJSON_TARGET_HASWELL
//
#include "simdjson/haswell/implementation.h"
#include "simdjson/haswell/intrinsics.h"

View File

@ -1,2 +1,2 @@
SIMDJSON_UNTARGET_REGION
SIMDJSON_UNTARGET_HASWELL
#undef SIMDJSON_IMPLEMENTATION

View File

@ -3,7 +3,7 @@
#include "simdjson/implementation.h"
// The constructor may be executed on any host, so we take care not to use SIMDJSON_TARGET_REGION
// The constructor may be executed on any host, so we take care not to use SIMDJSON_TARGET_HASWELL
namespace simdjson {
namespace haswell {

View File

@ -45,7 +45,7 @@ SIMDJSON_TARGET_HASWELL
static simdjson_really_inline uint64_t _blsr_u64(uint64_t n) {
return (n - 1) & n;
}
SIMDJSON_UNTARGET_REGION
SIMDJSON_UNTARGET_HASWELL
#endif // _blsr_u64
#endif // SIMDJSON_CLANG_VISUAL_STUDIO

View File

@ -51,4 +51,21 @@
#endif
#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

View File

@ -5,7 +5,13 @@
#if SIMDJSON_IMPLEMENTATION_WESTMERE
#ifndef 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_UNTARGET_WESTMERE
#endif
namespace simdjson {
/**
@ -16,7 +22,7 @@ namespace westmere {
} // namespace simdjson
//
// These two need to be included outside SIMDJSON_TARGET_REGION
// These two need to be included outside SIMDJSON_TARGET_WESTMERE
//
#include "simdjson/westmere/implementation.h"
#include "simdjson/westmere/intrinsics.h"

View File

@ -1,2 +1,2 @@
SIMDJSON_UNTARGET_REGION
SIMDJSON_UNTARGET_WESTMERE
#undef SIMDJSON_IMPLEMENTATION

View File

@ -3,7 +3,7 @@
#include "simdjson/implementation.h"
// The constructor may be executed on any host, so we take care not to use SIMDJSON_TARGET_REGION
// The constructor may be executed on any host, so we take care not to use SIMDJSON_TARGET_WESTMERE
namespace simdjson {
namespace westmere {