Skip to content

Commit b8730cf

Browse files
authored
Merge pull request #21354 from BradleyWood/0.51-xr0-aot
(0.51) x86: check xcr0 in AOT compiles
2 parents 84b67a4 + 89b10df commit b8730cf

File tree

3 files changed

+17
-48
lines changed

3 files changed

+17
-48
lines changed

runtime/compiler/env/ProcessorDetection.cpp

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,6 @@
116116
#include <strings.h>
117117
#endif
118118

119-
#if defined(OMR_OS_WINDOWS) && defined(TR_TARGET_X86)
120-
#include <intrin.h>
121-
#elif defined(TR_TARGET_X86)
122-
inline unsigned long long _xgetbv(unsigned int ecx)
123-
{
124-
unsigned int eax, edx;
125-
__asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(ecx));
126-
return ((unsigned long long)edx << 32) | eax;
127-
}
128-
#endif
129-
130119
#if defined(J9ZOS390)
131120
extern "C" bool _isPSWInProblemState(); /* 390 asm stub */
132121
#endif
@@ -345,43 +334,6 @@ TR_J9VM::initializeProcessorType()
345334
OMRProcessorDesc processorDescription = TR::Compiler->target.cpu.getProcessorDescription();
346335
OMRPORT_ACCESS_FROM_OMRPORT(TR::Compiler->omrPortLib);
347336

348-
bool disableAVX = true;
349-
bool disableAVX512 = true;
350-
351-
#if defined(TR_TARGET_X86)
352-
// Check XCRO register for OS support of xmm/ymm/zmm
353-
if (TRUE == omrsysinfo_processor_has_feature(&processorDescription, OMR_FEATURE_X86_OSXSAVE))
354-
{
355-
// '6' = mask for XCR0[2:1]='11b' (XMM state and YMM state are enabled)
356-
disableAVX = ((6 & _xgetbv(0)) != 6);
357-
// 'e6' = (mask for XCR0[7:5]='111b' (Opmask, ZMM_Hi256, Hi16_ZMM) + XCR0[2:1]='11b' (XMM/YMM))
358-
disableAVX512 = ((0xe6 & _xgetbv(0)) != 0xe6);
359-
}
360-
#endif
361-
362-
if (disableAVX)
363-
{
364-
// Unset AVX/AVX2 if not enabled via CR0 or otherwise disabled
365-
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_X86_AVX, FALSE);
366-
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_X86_AVX2, FALSE);
367-
}
368-
369-
if (disableAVX512)
370-
{
371-
// Unset AVX-512 if not enabled via CR0 or otherwise disabled
372-
// If other AVX-512 extensions are supported in the port library, they need to be disabled here
373-
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_X86_AVX512F, FALSE);
374-
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_X86_AVX512VL, FALSE);
375-
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_X86_AVX512BW, FALSE);
376-
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_X86_AVX512CD, FALSE);
377-
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_X86_AVX512DQ, FALSE);
378-
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_X86_AVX512_BITALG, FALSE);
379-
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_X86_AVX512_VBMI, FALSE);
380-
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_X86_AVX512_VBMI2, FALSE);
381-
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_X86_AVX512_VNNI, FALSE);
382-
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_X86_AVX512_VPOPCNTDQ, FALSE);
383-
}
384-
385337
TR::Compiler->target.cpu = TR::CPU::customize(processorDescription);
386338

387339
const char *vendor = TR::Compiler->target.cpu.getProcessorVendorId();

runtime/compiler/x/env/J9CPU.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ J9::X86::CPU::detectRelocatable(OMRPortLibrary * const omrPortLib)
6767
return TR::CPU::customize(portableProcessorDescription);
6868
}
6969

70+
TR::CPU
71+
J9::X86::CPU::detect(OMRPortLibrary * const omrPortLib)
72+
{
73+
if (omrPortLib == NULL)
74+
return TR::CPU();
75+
76+
TR::CPU::enableFeatureMasks();
77+
return OMR::X86::CPU::detect(omrPortLib);
78+
}
79+
7080
void
7181
J9::X86::CPU::enableFeatureMasks()
7282
{

runtime/compiler/x/env/J9CPU.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ class OMR_EXTENSIBLE CPU : public J9::CPU
5959
*/
6060
static TR::CPU detectRelocatable(OMRPortLibrary * const omrPortLib);
6161

62+
/**
63+
* @brief A factory method used to construct a CPU object based on the underlying hardware
64+
* @param[in] omrPortLib : the port library
65+
* @return TR::CPU
66+
*/
67+
static TR::CPU detect(OMRPortLibrary * const omrPortLib);
68+
6269
/**
6370
* @brief Intialize _supportedFeatureMasks to the list of processor features that will be exploited by the compiler and set _isSupportedFeatureMasksEnabled to true
6471
* @return void

0 commit comments

Comments
 (0)