📄 mmintrin.h
字号:
/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *//* As a special exception, if you include this header file into source files compiled by GCC, this header file does not by itself cause the resulting executable to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU General Public License. *//* Implemented from the specification included in the Intel C++ Compiler User Guide and Reference, version 8.0. */#ifndef _MMINTRIN_H_INCLUDED#define _MMINTRIN_H_INCLUDED#ifndef __MMX__# error "MMX instruction set not enabled"#else/* The data type intended for user use. */typedef int __m64 __attribute__ ((__mode__ (__V2SI__)));/* Internal data types for implementing the intrinsics. */typedef int __v2si __attribute__ ((__mode__ (__V2SI__)));typedef int __v4hi __attribute__ ((__mode__ (__V4HI__)));typedef int __v8qi __attribute__ ((__mode__ (__V8QI__)));/* Empty the multimedia state. */static __inline void_mm_empty (void){ __builtin_ia32_emms ();}static __inline void_m_empty (void){ _mm_empty ();}/* Convert I to a __m64 object. The integer is zero-extended to 64-bits. */static __inline __m64 _mm_cvtsi32_si64 (int __i){ long long __tmp = (unsigned int)__i; return (__m64) __tmp;}static __inline __m64 _m_from_int (int __i){ return _mm_cvtsi32_si64 (__i);}#ifdef __x86_64__/* Convert I to a __m64 object. */static __inline __m64 _mm_cvtsi64x_si64 (long long __i){ return (__m64) __i;}/* Convert I to a __m64 object. */static __inline __m64 _mm_set_pi64x (long long __i){ return (__m64) __i;}#endif/* Convert the lower 32 bits of the __m64 object into an integer. */static __inline int_mm_cvtsi64_si32 (__m64 __i){ long long __tmp = (long long)__i; return __tmp;}static __inline int_m_to_int (__m64 __i){ return _mm_cvtsi64_si32 (__i);}#ifdef __x86_64__/* Convert the lower 32 bits of the __m64 object into an integer. */static __inline long long_mm_cvtsi64_si64x (__m64 __i){ return (long long)__i;}#endif/* Pack the four 16-bit values from M1 into the lower four 8-bit values of the result, and the four 16-bit values from M2 into the upper four 8-bit values of the result, all with signed saturation. */static __inline __m64_mm_packs_pi16 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_packsswb ((__v4hi)__m1, (__v4hi)__m2);}static __inline __m64_m_packsswb (__m64 __m1, __m64 __m2){ return _mm_packs_pi16 (__m1, __m2);}/* Pack the two 32-bit values from M1 in to the lower two 16-bit values of the result, and the two 32-bit values from M2 into the upper two 16-bit values of the result, all with signed saturation. */static __inline __m64_mm_packs_pi32 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_packssdw ((__v2si)__m1, (__v2si)__m2);}static __inline __m64_m_packssdw (__m64 __m1, __m64 __m2){ return _mm_packs_pi32 (__m1, __m2);}/* Pack the four 16-bit values from M1 into the lower four 8-bit values of the result, and the four 16-bit values from M2 into the upper four 8-bit values of the result, all with unsigned saturation. */static __inline __m64_mm_packs_pu16 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_packuswb ((__v4hi)__m1, (__v4hi)__m2);}static __inline __m64_m_packuswb (__m64 __m1, __m64 __m2){ return _mm_packs_pu16 (__m1, __m2);}/* Interleave the four 8-bit values from the high half of M1 with the four 8-bit values from the high half of M2. */static __inline __m64_mm_unpackhi_pi8 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_punpckhbw ((__v8qi)__m1, (__v8qi)__m2);}static __inline __m64_m_punpckhbw (__m64 __m1, __m64 __m2){ return _mm_unpackhi_pi8 (__m1, __m2);}/* Interleave the two 16-bit values from the high half of M1 with the two 16-bit values from the high half of M2. */static __inline __m64_mm_unpackhi_pi16 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_punpckhwd ((__v4hi)__m1, (__v4hi)__m2);}static __inline __m64_m_punpckhwd (__m64 __m1, __m64 __m2){ return _mm_unpackhi_pi16 (__m1, __m2);}/* Interleave the 32-bit value from the high half of M1 with the 32-bit value from the high half of M2. */static __inline __m64_mm_unpackhi_pi32 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_punpckhdq ((__v2si)__m1, (__v2si)__m2);}static __inline __m64_m_punpckhdq (__m64 __m1, __m64 __m2){ return _mm_unpackhi_pi32 (__m1, __m2);}/* Interleave the four 8-bit values from the low half of M1 with the four 8-bit values from the low half of M2. */static __inline __m64_mm_unpacklo_pi8 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_punpcklbw ((__v8qi)__m1, (__v8qi)__m2);}static __inline __m64_m_punpcklbw (__m64 __m1, __m64 __m2){ return _mm_unpacklo_pi8 (__m1, __m2);}/* Interleave the two 16-bit values from the low half of M1 with the two 16-bit values from the low half of M2. */static __inline __m64_mm_unpacklo_pi16 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_punpcklwd ((__v4hi)__m1, (__v4hi)__m2);}static __inline __m64_m_punpcklwd (__m64 __m1, __m64 __m2){ return _mm_unpacklo_pi16 (__m1, __m2);}/* Interleave the 32-bit value from the low half of M1 with the 32-bit value from the low half of M2. */static __inline __m64_mm_unpacklo_pi32 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_punpckldq ((__v2si)__m1, (__v2si)__m2);}static __inline __m64_m_punpckldq (__m64 __m1, __m64 __m2){ return _mm_unpacklo_pi32 (__m1, __m2);}/* Add the 8-bit values in M1 to the 8-bit values in M2. */static __inline __m64_mm_add_pi8 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_paddb ((__v8qi)__m1, (__v8qi)__m2);}static __inline __m64_m_paddb (__m64 __m1, __m64 __m2){ return _mm_add_pi8 (__m1, __m2);}/* Add the 16-bit values in M1 to the 16-bit values in M2. */static __inline __m64_mm_add_pi16 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_paddw ((__v4hi)__m1, (__v4hi)__m2);}static __inline __m64_m_paddw (__m64 __m1, __m64 __m2){ return _mm_add_pi16 (__m1, __m2);}/* Add the 32-bit values in M1 to the 32-bit values in M2. */static __inline __m64_mm_add_pi32 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_paddd ((__v2si)__m1, (__v2si)__m2);}static __inline __m64_m_paddd (__m64 __m1, __m64 __m2){ return _mm_add_pi32 (__m1, __m2);}/* Add the 64-bit values in M1 to the 64-bit values in M2. */static __inline __m64_mm_add_si64 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_paddq ((long long)__m1, (long long)__m2);}/* Add the 8-bit values in M1 to the 8-bit values in M2 using signed saturated arithmetic. */static __inline __m64_mm_adds_pi8 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_paddsb ((__v8qi)__m1, (__v8qi)__m2);}static __inline __m64_m_paddsb (__m64 __m1, __m64 __m2){ return _mm_adds_pi8 (__m1, __m2);}/* Add the 16-bit values in M1 to the 16-bit values in M2 using signed saturated arithmetic. */static __inline __m64_mm_adds_pi16 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_paddsw ((__v4hi)__m1, (__v4hi)__m2);}static __inline __m64_m_paddsw (__m64 __m1, __m64 __m2){ return _mm_adds_pi16 (__m1, __m2);}/* Add the 8-bit values in M1 to the 8-bit values in M2 using unsigned saturated arithmetic. */static __inline __m64_mm_adds_pu8 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_paddusb ((__v8qi)__m1, (__v8qi)__m2);}static __inline __m64_m_paddusb (__m64 __m1, __m64 __m2){ return _mm_adds_pu8 (__m1, __m2);}/* Add the 16-bit values in M1 to the 16-bit values in M2 using unsigned saturated arithmetic. */static __inline __m64_mm_adds_pu16 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_paddusw ((__v4hi)__m1, (__v4hi)__m2);}static __inline __m64_m_paddusw (__m64 __m1, __m64 __m2){ return _mm_adds_pu16 (__m1, __m2);}/* Subtract the 8-bit values in M2 from the 8-bit values in M1. */static __inline __m64_mm_sub_pi8 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_psubb ((__v8qi)__m1, (__v8qi)__m2);}static __inline __m64_m_psubb (__m64 __m1, __m64 __m2){ return _mm_sub_pi8 (__m1, __m2);}/* Subtract the 16-bit values in M2 from the 16-bit values in M1. */static __inline __m64_mm_sub_pi16 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_psubw ((__v4hi)__m1, (__v4hi)__m2);}static __inline __m64_m_psubw (__m64 __m1, __m64 __m2){ return _mm_sub_pi16 (__m1, __m2);}/* Subtract the 32-bit values in M2 from the 32-bit values in M1. */static __inline __m64_mm_sub_pi32 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_psubd ((__v2si)__m1, (__v2si)__m2);}static __inline __m64_m_psubd (__m64 __m1, __m64 __m2){ return _mm_sub_pi32 (__m1, __m2);}/* Add the 64-bit values in M1 to the 64-bit values in M2. */static __inline __m64_mm_sub_si64 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_psubq ((long long)__m1, (long long)__m2);}/* Subtract the 8-bit values in M2 from the 8-bit values in M1 using signed saturating arithmetic. */static __inline __m64_mm_subs_pi8 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_psubsb ((__v8qi)__m1, (__v8qi)__m2);}static __inline __m64_m_psubsb (__m64 __m1, __m64 __m2){ return _mm_subs_pi8 (__m1, __m2);}/* Subtract the 16-bit values in M2 from the 16-bit values in M1 using signed saturating arithmetic. */static __inline __m64_mm_subs_pi16 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_psubsw ((__v4hi)__m1, (__v4hi)__m2);}static __inline __m64_m_psubsw (__m64 __m1, __m64 __m2){ return _mm_subs_pi16 (__m1, __m2);}/* Subtract the 8-bit values in M2 from the 8-bit values in M1 using unsigned saturating arithmetic. */static __inline __m64_mm_subs_pu8 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_psubusb ((__v8qi)__m1, (__v8qi)__m2);}static __inline __m64_m_psubusb (__m64 __m1, __m64 __m2){ return _mm_subs_pu8 (__m1, __m2);}/* Subtract the 16-bit values in M2 from the 16-bit values in M1 using unsigned saturating arithmetic. */static __inline __m64_mm_subs_pu16 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_psubusw ((__v4hi)__m1, (__v4hi)__m2);}static __inline __m64_m_psubusw (__m64 __m1, __m64 __m2){ return _mm_subs_pu16 (__m1, __m2);}/* Multiply four 16-bit values in M1 by four 16-bit values in M2 producing four 32-bit intermediate results, which are then summed by pairs to produce two 32-bit results. */static __inline __m64_mm_madd_pi16 (__m64 __m1, __m64 __m2){ return (__m64) __builtin_ia32_pmaddwd ((__v4hi)__m1, (__v4hi)__m2);}static __inline __m64_m_pmaddwd (__m64 __m1, __m64 __m2){ return _mm_madd_pi16 (__m1, __m2);}/* Multiply four signed 16-bit values in M1 by four signed 16-bit values in M2 and produce the high 16 bits of the 32-bit results. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -