summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qsimd.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-08-20 21:19:54 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-08-24 13:01:10 (GMT)
commitd9b567288f301e44abedebf5b9b553c2878f2c77 (patch)
tree0ad0d69158b1055507f57a2bf78208c7fd4816c1 /src/corelib/tools/qsimd.cpp
parent5070c3ae331faf18f6997535356853cc61ef0ad7 (diff)
downloadQt-d9b567288f301e44abedebf5b9b553c2878f2c77.zip
Qt-d9b567288f301e44abedebf5b9b553c2878f2c77.tar.gz
Qt-d9b567288f301e44abedebf5b9b553c2878f2c77.tar.bz2
Report the detected CPU features in the corelib boilerplate
Diffstat (limited to 'src/corelib/tools/qsimd.cpp')
-rw-r--r--src/corelib/tools/qsimd.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index a5ec3c5..2472449 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -41,6 +41,7 @@
#include "qsimd_p.h"
#include <QByteArray>
+#include <stdio.h>
#if defined(Q_OS_WINCE)
#include <windows.h>
@@ -404,4 +405,56 @@ uint qDetectCPUFeatures()
return features;
}
+void qDumpCPUFeatures()
+{
+ /*
+ * Use kdesdk/scripts/generate_string_table.pl to update the table below.
+ * Here's the data:
+mmx
+mmxext
+mmx3dnow
+mmx3dnowext
+sse
+sse2
+cmov
+iwmmxt
+neon
+sse3
+ssse3
+sse4.1
+sse4.2
+avx
+ */
+ static const char features_string[] =
+ "mmx\0"
+ "mmxext\0"
+ "mmx3dnow\0"
+ "mmx3dnowext\0"
+ "sse\0"
+ "sse2\0"
+ "cmov\0"
+ "iwmmxt\0"
+ "neon\0"
+ "sse3\0"
+ "ssse3\0"
+ "sse4.1\0"
+ "sse4.2\0"
+ "avx\0"
+ "\0";
+
+ static const int features_indices[] = {
+ 0, 4, 11, 20, 32, 36, 41, 46,
+ 53, 58, 63, 69, 76, 83, -1
+ };
+ const int features_count = (sizeof features_indices - 1) / (sizeof features_indices[0]);
+
+ uint features = qDetectCPUFeatures();
+ printf("Processor features: ");
+ for (int i = 0; i < features_count; ++i) {
+ if (features & (1 << i))
+ printf(" %s", features_string + features_indices[i]);
+ }
+ puts("");
+}
+
QT_END_NAMESPACE