2 ==============================================================================
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
7 JUCE is an open source library subject to commercial or open-source
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
20 ==============================================================================
26 #if JUCE_INTEL && ! JUCE_NO_INLINE_ASM
28 namespace SystemStatsHelpers
31 static void doCPUID (uint32
& a
, uint32
& b
, uint32
& c
, uint32
& d
, uint32 type
)
33 uint32 la
= a
, lb
= b
, lc
= c
, ld
= d
;
35 #if JUCE_32BIT && defined (__pic__)
36 asm ("mov %%ebx, %%edi\n"
39 : "=a" (la
), "=D" (lb
), "=c" (lc
), "=d" (ld
)
40 : "a" (type
), "c" (0));
43 : "=a" (la
), "=b" (lb
), "=c" (lc
), "=d" (ld
)
44 : "a" (type
), "c" (0));
47 a
= la
; b
= lb
; c
= lc
; d
= ld
;
50 static void getCPUInfo (bool& hasMMX
,
71 bool& hasAVX512VPOPCNTDQ
)
73 uint32 a
= 0, b
= 0, d
= 0, c
= 0;
74 SystemStatsHelpers::doCPUID (a
, b
, c
, d
, 1);
76 hasMMX
= (d
& (1u << 23)) != 0;
77 hasSSE
= (d
& (1u << 25)) != 0;
78 hasSSE2
= (d
& (1u << 26)) != 0;
79 has3DNow
= (b
& (1u << 31)) != 0;
80 hasSSE3
= (c
& (1u << 0)) != 0;
81 hasSSSE3
= (c
& (1u << 9)) != 0;
82 hasFMA3
= (c
& (1u << 12)) != 0;
83 hasSSE41
= (c
& (1u << 19)) != 0;
84 hasSSE42
= (c
& (1u << 20)) != 0;
85 hasAVX
= (c
& (1u << 28)) != 0;
87 SystemStatsHelpers::doCPUID (a
, b
, c
, d
, 0x80000001);
88 hasFMA4
= (c
& (1u << 16)) != 0;
90 SystemStatsHelpers::doCPUID (a
, b
, c
, d
, 7);
91 hasAVX2
= (b
& (1u << 5)) != 0;
92 hasAVX512F
= (b
& (1u << 16)) != 0;
93 hasAVX512DQ
= (b
& (1u << 17)) != 0;
94 hasAVX512IFMA
= (b
& (1u << 21)) != 0;
95 hasAVX512PF
= (b
& (1u << 26)) != 0;
96 hasAVX512ER
= (b
& (1u << 27)) != 0;
97 hasAVX512CD
= (b
& (1u << 28)) != 0;
98 hasAVX512BW
= (b
& (1u << 30)) != 0;
99 hasAVX512VL
= (b
& (1u << 31)) != 0;
100 hasAVX512VBMI
= (c
& (1u << 1)) != 0;
101 hasAVX512VPOPCNTDQ
= (c
& (1u << 14)) != 0;
104 } // namespace SystemStatsHelpers