diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2013-08-06 19:32:37 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-27 06:26:57 +0200 |
commit | 689e8055f5c4f3bbdbb9a90ac0405b5295f81374 (patch) | |
tree | 619de88b9d816d5d9d8b7b0fc420bd286f81627d /src/corelib/tools/qhash.cpp | |
parent | cb09e1e88944e1ab9b0d00a95cdc71bdab69ad58 (diff) |
Add support for single-file multi-target intrinsics in Qt
GCC 4.9 now allows us to #include any and all intrinsics headers, not
just the one for which we're compiling code, a behavior that ICC and
MSVC have had for some time. With that, we're able to have the functions
for different targets in the same source file. See the GCC manual:
http://gcc.gnu.org/onlinedocs/gcc/Function-Multiversioning.html
This functionality is notified by the QT_COMPILER_SUPPORTS_HERE(XXX)
macro, which indicates that all the intrinsics from
QT_COMPILER_SUPPORTS_xxx are available and enabled. To complement, a
QT_COMPILER_SUPPORTS(XXX) macro is also added.
Unlike ICC and MSVC, GCC requires a special function attribute, which
will also cause code optimization. That's the QT_FUNCTION_TARGET macro.
Note: because of the absence of the target attribute, ICC and MSVC will
not generate instructions with the VEX prefix unless they only exist
with the VEX prefix or if -mavx / -arch:AVX are enabled.
Change-Id: I0c1880c20324bd8e0fc68a863e36d1fa7755dff0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'src/corelib/tools/qhash.cpp')
-rw-r--r-- | src/corelib/tools/qhash.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index e227a483c4..8e4f0f6407 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -94,13 +94,14 @@ QT_BEGIN_NAMESPACE (for instance, gcc 4.4 does that even at -O0). */ -#ifdef __SSE4_2__ +#if QT_COMPILER_SUPPORTS_HERE(SSE4_2) static inline bool hasFastCrc32() { - return true; + return qCpuHasFeature(SSE4_2); } template <typename Char> +QT_FUNCTION_TARGET(SSE4_2) static uint crc32(const Char *ptr, size_t len, uint h) { // The CRC32 instructions from Nehalem calculate a 32-bit CRC32 checksum |