android: Update app-specific/MIME type icons
[LibreOffice.git] / include / tools / cpuid.hxx
blob4f309ff11e9692d47f1ce597c22932ef68e3c421
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #pragma once
13 #include <sal/config.h>
14 #include <tools/toolsdllapi.h>
15 #include <o3tl/typed_flags_set.hxx>
16 #include <rtl/ustring.hxx>
20 Do NOT include this header in source files compiled with CPU-specific code.
21 TODO: For the header to be safe that way, it should be free of any templates
22 or inline functions, otherwise their possibly emitted copies compiled
23 with the CPU-specific instructions might be chosen by the linker as the copy
24 to keep.
26 Also see the note at the top of simdsupport.hxx .
30 namespace cpuid {
32 enum class InstructionSetFlags
34 NONE = 0x00,
35 HYPER = 0x01,
36 SSE2 = 0x02,
37 SSSE3 = 0x04,
38 SSE41 = 0x08,
39 SSE42 = 0x10,
40 AVX = 0x20,
41 AVX2 = 0x40,
42 AVX512F = 0x80
45 } // end cpuid
47 namespace o3tl {
48 template<> struct typed_flags<cpuid::InstructionSetFlags> : is_typed_flags<cpuid::InstructionSetFlags, 0x0ff> {};
51 namespace cpuid {
53 /** Get supported instruction set flags determined at runtime by probing the CPU.
55 TOOLS_DLLPUBLIC InstructionSetFlags getCpuInstructionSetFlags();
57 /** Check if a certain instruction set is supported by the CPU at runtime.
59 TOOLS_DLLPUBLIC bool isCpuInstructionSetSupported(InstructionSetFlags eInstructions);
61 /** Returns a string of supported instructions.
63 TOOLS_DLLPUBLIC OUString instructionSetSupportedString();
65 /** Check if SSE2 is supported by the CPU
67 inline bool hasSSE2()
69 return isCpuInstructionSetSupported(InstructionSetFlags::SSE2);
72 /** Check if SSSE3 is supported by the CPU
74 inline bool hasSSSE3()
76 return isCpuInstructionSetSupported(InstructionSetFlags::SSSE3);
79 /** Check if AVX is supported by the CPU
81 inline bool hasAVX()
83 return isCpuInstructionSetSupported(InstructionSetFlags::AVX);
86 /** Check if AVX2 is supported by the CPU
88 inline bool hasAVX2()
90 return isCpuInstructionSetSupported(InstructionSetFlags::AVX2);
93 /** Check if AVX512F is supported by the CPU
95 inline bool hasAVX512F()
97 return isCpuInstructionSetSupported(InstructionSetFlags::AVX512F);
100 /** Check if Hyper Threading is supported
102 inline bool hasHyperThreading()
104 return isCpuInstructionSetSupported(InstructionSetFlags::HYPER);
107 } // end cpuid
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */