Skip to content

Commit af8b52e

Browse files
committed
Target region for entire compilation of an implementation
1 parent 7965889 commit af8b52e

37 files changed

+118
-149
lines changed

include/simdjson/portability.h

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,32 +103,27 @@ use a 64-bit target such as x64 or 64-bit ARM.")
103103
#ifdef __clang__
104104
// clang does not have GCC push pop
105105
// warning: clang attribute push can't be used within a namespace in clang up
106-
// til 8.0 so TARGET_REGION and UNTARGET_REGION must be *outside* of a
106+
// til 8.0 so SIMDJSON_TARGET_REGION and SIMDJSON_UNTARGET_REGION must be *outside* of a
107107
// namespace.
108-
#define TARGET_REGION(T) \
108+
#define SIMDJSON_TARGET_REGION(T) \
109109
_Pragma(STRINGIFY( \
110110
clang attribute push(__attribute__((target(T))), apply_to = function)))
111-
#define UNTARGET_REGION _Pragma("clang attribute pop")
111+
#define SIMDJSON_UNTARGET_REGION _Pragma("clang attribute pop")
112112
#elif defined(__GNUC__)
113113
// GCC is easier
114-
#define TARGET_REGION(T) \
114+
#define SIMDJSON_TARGET_REGION(T) \
115115
_Pragma("GCC push_options") _Pragma(STRINGIFY(GCC target(T)))
116-
#define UNTARGET_REGION _Pragma("GCC pop_options")
116+
#define SIMDJSON_UNTARGET_REGION _Pragma("GCC pop_options")
117117
#endif // clang then gcc
118118
119119
#endif // x86
120120
121121
// Default target region macros don't do anything.
122-
#ifndef TARGET_REGION
123-
#define TARGET_REGION(T)
124-
#define UNTARGET_REGION
122+
#ifndef SIMDJSON_TARGET_REGION
123+
#define SIMDJSON_TARGET_REGION(T)
124+
#define SIMDJSON_UNTARGET_REGION
125125
#endif
126126
127-
// under GCC and CLANG, we use these two macros
128-
#define TARGET_HASWELL TARGET_REGION("avx2,bmi,pclmul,lzcnt")
129-
#define TARGET_WESTMERE TARGET_REGION("sse4.2,pclmul")
130-
#define TARGET_ARM64
131-
132127
// Is threading enabled?
133128
#if defined(BOOST_HAS_THREADS) || defined(_REENTRANT) || defined(_MT)
134129
#ifndef SIMDJSON_THREADS_ENABLED

src/arm64/begin_implementation.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "simdjson.h"
2+
#include "arm64/implementation.h"
3+
#include "arm64/intrinsics.h" // Generally need to be included outside SIMDJSON_TARGET_REGION
4+
5+
#define SIMDJSON_IMPLEMENTATION arm64

src/arm64/bitmanipulation.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define SIMDJSON_ARM64_BITMANIPULATION_H
33

44
#include "simdjson.h"
5-
#include "arm64/intrinsics.h"
65

76
namespace simdjson {
87
namespace arm64 {

src/arm64/bitmask.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
#include "simdjson.h"
55

6-
#include "arm64/intrinsics.h"
7-
86
namespace simdjson {
97
namespace arm64 {
108

@@ -38,6 +36,6 @@ really_inline uint64_t prefix_xor(uint64_t bitmask) {
3836

3937
} // namespace arm64
4038
} // namespace simdjson
41-
UNTARGET_REGION
39+
SIMDJSON_UNTARGET_REGION
4240

4341
#endif

src/arm64/dom_parser_implementation.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#include "simdjson.h"
2-
#include "arm64/implementation.h"
1+
#include "arm64/begin_implementation.h"
32
#include "arm64/dom_parser_implementation.h"
43

54
//
@@ -10,7 +9,7 @@
109
#include "arm64/bitmanipulation.h"
1110

1211
namespace simdjson {
13-
namespace arm64 {
12+
namespace SIMDJSON_IMPLEMENTATION {
1413

1514
using namespace simd;
1615

@@ -132,7 +131,8 @@ WARN_UNUSED error_code dom_parser_implementation::stage1(const uint8_t *_buf, si
132131
WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) const noexcept {
133132
return simdjson::arm64::stage1::generic_validate_utf8(buf,len);
134133
}
135-
} // namespace arm64
134+
135+
} // namespace SIMDJSON_IMPLEMENTATION
136136
} // namespace simdjson
137137

138138
//
@@ -143,7 +143,7 @@ WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) cons
143143
#include "arm64/numberparsing.h"
144144

145145
namespace simdjson {
146-
namespace arm64 {
146+
namespace SIMDJSON_IMPLEMENTATION {
147147

148148
#include "generic/stage2/logger.h"
149149
#include "generic/stage2/atomparsing.h"
@@ -156,5 +156,7 @@ WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, siz
156156
return stage2(_doc);
157157
}
158158

159-
} // namespace arm64
159+
} // namespace SIMDJSON_IMPLEMENTATION
160160
} // namespace simdjson
161+
162+
#include "arm64/end_implementation.h"

src/arm64/end_implementation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#undef SIMDJSON_IMPLEMENTATION

src/arm64/implementation.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
#include "simdjson.h"
2-
#include "arm64/implementation.h"
1+
#include "arm64/begin_implementation.h"
32
#include "arm64/dom_parser_implementation.h"
43

5-
TARGET_HASWELL
6-
74
namespace simdjson {
8-
namespace arm64 {
5+
namespace SIMDJSON_IMPLEMENTATION {
96

107
WARN_UNUSED error_code implementation::create_dom_parser_implementation(
118
size_t capacity,
@@ -19,7 +16,7 @@ WARN_UNUSED error_code implementation::create_dom_parser_implementation(
1916
return SUCCESS;
2017
}
2118

22-
} // namespace arm64
19+
} // namespace SIMDJSON_IMPLEMENTATION
2320
} // namespace simdjson
2421

25-
UNTARGET_REGION
22+
#include "arm64/end_implementation.h"

src/arm64/numberparsing.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include "simdjson.h"
55
#include "jsoncharutils.h"
6-
#include "arm64/intrinsics.h"
76
#include "arm64/bitmanipulation.h"
87
#include <cmath>
98
#include <limits>

src/arm64/simd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "simdjson.h"
55
#include "simdprune_tables.h"
66
#include "arm64/bitmanipulation.h"
7-
#include "arm64/intrinsics.h"
87
#include <type_traits>
98

109

src/arm64/stringparsing.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "simdjson.h"
55
#include "jsoncharutils.h"
66
#include "arm64/simd.h"
7-
#include "arm64/intrinsics.h"
87
#include "arm64/bitmanipulation.h"
98

109
namespace simdjson {

0 commit comments

Comments
 (0)