LMMS
Loading...
Searching...
No Matches
juce_intel_SharedCode.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
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.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26#if JUCE_INTEL && ! JUCE_NO_INLINE_ASM
27
28namespace SystemStatsHelpers
29{
30
31static void doCPUID (uint32& a, uint32& b, uint32& c, uint32& d, uint32 type)
32{
33 uint32 la = a, lb = b, lc = c, ld = d;
34
35 #if JUCE_32BIT && defined (__pic__)
36 asm ("mov %%ebx, %%edi\n"
37 "cpuid\n"
38 "xchg %%edi, %%ebx\n"
39 : "=a" (la), "=D" (lb), "=c" (lc), "=d" (ld)
40 : "a" (type), "c" (0));
41 #else
42 asm ("cpuid\n"
43 : "=a" (la), "=b" (lb), "=c" (lc), "=d" (ld)
44 : "a" (type), "c" (0));
45 #endif
46
47 a = la; b = lb; c = lc; d = ld;
48}
49
50static void getCPUInfo (bool& hasMMX,
51 bool& hasSSE,
52 bool& hasSSE2,
53 bool& has3DNow,
54 bool& hasSSE3,
55 bool& hasSSSE3,
56 bool& hasFMA3,
57 bool& hasSSE41,
58 bool& hasSSE42,
59 bool& hasAVX,
60 bool& hasFMA4,
61 bool& hasAVX2,
62 bool& hasAVX512F,
63 bool& hasAVX512DQ,
64 bool& hasAVX512IFMA,
65 bool& hasAVX512PF,
66 bool& hasAVX512ER,
67 bool& hasAVX512CD,
68 bool& hasAVX512BW,
69 bool& hasAVX512VL,
70 bool& hasAVX512VBMI,
71 bool& hasAVX512VPOPCNTDQ)
72{
73 uint32 a = 0, b = 0, d = 0, c = 0;
74 SystemStatsHelpers::doCPUID (a, b, c, d, 1);
75
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;
86
87 SystemStatsHelpers::doCPUID (a, b, c, d, 0x80000001);
88 hasFMA4 = (c & (1u << 16)) != 0;
89
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;
102}
103
104} // namespace SystemStatsHelpers
105
106#endif
107
108} // namespace juce
uint8_t a
Definition Spc_Cpu.h:141
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
uint32_t uint32
Definition basics.h:90
unsigned d
Definition inflate.c:940
Definition carla_juce.cpp:31
return c
Definition crypt.c:175
b
Definition crypt.c:628