Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 5d1bbec

Browse files
committed
Enable hardware intrinsic in debug and reflection
1 parent 9b10a28 commit 5d1bbec

File tree

15 files changed

+185
-99
lines changed

15 files changed

+185
-99
lines changed

src/dlls/mscorrc/mscorrc.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@ BEGIN
853853
IDS_EE_SIMD_PARTIAL_TRUST_DISALLOWED "SIMD intrinsics may not be used by partial trust applications."
854854
IDS_IBC_MISSING_EXTERNAL_TYPE "The generic type specified by the IBC data is not available to this assembly"
855855
IDS_IBC_MISSING_EXTERNAL_METHOD "The generic method specified by the IBC data is not available to this assembly"
856+
IDS_EE_HWINTRINSIC_NGEN_DISALLOWED "Hardware intrinsics may not be used with ngen."
856857

857858
IDS_INET_E_CANNOT_CONNECT "Cannot connect to URL for '%1'."
858859
IDS_INET_E_RESOURCE_NOT_FOUND "The server or proxy was not found for '%1'."

src/dlls/mscorrc/resource.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@
613613
#define IDS_EE_SIMD_PARTIAL_TRUST_DISALLOWED 0x1ac4
614614
#define IDS_IBC_MISSING_EXTERNAL_TYPE 0x1ac5
615615
#define IDS_IBC_MISSING_EXTERNAL_METHOD 0x1ac6
616+
#define IDS_EE_HWINTRINSIC_NGEN_DISALLOWED 0x1ac7
616617

617618
#define BFA_INVALID_FILE_TOKEN 0x2000
618619
#define BFA_INVALID_TOKEN_TYPE 0x2001

src/jit/compiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2561,7 +2561,7 @@ void Compiler::compSetProcessor()
25612561

25622562
#endif // _TARGET_X86_
25632563

2564-
// Instruction set flags fo// Instruction set flags for Intel hardware intrinsics
2564+
// Instruction set flags for Intel hardware intrinsics
25652565
#ifdef _TARGET_XARCH_
25662566
opts.compSupportsISA = 0;
25672567

src/jit/compiler.h

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3021,22 +3021,22 @@ class Compiler
30213021
InstructionSet lookupHWIntrinsicISA(const char* className);
30223022
NamedIntrinsic lookupHWIntrinsic(const char* methodName, InstructionSet isa);
30233023
InstructionSet isaOfHWIntrinsic(NamedIntrinsic intrinsic);
3024-
GenTree* impX86HWIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method);
3025-
GenTree* impSSEIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method);
3026-
GenTree* impSSE2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method);
3027-
GenTree* impSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method);
3028-
GenTree* impSSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method);
3029-
GenTree* impSSE41Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method);
3030-
GenTree* impSSE42Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method);
3031-
GenTree* impAVXIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method);
3032-
GenTree* impAVX2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method);
3033-
GenTree* impAESIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method);
3034-
GenTree* impBMI1Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method);
3035-
GenTree* impBMI2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method);
3036-
GenTree* impFMAIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method);
3037-
GenTree* impLZCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method);
3038-
GenTree* impPCLMULQDQIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method);
3039-
GenTree* impPOPCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method);
3024+
GenTree* impX86HWIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
3025+
GenTree* impSSEIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
3026+
GenTree* impSSE2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
3027+
GenTree* impSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
3028+
GenTree* impSSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
3029+
GenTree* impSSE41Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
3030+
GenTree* impSSE42Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
3031+
GenTree* impAVXIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
3032+
GenTree* impAVX2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
3033+
GenTree* impAESIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
3034+
GenTree* impBMI1Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
3035+
GenTree* impBMI2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
3036+
GenTree* impFMAIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
3037+
GenTree* impLZCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
3038+
GenTree* impPCLMULQDQIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
3039+
GenTree* impPOPCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
30403040
#endif
30413041
GenTreePtr impArrayAccessIntrinsic(CORINFO_CLASS_HANDLE clsHnd,
30423042
CORINFO_SIG_INFO* sig,
@@ -7824,6 +7824,15 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
78247824
#endif
78257825
}
78267826

