Add proper detection of x86 RDRAND instruction
The instruction is "RDRAND", but the feature name, according to GCC, is RDRND, so I had to change some macros in qsimd_p.h. Change-Id: Icd0e0d4b27cb4e5eb892fffd14b5166779137e63 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
f17095653e
commit
dfdc466dc1
56
config.tests/common/rdrnd/rdrnd.cpp
Normal file
56
config.tests/common/rdrnd/rdrnd.cpp
Normal file
@ -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;
|
||||
}
|
3
config.tests/common/rdrnd/rdrnd.pro
Normal file
3
config.tests/common/rdrnd/rdrnd.pro
Normal file
@ -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
|
@ -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)"
|
||||
},
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -107,6 +107,7 @@ addSimdCompiler(avx512vl)
|
||||
addSimdCompiler(avx512ifma)
|
||||
addSimdCompiler(avx512vbmi)
|
||||
addSimdCompiler(f16c)
|
||||
addSimdCompiler(rdrnd)
|
||||
addSimdCompiler(neon)
|
||||
addSimdCompiler(mips_dsp)
|
||||
addSimdCompiler(mips_dspr2)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user