[llvm-commits] [vector_llvm] CVS: llvm/include/SIMD/SSE.h Scalar.h

Robert Bocchino bocchino at cs.uiuc.edu
Tue Oct 18 12:34:43 PDT 2005



Changes in directory llvm/include/SIMD:

SSE.h added (r1.1.2.1)
Scalar.h added (r1.1.2.1)
---
Log message:

Initial commit of Vector LLVM.


---
Diffs of the changes:  (+56 -0)

 SSE.h    |   41 +++++++++++++++++++++++++++++++++++++++++
 Scalar.h |   15 +++++++++++++++
 2 files changed, 56 insertions(+)


Index: llvm/include/SIMD/SSE.h
diff -c /dev/null llvm/include/SIMD/SSE.h:1.1.2.1
*** /dev/null	Tue Oct 18 14:34:42 2005
--- llvm/include/SIMD/SSE.h	Tue Oct 18 14:34:32 2005
***************
*** 0 ****
--- 1,41 ----
+ #ifndef SSE_H
+ #define SSE_H
+ 
+ #include <emmintrin.h>
+ #include "Scalar.h"
+ 
+ // Some obvious missing SSE intrinsics
+ 
+ #define _mm_splat_epi16(x) _mm_set_epi16(x,x,x,x,x,x,x,x)
+ #define _mm_splat_epi32(x) _mm_set_epi32(x,x,x,x)
+ #define _mm_pack_epi32(a,b) _mm_packs_epi32( _mm_srai_epi32( _mm_slli_epi32( a, 16), 16), \
+   				             _mm_srai_epi32( _mm_slli_epi32( b, 16), 16) )
+ #define _mm_pack_epu32(a,b) _mm_packs_epi32( _mm_srai_epi32( _mm_slli_epi32( a, 16), 16), \
+   				             _mm_srai_epi32( _mm_slli_epi32( b, 16), 16) )
+ #define _mm_pack_epi16(x,y) _mm_packs_epi16( _mm_srai_epi16( _mm_slli_epi16( x, 8), 8), \
+                                              _mm_srai_epi16( _mm_slli_epi16( y, 8), 8) )
+ #define _mm_select_si128(msk, a, b) _mm_or_si128(_mm_and_si128(a, msk), _mm_andnot_si128(msk, b))
+ 
+ 
+ // Printing
+ 
+ inline void print_vector_short(__m128i v) {
+   unsigned i;
+   for (i = 0; i < 8; ++i)
+     printf("%04X ", elt_short(v, i));
+   printf("\n");
+ }
+ 
+ // AltiVec conversions
+ 
+ inline __m128i _mm_mr_epi16(__m128i x, __m128i y) {
+   __m128i c = _mm_splat_epi32(1<<14);
+   __m128i tmp_hi = _mm_mulhi_epi16(x, y);
+   __m128i tmp_lo = _mm_mullo_epi16(x, y);
+   return _mm_pack_epi32(_mm_srai_epi32(_mm_add_epi32(_mm_unpacklo_epi16(tmp_lo, tmp_hi), c), 15),
+ 			_mm_srai_epi32(_mm_add_epi32(_mm_unpackhi_epi16(tmp_lo, tmp_hi), c), 15));
+ }
+ 
+ #define _mm_mradds_epi16(x, y, z) _mm_adds_epi16(_mm_mr_epi16(x,y),z)
+ 
+ #endif


Index: llvm/include/SIMD/Scalar.h
diff -c /dev/null llvm/include/SIMD/Scalar.h:1.1.2.1
*** /dev/null	Tue Oct 18 14:34:43 2005
--- llvm/include/SIMD/Scalar.h	Tue Oct 18 14:34:32 2005
***************
*** 0 ****
--- 1,15 ----
+ #ifndef SCALAR_H
+ #define SCALAR_H
+ 
+ // Scalar versions of common SIMD operations
+ 
+ #define saturate_short(x) (((x) < -32768) ? -32768 : (((x) > 32767) ? 32767 : (x)))
+ #define adds_short(x, y) saturate_short(x+y)
+ #define subs_short(x, y) saturate_short(x-y)
+ #define mradds_short(x, y, z) saturate_short((((x*y) + (1<<14))>>15)+z)
+ 
+ // Access to scalar elements
+ 
+ #define elt_short(vec,i) ((short*) &vec)[i]
+ 
+ #endif






More information about the llvm-commits mailing list