Re: [Mingw-w64-public] [PATCH] intrin-impl.h: Added __popcnt16, __popcnt, and __popcnt64.
Hey guys, > Thanks, but I'd be more interested in documentation how to get cross > compilation setup with clang + mingw-w64. I did one in the past, but it > required patching clang and llvm and working around misc problems I > don't quite remember in details. > I haven't tried but I doubt it will be smooth. All patches for achieving this is currently being upstreamed and reviewed. http://lists.llvm.org/pipermail/llvm-dev/2017-February/110097.html There will be instructions on how to do this and the unofficial llvm mingw-w64 build bot will be switched over to this soon. Just bare with me for a week or so to get everything reviewed and in tree. Best, Martell On Fri, Feb 17, 2017 at 12:22 PM, Mateusz Mikuławrote: > Hello Jacek, > > > Thanks for testing. Sadly, I found that the patch wasn't correct. Could > you please try the attached one? > > New patch is also fine. > > > Thanks, but I'd be more interested in documentation how to get cross > compilation setup with clang + mingw-w64. I did one in the past, but it > required patching clang and llvm and working around misc problems I > don't quite remember in details. > > I haven't tried but I doubt it will be smooth. > > 2017-02-17 12:55 GMT+01:00 Jacek Caban : > > > Hi Mateusz, > > > > On 17.02.2017 00:06, Mateusz Mikuła wrote: > > > Hello Jacek, > > > > > > With this patch clang builds example code from first message with and > > > without `-fms-extensions`. > > > > Thanks for testing. Sadly, I found that the patch wasn't correct. Could > > you please try the attached one? > > > > > I can provide prebuild clang-svn pacakge for msys2. > > > > Thanks, but I'd be more interested in documentation how to get cross > > compilation setup with clang + mingw-w64. I did one in the past, but it > > required patching clang and llvm and working around misc problems I > > don't quite remember in details. > > > > Jacek > > > > > > -- > > Check out the vibrant tech community on one of the world's most > > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > > ___ > > Mingw-w64-public mailing list > > Mingw-w64-public@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public > > > > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > ___ > Mingw-w64-public mailing list > Mingw-w64-public@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public > -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] [PATCH] intrin-impl.h: Guard all intrins definitions by __has_builtin.
Patch is ok. Thanks, please apply. Kai 2017-02-17 13:25 GMT+01:00 Jacek Caban: > Please review. > > --- > mingw-w64-headers/include/psdk_inc/intrin-impl.h | 230 > ++- > 1 file changed, 226 insertions(+), 4 deletions(-) > > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > ___ > Mingw-w64-public mailing list > Mingw-w64-public@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public > -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] [PATCH] intrin-impl.h: Guard all intrins definitions by __has_builtin.
If the compiler has a builtin for the intrinsic, why would mingw-w64 still provide a prototype for it? It seems like it would have no benefit and be likely to just cause compiler errors in the future. --David On Fri, Feb 17, 2017 at 4:25 AM, Jacek Cabanwrote: > Please review. > > --- > mingw-w64-headers/include/psdk_inc/intrin-impl.h | 230 > ++- > 1 file changed, 226 insertions(+), 4 deletions(-) > > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > ___ > Mingw-w64-public mailing list > Mingw-w64-public@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public > -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
[Mingw-w64-public] [PATCH] intrin-impl.h: Guard all intrins definitions by __has_builtin.
Please review. --- mingw-w64-headers/include/psdk_inc/intrin-impl.h | 230 ++- 1 file changed, 226 insertions(+), 4 deletions(-) diff --git a/mingw-w64-headers/include/psdk_inc/intrin-impl.h b/mingw-w64-headers/include/psdk_inc/intrin-impl.h index fc781ff..c6b98f6 100644 --- a/mingw-w64-headers/include/psdk_inc/intrin-impl.h +++ b/mingw-w64-headers/include/psdk_inc/intrin-impl.h @@ -550,21 +550,25 @@ extern "C" { #if __INTRINSIC_PROLOG(_lrotl) unsigned long _lrotl(unsigned long __X, int __C); +#if !__has_builtin(_lrotl) __INTRINSICS_USEINLINE unsigned long _lrotl(unsigned long __X, int __C) { return (__X << __C) | (__X >> ((sizeof(long) * 8) - __C)); } +#endif #define __INTRINSIC_DEFINED__lrotl #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(_lrotr) unsigned long _lrotr(unsigned long __X, int __C); +#if !__has_builtin(_lrotr) __INTRINSICS_USEINLINE unsigned long _lrotr(unsigned long __X, int __C) { return (__X >> __C) | (__X << ((sizeof(long) * 8) - __C)); } +#endif #define __INTRINSIC_DEFINED__lrotr #endif /* __INTRINSIC_PROLOG */ @@ -572,291 +576,370 @@ unsigned long _lrotr(unsigned long __X, int __C) #if __INTRINSIC_PROLOG(__faststorefence) void __faststorefence(void); +#if !__has_builtin(__faststorefence) __INTRINSICS_USEINLINE void __faststorefence(void) { /* Turns out this is actually faster than MS's "trick" on newer cpus. Note that this builtin performs an implicit ReadWriteBarrier. */ __builtin_ia32_sfence(); } +#endif #define __INTRINSIC_DEFINED___faststorefence #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(__stosq) __MINGW_EXTENSION void __stosq(unsigned __int64 *, unsigned __int64, size_t); +#if !__has_builtin(__stosq) __INTRINSICS_USEINLINE __buildstos(__stosq, unsigned __int64, "q|q") +#endif #define __INTRINSIC_DEFINED___stosq #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(_interlockedbittestandset64) __MINGW_EXTENSION unsigned char _interlockedbittestandset64(__int64 *a, __int64 b); +#if !__has_builtin(_interlockedbittestandset64) __INTRINSICS_USEINLINE __buildbittesti(_interlockedbittestandset64, __int64, "lock bts{q %[Offset],%[Base] | %[Base],%[Offset]}" __FLAGSET, "J", __int64) +#endif #define __INTRINSIC_DEFINED__interlockedbittestandset64 #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(_interlockedbittestandreset64) __MINGW_EXTENSION unsigned char _interlockedbittestandreset64(__int64 *a, __int64 b); +#if !__has_builtin(_interlockedbittestandreset64) __INTRINSICS_USEINLINE __buildbittesti(_interlockedbittestandreset64, __int64, "lock btr{q %[Offset],%[Base] | %[Base],%[Offset]}" __FLAGSET, "J", __int64) +#endif #define __INTRINSIC_DEFINED__interlockedbittestandreset64 #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(_interlockedbittestandcomplement64) __MINGW_EXTENSION unsigned char _interlockedbittestandcomplement64(__int64 *a, __int64 b); +#if !__has_builtin(_interlockedbittestandcomplement64) __INTRINSICS_USEINLINE __buildbittesti(_interlockedbittestandcomplement64, __int64, "lock btc{q %[Offset],%[Base] | %[Base],%[Offset]}" __FLAGSET, "J", __int64) +#endif #define __INTRINSIC_DEFINED__interlockedbittestandcomplement64 #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(InterlockedBitTestAndSet64) __MINGW_EXTENSION unsigned char InterlockedBitTestAndSet64(volatile __int64 *a, __int64 b); +#if !__has_builtin(InterlockedBitTestAndSet64) __INTRINSICS_USEINLINE __buildbittesti(InterlockedBitTestAndSet64, volatile __int64, "lock bts{q %[Offset],%[Base] | %[Base],%[Offset]}" __FLAGSET, "J", __int64) +#endif #define __INTRINSIC_DEFINED_InterlockedBitTestAndSet64 #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(InterlockedBitTestAndReset64) __MINGW_EXTENSION unsigned char InterlockedBitTestAndReset64(volatile __int64 *a, __int64 b); +#if !__has_builtin(InterlockedBitTestAndReset64) __INTRINSICS_USEINLINE __buildbittesti(InterlockedBitTestAndReset64, volatile __int64, "lock btr{q %[Offset],%[Base] | %[Base],%[Offset]}" __FLAGSET, "J", __int64) +#endif #define __INTRINSIC_DEFINED_InterlockedBitTestAndReset64 #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(InterlockedBitTestAndComplement64) __MINGW_EXTENSION unsigned char InterlockedBitTestAndComplement64(volatile __int64 *a, __int64 b); +#if !__has_builtin(InterlockedBitTestAndComplement64) __INTRINSICS_USEINLINE __buildbittesti(InterlockedBitTestAndComplement64, volatile __int64, "lock btc{q %[Offset],%[Base] | %[Base],%[Offset]}" __FLAGSET, "J", __int64) +#endif #define __INTRINSIC_DEFINED_InterlockedBitTestAndComplement64 #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(_InterlockedAnd64) __MINGW_EXTENSION __int64 _InterlockedAnd64(__int64 volatile *, __int64); +#if !__has_builtin(_InterlockedAnd64) __INTRINSICS_USEINLINE __buildlogicali(_InterlockedAnd64, __int64, and) +#endif #define __INTRINSIC_DEFINED__InterlockedAnd64 #endif /*
Re: [Mingw-w64-public] [PATCH] intrin-impl.h: Added __popcnt16, __popcnt, and __popcnt64.
Hello Jacek, > Thanks for testing. Sadly, I found that the patch wasn't correct. Could you please try the attached one? New patch is also fine. > Thanks, but I'd be more interested in documentation how to get cross compilation setup with clang + mingw-w64. I did one in the past, but it required patching clang and llvm and working around misc problems I don't quite remember in details. I haven't tried but I doubt it will be smooth. 2017-02-17 12:55 GMT+01:00 Jacek Caban: > Hi Mateusz, > > On 17.02.2017 00:06, Mateusz Mikuła wrote: > > Hello Jacek, > > > > With this patch clang builds example code from first message with and > > without `-fms-extensions`. > > Thanks for testing. Sadly, I found that the patch wasn't correct. Could > you please try the attached one? > > > I can provide prebuild clang-svn pacakge for msys2. > > Thanks, but I'd be more interested in documentation how to get cross > compilation setup with clang + mingw-w64. I did one in the past, but it > required patching clang and llvm and working around misc problems I > don't quite remember in details. > > Jacek > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > ___ > Mingw-w64-public mailing list > Mingw-w64-public@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public > > -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] [PATCH] intrin-impl.h: Added __popcnt16, __popcnt, and __popcnt64.
Hi Mateusz, On 17.02.2017 00:06, Mateusz Mikuła wrote: > Hello Jacek, > > With this patch clang builds example code from first message with and > without `-fms-extensions`. Thanks for testing. Sadly, I found that the patch wasn't correct. Could you please try the attached one? > I can provide prebuild clang-svn pacakge for msys2. Thanks, but I'd be more interested in documentation how to get cross compilation setup with clang + mingw-w64. I did one in the past, but it required patching clang and llvm and working around misc problems I don't quite remember in details. Jacek commit 68c803328439f119198b8dc64814b03e3c3aadef Author: Jacek CabanDate: Fri Feb 17 12:46:44 2017 +0100 intrin-impl.h: Guard all intrins definitions by __has_builtin. diff --git a/mingw-w64-headers/include/psdk_inc/intrin-impl.h b/mingw-w64-headers/include/psdk_inc/intrin-impl.h index fc781ff..c6b98f6 100644 --- a/mingw-w64-headers/include/psdk_inc/intrin-impl.h +++ b/mingw-w64-headers/include/psdk_inc/intrin-impl.h @@ -550,21 +550,25 @@ extern "C" { #if __INTRINSIC_PROLOG(_lrotl) unsigned long _lrotl(unsigned long __X, int __C); +#if !__has_builtin(_lrotl) __INTRINSICS_USEINLINE unsigned long _lrotl(unsigned long __X, int __C) { return (__X << __C) | (__X >> ((sizeof(long) * 8) - __C)); } +#endif #define __INTRINSIC_DEFINED__lrotl #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(_lrotr) unsigned long _lrotr(unsigned long __X, int __C); +#if !__has_builtin(_lrotr) __INTRINSICS_USEINLINE unsigned long _lrotr(unsigned long __X, int __C) { return (__X >> __C) | (__X << ((sizeof(long) * 8) - __C)); } +#endif #define __INTRINSIC_DEFINED__lrotr #endif /* __INTRINSIC_PROLOG */ @@ -572,291 +576,370 @@ unsigned long _lrotr(unsigned long __X, int __C) #if __INTRINSIC_PROLOG(__faststorefence) void __faststorefence(void); +#if !__has_builtin(__faststorefence) __INTRINSICS_USEINLINE void __faststorefence(void) { /* Turns out this is actually faster than MS's "trick" on newer cpus. Note that this builtin performs an implicit ReadWriteBarrier. */ __builtin_ia32_sfence(); } +#endif #define __INTRINSIC_DEFINED___faststorefence #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(__stosq) __MINGW_EXTENSION void __stosq(unsigned __int64 *, unsigned __int64, size_t); +#if !__has_builtin(__stosq) __INTRINSICS_USEINLINE __buildstos(__stosq, unsigned __int64, "q|q") +#endif #define __INTRINSIC_DEFINED___stosq #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(_interlockedbittestandset64) __MINGW_EXTENSION unsigned char _interlockedbittestandset64(__int64 *a, __int64 b); +#if !__has_builtin(_interlockedbittestandset64) __INTRINSICS_USEINLINE __buildbittesti(_interlockedbittestandset64, __int64, "lock bts{q %[Offset],%[Base] | %[Base],%[Offset]}" __FLAGSET, "J", __int64) +#endif #define __INTRINSIC_DEFINED__interlockedbittestandset64 #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(_interlockedbittestandreset64) __MINGW_EXTENSION unsigned char _interlockedbittestandreset64(__int64 *a, __int64 b); +#if !__has_builtin(_interlockedbittestandreset64) __INTRINSICS_USEINLINE __buildbittesti(_interlockedbittestandreset64, __int64, "lock btr{q %[Offset],%[Base] | %[Base],%[Offset]}" __FLAGSET, "J", __int64) +#endif #define __INTRINSIC_DEFINED__interlockedbittestandreset64 #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(_interlockedbittestandcomplement64) __MINGW_EXTENSION unsigned char _interlockedbittestandcomplement64(__int64 *a, __int64 b); +#if !__has_builtin(_interlockedbittestandcomplement64) __INTRINSICS_USEINLINE __buildbittesti(_interlockedbittestandcomplement64, __int64, "lock btc{q %[Offset],%[Base] | %[Base],%[Offset]}" __FLAGSET, "J", __int64) +#endif #define __INTRINSIC_DEFINED__interlockedbittestandcomplement64 #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(InterlockedBitTestAndSet64) __MINGW_EXTENSION unsigned char InterlockedBitTestAndSet64(volatile __int64 *a, __int64 b); +#if !__has_builtin(InterlockedBitTestAndSet64) __INTRINSICS_USEINLINE __buildbittesti(InterlockedBitTestAndSet64, volatile __int64, "lock bts{q %[Offset],%[Base] | %[Base],%[Offset]}" __FLAGSET, "J", __int64) +#endif #define __INTRINSIC_DEFINED_InterlockedBitTestAndSet64 #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(InterlockedBitTestAndReset64) __MINGW_EXTENSION unsigned char InterlockedBitTestAndReset64(volatile __int64 *a, __int64 b); +#if !__has_builtin(InterlockedBitTestAndReset64) __INTRINSICS_USEINLINE __buildbittesti(InterlockedBitTestAndReset64, volatile __int64, "lock btr{q %[Offset],%[Base] | %[Base],%[Offset]}" __FLAGSET, "J", __int64) +#endif #define __INTRINSIC_DEFINED_InterlockedBitTestAndReset64 #endif /* __INTRINSIC_PROLOG */ #if __INTRINSIC_PROLOG(InterlockedBitTestAndComplement64) __MINGW_EXTENSION unsigned char InterlockedBitTestAndComplement64(volatile __int64
Re: [Mingw-w64-public] sqrt.patch from bug #567
On 02/17/2017 10:39 AM, Mateusz wrote: > And version 2 proposed by Kai Tietz. > > W dniu 2017-02-17 o 10:10, Mateusz pisze: >> Hi! >> >> There are lots of complaint about sqrt -- see bug #567. Martin Whitaker >> prepared a patch which I converted to git form for easy apply. >> >> Please review. > > > Applied Kai's to master and v5.x. I assume Kai approved the original before working on the new proposed version. signature.asc Description: OpenPGP digital signature -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] sqrt.patch from bug #567
And version 2 proposed by Kai Tietz. W dniu 2017-02-17 o 10:10, Mateusz pisze: > Hi! > > There are lots of complaint about sqrt -- see bug #567. Martin Whitaker > prepared a patch which I converted to git form for easy apply. > > Please review. diff --git a/mingw-w64-crt/math/sqrt.def.h b/mingw-w64-crt/math/sqrt.def.h index 602409a..0cd401d 100644 --- a/mingw-w64-crt/math/sqrt.def.h +++ b/mingw-w64-crt/math/sqrt.def.h @@ -71,8 +71,15 @@ __FLT_ABI (sqrt) (__FLT_TYPE x) if (x_class == FP_ZERO) return __FLT_CST (-0.0); - __FLT_RPT_DOMAIN ("sqrt", x, 0.0, x); - return x; + if (x_class == FP_NAN) +{ + __FLT_RPT_DOMAIN ("sqrt", x, 0.0, x); + return x; +} + + res = -__FLT_NAN; + __FLT_RPT_DOMAIN ("sqrt", x, 0.0, res); + return res; } else if (x_class == FP_ZERO) return __FLT_CST (0.0); -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
[Mingw-w64-public] sqrt.patch from bug #567
Hi! There are lots of complaint about sqrt -- see bug #567. Martin Whitaker prepared a patch which I converted to git form for easy apply. Please review. diff --git a/mingw-w64-crt/math/sqrt.def.h b/mingw-w64-crt/math/sqrt.def.h index 602409a..b6f5460 100644 --- a/mingw-w64-crt/math/sqrt.def.h +++ b/mingw-w64-crt/math/sqrt.def.h @@ -66,14 +66,20 @@ __FLT_ABI (sqrt) (__FLT_TYPE x) { __FLT_TYPE res = __FLT_CST (0.0); int x_class = fpclassify (x); - if (x_class == FP_NAN || signbit (x)) + if (x_class == FP_NAN) { - if (x_class == FP_ZERO) - return __FLT_CST (-0.0); - __FLT_RPT_DOMAIN ("sqrt", x, 0.0, x); return x; } + else if (signbit (x)) +{ + if (x_class == FP_ZERO) +return __FLT_CST (-0.0); + + res = -__FLT_NAN; + __FLT_RPT_DOMAIN ("sqrt", x, 0.0, res); + return res; +} else if (x_class == FP_ZERO) return __FLT_CST (0.0); else if (x_class == FP_INFINITE) -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public