1 /* This file is part of the Vc library.
3 Copyright (C) 2010-2012 Matthias Kretz <kretz@kde.org>
5 Vc is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation, either version 3 of
8 the License, or (at your option) any later version.
10 Vc is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with Vc. If not, see <http://www.gnu.org/licenses/>.
20 #include <Vc/global.h>
22 #include "common/support.h"
32 __attribute__((target("no-sse2,no-avx")))
34 bool isImplementationSupported(Implementation impl)
37 // for AVX we need to check for OSXSAVE and AVX
43 return CpuId::hasSse2();
45 return CpuId::hasSse3();
47 return CpuId::hasSsse3();
49 return CpuId::hasSse41();
51 return CpuId::hasSse42();
53 return CpuId::hasSse4a();
55 return CpuId::hasXop();
57 return CpuId::hasFma4();
59 #if defined(VC_MSVC) && VC_MSVC >= 160040219 // MSVC 2010 SP1 introduced _xgetbv
60 unsigned long long xcrFeatureMask = _xgetbv(_XCR_XFEATURE_ENABLED_MASK);
61 return (xcrFeatureMask & 0x6) != 0;
62 #elif !defined(VC_NO_XGETBV)
63 if (CpuId::hasOsxsave() && CpuId::hasAvx()) {
65 asm("xgetbv" : "=a"(eax) : "c"(0) : "edx");
66 return (eax & 0x06) == 0x06;
76 // vim: sw=4 sts=4 et tw=100