Eric Christopher | d1428bf | 2013-08-31 00:22:48 +0000 | [diff] [blame] | 1 | /* ===-------- Intrin.h ---------------------------------------------------=== |
| 2 | * |
| 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 4 | * of this software and associated documentation files (the "Software"), to deal |
| 5 | * in the Software without restriction, including without limitation the rights |
| 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 7 | * copies of the Software, and to permit persons to whom the Software is |
| 8 | * furnished to do so, subject to the following conditions: |
| 9 | * |
| 10 | * The above copyright notice and this permission notice shall be included in |
| 11 | * all copies or substantial portions of the Software. |
| 12 | * |
| 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 19 | * THE SOFTWARE. |
| 20 | * |
| 21 | *===-----------------------------------------------------------------------=== |
| 22 | */ |
| 23 | |
| 24 | /* Only include this if we're compiling for the windows platform. */ |
| 25 | #ifndef _MSC_VER |
| 26 | #include_next <Intrin.h> |
| 27 | #else |
| 28 | |
| 29 | #ifndef __INTRIN_H |
| 30 | #define __INTRIN_H |
| 31 | |
| 32 | /* First include the standard intrinsics. */ |
| 33 | #include <x86intrin.h> |
| 34 | |
Eric Christopher | 0db88a7 | 2013-09-18 22:24:01 +0000 | [diff] [blame] | 35 | #ifdef __cplusplus |
| 36 | extern "C" { |
| 37 | #endif |
| 38 | |
Eric Christopher | d1428bf | 2013-08-31 00:22:48 +0000 | [diff] [blame] | 39 | /* And the random ones that aren't in those files. */ |
| 40 | __m64 _m_from_float(float); |
| 41 | __m64 _m_from_int(int _l); |
| 42 | void _m_prefetch(void *); |
| 43 | float _m_to_float(__m64); |
| 44 | int _m_to_int(__m64 _M); |
| 45 | |
| 46 | /* Other assorted instruction intrinsics. */ |
| 47 | void __addfsbyte(unsigned long, unsigned char); |
| 48 | void __addfsdword(unsigned long, unsigned long); |
| 49 | void __addfsword(unsigned long, unsigned short); |
| 50 | void __code_seg(const char *); |
| 51 | void __cpuid(int[4], int); |
| 52 | void __cpuidex(int[4], int, int); |
Eric Christopher | 0db88a7 | 2013-09-18 22:24:01 +0000 | [diff] [blame] | 53 | void __debugbreak(void); |
Eric Christopher | d1428bf | 2013-08-31 00:22:48 +0000 | [diff] [blame] | 54 | __int64 __emul(int, int); |
| 55 | unsigned __int64 __emulu(unsigned int, unsigned int); |
Eric Christopher | 0db88a7 | 2013-09-18 22:24:01 +0000 | [diff] [blame] | 56 | void __cdecl __fastfail(unsigned int); |
Eric Christopher | d1428bf | 2013-08-31 00:22:48 +0000 | [diff] [blame] | 57 | unsigned int __getcallerseflags(void); |
| 58 | void __halt(void); |
| 59 | unsigned char __inbyte(unsigned short); |
| 60 | void __inbytestring(unsigned short, unsigned char *, unsigned long); |
| 61 | void __incfsbyte(unsigned long); |
| 62 | void __incfsdword(unsigned long); |
| 63 | void __incfsword(unsigned long); |
| 64 | unsigned long __indword(unsigned short); |
| 65 | void __indwordstring(unsigned short, unsigned long *, unsigned long); |
| 66 | void __int2c(void); |
| 67 | void __invlpg(void *); |
| 68 | unsigned short __inword(unsigned short); |
| 69 | void __inwordstring(unsigned short, unsigned short *, unsigned long); |
| 70 | void __lidt(void *); |
| 71 | unsigned __int64 __ll_lshift(unsigned __int64, int); |
| 72 | __int64 __ll_rshift(__int64, int); |
| 73 | void __llwpcb(void *); |
| 74 | unsigned char __lwpins32(unsigned int, unsigned int, unsigned int); |
| 75 | void __lwpval32(unsigned int, unsigned int, unsigned int); |
| 76 | unsigned int __lzcnt(unsigned int); |
| 77 | unsigned short __lzcnt16(unsigned short); |
| 78 | void __movsb(unsigned char *, unsigned char const *, size_t); |
| 79 | void __movsd(unsigned long *, unsigned long const *, size_t); |
| 80 | void __movsw(unsigned short *, unsigned short const *, size_t); |
| 81 | void __nop(void); |
| 82 | void __nvreg_restore_fence(void); |
| 83 | void __nvreg_save_fence(void); |
| 84 | void __outbyte(unsigned short, unsigned char); |
| 85 | void __outbytestring(unsigned short, unsigned char *, unsigned long); |
| 86 | void __outdword(unsigned short, unsigned long); |
| 87 | void __outdwordstring(unsigned short, unsigned long *, unsigned long); |
| 88 | void __outword(unsigned short, unsigned short); |
| 89 | void __outwordstring(unsigned short, unsigned short *, unsigned long); |
| 90 | unsigned int __popcnt(unsigned int); |
| 91 | unsigned short __popcnt16(unsigned short); |
| 92 | unsigned __int64 __rdtsc(void); |
| 93 | unsigned __int64 __rdtscp(unsigned int *); |
| 94 | unsigned long __readcr0(void); |
| 95 | unsigned long __readcr2(void); |
| 96 | unsigned long __readcr3(void); |
| 97 | unsigned long __readcr5(void); |
| 98 | unsigned long __readcr8(void); |
| 99 | unsigned int __readdr(unsigned int); |
| 100 | unsigned int __readeflags(void); |
| 101 | unsigned char __readfsbyte(unsigned long); |
| 102 | unsigned long __readfsdword(unsigned long); |
| 103 | unsigned __int64 __readfsqword(unsigned long); |
| 104 | unsigned short __readfsword(unsigned long); |
| 105 | unsigned __int64 __readmsr(unsigned long); |
| 106 | unsigned __int64 __readpmc(unsigned long); |
| 107 | unsigned long __segmentlimit(unsigned long); |
| 108 | void __sidt(void *); |
| 109 | void *__slwpcb(void); |
| 110 | void __stosb(unsigned char *, unsigned char, size_t); |
| 111 | void __stosd(unsigned long *, unsigned long, size_t); |
| 112 | void __stosw(unsigned short *, unsigned short, size_t); |
| 113 | void __svm_clgi(void); |
| 114 | void __svm_invlpga(void *, int); |
| 115 | void __svm_skinit(int); |
| 116 | void __svm_stgi(void); |
| 117 | void __svm_vmload(size_t); |
| 118 | void __svm_vmrun(size_t); |
| 119 | void __svm_vmsave(size_t); |
| 120 | void __ud2(void); |
| 121 | unsigned __int64 __ull_rshift(unsigned __int64, int); |
| 122 | void __vmx_off(void); |
| 123 | void __vmx_vmptrst(unsigned __int64 *); |
| 124 | void __wbinvd(void); |
| 125 | void __writecr0(unsigned int); |
| 126 | void __writecr3(unsigned int); |
| 127 | void __writecr4(unsigned int); |
| 128 | void __writecr8(unsigned int); |
| 129 | void __writedr(unsigned int, unsigned int); |
| 130 | void __writeeflags(unsigned int); |
| 131 | void __writefsbyte(unsigned long, unsigned char); |
| 132 | void __writefsdword(unsigned long, unsigned long); |
| 133 | void __writefsqword(unsigned long, unsigned __int64); |
| 134 | void __writefsword(unsigned long, unsigned short); |
| 135 | void __writemsr(unsigned long, unsigned __int64); |
| 136 | void *_AddressOfReturnAddress(void); |
| 137 | unsigned int _andn_u32(unsigned int, unsigned int); |
| 138 | unsigned int _bextr_u32(unsigned int, unsigned int, unsigned int); |
| 139 | unsigned int _bextr_u32(unsigned int, unsigned int, unsigned int); |
| 140 | unsigned int _bextri_u32(unsigned int, unsigned int); |
| 141 | unsigned char _BitScanForward(unsigned long *_Index, unsigned long _Mask); |
| 142 | unsigned char _BitScanReverse(unsigned long *_Index, unsigned long _Mask); |
| 143 | unsigned char _bittest(long const *, long); |
| 144 | unsigned char _bittestandcomplement(long *, long); |
| 145 | unsigned char _bittestandreset(long *, long); |
| 146 | unsigned char _bittestandset(long *, long); |
| 147 | unsigned int _blcfill_u32(unsigned int); |
| 148 | unsigned int _blci_u32(unsigned int); |
| 149 | unsigned int _blcic_u32(unsigned int); |
| 150 | unsigned int _blcmsk_u32(unsigned int); |
| 151 | unsigned int _blcs_u32(unsigned int); |
| 152 | unsigned int _blsfill_u32(unsigned int); |
| 153 | unsigned int _blsi_u32(unsigned int); |
| 154 | unsigned int _blsic_u32(unsigned int); |
| 155 | unsigned int _blsmsk_u32(unsigned int); |
| 156 | unsigned int _blsmsk_u32(unsigned int); |
| 157 | unsigned int _blsr_u32(unsigned int); |
| 158 | unsigned int _blsr_u32(unsigned int); |
| 159 | unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64); |
| 160 | unsigned long __cdecl _byteswap_ulong(unsigned long); |
| 161 | unsigned short __cdecl _byteswap_ushort(unsigned short); |
| 162 | unsigned _bzhi_u32(unsigned int, unsigned int); |
| 163 | void __cdecl _disable(void); |
| 164 | void __cdecl _enable(void); |
| 165 | void __cdecl _fxrstor(void const *); |
| 166 | void __cdecl _fxsave(void *); |
| 167 | long _InterlockedAddLargeStatistic(__int64 volatile *_Addend, long _Value); |
| 168 | long _InterlockedAnd(long volatile *_Value, long _Mask); |
| 169 | short _InterlockedAnd16(short volatile *_Value, short _Mask); |
| 170 | char _InterlockedAnd8(char volatile *_Value, char _Mask); |
| 171 | unsigned char _interlockedbittestandreset(long volatile *, long); |
| 172 | unsigned char _interlockedbittestandset(long volatile *, long); |
| 173 | long __cdecl _InterlockedCompareExchange(long volatile *_Destination, |
| 174 | long _Exchange, long _Comparand); |
| 175 | long _InterlockedCompareExchange_HLEAcquire(long volatile *, long, long); |
| 176 | long _InterlockedCompareExchange_HLERelease(long volatile *, long, long); |
| 177 | short _InterlockedCompareExchange16(short volatile *_Destination, |
| 178 | short _Exchange, short _Comparand); |
| 179 | __int64 _InterlockedCompareExchange64(__int64 volatile *_Destination, |
| 180 | __int64 _Exchange, __int64 _Comparand); |
| 181 | __int64 _InterlockedcompareExchange64_HLEAcquire(__int64 volatile *, __int64, |
| 182 | __int64); |
| 183 | __int64 _InterlockedCompareExchange64_HLERelease(__int64 volatile *, __int64, |
| 184 | __int64); |
| 185 | char _InterlockedCompareExchange8(char volatile *_Destination, char _Exchange, |
| 186 | char _Comparand); |
| 187 | void *_InterlockedCompareExchangePointer_HLEAcquire(void *volatile *, void *, |
| 188 | void *); |
| 189 | void *_InterlockedCompareExchangePointer_HLERelease(void *volatile *, void *, |
| 190 | void *); |
| 191 | long __cdecl _InterlockedDecrement(long volatile *_Addend); |
| 192 | short _InterlockedDecrement16(short volatile *_Addend); |
| 193 | long __cdecl _InterlockedExchange(long volatile *_Target, long _Value); |
| 194 | short _InterlockedExchange16(short volatile *_Target, short _Value); |
| 195 | char _InterlockedExchange8(char volatile *_Target, char _Value); |
| 196 | long __cdecl _InterlockedExchangeAdd(long volatile *_Addend, long _Value); |
| 197 | long _InterlockedExchangeAdd_HLEAcquire(long volatile *, long); |
| 198 | long _InterlockedExchangeAdd_HLERelease(long volatile *, long); |
| 199 | char _InterlockedExchangeAdd8(char volatile *_Addend, char _Value); |
| 200 | long __cdecl _InterlockedIncrement(long volatile *_Addend); |
| 201 | short _InterlockedIncrement16(short volatile *_Addend); |
| 202 | long _InterlockedOr(long volatile *_Value, long _Mask); |
| 203 | short _InterlockedOr16(short volatile *_Value, short _Mask); |
| 204 | char _InterlockedOr8(char volatile *_Value, char _Mask); |
| 205 | long _InterlockedXor(long volatile *_Value, long _Mask); |
| 206 | short _InterlockedXor16(short volatile *_Value, short _Mask); |
| 207 | char _InterlockedXor8(char volatile *_Value, char _Mask); |
| 208 | void __cdecl _invpcid(unsigned int, void *); |
| 209 | unsigned long __cdecl _lrotl(unsigned long, int); |
| 210 | unsigned long __cdecl _lrotr(unsigned long, int); |
| 211 | unsigned int _lzcnt_u32(unsigned int); |
| 212 | void _ReadBarrier(void); |
| 213 | void _ReadWriteBarrier(void); |
| 214 | void *_ReturnAddress(void); |
| 215 | unsigned int _rorx_u32(unsigned int, const unsigned int); |
| 216 | int __cdecl _rdrand16_step(unsigned short *); |
| 217 | int __cdecl _rdrand32_step(unsigned int *); |
Eric Christopher | fb4b433 | 2013-08-31 00:27:38 +0000 | [diff] [blame] | 218 | unsigned int __cdecl _rotl(unsigned int _Value, int _Shift); |
Eric Christopher | d1428bf | 2013-08-31 00:22:48 +0000 | [diff] [blame] | 219 | unsigned short _rotl16(unsigned short _Value, unsigned char _Shift); |
| 220 | unsigned __int64 __cdecl _rotl64(unsigned __int64 _Value, int _Shift); |
| 221 | unsigned char _rotl8(unsigned char _Value, unsigned char _Shift); |
| 222 | unsigned int __cdecl _rotr(unsigned int _Value, int _Shift); |
| 223 | unsigned short _rotr16(unsigned short _Value, unsigned char _Shift); |
| 224 | unsigned __int64 __cdecl _rotr64(unsigned __int64 _Value, int _Shift); |
| 225 | unsigned char _rotr8(unsigned char _Value, unsigned char _Shift); |
| 226 | int _sarx_i32(int, unsigned int); |
| 227 | |
| 228 | /* FIXME: Need definition for jmp_buf. |
| 229 | int __cdecl _setjmp(jmp_buf); */ |
| 230 | |
| 231 | unsigned int _shlx_u32(unsigned int, unsigned int); |
| 232 | unsigned int _shrx_u32(unsigned int, unsigned int); |
| 233 | void _Store_HLERelease(long volatile *, long); |
| 234 | void _Store64_HLERelease(__int64 volatile *, __int64); |
| 235 | void _StorePointer_HLERelease(void *volatile *, void *); |
| 236 | unsigned int _t1mskc_u32(unsigned int); |
| 237 | unsigned int _tzcnt_u32(unsigned int); |
| 238 | unsigned int _tzcnt_u32(unsigned int); |
| 239 | unsigned int _tzmsk_u32(unsigned int); |
| 240 | void _WriteBarrier(void); |
| 241 | void _xabort(const unsigned int imm); |
| 242 | unsigned __int32 xbegin(void); |
| 243 | void _xend(void); |
| 244 | unsigned __int64 __cdecl _xgetbv(unsigned int); |
| 245 | void __cdecl _xrstor(void const *, unsigned __int64); |
| 246 | void __cdecl _xsave(void *, unsigned __int64); |
| 247 | void __cdecl _xsaveopt(void *, unsigned __int64); |
| 248 | void __cdecl _xsetbv(unsigned int, unsigned __int64); |
| 249 | unsigned char _xtest(void); |
| 250 | |
| 251 | /* These additional intrinsics are turned on in x64/amd64/x86_64 mode. */ |
| 252 | #ifdef __X86_64__ |
| 253 | void __addgsbyte(unsigned long, unsigned char); |
| 254 | void __addgsdword(unsigned long, unsigned long); |
| 255 | void __addgsqword(unsigned long, unsigned __int64); |
| 256 | void __addgsword(unsigned long, unsigned short); |
| 257 | void __faststorefence(void); |
| 258 | void __incgsbyte(unsigned long); |
| 259 | void __incgsdword(unsigned long); |
| 260 | void __incgsqword(unsigned long); |
| 261 | void __incgsword(unsigned long); |
| 262 | unsigned __int64 __popcnt64(unsigned __int64); |
| 263 | unsigned __int64 __shiftleft128(unsigned __int64 _LowPart, |
| 264 | unsigned __int64 _HighPart, |
| 265 | unsigned char _Shift); |
| 266 | unsigned __int64 __shiftright128(unsigned __int64 _LowPart, |
| 267 | unsigned __int64 _HighPart, |
| 268 | unsigned char _Shift); |
| 269 | void __stosq(unsigned __int64 *, unsigned __int64, size_t); |
| 270 | unsigned __int64 _andn_u64(unsigned __int64, unsigned __int64); |
| 271 | unsigned __int64 _bextr_u64(unsigned __int64, unsigned int, unsigned int); |
| 272 | unsigned __int64 _bextri_u64(unsigned __int64, unsigned int); |
| 273 | unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask); |
| 274 | unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask); |
| 275 | unsigned char _bittest64(__int64 const *, __int64); |
| 276 | unsigned char _bittestandcomplement64(__int64 *, __int64); |
| 277 | unsigned char _bittestandreset64(__int64 *, __int64); |
| 278 | unsigned char _bittestandset64(__int64 *, __int64); |
| 279 | unsigned __int64 _blcfill_u64(unsigned __int64); |
| 280 | unsigned __int64 _blci_u64(unsigned __int64); |
| 281 | unsigned __int64 _blcic_u64(unsigned __int64); |
| 282 | unsigned __int64 _blcmsk_u64(unsigned __int64); |
| 283 | unsigned __int64 _blcs_u64(unsigned __int64); |
| 284 | unsigned __int64 _blsfill_u64(unsigned __int64); |
| 285 | unsigned __int64 _blsi_u64(unsigned __int64); |
| 286 | unsigned __int64 _blsic_u64(unsigned __int64); |
| 287 | unsigned __int64 _blmsk_u64(unsigned __int64); |
| 288 | unsigned __int64 _blsr_u64(unsigned __int64); |
| 289 | unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64); |
| 290 | unsigned __int64 _bzhi_u64(unsigned __int64, unsigned int); |
| 291 | void __cdecl _fxrstor64(void const *); |
| 292 | void __cdecl _fxsave64(void *); |
| 293 | long _InterlockedAnd_np(long volatile *_Value, long _Mask); |
| 294 | short _InterlockedAnd16_np(short volatile *_Value, short _Mask); |
| 295 | __int64 _InterlockedAnd64_np(__int64 volatile *_Value, __int64 _Mask); |
| 296 | char _InterlockedAnd8_np(char volatile *_Value, char _Mask); |
| 297 | unsigned char _interlockedbittestandreset64(__int64 volatile *, __int64); |
| 298 | unsigned char _interlockedbittestandset64(__int64 volatile *, __int64); |
| 299 | long _InterlockedCompareExchange_np(long volatile *_Destination, long _Exchange, |
| 300 | long _Comparand); |
| 301 | unsigned char _InterlockedCompareExchange128(__int64 volatile *_Destination, |
| 302 | __int64 _ExchangeHigh, |
| 303 | __int64 _ExchangeLow, |
| 304 | __int64 *_CompareandResult); |
| 305 | unsigned char _InterlockedCompareExchange128_np(__int64 volatile *_Destination, |
| 306 | __int64 _ExchangeHigh, |
| 307 | __int64 _ExchangeLow, |
| 308 | __int64 *_ComparandResult); |
| 309 | short _InterlockedCompareExchange16_np(short volatile *_Destination, |
| 310 | short _Exchange, short _Comparand); |
| 311 | __int64 _InterlockedCompareExchange64_np(__int64 volatile *_Destination, |
| 312 | __int64 _Exchange, __int64 _Comparand); |
| 313 | void *_InterlockedCompareExchangePointer_np(void *volatile *_Destination, |
| 314 | void *_Exchange, void *_Comparand); |
| 315 | long _InterlockedOr_np(long volatile *_Value, long _Mask); |
| 316 | short _InterlockedOr16_np(short volatile *_Value, short _Mask); |
| 317 | __int64 _InterlockedOr64_np(__int64 volatile *_Value, _int64 _Mask); |
| 318 | char _InterlockedOr8_np(char volatile *_Value, char _Mask); |
| 319 | long _InterlockedXor_np(long volatile *_Value, long _Mask); |
| 320 | short _InterlockedXor16_np(short volatile *_Value, short _Mask); |
| 321 | __int64 _InterlockedXor64_np(__int64 volatile *_Value, __int64 _Mask); |
| 322 | char _InterlockedXor8_np(char volatile *_Value, char _Mask); |
| 323 | unsigned __int64 _lzcnt_u64(unsigned __int64); |
| 324 | __int64 _mul128(__int64 _Multiplier, __int64 _Multiplicand, |
| 325 | __int64 *_HighProduct); |
| 326 | unsigned int __cdecl _readfsbase_u32(void); |
| 327 | unsigned __int64 __cdecl _readfsbase_u64(void); |
| 328 | unsigned int __cdecl _readgsbase_u32(void); |
| 329 | unsigned __int64 __cdecl _readgsbase_u64(void); |
| 330 | unsigned __int64 _rorx_u64(unsigned __int64, const unsigned int); |
| 331 | unsigned __int64 _tzcnt_u64(unsigned __int64); |
| 332 | unsigned __int64 _tzmsk_u64(unsigned __int64); |
| 333 | unsigned __int64 _umul128(unsigned __int64 _Multiplier, |
| 334 | unsigned __int64 _Multiplicand, |
| 335 | unsigned __int64 *_HighProduct); |
| 336 | void __cdecl _writefsbase_u32(unsigned int); |
| 337 | void _cdecl _writefsbase_u64(unsigned __int64); |
| 338 | void __cdecl _writegsbase_u32(unsigned int); |
| 339 | void __cdecl _writegsbase_u64(unsigned __int64); |
| 340 | void __cdecl _xrstor64(void const *, unsigned __int64); |
| 341 | void __cdecl _xsave64(void *, unsigned __int64); |
| 342 | void __cdecl _xsaveopt64(void *, unsigned __int64); |
Eric Christopher | 0db88a7 | 2013-09-18 22:24:01 +0000 | [diff] [blame] | 343 | |
Reid Kleckner | f0e2322 | 2013-09-19 00:19:53 +0000 | [diff] [blame] | 344 | #endif /* __X86_64__ */ |
| 345 | |
Eric Christopher | cc87253 | 2013-09-18 22:40:18 +0000 | [diff] [blame] | 346 | #ifdef __cplusplus |
Eric Christopher | 0db88a7 | 2013-09-18 22:24:01 +0000 | [diff] [blame] | 347 | } |
Eric Christopher | d1428bf | 2013-08-31 00:22:48 +0000 | [diff] [blame] | 348 | #endif |
Reid Kleckner | f0e2322 | 2013-09-19 00:19:53 +0000 | [diff] [blame] | 349 | |
| 350 | #endif /* __INTRIN_H */ |
| 351 | #endif /* _MSC_VER */ |