| 1 | #ifndef SIMDJSON_BUILTIN_H |
| 2 | #define SIMDJSON_BUILTIN_H |
| 3 | |
| 4 | #include "simdjson/implementations.h" |
| 5 | |
| 6 | // Determine the best builtin implementation |
| 7 | #ifndef SIMDJSON_BUILTIN_IMPLEMENTATION |
| 8 | #if SIMDJSON_CAN_ALWAYS_RUN_ICELAKE |
| 9 | #define SIMDJSON_BUILTIN_IMPLEMENTATION icelake |
| 10 | #elif SIMDJSON_CAN_ALWAYS_RUN_HASWELL |
| 11 | #define SIMDJSON_BUILTIN_IMPLEMENTATION haswell |
| 12 | #elif SIMDJSON_CAN_ALWAYS_RUN_WESTMERE |
| 13 | #define SIMDJSON_BUILTIN_IMPLEMENTATION westmere |
| 14 | #elif SIMDJSON_CAN_ALWAYS_RUN_ARM64 |
| 15 | #define SIMDJSON_BUILTIN_IMPLEMENTATION arm64 |
| 16 | #elif SIMDJSON_CAN_ALWAYS_RUN_PPC64 |
| 17 | #define SIMDJSON_BUILTIN_IMPLEMENTATION ppc64 |
| 18 | #elif SIMDJSON_CAN_ALWAYS_RUN_FALLBACK |
| 19 | #define SIMDJSON_BUILTIN_IMPLEMENTATION fallback |
| 20 | #else |
| 21 | #error "All possible implementations (including fallback) have been disabled! simdjson will not run." |
| 22 | #endif |
| 23 | #endif // SIMDJSON_BUILTIN_IMPLEMENTATION |
| 24 | |
| 25 | #define SIMDJSON_IMPLEMENTATION SIMDJSON_BUILTIN_IMPLEMENTATION |
| 26 | |
| 27 | // ondemand is only compiled as part of the builtin implementation at present |
| 28 | |
| 29 | // Interface declarations |
| 30 | #include "simdjson/generic/implementation_simdjson_result_base.h" |
| 31 | #include "simdjson/generic/ondemand.h" |
| 32 | |
| 33 | // Inline definitions |
| 34 | #include "simdjson/generic/implementation_simdjson_result_base-inl.h" |
| 35 | #include "simdjson/generic/ondemand-inl.h" |
| 36 | |
| 37 | #undef SIMDJSON_IMPLEMENTATION |
| 38 | |
| 39 | namespace simdjson { |
| 40 | /** |
| 41 | * Represents the best statically linked simdjson implementation that can be used by the compiling |
| 42 | * program. |
| 43 | * |
| 44 | * Detects what options the program is compiled against, and picks the minimum implementation that |
| 45 | * will work on any computer that can run the program. For example, if you compile with g++ |
| 46 | * -march=westmere, it will pick the westmere implementation. The haswell implementation will |
| 47 | * still be available, and can be selected at runtime, but the builtin implementation (and any |
| 48 | * code that uses it) will use westmere. |
| 49 | */ |
| 50 | namespace builtin = SIMDJSON_BUILTIN_IMPLEMENTATION; |
| 51 | /** |
| 52 | * @copydoc simdjson::SIMDJSON_BUILTIN_IMPLEMENTATION::ondemand |
| 53 | */ |
| 54 | namespace ondemand = SIMDJSON_BUILTIN_IMPLEMENTATION::ondemand; |
| 55 | /** |
| 56 | * Function which returns a pointer to an implementation matching the "builtin" implementation. |
| 57 | * The builtin implementation is the best statically linked simdjson implementation that can be used by the compiling |
| 58 | * program. If you compile with g++ -march=haswell, this will return the haswell implementation. |
| 59 | * It is handy to be able to check what builtin was used: builtin_implementation()->name(). |
| 60 | */ |
| 61 | const implementation * builtin_implementation(); |
| 62 | } // namespace simdjson |
| 63 | |
| 64 | #endif // SIMDJSON_BUILTIN_H |
| 65 | |