summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qsimd.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Store the GCC version number in Q_CC_GNUThiago Macieira2014-11-051-1/+1
| | | | | | | | | | | The sequence of (__GNUC__ * 100 + __GNUC_MINOR__) was used in quite a few places. Simplify it to make the code more readable. This follows the change done for Clang, which was quite necessary since Apple's version of Clang has different build numbers. Change-Id: I886271a5a5f21ae59485ecf8d140527723345a46 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Remove the last remnants of iWMMXt in QtThiago Macieira2014-08-051-15/+7
| | | | | | | | This code hasn't been tested for at least 4 years. It's not maintained and probably doesn't work. Change-Id: I4b9a5179e34111b400914f91caa6b741b69771bb Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Add a few missing Neon constructsThiago Macieira2014-08-051-7/+6
| | | | | | | | | | | The #undef in qcompilerdetection.h was missing. And apparently we can detect Neon since Windows Mobile 6 too. Change-Id: I38a5f71b2704a29a706183e39f43db3a78a729db Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Use an enum to check that the OS is saving the register stateThiago Macieira2014-07-311-1/+18
| | | | | | | | | | | | It's easier to read AVXState and AVX512State than 6 and 0xe6. Also add a note that where we should have checked whether the SSE state is being saved by the OS. However, we won't do it because it's just a waste of CPU cycles: any OS Qt 5 runs on will enable the proper state-saving. Change-Id: Id87b59fe1388a6cab983c9412341e36a86dd15c5 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* MIPS: Support recognition of the DSP ASE at run-timeAdrian Perez de Castro2014-06-271-2/+141
| | | | | | | | | | | | | Add detection of MIPS DSPr2 at run-time in qsimd.cpp. This makes it possible to have generic Qt builds for MIPS that can enable the fast code paths for processors with the DSP ASE at run-time. Also, this makes it possible to manually disable them by setting the environment variable "QT_NO_CPU_FEATURE=dspr2". Last, but not least, functions requiring DSPr2 are not enabled when running in CPUs with version-1 DSP. Change-Id: Ia5a01d84119553c22ab83386c74a6cb8ba5fee53 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use qregister(u)int in qsimd.cpp x86 codeThiago Macieira2014-02-011-3/+3
| | | | | | | | | | This way, the same codebase works for x86, x86-64 LP64 and x86-64 ILP32 (a.k.a. x32). Task-number: QTBUG-35463 Change-Id: Iffcecc6a4c03267fb64e287c2d6226d078d7d115 Reviewed-by: hjk <hjk121@nokiamail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove last traces of QT_COMPILER_SUPPORTS_NEONTor Arne Vestbø2014-01-161-2/+2
| | | | | | | | | | | Fixes ARM build, as the NEON drawhelpers and image conversion functions were ifdef'ed out. Follow-up to 1b12c0608be2359baa2f96ae28b135a84abd388c. Change-Id: I0b5e89c8f445741432db2dfe1f8d971b971c8605 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Don't try to detect the CPUID instruction if we're compiling for PentiumThiago Macieira2013-08-271-1/+1
| | | | | | | | | | | | | | | | If we're compiling for Pentium or better CPUs, then we know that the CPUID instruction is present (I think it was introduced in late 486s, actually). So don't try to detect it. Simply assume it's there and then execute it. This means that if you compile Qt for Pentium (or higher) and run it on an i386 or i486, you'll get a SIGILL (or whatever your OS produces for an #UD processor exception). If the CPU detection code even got run -- SIGILL might happen for any other instructions found along the way. Change-Id: Iacd4a94a51363a609a61fc2bfd2e218fb290272d Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use the GCC inline assembly when building for MinGWThiago Macieira2013-06-041-5/+5
| | | | | | | | | | | MinGW has a longstanding problem of providing the MSVC intrinsics that every Windows developer expects to be there. Other projects have run into those problems. So instead just use the GCC inline assembly. Change-Id: I5651f97f9a4dfbf98ebbf063f91f221eab80b224 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* match #ifdefs relating to arm compilationOswald Buddenhagen2013-03-241-1/+1
| | | | | | | | use the same conditional around the #include as the actual code below uses, otherwise we risk mismatches. Change-Id: I8ca32c0178b1970928626a927948b06d4c6d31b9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Fix module name formatSze Howe Koh2013-01-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow the conventions at http://qt-project.org/wiki/Spelling_Module_Names_in_Qt_Documentation QtCore -> Qt Core QtDBus -> Qt D-Bus QtDesigner -> Qt Designer QtGui -> Qt GUI QtImageFormats -> Qt Image Formats QtNetwork -> Qt Network QtPrintSupport -> Qt Print Support QtScript -> Qt Script QtSql -> Qt SQL QtSvg -> Qt SVG QtTest -> Qt Test QtWebKit -> Qt WebKit QtWidgets -> Qt Widgets QtXml -> Qt XML QtConcurrent -> Qt Concurrent (partial) QtQuick -> Qt Quick (partial) Also, distinguish between "module" and "library" Change-Id: Icb8aa695ae60b0e45920b0c8fce4dc763a12b0cd Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Doc: Fix spelling errorsSergio Ahumada2012-08-171-1/+1
| | | | | Change-Id: Ibae8d10183f6b15a16b1499daa2df8802dbb014e Reviewed-by: Geir Vattekar <geir.vattekar@nokia.com>
* Disable CPUID checking with GCC 4.2 or olderThiago Macieira2012-08-151-0/+22
| | | | | | | | | | | | | | | | | | | | | | | This is not the first time that GCC 4.2 on Mac has produced bad code surrounding the CPUID instruction (see also commit 81d1f79a7f4b0f67d71). So declare it broken beyond repair and don't run the instruction at all. Instead, initialise the set of features found to be exactly that which we detected at compile-time. For that reason, we can also disable the runtime checking of the processor (minFeatures == detected features). At the time of this commit, only the draw helpers and one QImage helper make use of the runtime detection. Since the detection now switches to compile-time, QtGui will start carrying dead code for GCC 4.2 and earlier: it will never run the SSE2/SSSE3 code on 32-bit builds. (GCC 4.2 does not support AVX, so that code won't be built) Note: all Clang versions report that they are GCC 4.2, so we need to exclude it from the test; ICC reports the same version as the system's GCC. Change-Id: I43f168a9480a2479c6444eea175782b2eadc2ab2 Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
* Make the CPU detection much more efficient in user codeThiago Macieira2012-07-021-40/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | First, check that the option in question hasn't been already enabled by the compiler, via compiler switches. If it has been, then we don't need to verify anything, and we can assume that it's safe to use such instructions. For example, on an x86-64 build, qCpuHasFeature(SSE2) is always a constant true. If the compile-time check fails, then we proceed to try and detect the processor features at runtime. But instead of insisting on a call to qDetectCPUFeatures, allow the code using the detection to read from a variable and simply test it for values. Only if the variable isn't initialised should it make a function call. The Q_ASSUME allows this code to be very efficient even with multiple uses of qCpuHasFeature. Change the uninitialised value from -1 to 0 so that simpler instructions can be used to check for non-initialisation. The qDetectCPUFeatures function is renamed to qDetectCpuFeatures to match the Qt coding style and also to catch uses this code that need to be adapted. Change-Id: I24ca5a6ad21075e2e249e1a4f8f5057b8f68ce7c Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix the confusion caused by the QT_ALWAYS_HAVE_xxx macrosThiago Macieira2012-05-311-1/+1
| | | | | | | | | | | | | | | | | | | | The QT_ALWAYS_HAVE_xxx macros are gone: they were hard to use and not defined properly. It indicated that the compiler was producing code that required that particular instruction set, so we could use it in our code unconditionally. Instead, let's use the GCC-style __SSE2__ and __ARM_NEON__. MSVC does not generate the __SSE2__ macro, so let's do it for the compiler. Also, define __AVX__ and the macros for the technologies leading to it when we manage to detect an /arch:AVX build (currently not possible, see note in the header). ICC and MSVC allow one to use the intrinsics anywhere, but for Qt all uses of the intrinsics are either in specially-built files, protected by runtime checks, or they are unconditional (qstring.cpp). So we only use the intrinsics when the compiler was instructed to generate code for that instruction set anyway. Change-Id: If8382f30422cee0e5831d051b003acf036824abf Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* Overhaul the qsimd_p.h: rename macros and update conditionalsThiago Macieira2012-05-311-2/+2
| | | | | | | | | | | | | | | The QT_HAVE_xxx macros are replaced with QT_COMPILER_SUPPORTS_xxx. They indicate that the compiler supports those intrinsics, but not necessarily that they can be used right now. ICC and MSVC allow one to use the intrinsics anywhere, but for Qt all uses of the intrinsics are either in specially-built files, protected by runtime checks, or they are unconditional (qstring.cpp). So we only use the intrinsics when the compiler was instructed to generate code for that instruction set anyway. Change-Id: Ie58eebbc0518ad1d5420a85174fd84153bb9abaa Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* Get rid of ambiguous overload for xgetbv.Jan-Arve Saether2012-05-211-2/+2
| | | | | | | | | | | | | | The patch that broke this was assuming the signature of xgetbv was _xgetbv(int). This lead to that there were no exact match for the function resolver, thus the ambiguity. Apparently, the signature of _xgetbv is _xgetbv(unsigned int). Changing the static xgetbv to uint makes the match exact, thus no more ambiguity. Change-Id: I8db95e00a9fef264d7a1f84d02bb929db84e6e5a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
* Compile fix: Do not rely on __cpuidex() for msvc2008Jan-Arve Saether2012-05-191-4/+5
| | | | | | | | | | | | | | | Since its hard to detect if __cpuidex() is actually available at compile time, we'll add a function overload that will be chosen if the intrinsic __cpuidex() is not available. Note that the QtXgetbvHack that was used for _xgetbv did not really work (MS compiler will bail out because of ambiguous overloads if the intrinsic _xgetbv existed). Therefore, we apply the same workaround for _xgetbv. Change-Id: Iee3bf8bc6352ba0861b05d779f1f001d4eb013ff Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix MinGW-w64 compilationJonathan Liu2012-04-301-3/+3
| | | | | | | | | Use qintptr and quintptr for exchanging data with registers for cpuid as the size of long does not match the size of the register on Win64 which uses the LLP64 data model. Change-Id: I23b8c8e0977166f7e62795c16e9080e44d9f25f5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* fix build with mingwKonstantin Ritt2012-04-271-17/+17
| | | | | | | since MinGW is GCC, invert the order and place the GCC constructs first Change-Id: I98113aa77e51f9e01c3641987e915bf475053a60 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix C++11 compilationOlivier Goffart2012-04-261-6/+6
| | | | | | | | Fix compilation with compilers that support user defined literal (such as GCC 4.7) Change-Id: I31cd3d2177688f963ab33cf68cd6060a5fb8640f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add detection code for AVX2, HLE, RTM and AES to qsimd.cppThiago Macieira2012-04-251-16/+35
| | | | | | | | | | | | | | | AES is currently not enabled, since we don't use it for anything. The code is here with the proper detection should we want to in the future. RTM and HLE (Transactional Memory Extensions) I'll use soon in the locking code. Also rename a few variables to make it easier to read later on. Change-Id: I800c66d7e1ba86ec037692928d94f53ea5d5868f Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
* Replace the x86 XGETBV instruction with its opcode bytesThiago Macieira2012-04-251-1/+1
| | | | | | | | | | | | | This is a new instruction, present on the SandyBridge architecture and later. Some older assemblers do not support it and produce: {standard input}:225:no such instruction: `xgetbv' The use of this instruction is protected by a CPUID check (function 1, ECX bit 27), so we only run it in processors that do support it. Change-Id: Ife7500c0deaab9539074835a4511e8c19602608e Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* Update the x86 feature-detection code, unifying x86 and x86-64Thiago Macieira2012-04-251-125/+113
| | | | | | | | | | | | | | | Most of it is the same for both of them, so let's avoid doing everything twice. Or more, since we may support x32 soon. For Windows, use the intrinsics. For GCC, we'd like to use cpuid.h, but it only exists since GCC 4.3, so we can't. And properly detect AVX support: it's not enough to detect that the processor supports them, we also need to check that the OS enabled support for the 256-bit registers. Change-Id: Ibb4872cdb774de5701b18c40f4e612330a266214 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
* Use the Q_PROCESSOR_* macros in qsimd.cppThiago Macieira2012-04-231-3/+3
| | | | | Change-Id: I7be9b14a24329be32c43603ae87df17328696109 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* Fixed QSimd WindowsCE buildBjoern Breitmeyer2012-04-191-1/+8
| | | | | | Change-Id: I94de251cf1f283d30f92d0fb9d37a1646765cbdd Reviewed-by: Andreas Holzammer <andreas.holzammer@kdab.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
* Add early-clobbers to the output variables in CPUIDThiago Macieira2012-04-101-3/+3
| | | | | | | | | | | | | | | Without those early-clobbers, the compiler might decide to schedule a register that is also used as output. The existing early clobber in the tmp variable was there so the compiler wouldn't use a register scheduled as input (especially EAX). To be honest, I'm not convinced that the compiler should be allowed to do this. That means that two output variables are scheduled to the same register... still, this fixes a problem found with GCC 4.2 (at least the Mac one). Change-Id: I6cd4676284e9a83d6aac4b439c6e58e347c40106 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* Fix compilation with MinGW.Marcel Krems2012-04-051-1/+7
| | | | | Change-Id: I494c84e8e6889a7d7bb3b29669337483732d02c2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add missing include on 32-bit buildsJoão Abecasis2012-04-021-3/+1
| | | | | | | | | Commit cc3ff3c1 introduced uncoditional use of _BitScanForward on Windows, so adapt include conditions to match use of function. Change-Id: I46ea4212ea3a01d9c4ecb19377b21e9b0f16e179 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make qsimd.cpp also complain if required features are missingThiago Macieira2012-03-281-2/+58
| | | | | | | | | | | | | | | | | | 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>
* Add support for detecting SSE2 and SSE3 on WinCEThiago Macieira2012-03-261-0/+4
| | | | | | Change-Id: Ic26ba2073d1f1d7e12338811b86f9b99ea8f1eac Reviewed-by: Andreas Holzammer <andreas.holzammer@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove detection for MMX support and related technologyThiago Macieira2012-03-231-37/+5
| | | | | | | | | | | | This also removes the check for SSE, but the check for SSE2 and further technologies is kept. If SSE2 is present, then SSE is too. We don't have any code that uses the original SSE instructions only. Remove the CMOV detection, since we don't use that anywhere and we're not likely to ever use them.. Change-Id: I3faf2c555ad1c007c52a54644138902f716c1fe1 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* Remove the false information that IA-64 supports SSE2Thiago Macieira2012-03-221-6/+0
| | | | | | | | | This must have been a mistake. IA-64 processors used to contain an IA-32 core, which supported SSE2. However, the IA-64 mode supported no such thing. Change-Id: I731c6018166af6b897cb697c68aad4ef3ae93132 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
* Explicit use of null namespace breaks namespaced buildDonald Carr2012-03-141-3/+3
| | | | | | | | These changes are currently required to successfully build Qt when it is configured with a namespace via the configure -qtnamespace argument Change-Id: I9f3ab30579c16085c4d3d05705336b810466c331 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix compilation with MinGW-w64Jonathan Liu2012-02-081-1/+1
| | | | | | | | | | | | | | | Fix compilation with MinGW-w64 with the following changes: - Include intrin.h to fix __cpuid not declared error - Include intrin.h before *mmintrin.h headers to avoid extern linkable mismatch - Use quintptr instead of unsigned long to handle LLP64 - Do not declare winuser.h structs already provided with MinGW-w64 - Work around IID_IShellItem being declared but not defined with MinGW-w64 - Remove incorrect use of SUCCEEDED macro on pointer Change-Id: Ia21f8e3a1d225cf501e646eacd968bfc744ce0a2 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
* Windows: Fix inclusion of <windows.h>Friedemann Kleint2012-02-011-9/+8
| | | | | | | | | | | | | - Always use <qt_windows.h> as the last file to be included. - Remove it from some headers, use Qt::HANDLE instead of HANDLE. - Clean up #ifdef, use Q_OS_WIN for Windows/Windows CE. - Add NOMINMAX to qt_windows.h to avoid problems with the min/max macros. - Remove <windows.h> from qplatformdefs.h (VS2005) Change-Id: Ic44e2cb3eafce38e1ad645c3bf85745439398e50 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Make all uses of QBasicAtomicInt and Pointer use load() and store()Thiago Macieira2011-10-031-4/+4
| | | | | | | | | | | | | | Most of these changes are search-and-replace of d->ref ==, d->ref != and d->ref =. The QBasicAtomicPointer in QObjectPrivate::Connection didn't need to be basic, so I made it QAtomicPointer. Change-Id: Ie3271abd1728af599f9ab17c6f4868e475f17bb6 Reviewed-on: http://codereview.qt-project.org/5030 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Update licenseheader text in source files for qtbase Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+413
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12