7827+
bool compSupports(InstructionSet isa)
7828+
{
7829+
#ifdef _TARGET_XARCH_
7830+
return (opts.compSupportsISA & (1 << isa)) != 0;
7831+
#else
7832+
return false;
7833+
#endif
7834+
}
7835+
78277836
/*
78287837
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
78297838
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
@@ -7938,16 +7947,11 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
79387947
#endif // _TARGET_XARCH_
79397948

79407949
#ifdef _TARGET_XARCH_
7941-
// only for Intel hardware intrinsics
79427950
uint64_t compSupportsISA;
79437951
void setSupportedISA(InstructionSet isa)
79447952
{
79457953
compSupportsISA |= 1 << isa;
79467954
}
7947-
bool compSupports(InstructionSet isa)
7948-
{
7949-
return (compSupportsISA & (1 << isa)) != 0;
7950-
}
79517955
#endif
79527956

79537957
// optimize maximally and/or favor speed over size?

src/jit/hwintrinsicxarch.cpp

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -154,225 +154,226 @@ InstructionSet Compiler::isaOfHWIntrinsic(NamedIntrinsic intrinsic)
154154
// Arguments:
155155
// intrinsic -- id of the intrinsic function.
156156
// method -- method handle of the intrinsic function.
157+
// sig -- signature of the intrinsic call
157158
//
158159
// Return Value:
159160
// the expanded intrinsic.
160161
//
161-
GenTree* Compiler::impX86HWIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method)
162+
GenTree* Compiler::impX86HWIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig)
162163
{
163164
InstructionSet isa = isaOfHWIntrinsic(intrinsic);
164165
switch (isa)
165166
{
166167
case InstructionSet_SSE:
167-
return impSSEIntrinsic(intrinsic, method);
168+
return impSSEIntrinsic(intrinsic, method, sig);
168169
case InstructionSet_SSE2:
169-
return impSSE2Intrinsic(intrinsic, method);
170+
return impSSE2Intrinsic(intrinsic, method, sig);
170171
case InstructionSet_SSE3:
171-
return impSSE3Intrinsic(intrinsic, method);
172+
return impSSE3Intrinsic(intrinsic, method, sig);
172173
case InstructionSet_SSSE3:
173-
return impSSSE3Intrinsic(intrinsic, method);
174+
return impSSSE3Intrinsic(intrinsic, method, sig);
174175
case InstructionSet_SSE41:
175-
return impSSE41Intrinsic(intrinsic, method);
176+
return impSSE41Intrinsic(intrinsic, method, sig);
176177
case InstructionSet_SSE42:
177-
return impSSE42Intrinsic(intrinsic, method);
178+
return impSSE42Intrinsic(intrinsic, method, sig);
178179
case InstructionSet_AVX:
179-
return impAVXIntrinsic(intrinsic, method);
180+
return impAVXIntrinsic(intrinsic, method, sig);
180181
case InstructionSet_AVX2:
181-
return impAVX2Intrinsic(intrinsic, method);
182+
return impAVX2Intrinsic(intrinsic, method, sig);
182183

183184
case InstructionSet_AES:
184-
return impAESIntrinsic(intrinsic, method);
185+
return impAESIntrinsic(intrinsic, method, sig);
185186
case InstructionSet_BMI1:
186-
return impBMI1Intrinsic(intrinsic, method);
187+
return impBMI1Intrinsic(intrinsic, method, sig);
187188
case InstructionSet_BMI2:
188-
return impBMI2Intrinsic(intrinsic, method);
189+
return impBMI2Intrinsic(intrinsic, method, sig);
189190
case InstructionSet_FMA:
190-
return impFMAIntrinsic(intrinsic, method);
191+
return impFMAIntrinsic(intrinsic, method, sig);
191192
case InstructionSet_LZCNT:
192-
return impLZCNTIntrinsic(intrinsic, method);
193+
return impLZCNTIntrinsic(intrinsic, method, sig);
193194
case InstructionSet_PCLMULQDQ:
194-
return impPCLMULQDQIntrinsic(intrinsic, method);
195+
return impPCLMULQDQIntrinsic(intrinsic, method, sig);
195196
case InstructionSet_POPCNT:
196-
return impPOPCNTIntrinsic(intrinsic, method);
197+
return impPOPCNTIntrinsic(intrinsic, method, sig);
197198
default:
198199
return nullptr;
199200
}
200201
}
201202

202-
GenTree* Compiler::impSSEIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method)
203+
GenTree* Compiler::impSSEIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig)
203204
{
204205
switch (intrinsic)
205206
{
206207
case NI_SSE_IsSupported:
207-
return gtNewIconNode(opts.compSupports(InstructionSet_SSE));
208+
return gtNewIconNode(compSupports(InstructionSet_SSE));
208209

209210
default:
210211
return nullptr;
211212
}
212213
}
213214

214-
GenTree* Compiler::impSSE2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method)
215+
GenTree* Compiler::impSSE2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig)
215216
{
216217
switch (intrinsic)
217218
{
218219
case NI_SSE2_IsSupported:
219-
return gtNewIconNode(opts.compSupports(InstructionSet_SSE2));
220+
return gtNewIconNode(compSupports(InstructionSet_SSE2));
220221

221222
default:
222223
return nullptr;
223224
}
224225
}
225226

226-
GenTree* Compiler::impSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method)
227+
GenTree* Compiler::impSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig)
227228
{
228229
switch (intrinsic)
229230
{
230231
case NI_SSE3_IsSupported:
231-
return gtNewIconNode(opts.compSupports(InstructionSet_SSE3));
232+
return gtNewIconNode(compSupports(InstructionSet_SSE3));
232233

233234
default:
234235
return nullptr;
235236
}
236237
}
237238

238-
GenTree* Compiler::impSSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method)
239+
GenTree* Compiler::impSSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig)
239240
{
240241
switch (intrinsic)
241242
{
242243
case NI_SSSE3_IsSupported:
243-
return gtNewIconNode(opts.compSupports(InstructionSet_SSSE3));
244+
return gtNewIconNode(compSupports(InstructionSet_SSSE3));
244245

245246
default:
246247
return nullptr;
247248
}
248249
}
249250

250-
GenTree* Compiler::impSSE41Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method)
251+
GenTree* Compiler::impSSE41Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig)
251252
{
252253
switch (intrinsic)
253254
{
254255
case NI_SSE41_IsSupported:
255-
return gtNewIconNode(opts.compSupports(InstructionSet_SSE41));
256+
return gtNewIconNode(compSupports(InstructionSet_SSE41));
256257

257258
default:
258259
return nullptr;
259260
}
260261
}
261262

262-
GenTree* Compiler::impSSE42Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method)
263+
GenTree* Compiler::impSSE42Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig)
263264
{
264265
switch (intrinsic)
265266
{
266267
case NI_SSE42_IsSupported:
267-
return gtNewIconNode(opts.compSupports(InstructionSet_SSE42));
268+
return gtNewIconNode(compSupports(InstructionSet_SSE42));
268269

269270
default:
270271
return nullptr;
271272
}
272273
}
273274

274-
GenTree* Compiler::impAVXIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method)
275+
GenTree* Compiler::impAVXIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig)
275276
{
276277
switch (intrinsic)
277278
{
278279
case NI_AVX_IsSupported:
279-
return gtNewIconNode(opts.compSupports(InstructionSet_AVX));
280+
return gtNewIconNode(compSupports(InstructionSet_AVX));
280281

281282
default:
282283
return nullptr;
283284
}
284285
}
285286

286-
GenTree* Compiler::impAVX2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method)
287+
GenTree* Compiler::impAVX2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig)
287288
{
288289
switch (intrinsic)
289290
{
290291
case NI_AVX2_IsSupported:
291-
return gtNewIconNode(opts.compSupports(InstructionSet_AVX2));
292+
return gtNewIconNode(compSupports(InstructionSet_AVX2));
292293

293294
default:
294295
return nullptr;
295296
}
296297
}
297298

298-
GenTree* Compiler::impAESIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method)
299+
GenTree* Compiler::impAESIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig)
299300
{
300301
switch (intrinsic)
301302
{
302303
case NI_AES_IsSupported:
303-
return gtNewIconNode(opts.compSupports(InstructionSet_AES));
304+
return gtNewIconNode(compSupports(InstructionSet_AES));
304305

305306
default:
306307
return nullptr;
307308
}
308309
}
309310

310-
GenTree* Compiler::impBMI1Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method)
311+
GenTree* Compiler::impBMI1Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig)
311312
{
312313
switch (intrinsic)
313314
{
314315
case NI_BMI1_IsSupported:
315-
return gtNewIconNode(opts.compSupports(InstructionSet_BMI1));
316+
return gtNewIconNode(compSupports(InstructionSet_BMI1));
316317

317318
default:
318319
return nullptr;
319320
}
320321
}
321322

322-
GenTree* Compiler::impBMI2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method)
323+
GenTree* Compiler::impBMI2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig)
323324
{
324325
switch (intrinsic)
325326
{
326327
case NI_BMI2_IsSupported:
327-
return gtNewIconNode(opts.compSupports(InstructionSet_BMI2));
328+
return gtNewIconNode(compSupports(InstructionSet_BMI2));
328329

329330
default:
330331
return nullptr;
331332
}
332333
}
333334

334-
GenTree* Compiler::impFMAIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method)
335+
GenTree* Compiler::impFMAIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig)
335336
{
336337
switch (intrinsic)
337338
{
338339
case NI_FMA_IsSupported:
339-
return gtNewIconNode(opts.compSupports(InstructionSet_FMA));
340+
return gtNewIconNode(compSupports(InstructionSet_FMA));
340341

341342
default:
342343
return nullptr;
343344
}
344345
}
345346

346-
GenTree* Compiler::impLZCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method)
347+
GenTree* Compiler::impLZCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig)
347348
{
348349
switch (intrinsic)
349350
{
350351
case NI_LZCNT_IsSupported:
351-
return gtNewIconNode(opts.compSupports(InstructionSet_LZCNT));
352+
return gtNewIconNode(compSupports(InstructionSet_LZCNT));
352353

353354
default:
354355
return nullptr;
355356
}
356357
}
357358

358-
GenTree* Compiler::impPCLMULQDQIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method)
359+
GenTree* Compiler::impPCLMULQDQIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig)
359360
{
360361
switch (intrinsic)
361362
{
362363
case NI_PCLMULQDQ_IsSupported:
363-
return gtNewIconNode(opts.compSupports(InstructionSet_PCLMULQDQ));
364+
return gtNewIconNode(compSupports(InstructionSet_PCLMULQDQ));
364365

365366
default:
366367
return nullptr;
367368
}
368369
}
369370

370-
GenTree* Compiler::impPOPCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method)
371+
GenTree* Compiler::impPOPCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig)
371372
{
372373
switch (intrinsic)
373374
{
374375
case NI_POPCNT_IsSupported:
375-
return gtNewIconNode(opts.compSupports(InstructionSet_POPCNT));
376+
return gtNewIconNode(compSupports(InstructionSet_POPCNT));
376377

377378
default:
378379
return nullptr;

src/jit/importer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3324,7 +3324,7 @@ GenTreePtr Compiler::impIntrinsic(GenTreePtr newobjThis,
33243324
//
33253325
// We disable the inlining of instrinsics for MinOpts.
33263326
//
3327-
if (!mustExpand && (opts.compDbgCode || opts.MinOpts()))
3327+
if (!mustExpand && (opts.compDbgCode || opts.MinOpts()) && !gtIsRecursiveCall(method))
33283328
{
33293329
*pIntrinsicID = CORINFO_INTRINSIC_Illegal;
33303330
return retNode;
@@ -3738,7 +3738,7 @@ GenTreePtr Compiler::impIntrinsic(GenTreePtr newobjThis,
37383738
#ifdef _TARGET_XARCH_
37393739
if (ni > NI_HW_INTRINSIC_START && ni < NI_HW_INTRINSIC_END)
37403740
{
3741-
retNode = impX86HWIntrinsic(ni, method);
3741+
retNode = impX86HWIntrinsic(ni, method, sig);
37423742
}
37433743
#endif
37443744
switch (ni)

0 commit comments

Comments
 (0)