From: Tim Rowley Date: Thu, 26 May 2016 16:51:48 +0000 (-0600) Subject: swr: [rasterizer common] workaround clang for windows __cpuid() bug X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=95f21a97666d5eb112fffc4d724e54229e06ebf8;p=mesa.git swr: [rasterizer common] workaround clang for windows __cpuid() bug Reviewed-by: Bruce Cherniak --- diff --git a/src/gallium/drivers/swr/rasterizer/common/isa.hpp b/src/gallium/drivers/swr/rasterizer/common/isa.hpp index ef381799bc3..a62350f2b60 100644 --- a/src/gallium/drivers/swr/rasterizer/common/isa.hpp +++ b/src/gallium/drivers/swr/rasterizer/common/isa.hpp @@ -30,7 +30,11 @@ #include #include -#if defined(_WIN32) +// Clang for Windows does supply an intrin.h with __cpuid intrinsics, however... +// It seems to not realize that a write to "b" (ebx) will kill the value in rbx. +// This attempts to use the "native" clang / gcc intrinsics instead of the windows +// compatible ones. +#if defined(_MSC_VER) && !defined(__clang__) #include #else #include @@ -128,7 +132,7 @@ private: // Calling __cpuid with 0x0 as the function_id argument // gets the number of the highest valid function ID. -#if defined(_WIN32) +#if defined(_MSC_VER) && !defined(__clang__) __cpuid(cpui.data(), 0); nIds_ = cpui[0]; #else @@ -137,7 +141,7 @@ private: for (int i = 0; i <= nIds_; ++i) { -#if defined(_WIN32) +#if defined(_MSC_VER) && !defined(__clang__) __cpuidex(cpui.data(), i, 0); #else int *data = cpui.data(); @@ -178,7 +182,7 @@ private: // Calling __cpuid with 0x80000000 as the function_id argument // gets the number of the highest valid extended ID. -#if defined(_WIN32) +#if defined(_MSC_VER) && !defined(__clang__) __cpuid(cpui.data(), 0x80000000); nExIds_ = cpui[0]; #else @@ -190,7 +194,7 @@ private: for (unsigned i = 0x80000000; i <= nExIds_; ++i) { -#if defined(_WIN32) +#if defined(_MSC_VER) && !defined(__clang__) __cpuidex(cpui.data(), i, 0); #else int *data = cpui.data();