summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.tests/common/rdrnd/rdrnd.cpp56
-rw-r--r--config.tests/common/rdrnd/rdrnd.pro3
-rw-r--r--configure.json15
-rw-r--r--mkspecs/common/gcc-base.conf1
-rw-r--r--mkspecs/common/msvc-version.conf1
-rw-r--r--mkspecs/features/simd.prf1
-rw-r--r--mkspecs/linux-icc/qmake.conf3
-rw-r--r--mkspecs/macx-icc/qmake.conf3
-rw-r--r--src/corelib/tools/qsimd_p.h8
9 files changed, 83 insertions, 8 deletions
diff --git a/config.tests/common/rdrnd/rdrnd.cpp b/config.tests/common/rdrnd/rdrnd.cpp
new file mode 100644
index 0000000000..597f7257bf
--- /dev/null
+++ b/config.tests/common/rdrnd/rdrnd.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Intel Corporation.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <immintrin.h>
+
+int main(int, char**)
+{
+ unsigned short us;
+ unsigned int ui;
+ if (_rdrand16_step(&us))
+ return 1;
+ if (_rdrand32_step(&ui))
+ return 1;
+#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
+ unsigned long long ull;
+ if (_rdrand64_step(&ull))
+ return 1;
+#endif
+ return 0;
+}
diff --git a/config.tests/common/rdrnd/rdrnd.pro b/config.tests/common/rdrnd/rdrnd.pro
new file mode 100644
index 0000000000..37e636dc3f
--- /dev/null
+++ b/config.tests/common/rdrnd/rdrnd.pro
@@ -0,0 +1,3 @@
+SOURCES += rdrnd.cpp
+!defined(QMAKE_CFLAGS_RDRND, "var"): error("This compiler does not support the RDRAND instruction")
+else: QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_RDRND
diff --git a/configure.json b/configure.json
index 7a118d860e..545e128b76 100644
--- a/configure.json
+++ b/configure.json
@@ -321,6 +321,11 @@
"type": "compile",
"test": "common/f16c"
},
+ "rdrnd": {
+ "label": "RDRAND instruction",
+ "type": "compile",
+ "test": "common/rdrnd"
+ },
"shani": {
"label": "SHA new instructions",
"type": "compile",
@@ -896,6 +901,14 @@
{ "type": "define", "name": "QT_COMPILER_SUPPORTS_AES", "value": 1 }
]
},
+ "rdrnd": {
+ "label": "RDRAND",
+ "condition": "tests.rdrnd",
+ "output": [
+ "privateConfig",
+ { "type": "define", "name": "QT_COMPILER_SUPPORTS_RDRND", "value": 1 }
+ ]
+ },
"shani": {
"label": "SHA",
"condition": "features.sse2 && tests.shani",
@@ -1188,7 +1201,7 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5
{
"message": "Other x86",
"type": "featureList",
- "args": "aesni f16c shani",
+ "args": "aesni f16c rdrnd shani",
"condition": "(arch.i386 || arch.x86_64)"
},
{
diff --git a/mkspecs/common/gcc-base.conf b/mkspecs/common/gcc-base.conf
index 1a93a51f6b..b63f96524b 100644
--- a/mkspecs/common/gcc-base.conf
+++ b/mkspecs/common/gcc-base.conf
@@ -87,6 +87,7 @@ QMAKE_CFLAGS_SSSE3 += -mssse3
QMAKE_CFLAGS_SSE4_1 += -msse4.1
QMAKE_CFLAGS_SSE4_2 += -msse4.2
QMAKE_CFLAGS_F16C += -mf16c
+QMAKE_CFLAGS_RDRND += -mrdrnd
QMAKE_CFLAGS_AVX += -mavx
QMAKE_CFLAGS_AVX2 += -mavx2
QMAKE_CFLAGS_AVX512F += -mavx512f
diff --git a/mkspecs/common/msvc-version.conf b/mkspecs/common/msvc-version.conf
index d8ec089f55..c2e22f455a 100644
--- a/mkspecs/common/msvc-version.conf
+++ b/mkspecs/common/msvc-version.conf
@@ -50,6 +50,7 @@ greaterThan(QMAKE_MSC_VER, 1799) {
QMAKE_CXXFLAGS += -FS -Zc:rvalueCast -Zc:inline
QMAKE_CFLAGS_F16C = -arch:AVX
+ QMAKE_CFLAGS_RDRND =
equals(QMAKE_MSC_VER, 1800) {
QMAKE_CFLAGS_RELEASE += -Zc:strictStrings
diff --git a/mkspecs/features/simd.prf b/mkspecs/features/simd.prf
index aca9ae6243..8471ce7e7c 100644
--- a/mkspecs/features/simd.prf
+++ b/mkspecs/features/simd.prf
@@ -107,6 +107,7 @@ addSimdCompiler(avx512vl)
addSimdCompiler(avx512ifma)
addSimdCompiler(avx512vbmi)
addSimdCompiler(f16c)
+addSimdCompiler(rdrnd)
addSimdCompiler(neon)
addSimdCompiler(mips_dsp)
addSimdCompiler(mips_dspr2)
diff --git a/mkspecs/linux-icc/qmake.conf b/mkspecs/linux-icc/qmake.conf
index d043d54740..1d94f0c931 100644
--- a/mkspecs/linux-icc/qmake.conf
+++ b/mkspecs/linux-icc/qmake.conf
@@ -45,8 +45,9 @@ QMAKE_CFLAGS_AVX512PF += -xMIC-AVX512
QMAKE_CFLAGS_AVX512DQ += -xCORE-AVX512
QMAKE_CFLAGS_AVX512BW += -xCORE-AVX512
QMAKE_CFLAGS_AVX512VL += -xCORE-AVX512
-QMAKE_CFLAGS_F16C += $$QMAKE_CFLAGS_AVX2
QMAKE_CFLAGS_AESNI += -maes
+QMAKE_CFLAGS_F16C += $$QMAKE_CFLAGS_AVX2
+QMAKE_CFLAGS_RDRND += -mrdrnd
QMAKE_CFLAGS_SHANI += -msha
QMAKE_CXX = icpc
diff --git a/mkspecs/macx-icc/qmake.conf b/mkspecs/macx-icc/qmake.conf
index ec8e13452f..80cffbf9dc 100644
--- a/mkspecs/macx-icc/qmake.conf
+++ b/mkspecs/macx-icc/qmake.conf
@@ -43,8 +43,9 @@ QMAKE_CFLAGS_AVX512PF += -xMIC-AVX512
QMAKE_CFLAGS_AVX512DQ += -xCORE-AVX512
QMAKE_CFLAGS_AVX512BW += -xCORE-AVX512
QMAKE_CFLAGS_AVX512VL += -xCORE-AVX512
-QMAKE_CFLAGS_F16C += $$QMAKE_CFLAGS_AVX2
QMAKE_CFLAGS_AESNI += -maes
+QMAKE_CFLAGS_F16C += $$QMAKE_CFLAGS_AVX2
+QMAKE_CFLAGS_RDRND += -mrdrnd
QMAKE_CFLAGS_SHANI += -msha
QMAKE_CXX = icpc
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 725b6b6765..44f6f1cc91 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -287,7 +287,7 @@
#define QT_FUNCTION_TARGET_STRING_PCLMUL "pclmul,sse4.2"
#define QT_FUNCTION_TARGET_STRING_POPCNT "popcnt"
#define QT_FUNCTION_TARGET_STRING_F16C "f16c,avx"
-#define QT_FUNCTION_TARGET_STRING_RDRAND "rdrnd"
+#define QT_FUNCTION_TARGET_STRING_RDRND "rdrnd"
#define QT_FUNCTION_TARGET_STRING_BMI "bmi"
#define QT_FUNCTION_TARGET_STRING_BMI2 "bmi2"
#define QT_FUNCTION_TARGET_STRING_RDSEED "rdseed"
@@ -330,8 +330,6 @@
# include <arm_acle.h>
#endif
-#undef QT_COMPILER_SUPPORTS_SIMD_ALWAYS
-
QT_BEGIN_NAMESPACE
@@ -357,7 +355,7 @@ enum CPUFeatures {
CpuFeatureAES = (0 + 25),
CpuFeatureAVX = (0 + 28),
CpuFeatureF16C = (0 + 29),
- CpuFeatureRDRAND = (0 + 30),
+ CpuFeatureRDRND = (0 + 30),
// 31 is always zero and we've used it for the QSimdInitialized
// in level 7, leaf 0, EBX
@@ -396,7 +394,7 @@ static const quint64 qCompilerCpuFeatures = 0
| (Q_UINT64_C(1) << CpuFeatureRTM)
#endif
#ifdef __RDRND__
- | (Q_UINT64_C(1) << CpuFeatureRDRAND)
+ | (Q_UINT64_C(1) << CpuFeatureRDRND)
#endif
#ifdef __RDSEED__
| (Q_UINT64_C(1) << CpuFeatureRDSEED)