1/* Copyright (C) 2004-2015 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 3, 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 Under Section 7 of GPL version 3, you are granted additional 16 permissions described in the GCC Runtime Library Exception, version 17 3.1, as published by the Free Software Foundation. 18 19 You should have received a copy of the GNU General Public License and 20 a copy of the GCC Runtime Library Exception along with this program; 21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 22 <http://www.gnu.org/licenses/>. */ 23 24/* Implemented from the mm3dnow.h (of supposedly AMD origin) included with 25 MSVC 7.1. */ 26 27#ifndef _MM3DNOW_H_INCLUDED 28#define _MM3DNOW_H_INCLUDED 29 30#include <mmintrin.h> 31#include <prfchwintrin.h> 32 33#ifndef __3dNOW__ 34#pragma GCC push_options 35#pragma GCC target("3dnow") 36#define __DISABLE_3dNOW__ 37#endif /* __3dNOW__ */ 38 39extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 40_m_femms (void) 41{ 42 __builtin_ia32_femms(); 43} 44 45extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 46_m_pavgusb (__m64 __A, __m64 __B) 47{ 48 return (__m64)__builtin_ia32_pavgusb ((__v8qi)__A, (__v8qi)__B); 49} 50 51extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 52_m_pf2id (__m64 __A) 53{ 54 return (__m64)__builtin_ia32_pf2id ((__v2sf)__A); 55} 56 57extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 58_m_pfacc (__m64 __A, __m64 __B) 59{ 60 return (__m64)__builtin_ia32_pfacc ((__v2sf)__A, (__v2sf)__B); 61} 62 63extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 64_m_pfadd (__m64 __A, __m64 __B) 65{ 66 return (__m64)__builtin_ia32_pfadd ((__v2sf)__A, (__v2sf)__B); 67} 68 69extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 70_m_pfcmpeq (__m64 __A, __m64 __B) 71{ 72 return (__m64)__builtin_ia32_pfcmpeq ((__v2sf)__A, (__v2sf)__B); 73} 74 75extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 76_m_pfcmpge (__m64 __A, __m64 __B) 77{ 78 return (__m64)__builtin_ia32_pfcmpge ((__v2sf)__A, (__v2sf)__B); 79} 80 81extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 82_m_pfcmpgt (__m64 __A, __m64 __B) 83{ 84 return (__m64)__builtin_ia32_pfcmpgt ((__v2sf)__A, (__v2sf)__B); 85} 86 87extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 88_m_pfmax (__m64 __A, __m64 __B) 89{ 90 return (__m64)__builtin_ia32_pfmax ((__v2sf)__A, (__v2sf)__B); 91} 92 93extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 94_m_pfmin (__m64 __A, __m64 __B) 95{ 96 return (__m64)__builtin_ia32_pfmin ((__v2sf)__A, (__v2sf)__B); 97} 98 99extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 100_m_pfmul (__m64 __A, __m64 __B) 101{ 102 return (__m64)__builtin_ia32_pfmul ((__v2sf)__A, (__v2sf)__B); 103} 104 105extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 106_m_pfrcp (__m64 __A) 107{ 108 return (__m64)__builtin_ia32_pfrcp ((__v2sf)__A); 109} 110 111extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 112_m_pfrcpit1 (__m64 __A, __m64 __B) 113{ 114 return (__m64)__builtin_ia32_pfrcpit1 ((__v2sf)__A, (__v2sf)__B); 115} 116 117extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 118_m_pfrcpit2 (__m64 __A, __m64 __B) 119{ 120 return (__m64)__builtin_ia32_pfrcpit2 ((__v2sf)__A, (__v2sf)__B); 121} 122 123extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 124_m_pfrsqrt (__m64 __A) 125{ 126 return (__m64)__builtin_ia32_pfrsqrt ((__v2sf)__A); 127} 128 129extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 130_m_pfrsqit1 (__m64 __A, __m64 __B) 131{ 132 return (__m64)__builtin_ia32_pfrsqit1 ((__v2sf)__A, (__v2sf)__B); 133} 134 135extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 136_m_pfsub (__m64 __A, __m64 __B) 137{ 138 return (__m64)__builtin_ia32_pfsub ((__v2sf)__A, (__v2sf)__B); 139} 140 141extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 142_m_pfsubr (__m64 __A, __m64 __B) 143{ 144 return (__m64)__builtin_ia32_pfsubr ((__v2sf)__A, (__v2sf)__B); 145} 146 147extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 148_m_pi2fd (__m64 __A) 149{ 150 return (__m64)__builtin_ia32_pi2fd ((__v2si)__A); 151} 152 153extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 154_m_pmulhrw (__m64 __A, __m64 __B) 155{ 156 return (__m64)__builtin_ia32_pmulhrw ((__v4hi)__A, (__v4hi)__B); 157} 158 159extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 160_m_prefetch (void *__P) 161{ 162 __builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */); 163} 164 165extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 166_m_from_float (float __A) 167{ 168 return __extension__ (__m64)(__v2sf){ __A, 0.0f }; 169} 170 171extern __inline float __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 172_m_to_float (__m64 __A) 173{ 174 union { __v2sf v; float a[2]; } __tmp; 175 __tmp.v = (__v2sf)__A; 176 return __tmp.a[0]; 177} 178 179#ifdef __3dNOW_A__ 180 181extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 182_m_pf2iw (__m64 __A) 183{ 184 return (__m64)__builtin_ia32_pf2iw ((__v2sf)__A); 185} 186 187extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 188_m_pfnacc (__m64 __A, __m64 __B) 189{ 190 return (__m64)__builtin_ia32_pfnacc ((__v2sf)__A, (__v2sf)__B); 191} 192 193extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 194_m_pfpnacc (__m64 __A, __m64 __B) 195{ 196 return (__m64)__builtin_ia32_pfpnacc ((__v2sf)__A, (__v2sf)__B); 197} 198 199extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 200_m_pi2fw (__m64 __A) 201{ 202 return (__m64)__builtin_ia32_pi2fw ((__v2si)__A); 203} 204 205extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 206_m_pswapd (__m64 __A) 207{ 208 return (__m64)__builtin_ia32_pswapdsf ((__v2sf)__A); 209} 210 211#endif /* __3dNOW_A__ */ 212 213#ifdef __DISABLE_3dNOW__ 214#undef __DISABLE_3dNOW__ 215#pragma GCC pop_options 216#endif /* __DISABLE_3dNOW__ */ 217 218#endif /* _MM3DNOW_H_INCLUDED */ 219