probinson created this revision. probinson added reviewers: craig.topper, RKSimon, pengfei, goldstein.w.n. Herald added a project: All. probinson requested review of this revision.
While looking at adding intrinsic function descriptions, I found some oddities in the conditionals. I've fiddled with some of them. This is not a complete audit. Two headers have been changed to require only immintrin.h and not x86intrin.h; this conforms to which header actually includes them, and with Intel documentation. One function in bmi2intrin.h was defined only in 32-bit mode, for no apparent reason; I fixed that. clzerointrin.h is included from x86intrin.h, so I made it not check for immintrin.h. This is an AMD only instruction so there's no Intel documentation to check against. https://reviews.llvm.org/D153576 Files: clang/lib/Headers/bmi2intrin.h clang/lib/Headers/clzerointrin.h clang/lib/Headers/rdseedintrin.h Index: clang/lib/Headers/rdseedintrin.h =================================================================== --- clang/lib/Headers/rdseedintrin.h +++ clang/lib/Headers/rdseedintrin.h @@ -7,8 +7,8 @@ *===-----------------------------------------------------------------------=== */ -#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H -#error "Never use <rdseedintrin.h> directly; include <x86intrin.h> instead." +#ifndef __IMMINTRIN_H +#error "Never use <rdseedintrin.h> directly; include <immintrin.h> instead." #endif #ifndef __RDSEEDINTRIN_H Index: clang/lib/Headers/clzerointrin.h =================================================================== --- clang/lib/Headers/clzerointrin.h +++ clang/lib/Headers/clzerointrin.h @@ -6,7 +6,7 @@ * *===-----------------------------------------------------------------------=== */ -#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H +#ifndef __X86INTRIN_H #error "Never use <clzerointrin.h> directly; include <x86intrin.h> instead." #endif Index: clang/lib/Headers/bmi2intrin.h =================================================================== --- clang/lib/Headers/bmi2intrin.h +++ clang/lib/Headers/bmi2intrin.h @@ -7,8 +7,8 @@ *===-----------------------------------------------------------------------=== */ -#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H -#error "Never use <bmi2intrin.h> directly; include <x86intrin.h> instead." +#ifndef __IMMINTRIN_H +#error "Never use <bmi2intrin.h> directly; include <immintrin.h> instead." #endif #ifndef __BMI2INTRIN_H @@ -35,6 +35,14 @@ return __builtin_ia32_pext_si(__X, __Y); } +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_mulx_u32(unsigned int __X, unsigned int __Y, unsigned int *__P) +{ + unsigned long long __res = (unsigned long long) __X * __Y; + *__P = (unsigned int)(__res >> 32); + return (unsigned int)__res; +} + #ifdef __x86_64__ static __inline__ unsigned long long __DEFAULT_FN_ATTRS @@ -64,17 +72,7 @@ return (unsigned long long) __res; } -#else /* !__x86_64__ */ - -static __inline__ unsigned int __DEFAULT_FN_ATTRS -_mulx_u32 (unsigned int __X, unsigned int __Y, unsigned int *__P) -{ - unsigned long long __res = (unsigned long long) __X * __Y; - *__P = (unsigned int) (__res >> 32); - return (unsigned int) __res; -} - -#endif /* !__x86_64__ */ +#endif /* __x86_64__ */ #undef __DEFAULT_FN_ATTRS
Index: clang/lib/Headers/rdseedintrin.h =================================================================== --- clang/lib/Headers/rdseedintrin.h +++ clang/lib/Headers/rdseedintrin.h @@ -7,8 +7,8 @@ *===-----------------------------------------------------------------------=== */ -#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H -#error "Never use <rdseedintrin.h> directly; include <x86intrin.h> instead." +#ifndef __IMMINTRIN_H +#error "Never use <rdseedintrin.h> directly; include <immintrin.h> instead." #endif #ifndef __RDSEEDINTRIN_H Index: clang/lib/Headers/clzerointrin.h =================================================================== --- clang/lib/Headers/clzerointrin.h +++ clang/lib/Headers/clzerointrin.h @@ -6,7 +6,7 @@ * *===-----------------------------------------------------------------------=== */ -#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H +#ifndef __X86INTRIN_H #error "Never use <clzerointrin.h> directly; include <x86intrin.h> instead." #endif Index: clang/lib/Headers/bmi2intrin.h =================================================================== --- clang/lib/Headers/bmi2intrin.h +++ clang/lib/Headers/bmi2intrin.h @@ -7,8 +7,8 @@ *===-----------------------------------------------------------------------=== */ -#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H -#error "Never use <bmi2intrin.h> directly; include <x86intrin.h> instead." +#ifndef __IMMINTRIN_H +#error "Never use <bmi2intrin.h> directly; include <immintrin.h> instead." #endif #ifndef __BMI2INTRIN_H @@ -35,6 +35,14 @@ return __builtin_ia32_pext_si(__X, __Y); } +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_mulx_u32(unsigned int __X, unsigned int __Y, unsigned int *__P) +{ + unsigned long long __res = (unsigned long long) __X * __Y; + *__P = (unsigned int)(__res >> 32); + return (unsigned int)__res; +} + #ifdef __x86_64__ static __inline__ unsigned long long __DEFAULT_FN_ATTRS @@ -64,17 +72,7 @@ return (unsigned long long) __res; } -#else /* !__x86_64__ */ - -static __inline__ unsigned int __DEFAULT_FN_ATTRS -_mulx_u32 (unsigned int __X, unsigned int __Y, unsigned int *__P) -{ - unsigned long long __res = (unsigned long long) __X * __Y; - *__P = (unsigned int) (__res >> 32); - return (unsigned int) __res; -} - -#endif /* !__x86_64__ */ +#endif /* __x86_64__ */ #undef __DEFAULT_FN_ATTRS
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits