summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2011-12-31 00:16:13 -0200
committerQt by Nokia <qt-info@nokia.com>2012-03-28 22:32:40 +0200
commitcc3ff3c1f6aa22de4fc70e741400d05d1a961af5 (patch)
tree6bd230d5548f6ba5aa05a11e52654a2a97426ac7 /src/corelib/tools
parentcbe8c1014621e863c95ffc856d87a3cff12ec608 (diff)
Make qsimd.cpp also complain if required features are missing
Record in a variable the features that the compiler used for code generation when Qt was compiled. Then complain if those are missing. This is required in qdrawhelper_plain.cpp to make it disable the plain build, keeping only the AVX, Neon or SSE2 builds. This code works for GCC, ICC on Unix and Clang. MSVC support is pending. It will involve defining the same macros from qsimd_p.h when the compiler support is detected. Other compilers are unknown. The only relevant one would be Sun Studio for x86, but I have no access to it to find out what macros it predefines. Change-Id: I25f2d90b3c7ac7bd0442f4b349b6ee3bd751a95b Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qsimd.cpp60
1 files changed, 58 insertions, 2 deletions
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index 5f54ae742d..7b05089c28 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -342,7 +342,49 @@ static const int features_indices[] = {
};
// end generated
-const int features_count = (sizeof features_indices - 1) / (sizeof features_indices[0]);
+static const int features_count = (sizeof features_indices - 1) / (sizeof features_indices[0]);
+
+static const uint minFeature = None
+#if defined __RTM__
+ | RTM
+#endif
+// don't define for HLE, since the HLE prefix can be run on older CPUs
+#if defined __AVX2__
+ | AVX2
+#endif
+#if defined __AVX__
+ | AVX
+#endif
+#if defined __SSE4_2__
+ | SSE4_2
+#endif
+#if defined __SSE4_1__
+ | SSE4_1
+#endif
+#if defined __SSSE3__
+ | SSSE3
+#endif
+#if defined __SSE3__
+ | SSE3
+#endif
+#if defined __SSE2__
+ | SSE2
+#endif
+#if defined __ARM_NEON__
+ | NEON
+#endif
+#if defined __IWMMXT__
+ | IWMMXT
+#endif
+ ;
+
+#ifdef Q_OS_WIN
+int ffs(int i)
+{
+ unsigned long result;
+ return _BitScanForward(&result, i) ? result : 0;
+}
+#endif
uint qDetectCPUFeatures()
{
@@ -360,6 +402,19 @@ uint qDetectCPUFeatures()
}
}
+ if (minFeature != 0 && (f & minFeature) != minFeature) {
+ uint missing = minFeature & ~f;
+ fprintf(stderr, "Incompatible processor. This Qt build requires the following features:\n ");
+ for (int i = 0; i < features_count; ++i) {
+ if (missing & (1 << i))
+ fprintf(stderr, "%s", features_string + features_indices[i]);
+ }
+ fprintf(stderr, "\n");
+ fflush(stderr);
+ qFatal("Aborted. Incompatible processor: missing feature 0x%x -%s.", missing,
+ features_string + features_indices[ffs(missing) - 1]);
+ }
+
features.store(f);
return f;
}
@@ -370,7 +425,8 @@ void qDumpCPUFeatures()
printf("Processor features: ");
for (int i = 0; i < features_count; ++i) {
if (features & (1 << i))
- printf("%s", features_string + features_indices[i]);
+ printf("%s%s", features_string + features_indices[i],
+ minFeature & (1 << i) ? "[required]" : "");
}
puts("");
}