1*eca53ba6SRoland Levillain // Copyright 2017 Google LLC 2*eca53ba6SRoland Levillain // 3*eca53ba6SRoland Levillain // Licensed under the Apache License, Version 2.0 (the "License"); 4*eca53ba6SRoland Levillain // you may not use this file except in compliance with the License. 5*eca53ba6SRoland Levillain // You may obtain a copy of the License at 6*eca53ba6SRoland Levillain // 7*eca53ba6SRoland Levillain // http://www.apache.org/licenses/LICENSE-2.0 8*eca53ba6SRoland Levillain // 9*eca53ba6SRoland Levillain // Unless required by applicable law or agreed to in writing, software 10*eca53ba6SRoland Levillain // distributed under the License is distributed on an "AS IS" BASIS, 11*eca53ba6SRoland Levillain // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*eca53ba6SRoland Levillain // See the License for the specific language governing permissions and 13*eca53ba6SRoland Levillain // limitations under the License. 14*eca53ba6SRoland Levillain 15*eca53ba6SRoland Levillain #include "cpu_features_macros.h" 16*eca53ba6SRoland Levillain 17*eca53ba6SRoland Levillain #ifdef CPU_FEATURES_ARCH_X86 18*eca53ba6SRoland Levillain #ifdef CPU_FEATURES_OS_WINDOWS 19*eca53ba6SRoland Levillain 20*eca53ba6SRoland Levillain #include "impl_x86__base_implementation.inl" 21*eca53ba6SRoland Levillain OverrideOsPreserves(OsPreserves * os_preserves)22*eca53ba6SRoland Levillainstatic void OverrideOsPreserves(OsPreserves* os_preserves) { 23*eca53ba6SRoland Levillain (void)os_preserves; 24*eca53ba6SRoland Levillain // No override 25*eca53ba6SRoland Levillain } 26*eca53ba6SRoland Levillain 27*eca53ba6SRoland Levillain #include "internal/windows_utils.h" 28*eca53ba6SRoland Levillain 29*eca53ba6SRoland Levillain #if defined(CPU_FEATURES_MOCK_CPUID_X86) 30*eca53ba6SRoland Levillain extern bool GetWindowsIsProcessorFeaturePresent(DWORD); 31*eca53ba6SRoland Levillain #else // CPU_FEATURES_MOCK_CPUID_X86 GetWindowsIsProcessorFeaturePresent(DWORD ProcessorFeature)32*eca53ba6SRoland Levillainstatic bool GetWindowsIsProcessorFeaturePresent(DWORD ProcessorFeature) { 33*eca53ba6SRoland Levillain return IsProcessorFeaturePresent(ProcessorFeature); 34*eca53ba6SRoland Levillain } 35*eca53ba6SRoland Levillain #endif 36*eca53ba6SRoland Levillain DetectFeaturesFromOs(X86Info * info,X86Features * features)37*eca53ba6SRoland Levillainstatic void DetectFeaturesFromOs(X86Info* info, X86Features* features) { 38*eca53ba6SRoland Levillain // Handling Windows platform through IsProcessorFeaturePresent. 39*eca53ba6SRoland Levillain // https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent 40*eca53ba6SRoland Levillain features->sse = 41*eca53ba6SRoland Levillain GetWindowsIsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE); 42*eca53ba6SRoland Levillain features->sse2 = 43*eca53ba6SRoland Levillain GetWindowsIsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE); 44*eca53ba6SRoland Levillain features->sse3 = 45*eca53ba6SRoland Levillain GetWindowsIsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE); 46*eca53ba6SRoland Levillain features->ssse3 = 47*eca53ba6SRoland Levillain GetWindowsIsProcessorFeaturePresent(PF_SSSE3_INSTRUCTIONS_AVAILABLE); 48*eca53ba6SRoland Levillain features->sse4_1 = 49*eca53ba6SRoland Levillain GetWindowsIsProcessorFeaturePresent(PF_SSE4_1_INSTRUCTIONS_AVAILABLE); 50*eca53ba6SRoland Levillain features->sse4_2 = 51*eca53ba6SRoland Levillain GetWindowsIsProcessorFeaturePresent(PF_SSE4_2_INSTRUCTIONS_AVAILABLE); 52*eca53ba6SRoland Levillain 53*eca53ba6SRoland Levillain // do not bother checking PF_AVX* 54*eca53ba6SRoland Levillain // cause AVX enabled processor will have XCR0 be exposed and this function will be skipped at all 55*eca53ba6SRoland Levillain } 56*eca53ba6SRoland Levillain 57*eca53ba6SRoland Levillain #endif // CPU_FEATURES_OS_WINDOWS 58*eca53ba6SRoland Levillain #endif // CPU_FEATURES_ARCH_X86 59