home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / gcc / i486-linux-gnu / 4.3 / include / mmintrin-common.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-03-16  |  5.4 KB  |  159 lines

  1. /* Copyright (C) 2007 Free Software Foundation, Inc.
  2.  
  3.    This file is part of GCC.
  4.  
  5.    GCC is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    GCC is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.    GNU General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with GCC; see the file COPYING.  If not, write to
  17.    the Free Software Foundation, 51 Franklin Street, Fifth Floor,
  18.    Boston, MA 02110-1301, USA.  */
  19.  
  20. /* As a special exception, if you include this header file into source
  21.    files compiled by GCC, this header file does not by itself cause
  22.    the resulting executable to be covered by the GNU General Public
  23.    License.  This exception does not however invalidate any other
  24.    reasons why the executable file might be covered by the GNU General
  25.    Public License.  */
  26.  
  27. /* Common definition of the ROUND and PTEST intrinsics that are shared
  28.    between SSE4.1 and SSE5.  */
  29.  
  30. #ifndef _MMINTRIN_COMMON_H_INCLUDED
  31. #define _MMINTRIN_COMMON_H_INCLUDED
  32.  
  33. #if !defined(__SSE5__) && !defined(__SSE4_1__)
  34. # error "SSE5 or SSE4.1 instruction set not enabled"
  35. #else
  36.  
  37. /* Rounding mode macros. */
  38. #define _MM_FROUND_TO_NEAREST_INT    0x00
  39. #define _MM_FROUND_TO_NEG_INF        0x01
  40. #define _MM_FROUND_TO_POS_INF        0x02
  41. #define _MM_FROUND_TO_ZERO        0x03
  42. #define _MM_FROUND_CUR_DIRECTION    0x04
  43.  
  44. #define _MM_FROUND_RAISE_EXC        0x00
  45. #define _MM_FROUND_NO_EXC        0x08
  46.  
  47. #define _MM_FROUND_NINT        \
  48.   (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_RAISE_EXC)
  49. #define _MM_FROUND_FLOOR    \
  50.   (_MM_FROUND_TO_NEG_INF | _MM_FROUND_RAISE_EXC)
  51. #define _MM_FROUND_CEIL        \
  52.   (_MM_FROUND_TO_POS_INF | _MM_FROUND_RAISE_EXC)
  53. #define _MM_FROUND_TRUNC    \
  54.   (_MM_FROUND_TO_ZERO | _MM_FROUND_RAISE_EXC)
  55. #define _MM_FROUND_RINT        \
  56.   (_MM_FROUND_CUR_DIRECTION | _MM_FROUND_RAISE_EXC)
  57. #define _MM_FROUND_NEARBYINT    \
  58.   (_MM_FROUND_CUR_DIRECTION | _MM_FROUND_NO_EXC)
  59.  
  60. /* Test Instruction */
  61. /* Packed integer 128-bit bitwise comparison. Return 1 if
  62.    (__V & __M) == 0.  */
  63. extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  64. _mm_testz_si128 (__m128i __M, __m128i __V)
  65. {
  66.   return __builtin_ia32_ptestz128 ((__v2di)__M, (__v2di)__V);
  67. }
  68.  
  69. /* Packed integer 128-bit bitwise comparison. Return 1 if
  70.    (__V & ~__M) == 0.  */
  71. extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  72. _mm_testc_si128 (__m128i __M, __m128i __V)
  73. {
  74.   return __builtin_ia32_ptestc128 ((__v2di)__M, (__v2di)__V);
  75. }
  76.  
  77. /* Packed integer 128-bit bitwise comparison. Return 1 if
  78.    (__V & __M) != 0 && (__V & ~__M) != 0.  */
  79. extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  80. _mm_testnzc_si128 (__m128i __M, __m128i __V)
  81. {
  82.   return __builtin_ia32_ptestnzc128 ((__v2di)__M, (__v2di)__V);
  83. }
  84.  
  85. /* Macros for packed integer 128-bit comparison intrinsics.  */
  86. #define _mm_test_all_zeros(M, V) _mm_testz_si128 ((M), (V))
  87.  
  88. #define _mm_test_all_ones(V) \
  89.   _mm_testc_si128 ((V), _mm_cmpeq_epi32 ((V), (V)))
  90.  
  91. #define _mm_test_mix_ones_zeros(M, V) _mm_testnzc_si128 ((M), (V))
  92.  
  93. /* Packed/scalar double precision floating point rounding.  */
  94.  
  95. #ifdef __OPTIMIZE__
  96. extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  97. _mm_round_pd (__m128d __V, const int __M)
  98. {
  99.   return (__m128d) __builtin_ia32_roundpd ((__v2df)__V, __M);
  100. }
  101.  
  102. extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  103. _mm_round_sd(__m128d __D, __m128d __V, const int __M)
  104. {
  105.   return (__m128d) __builtin_ia32_roundsd ((__v2df)__D,
  106.                        (__v2df)__V,
  107.                        __M);
  108. }
  109. #else
  110. #define _mm_round_pd(V, M) \
  111.   ((__m128d) __builtin_ia32_roundpd ((__v2df)(__m128d)(V), (int)(M)))
  112.  
  113. #define _mm_round_sd(D, V, M)                        \
  114.   ((__m128d) __builtin_ia32_roundsd ((__v2df)(__m128d)(D),        \
  115.                      (__v2df)(__m128d)(V), (int)(M)))
  116. #endif
  117.  
  118. /* Packed/scalar single precision floating point rounding.  */
  119.  
  120. #ifdef __OPTIMIZE__
  121. extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  122. _mm_round_ps (__m128 __V, const int __M)
  123. {
  124.   return (__m128) __builtin_ia32_roundps ((__v4sf)__V, __M);
  125. }
  126.  
  127. extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  128. _mm_round_ss (__m128 __D, __m128 __V, const int __M)
  129. {
  130.   return (__m128) __builtin_ia32_roundss ((__v4sf)__D,
  131.                       (__v4sf)__V,
  132.                       __M);
  133. }
  134. #else
  135. #define _mm_round_ps(V, M) \
  136.   ((__m128) __builtin_ia32_roundps ((__v4sf)(__m128)(V), (int)(M)))
  137.  
  138. #define _mm_round_ss(D, V, M)                        \
  139.   ((__m128) __builtin_ia32_roundss ((__v4sf)(__m128)(D),        \
  140.                     (__v4sf)(__m128)(V), (int)(M)))
  141. #endif
  142.  
  143. /* Macros for ceil/floor intrinsics.  */
  144. #define _mm_ceil_pd(V)       _mm_round_pd ((V), _MM_FROUND_CEIL)
  145. #define _mm_ceil_sd(D, V)  _mm_round_sd ((D), (V), _MM_FROUND_CEIL)
  146.  
  147. #define _mm_floor_pd(V)       _mm_round_pd((V), _MM_FROUND_FLOOR)
  148. #define _mm_floor_sd(D, V) _mm_round_sd ((D), (V), _MM_FROUND_FLOOR)
  149.  
  150. #define _mm_ceil_ps(V)       _mm_round_ps ((V), _MM_FROUND_CEIL)
  151. #define _mm_ceil_ss(D, V)  _mm_round_ss ((D), (V), _MM_FROUND_CEIL)
  152.  
  153. #define _mm_floor_ps(V)       _mm_round_ps ((V), _MM_FROUND_FLOOR)
  154. #define _mm_floor_ss(D, V) _mm_round_ss ((D), (V), _MM_FROUND_FLOOR)
  155.  
  156. #endif /* __SSE5__/__SSE4_1__ */
  157.  
  158. #endif /* _MMINTRIN_COMMON_H_INCLUDED */
  159.