x86emitter: initialize scalar field

CID:147038
This commit is contained in:
Gregory Hainaut 2016-03-28 14:33:21 +02:00
parent de24ce0a8f
commit 37de84d55f
2 changed files with 69 additions and 47 deletions

View File

@ -53,60 +53,62 @@ public:
// x86 CPU Capabilities Section (all boolean flags!)
// ----------------------------------------------------------------------------
u32 hasFloatingPointUnit :1;
u32 hasVirtual8086ModeEnhancements :1;
u32 hasDebuggingExtensions :1;
u32 hasPageSizeExtensions :1;
u32 hasTimeStampCounter :1;
u32 hasModelSpecificRegisters :1;
u32 hasPhysicalAddressExtension :1;
u32 hasCOMPXCHG8BInstruction :1;
u32 hasAdvancedProgrammableInterruptController :1;
u32 hasSEPFastSystemCall :1;
u32 hasMemoryTypeRangeRegisters :1;
u32 hasPTEGlobalFlag :1;
u32 hasMachineCheckArchitecture :1;
u32 hasConditionalMoveAndCompareInstructions :1;
u32 hasFGPageAttributeTable :1;
u32 has36bitPageSizeExtension :1;
u32 hasProcessorSerialNumber :1;
u32 hasCFLUSHInstruction :1;
u32 hasDebugStore :1;
u32 hasACPIThermalMonitorAndClockControl :1;
u32 hasFastStreamingSIMDExtensionsSaveRestore :1;
u32 hasStreamingSIMDExtensions :1;
u32 hasStreamingSIMD2Extensions :1;
u32 hasSelfSnoop :1;
union {
struct {
u32 hasFloatingPointUnit :1;
u32 hasVirtual8086ModeEnhancements :1;
u32 hasDebuggingExtensions :1;
u32 hasPageSizeExtensions :1;
u32 hasTimeStampCounter :1;
u32 hasModelSpecificRegisters :1;
u32 hasPhysicalAddressExtension :1;
u32 hasCOMPXCHG8BInstruction :1;
u32 hasAdvancedProgrammableInterruptController :1;
u32 hasSEPFastSystemCall :1;
u32 hasMemoryTypeRangeRegisters :1;
u32 hasPTEGlobalFlag :1;
u32 hasMachineCheckArchitecture :1;
u32 hasConditionalMoveAndCompareInstructions :1;
u32 hasFGPageAttributeTable :1;
u32 has36bitPageSizeExtension :1;
u32 hasProcessorSerialNumber :1;
u32 hasCFLUSHInstruction :1;
u32 hasDebugStore :1;
u32 hasACPIThermalMonitorAndClockControl :1;
u32 hasFastStreamingSIMDExtensionsSaveRestore :1;
u32 hasStreamingSIMDExtensions :1;
u32 hasStreamingSIMD2Extensions :1;
u32 hasSelfSnoop :1;
// is TRUE for both multi-core and Hyperthreaded CPUs.
u32 hasMultiThreading :1;
// is TRUE for both multi-core and Hyperthreaded CPUs.
u32 hasMultiThreading :1;
u32 hasThermalMonitor :1;
u32 hasIntel64BitArchitecture :1;
u32 hasStreamingSIMD3Extensions :1;
u32 hasSupplementalStreamingSIMD3Extensions :1;
u32 hasStreamingSIMD4Extensions :1;
u32 hasStreamingSIMD4Extensions2 :1;
u32 hasAVX :1;
u32 hasAVX2 :1;
u32 hasBMI1 :1;
u32 hasBMI2 :1;
u32 hasFMA :1;
u32 hasThermalMonitor :1;
u32 hasIntel64BitArchitecture :1;
u32 hasStreamingSIMD3Extensions :1;
u32 hasSupplementalStreamingSIMD3Extensions :1;
u32 hasStreamingSIMD4Extensions :1;
u32 hasStreamingSIMD4Extensions2 :1;
u32 hasAVX :1;
u32 hasAVX2 :1;
u32 hasBMI1 :1;
u32 hasBMI2 :1;
u32 hasFMA :1;
// AMD-specific CPU Features
u32 hasAMD64BitArchitecture :1;
u32 hasStreamingSIMD4ExtensionsA :1;
// AMD-specific CPU Features
u32 hasAMD64BitArchitecture :1;
u32 hasStreamingSIMD4ExtensionsA :1;
};
u32 AllCapabilities;
};
// Core Counts!
u32 PhysicalCores;
u32 LogicalCores;
public:
x86capabilities()
{
isIdentified = false;
VendorID = x86Vendor_Unknown;
}
x86capabilities();
void Identify();
void CountCores();

View File

@ -24,6 +24,26 @@ __aligned16 x86capabilities x86caps;
// Recompiled code buffer for SSE and MXCSR feature testing.
static __pagealigned u8 targetFXSAVE[512];
x86capabilities::x86capabilities() :
isIdentified(false),
VendorID(x86Vendor_Unknown),
FamilyID(0),
Model(0),
TypeID(0),
StepID(0),
Flags(0),
Flags2(0),
EFlags(0),
EFlags2(0),
SEFlag(0),
AllCapabilities(0),
PhysicalCores(0),
LogicalCores(0)
{
memzero(VendorName);
memzero(FamilyName);
}
// Warning! We've had problems with the MXCSR detection code causing stack corruption in
// MSVC PGO builds. The problem was fixed when I moved the MXCSR code to this function, and
// moved the recSSE[] array to a global static (it was local to cpudetectInit). Commented
@ -146,7 +166,7 @@ void x86capabilities::CountCores()
CountLogicalCores();
}
static const char* tbl_x86vendors[] =
static const char* tbl_x86vendors[] =
{
"GenuineIntel",
"AuthenticAMD",
@ -266,7 +286,7 @@ void x86capabilities::Identify()
hasSupplementalStreamingSIMD3Extensions = ( Flags2 >> 9 ) & 1; //ssse3
hasStreamingSIMD4Extensions = ( Flags2 >> 19 ) & 1; //sse4.1
hasStreamingSIMD4Extensions2 = ( Flags2 >> 20 ) & 1; //sse4.2
if((Flags2 >> 27) & 1) // OSXSAVE
{
if((_xgetbv(0) & 6) == 6) // XFEATURE_ENABLED_MASK[2:1] = '11b' (XMM state and YMM state are enabled by OS).