VST3: fetch midi mappings all at once, use it for note/sound-off
[carla.git] / source / modules / juce_core / native / juce_intel_SharedCode.h
blob17f47d2487cfc3d6e02bea3d0435e1c2b887bb4c
1 /*
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
8 licensing.
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
18 DISCLAIMED.
20 ==============================================================================
23 namespace juce
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"
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
47 a = la; b = lb; c = lc; d = ld;
50 static 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)
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
106 #endif
108 } // namespace juce