RKSimon created this revision. RKSimon added reviewers: echristo, mkuper, silvas, craig.topper. RKSimon added a subscriber: cfe-commits. RKSimon set the repository for this revision to rL LLVM.
Follow up to D12272 This adds the missing 3dnow intrinsics _m_to_float / _m_from_float and removes their unnecesary declarations from Intrin.h. These are really just wrappers to existing MMX instructions (they are moved to/from the MMX register as i32 as 3dnow doesn't provide float specific instructions). Final part to resolve PR23648 Repository: rL LLVM http://reviews.llvm.org/D12340 Files: lib/Headers/Intrin.h lib/Headers/mm3dnow.h test/CodeGen/3dnow-builtins.c Index: test/CodeGen/3dnow-builtins.c =================================================================== --- test/CodeGen/3dnow-builtins.c +++ test/CodeGen/3dnow-builtins.c @@ -5,6 +5,18 @@ #include <x86intrin.h> +__m64 test_m_from_float(float f) { + // CHECK-LABEL: define i64 @test_m_from_float + // CHECK: insertelement <2 x i32> + return _m_from_float(f); +} + +float test_m_to_float(__m64 m) { + // CHECK-LABEL: define float @test_m_to_float + // CHECK: extractelement <2 x i32> + return _m_to_float(m); +} + __m64 test_m_pavgusb(__m64 m1, __m64 m2) { // CHECK-LABEL: define i64 @test_m_pavgusb // CHECK: @llvm.x86.3dnow.pavgusb Index: lib/Headers/mm3dnow.h =================================================================== --- lib/Headers/mm3dnow.h +++ lib/Headers/mm3dnow.h @@ -37,6 +37,20 @@ __builtin_ia32_femms(); } +static __inline__ float __DEFAULT_FN_ATTRS +_m_to_float(__m64 __m) { + union { int __i; float __f; } __t; + __t.__i = __builtin_ia32_vec_ext_v2si((__v2si)__m, 0); + return __t.__f; +} + +static __inline__ __m64 __DEFAULT_FN_ATTRS +_m_from_float(float __f) { + union { int __i; float __f; } __t; + __t.__f = __f; + return (__m64)__builtin_ia32_vec_init_v2si(__t.__i, 0); +} + static __inline__ __m64 __DEFAULT_FN_ATTRS _m_pavgusb(__m64 __m1, __m64 __m2) { return (__m64)__builtin_ia32_pavgusb((__v8qi)__m1, (__v8qi)__m2); Index: lib/Headers/Intrin.h =================================================================== --- lib/Headers/Intrin.h +++ lib/Headers/Intrin.h @@ -46,12 +46,6 @@ extern "C" { #endif -#if defined(__MMX__) -/* And the random ones that aren't in those files. */ -__m64 _m_from_float(float); -float _m_to_float(__m64); -#endif - /* Other assorted instruction intrinsics. */ void __addfsbyte(unsigned long, unsigned char); void __addfsdword(unsigned long, unsigned long);
Index: test/CodeGen/3dnow-builtins.c =================================================================== --- test/CodeGen/3dnow-builtins.c +++ test/CodeGen/3dnow-builtins.c @@ -5,6 +5,18 @@ #include <x86intrin.h> +__m64 test_m_from_float(float f) { + // CHECK-LABEL: define i64 @test_m_from_float + // CHECK: insertelement <2 x i32> + return _m_from_float(f); +} + +float test_m_to_float(__m64 m) { + // CHECK-LABEL: define float @test_m_to_float + // CHECK: extractelement <2 x i32> + return _m_to_float(m); +} + __m64 test_m_pavgusb(__m64 m1, __m64 m2) { // CHECK-LABEL: define i64 @test_m_pavgusb // CHECK: @llvm.x86.3dnow.pavgusb Index: lib/Headers/mm3dnow.h =================================================================== --- lib/Headers/mm3dnow.h +++ lib/Headers/mm3dnow.h @@ -37,6 +37,20 @@ __builtin_ia32_femms(); } +static __inline__ float __DEFAULT_FN_ATTRS +_m_to_float(__m64 __m) { + union { int __i; float __f; } __t; + __t.__i = __builtin_ia32_vec_ext_v2si((__v2si)__m, 0); + return __t.__f; +} + +static __inline__ __m64 __DEFAULT_FN_ATTRS +_m_from_float(float __f) { + union { int __i; float __f; } __t; + __t.__f = __f; + return (__m64)__builtin_ia32_vec_init_v2si(__t.__i, 0); +} + static __inline__ __m64 __DEFAULT_FN_ATTRS _m_pavgusb(__m64 __m1, __m64 __m2) { return (__m64)__builtin_ia32_pavgusb((__v8qi)__m1, (__v8qi)__m2); Index: lib/Headers/Intrin.h =================================================================== --- lib/Headers/Intrin.h +++ lib/Headers/Intrin.h @@ -46,12 +46,6 @@ extern "C" { #endif -#if defined(__MMX__) -/* And the random ones that aren't in those files. */ -__m64 _m_from_float(float); -float _m_to_float(__m64); -#endif - /* Other assorted instruction intrinsics. */ void __addfsbyte(unsigned long, unsigned char); void __addfsdword(unsigned long, unsigned long);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits