Skip to content

Commit 7c98b9c

Browse files
committed
Revert "Revert "Unify instruction set definition (#33730)""
This reverts commit 5a71f14.
1 parent f79afdb commit 7c98b9c

32 files changed

+1888
-661
lines changed

src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ void MethodContext::recGetJitFlags(CORJIT_FLAGS* jitFlags, DWORD sizeInBytes, DW
11251125
void MethodContext::dmpGetJitFlags(DWORD key, DD value)
11261126
{
11271127
CORJIT_FLAGS* jitflags = (CORJIT_FLAGS*)GetJitFlags->GetBuffer(value.A);
1128-
printf("GetJitFlags key %u sizeInBytes-%u jitFlags-%016llX", key, value.B, jitflags->GetFlagsRaw());
1128+
printf("GetJitFlags key %u sizeInBytes-%u jitFlags-%016llX instructionSetFlags-%016llX", key, value.B, jitflags->GetFlagsRaw(), jitflags->GetInstructionSetFlagsRaw());
11291129
GetJitFlags->Unlock();
11301130
}
11311131
DWORD MethodContext::repGetJitFlags(CORJIT_FLAGS* jitFlags, DWORD sizeInBytes)

src/coreclr/src/inc/corinfo.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,11 @@ TODO: Talk about initializing strutures before use
217217
#endif
218218
#endif
219219

220-
SELECTANY const GUID JITEEVersionIdentifier = { /* c231d2d7-4764-4097-a9ef-5961041540df */
221-
0xc231d2d7,
222-
0x4764,
223-
0x4097,
224-
{0xa9, 0xef, 0x59, 0x61, 0x04, 0x15, 0x40, 0xdf}
220+
SELECTANY const GUID JITEEVersionIdentifier = { /* 54305fa1-a0d8-42e4-a6b4-b750a8143467 */
221+
0x54305fa1,
222+
0xa0d8,
223+
0x42e4,
224+
{0xa6, 0xb4, 0xb7, 0x50, 0xa8, 0x14, 0x34, 0x67}
225225
};
226226

227227
//////////////////////////////////////////////////////////////////////////////////////////////////////////
Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
2+
// Licensed to the .NET Foundation under one or more agreements.
3+
// The .NET Foundation licenses this file to you under the MIT license.
4+
// See the LICENSE file in the project root for more information.
5+
6+
// DO NOT EDIT THIS FILE! IT IS AUTOGENERATED
7+
// FROM /src/coreclr/src/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txt
8+
// using /src/coreclr/src/tools/Common/JitInterface/ThunkGenerator/gen.bat
9+
10+
#ifndef CORINFOINSTRUCTIONSET_H
11+
#define CORINFOINSTRUCTIONSET_H
12+
13+
enum CORINFO_InstructionSet
14+
{
15+
InstructionSet_ILLEGAL = 0,
16+
InstructionSet_NONE = 63,
17+
#ifdef TARGET_ARM64
18+
InstructionSet_ArmBase=1,
19+
InstructionSet_ArmBase_Arm64=2,
20+
InstructionSet_AdvSimd=3,
21+
InstructionSet_AdvSimd_Arm64=4,
22+
InstructionSet_Aes=5,
23+
InstructionSet_Crc32=6,
24+
InstructionSet_Crc32_Arm64=7,
25+
InstructionSet_Sha1=8,
26+
InstructionSet_Sha256=9,
27+
InstructionSet_Atomics=10,
28+
InstructionSet_Vector64=11,
29+
InstructionSet_Vector128=12,
30+
#endif // TARGET_ARM64
31+
#ifdef TARGET_AMD64
32+
InstructionSet_SSE=1,
33+
InstructionSet_SSE2=2,
34+
InstructionSet_SSE3=3,
35+
InstructionSet_SSSE3=4,
36+
InstructionSet_SSE41=5,
37+
InstructionSet_SSE42=6,
38+
InstructionSet_AVX=7,
39+
InstructionSet_AVX2=8,
40+
InstructionSet_AES=9,
41+
InstructionSet_BMI1=10,
42+
InstructionSet_BMI2=11,
43+
InstructionSet_FMA=12,
44+
InstructionSet_LZCNT=13,
45+
InstructionSet_PCLMULQDQ=14,
46+
InstructionSet_POPCNT=15,
47+
InstructionSet_Vector128=16,
48+
InstructionSet_Vector256=17,
49+
InstructionSet_BMI1_X64=18,
50+
InstructionSet_BMI2_X64=19,
51+
InstructionSet_LZCNT_X64=20,
52+
InstructionSet_POPCNT_X64=21,
53+
InstructionSet_SSE_X64=22,
54+
InstructionSet_SSE2_X64=23,
55+
InstructionSet_SSE41_X64=24,
56+
InstructionSet_SSE42_X64=25,
57+
#endif // TARGET_AMD64
58+
#ifdef TARGET_X86
59+
InstructionSet_SSE=1,
60+
InstructionSet_SSE2=2,
61+
InstructionSet_SSE3=3,
62+
InstructionSet_SSSE3=4,
63+
InstructionSet_SSE41=5,
64+
InstructionSet_SSE42=6,
65+
InstructionSet_AVX=7,
66+
InstructionSet_AVX2=8,
67+
InstructionSet_AES=9,
68+
InstructionSet_BMI1=10,
69+
InstructionSet_BMI2=11,
70+
InstructionSet_FMA=12,
71+
InstructionSet_LZCNT=13,
72+
InstructionSet_PCLMULQDQ=14,
73+
InstructionSet_POPCNT=15,
74+
InstructionSet_Vector128=16,
75+
InstructionSet_Vector256=17,
76+
InstructionSet_BMI1_X64=18,
77+
InstructionSet_BMI2_X64=19,
78+
InstructionSet_LZCNT_X64=20,
79+
InstructionSet_POPCNT_X64=21,
80+
InstructionSet_SSE_X64=22,
81+
InstructionSet_SSE2_X64=23,
82+
InstructionSet_SSE41_X64=24,
83+
InstructionSet_SSE42_X64=25,
84+
#endif // TARGET_X86
85+
86+
};
87+
88+
struct CORINFO_InstructionSetFlags
89+
{
90+
private:
91+
uint64_t _flags = 0;
92+
public:
93+
void AddInstructionSet(CORINFO_InstructionSet instructionSet)
94+
{
95+
_flags = _flags | (((uint64_t)1) << instructionSet);
96+
}
97+
98+
void RemoveInstructionSet(CORINFO_InstructionSet instructionSet)
99+
{
100+
_flags = _flags & ~(((uint64_t)1) << instructionSet);
101+
}
102+
103+
bool HasInstructionSet(CORINFO_InstructionSet instructionSet) const
104+
{
105+
return _flags & (((uint64_t)1) << instructionSet);
106+
}
107+
108+
bool Equals(CORINFO_InstructionSetFlags other) const
109+
{
110+
return _flags == other._flags;
111+
}
112+
113+
void Add(CORINFO_InstructionSetFlags other)
114+
{
115+
_flags |= other._flags;
116+
}
117+
118+
bool IsEmpty() const
119+
{
120+
return _flags == 0;
121+
}
122+
123+
void Reset()
124+
{
125+
_flags = 0;
126+
}
127+
128+
void Set64BitInstructionSetVariants()
129+
{
130+
#ifdef TARGET_ARM64
131+
if (HasInstructionSet(InstructionSet_ArmBase))
132+
AddInstructionSet(InstructionSet_ArmBase_Arm64);
133+
if (HasInstructionSet(InstructionSet_AdvSimd))
134+
AddInstructionSet(InstructionSet_AdvSimd_Arm64);
135+
if (HasInstructionSet(InstructionSet_Crc32))
136+
AddInstructionSet(InstructionSet_Crc32_Arm64);
137+
#endif // TARGET_ARM64
138+
#ifdef TARGET_AMD64
139+
if (HasInstructionSet(InstructionSet_SSE))
140+
AddInstructionSet(InstructionSet_SSE_X64);
141+
if (HasInstructionSet(InstructionSet_SSE2))
142+
AddInstructionSet(InstructionSet_SSE2_X64);
143+
if (HasInstructionSet(InstructionSet_SSE41))
144+
AddInstructionSet(InstructionSet_SSE41_X64);
145+
if (HasInstructionSet(InstructionSet_SSE42))
146+
AddInstructionSet(InstructionSet_SSE42_X64);
147+
if (HasInstructionSet(InstructionSet_BMI1))
148+
AddInstructionSet(InstructionSet_BMI1_X64);
149+
if (HasInstructionSet(InstructionSet_BMI2))
150+
AddInstructionSet(InstructionSet_BMI2_X64);
151+
if (HasInstructionSet(InstructionSet_LZCNT))
152+
AddInstructionSet(InstructionSet_LZCNT_X64);
153+
if (HasInstructionSet(InstructionSet_POPCNT))
154+
AddInstructionSet(InstructionSet_POPCNT_X64);
155+
#endif // TARGET_AMD64
156+
#ifdef TARGET_X86
157+
#endif // TARGET_X86
158+
159+
}
160+
161+
uint64_t GetFlagsRaw()
162+
{
163+
return _flags;
164+
}
165+
166+
void SetFromFlagsRaw(uint64_t flags)
167+
{
168+
_flags = flags;
169+
}
170+
};
171+
172+
inline CORINFO_InstructionSetFlags EnsureInstructionSetFlagsAreValid(CORINFO_InstructionSetFlags input)
173+
{
174+
CORINFO_InstructionSetFlags oldflags = input;
175+
CORINFO_InstructionSetFlags resultflags = input;
176+
do
177+
{
178+
oldflags = resultflags;
179+
#ifdef TARGET_ARM64
180+
if (resultflags.HasInstructionSet(InstructionSet_ArmBase) && !resultflags.HasInstructionSet(InstructionSet_ArmBase_Arm64))
181+
resultflags.RemoveInstructionSet(InstructionSet_ArmBase);
182+
if (resultflags.HasInstructionSet(InstructionSet_AdvSimd) && !resultflags.HasInstructionSet(InstructionSet_AdvSimd_Arm64))
183+
resultflags.RemoveInstructionSet(InstructionSet_AdvSimd);
184+
if (resultflags.HasInstructionSet(InstructionSet_Crc32) && !resultflags.HasInstructionSet(InstructionSet_Crc32_Arm64))
185+
resultflags.RemoveInstructionSet(InstructionSet_Crc32);
186+
if (resultflags.HasInstructionSet(InstructionSet_AdvSimd) && !resultflags.HasInstructionSet(InstructionSet_ArmBase))
187+
resultflags.RemoveInstructionSet(InstructionSet_AdvSimd);
188+
if (resultflags.HasInstructionSet(InstructionSet_Aes) && !resultflags.HasInstructionSet(InstructionSet_ArmBase))
189+
resultflags.RemoveInstructionSet(InstructionSet_Aes);
190+
if (resultflags.HasInstructionSet(InstructionSet_Crc32) && !resultflags.HasInstructionSet(InstructionSet_ArmBase))
191+
resultflags.RemoveInstructionSet(InstructionSet_Crc32);
192+
if (resultflags.HasInstructionSet(InstructionSet_Sha1) && !resultflags.HasInstructionSet(InstructionSet_ArmBase))
193+
resultflags.RemoveInstructionSet(InstructionSet_Sha1);
194+
if (resultflags.HasInstructionSet(InstructionSet_Sha256) && !resultflags.HasInstructionSet(InstructionSet_ArmBase))
195+
resultflags.RemoveInstructionSet(InstructionSet_Sha256);
196+
#endif // TARGET_ARM64
197+
#ifdef TARGET_AMD64
198+
if (resultflags.HasInstructionSet(InstructionSet_SSE) && !resultflags.HasInstructionSet(InstructionSet_SSE_X64))
199+
resultflags.RemoveInstructionSet(InstructionSet_SSE);
200+
if (resultflags.HasInstructionSet(InstructionSet_SSE2) && !resultflags.HasInstructionSet(InstructionSet_SSE2_X64))
201+
resultflags.RemoveInstructionSet(InstructionSet_SSE2);
202+
if (resultflags.HasInstructionSet(InstructionSet_SSE41) && !resultflags.HasInstructionSet(InstructionSet_SSE41_X64))
203+
resultflags.RemoveInstructionSet(InstructionSet_SSE41);
204+
if (resultflags.HasInstructionSet(InstructionSet_SSE42) && !resultflags.HasInstructionSet(InstructionSet_SSE42_X64))
205+
resultflags.RemoveInstructionSet(InstructionSet_SSE42);
206+
if (resultflags.HasInstructionSet(InstructionSet_BMI1) && !resultflags.HasInstructionSet(InstructionSet_BMI1_X64))
207+
resultflags.RemoveInstructionSet(InstructionSet_BMI1);
208+
if (resultflags.HasInstructionSet(InstructionSet_BMI2) && !resultflags.HasInstructionSet(InstructionSet_BMI2_X64))
209+
resultflags.RemoveInstructionSet(InstructionSet_BMI2);
210+
if (resultflags.HasInstructionSet(InstructionSet_LZCNT) && !resultflags.HasInstructionSet(InstructionSet_LZCNT_X64))
211+
resultflags.RemoveInstructionSet(InstructionSet_LZCNT);
212+
if (resultflags.HasInstructionSet(InstructionSet_POPCNT) && !resultflags.HasInstructionSet(InstructionSet_POPCNT_X64))
213+
resultflags.RemoveInstructionSet(InstructionSet_POPCNT);
214+
if (resultflags.HasInstructionSet(InstructionSet_SSE2) && !resultflags.HasInstructionSet(InstructionSet_SSE))
215+
resultflags.RemoveInstructionSet(InstructionSet_SSE2);
216+
if (resultflags.HasInstructionSet(InstructionSet_SSE3) && !resultflags.HasInstructionSet(InstructionSet_SSE2))
217+
resultflags.RemoveInstructionSet(InstructionSet_SSE3);
218+
if (resultflags.HasInstructionSet(InstructionSet_SSSE3) && !resultflags.HasInstructionSet(InstructionSet_SSE3))
219+
resultflags.RemoveInstructionSet(InstructionSet_SSSE3);
220+
if (resultflags.HasInstructionSet(InstructionSet_SSE41) && !resultflags.HasInstructionSet(InstructionSet_SSSE3))
221+
resultflags.RemoveInstructionSet(InstructionSet_SSE41);
222+
if (resultflags.HasInstructionSet(InstructionSet_SSE42) && !resultflags.HasInstructionSet(InstructionSet_SSE41))
223+
resultflags.RemoveInstructionSet(InstructionSet_SSE42);
224+
if (resultflags.HasInstructionSet(InstructionSet_AVX) && !resultflags.HasInstructionSet(InstructionSet_SSE42))
225+
resultflags.RemoveInstructionSet(InstructionSet_AVX);
226+
if (resultflags.HasInstructionSet(InstructionSet_AVX2) && !resultflags.HasInstructionSet(InstructionSet_AVX))
227+
resultflags.RemoveInstructionSet(InstructionSet_AVX2);
228+
if (resultflags.HasInstructionSet(InstructionSet_AES) && !resultflags.HasInstructionSet(InstructionSet_SSE2))
229+
resultflags.RemoveInstructionSet(InstructionSet_AES);
230+
if (resultflags.HasInstructionSet(InstructionSet_BMI1) && !resultflags.HasInstructionSet(InstructionSet_AVX))
231+
resultflags.RemoveInstructionSet(InstructionSet_BMI1);
232+
if (resultflags.HasInstructionSet(InstructionSet_BMI2) && !resultflags.HasInstructionSet(InstructionSet_AVX))
233+
resultflags.RemoveInstructionSet(InstructionSet_BMI2);
234+
if (resultflags.HasInstructionSet(InstructionSet_FMA) && !resultflags.HasInstructionSet(InstructionSet_AVX))
235+
resultflags.RemoveInstructionSet(InstructionSet_FMA);
236+
if (resultflags.HasInstructionSet(InstructionSet_PCLMULQDQ) && !resultflags.HasInstructionSet(InstructionSet_SSE2))
237+
resultflags.RemoveInstructionSet(InstructionSet_PCLMULQDQ);
238+
if (resultflags.HasInstructionSet(InstructionSet_POPCNT) && !resultflags.HasInstructionSet(InstructionSet_SSE42))
239+
resultflags.RemoveInstructionSet(InstructionSet_POPCNT);
240+
#endif // TARGET_AMD64
241+
#ifdef TARGET_X86
242+
if (resultflags.HasInstructionSet(InstructionSet_SSE2) && !resultflags.HasInstructionSet(InstructionSet_SSE))
243+
resultflags.RemoveInstructionSet(InstructionSet_SSE2);
244+
if (resultflags.HasInstructionSet(InstructionSet_SSE3) && !resultflags.HasInstructionSet(InstructionSet_SSE2))
245+
resultflags.RemoveInstructionSet(InstructionSet_SSE3);
246+
if (resultflags.HasInstructionSet(InstructionSet_SSSE3) && !resultflags.HasInstructionSet(InstructionSet_SSE3))
247+
resultflags.RemoveInstructionSet(InstructionSet_SSSE3);
248+
if (resultflags.HasInstructionSet(InstructionSet_SSE41) && !resultflags.HasInstructionSet(InstructionSet_SSSE3))
249+
resultflags.RemoveInstructionSet(InstructionSet_SSE41);
250+
if (resultflags.HasInstructionSet(InstructionSet_SSE42) && !resultflags.HasInstructionSet(InstructionSet_SSE41))
251+
resultflags.RemoveInstructionSet(InstructionSet_SSE42);
252+
if (resultflags.HasInstructionSet(InstructionSet_AVX) && !resultflags.HasInstructionSet(InstructionSet_SSE42))
253+
resultflags.RemoveInstructionSet(InstructionSet_AVX);
254+
if (resultflags.HasInstructionSet(InstructionSet_AVX2) && !resultflags.HasInstructionSet(InstructionSet_AVX))
255+
resultflags.RemoveInstructionSet(InstructionSet_AVX2);
256+
if (resultflags.HasInstructionSet(InstructionSet_AES) && !resultflags.HasInstructionSet(InstructionSet_SSE2))
257+
resultflags.RemoveInstructionSet(InstructionSet_AES);
258+
if (resultflags.HasInstructionSet(InstructionSet_BMI1) && !resultflags.HasInstructionSet(InstructionSet_AVX))
259+
resultflags.RemoveInstructionSet(InstructionSet_BMI1);
260+
if (resultflags.HasInstructionSet(InstructionSet_BMI2) && !resultflags.HasInstructionSet(InstructionSet_AVX))
261+
resultflags.RemoveInstructionSet(InstructionSet_BMI2);
262+
if (resultflags.HasInstructionSet(InstructionSet_FMA) && !resultflags.HasInstructionSet(InstructionSet_AVX))
263+
resultflags.RemoveInstructionSet(InstructionSet_FMA);
264+
if (resultflags.HasInstructionSet(InstructionSet_PCLMULQDQ) && !resultflags.HasInstructionSet(InstructionSet_SSE2))
265+
resultflags.RemoveInstructionSet(InstructionSet_PCLMULQDQ);
266+
if (resultflags.HasInstructionSet(InstructionSet_POPCNT) && !resultflags.HasInstructionSet(InstructionSet_SSE42))
267+
resultflags.RemoveInstructionSet(InstructionSet_POPCNT);
268+
#endif // TARGET_X86
269+
270+
} while (!oldflags.Equals(resultflags));
271+
return resultflags;
272+
}
273+
274+
275+
276+
#endif // CORINFOINSTRUCTIONSET_H

0 commit comments

Comments
 (0)