blob: a2c361c0288a49200d150fc6dd9c652dce32e012 [file] [log] [blame]
Eric Christopherd1428bf2013-08-31 00:22:48 +00001/* ===-------- 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 Christopher0db88a72013-09-18 22:24:01 +000035#ifdef __cplusplus
36extern "C" {
37#endif
38
Eric Christopherd1428bf2013-08-31 00:22:48 +000039/* And the random ones that aren't in those files. */
40__m64 _m_from_float(float);
41__m64 _m_from_int(int _l);
42void _m_prefetch(void *);
43float _m_to_float(__m64);
44int _m_to_int(__m64 _M);
45
46/* Other assorted instruction intrinsics. */
47void __addfsbyte(unsigned long, unsigned char);
48void __addfsdword(unsigned long, unsigned long);
49void __addfsword(unsigned long, unsigned short);
50void __code_seg(const char *);
51void __cpuid(int[4], int);
52void __cpuidex(int[4], int, int);
Eric Christopher0db88a72013-09-18 22:24:01 +000053void __debugbreak(void);
Eric Christopherd1428bf2013-08-31 00:22:48 +000054__int64 __emul(int, int);
55unsigned __int64 __emulu(unsigned int, unsigned int);
Eric Christopher0db88a72013-09-18 22:24:01 +000056void __cdecl __fastfail(unsigned int);
Eric Christopherd1428bf2013-08-31 00:22:48 +000057unsigned int __getcallerseflags(void);
58void __halt(void);
59unsigned char __inbyte(unsigned short);
60void __inbytestring(unsigned short, unsigned char *, unsigned long);
61void __incfsbyte(unsigned long);
62void __incfsdword(unsigned long);
63void __incfsword(unsigned long);
64unsigned long __indword(unsigned short);
65void __indwordstring(unsigned short, unsigned long *, unsigned long);
66void __int2c(void);
67void __invlpg(void *);
68unsigned short __inword(unsigned short);
69void __inwordstring(unsigned short, unsigned short *, unsigned long);
70void __lidt(void *);
71unsigned __int64 __ll_lshift(unsigned __int64, int);
72__int64 __ll_rshift(__int64, int);
73void __llwpcb(void *);
74unsigned char __lwpins32(unsigned int, unsigned int, unsigned int);
75void __lwpval32(unsigned int, unsigned int, unsigned int);
76unsigned int __lzcnt(unsigned int);
77unsigned short __lzcnt16(unsigned short);
78void __movsb(unsigned char *, unsigned char const *, size_t);
79void __movsd(unsigned long *, unsigned long const *, size_t);
80void __movsw(unsigned short *, unsigned short const *, size_t);
81void __nop(void);
82void __nvreg_restore_fence(void);
83void __nvreg_save_fence(void);
84void __outbyte(unsigned short, unsigned char);
85void __outbytestring(unsigned short, unsigned char *, unsigned long);
86void __outdword(unsigned short, unsigned long);
87void __outdwordstring(unsigned short, unsigned long *, unsigned long);
88void __outword(unsigned short, unsigned short);
89void __outwordstring(unsigned short, unsigned short *, unsigned long);
90unsigned int __popcnt(unsigned int);
91unsigned short __popcnt16(unsigned short);
92unsigned __int64 __rdtsc(void);
93unsigned __int64 __rdtscp(unsigned int *);
94unsigned long __readcr0(void);
95unsigned long __readcr2(void);
96unsigned long __readcr3(void);
97unsigned long __readcr5(void);
98unsigned long __readcr8(void);
99unsigned int __readdr(unsigned int);
100unsigned int __readeflags(void);
101unsigned char __readfsbyte(unsigned long);
102unsigned long __readfsdword(unsigned long);
103unsigned __int64 __readfsqword(unsigned long);
104unsigned short __readfsword(unsigned long);
105unsigned __int64 __readmsr(unsigned long);
106unsigned __int64 __readpmc(unsigned long);
107unsigned long __segmentlimit(unsigned long);
108void __sidt(void *);
109void *__slwpcb(void);
110void __stosb(unsigned char *, unsigned char, size_t);
111void __stosd(unsigned long *, unsigned long, size_t);
112void __stosw(unsigned short *, unsigned short, size_t);
113void __svm_clgi(void);
114void __svm_invlpga(void *, int);
115void __svm_skinit(int);
116void __svm_stgi(void);
117void __svm_vmload(size_t);
118void __svm_vmrun(size_t);
119void __svm_vmsave(size_t);
120void __ud2(void);
121unsigned __int64 __ull_rshift(unsigned __int64, int);
122void __vmx_off(void);
123void __vmx_vmptrst(unsigned __int64 *);
124void __wbinvd(void);
125void __writecr0(unsigned int);
126void __writecr3(unsigned int);
127void __writecr4(unsigned int);
128void __writecr8(unsigned int);
129void __writedr(unsigned int, unsigned int);
130void __writeeflags(unsigned int);
131void __writefsbyte(unsigned long, unsigned char);
132void __writefsdword(unsigned long, unsigned long);
133void __writefsqword(unsigned long, unsigned __int64);
134void __writefsword(unsigned long, unsigned short);
135void __writemsr(unsigned long, unsigned __int64);
136void *_AddressOfReturnAddress(void);
137unsigned int _andn_u32(unsigned int, unsigned int);
138unsigned int _bextr_u32(unsigned int, unsigned int, unsigned int);
139unsigned int _bextr_u32(unsigned int, unsigned int, unsigned int);
140unsigned int _bextri_u32(unsigned int, unsigned int);
141unsigned char _BitScanForward(unsigned long *_Index, unsigned long _Mask);
142unsigned char _BitScanReverse(unsigned long *_Index, unsigned long _Mask);
143unsigned char _bittest(long const *, long);
144unsigned char _bittestandcomplement(long *, long);
145unsigned char _bittestandreset(long *, long);
146unsigned char _bittestandset(long *, long);
147unsigned int _blcfill_u32(unsigned int);
148unsigned int _blci_u32(unsigned int);
149unsigned int _blcic_u32(unsigned int);
150unsigned int _blcmsk_u32(unsigned int);
151unsigned int _blcs_u32(unsigned int);
152unsigned int _blsfill_u32(unsigned int);
153unsigned int _blsi_u32(unsigned int);
154unsigned int _blsic_u32(unsigned int);
155unsigned int _blsmsk_u32(unsigned int);
156unsigned int _blsmsk_u32(unsigned int);
157unsigned int _blsr_u32(unsigned int);
158unsigned int _blsr_u32(unsigned int);
159unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64);
160unsigned long __cdecl _byteswap_ulong(unsigned long);
161unsigned short __cdecl _byteswap_ushort(unsigned short);
162unsigned _bzhi_u32(unsigned int, unsigned int);
163void __cdecl _disable(void);
164void __cdecl _enable(void);
165void __cdecl _fxrstor(void const *);
166void __cdecl _fxsave(void *);
167long _InterlockedAddLargeStatistic(__int64 volatile *_Addend, long _Value);
168long _InterlockedAnd(long volatile *_Value, long _Mask);
169short _InterlockedAnd16(short volatile *_Value, short _Mask);
170char _InterlockedAnd8(char volatile *_Value, char _Mask);
171unsigned char _interlockedbittestandreset(long volatile *, long);
172unsigned char _interlockedbittestandset(long volatile *, long);
173long __cdecl _InterlockedCompareExchange(long volatile *_Destination,
174 long _Exchange, long _Comparand);
175long _InterlockedCompareExchange_HLEAcquire(long volatile *, long, long);
176long _InterlockedCompareExchange_HLERelease(long volatile *, long, long);
177short _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);
185char _InterlockedCompareExchange8(char volatile *_Destination, char _Exchange,
186 char _Comparand);
187void *_InterlockedCompareExchangePointer_HLEAcquire(void *volatile *, void *,
188 void *);
189void *_InterlockedCompareExchangePointer_HLERelease(void *volatile *, void *,
190 void *);
191long __cdecl _InterlockedDecrement(long volatile *_Addend);
192short _InterlockedDecrement16(short volatile *_Addend);
193long __cdecl _InterlockedExchange(long volatile *_Target, long _Value);
194short _InterlockedExchange16(short volatile *_Target, short _Value);
195char _InterlockedExchange8(char volatile *_Target, char _Value);
196long __cdecl _InterlockedExchangeAdd(long volatile *_Addend, long _Value);
197long _InterlockedExchangeAdd_HLEAcquire(long volatile *, long);
198long _InterlockedExchangeAdd_HLERelease(long volatile *, long);
199char _InterlockedExchangeAdd8(char volatile *_Addend, char _Value);
200long __cdecl _InterlockedIncrement(long volatile *_Addend);
201short _InterlockedIncrement16(short volatile *_Addend);
202long _InterlockedOr(long volatile *_Value, long _Mask);
203short _InterlockedOr16(short volatile *_Value, short _Mask);
204char _InterlockedOr8(char volatile *_Value, char _Mask);
205long _InterlockedXor(long volatile *_Value, long _Mask);
206short _InterlockedXor16(short volatile *_Value, short _Mask);
207char _InterlockedXor8(char volatile *_Value, char _Mask);
208void __cdecl _invpcid(unsigned int, void *);
209unsigned long __cdecl _lrotl(unsigned long, int);
210unsigned long __cdecl _lrotr(unsigned long, int);
211unsigned int _lzcnt_u32(unsigned int);
212void _ReadBarrier(void);
213void _ReadWriteBarrier(void);
214void *_ReturnAddress(void);
215unsigned int _rorx_u32(unsigned int, const unsigned int);
216int __cdecl _rdrand16_step(unsigned short *);
217int __cdecl _rdrand32_step(unsigned int *);
Eric Christopherfb4b4332013-08-31 00:27:38 +0000218unsigned int __cdecl _rotl(unsigned int _Value, int _Shift);
Eric Christopherd1428bf2013-08-31 00:22:48 +0000219unsigned short _rotl16(unsigned short _Value, unsigned char _Shift);
220unsigned __int64 __cdecl _rotl64(unsigned __int64 _Value, int _Shift);
221unsigned char _rotl8(unsigned char _Value, unsigned char _Shift);
222unsigned int __cdecl _rotr(unsigned int _Value, int _Shift);
223unsigned short _rotr16(unsigned short _Value, unsigned char _Shift);
224unsigned __int64 __cdecl _rotr64(unsigned __int64 _Value, int _Shift);
225unsigned char _rotr8(unsigned char _Value, unsigned char _Shift);
226int _sarx_i32(int, unsigned int);
227
228/* FIXME: Need definition for jmp_buf.
229 int __cdecl _setjmp(jmp_buf); */
230
231unsigned int _shlx_u32(unsigned int, unsigned int);
232unsigned int _shrx_u32(unsigned int, unsigned int);
233void _Store_HLERelease(long volatile *, long);
234void _Store64_HLERelease(__int64 volatile *, __int64);
235void _StorePointer_HLERelease(void *volatile *, void *);
236unsigned int _t1mskc_u32(unsigned int);
237unsigned int _tzcnt_u32(unsigned int);
238unsigned int _tzcnt_u32(unsigned int);
239unsigned int _tzmsk_u32(unsigned int);
240void _WriteBarrier(void);
241void _xabort(const unsigned int imm);
242unsigned __int32 xbegin(void);
243void _xend(void);
244unsigned __int64 __cdecl _xgetbv(unsigned int);
245void __cdecl _xrstor(void const *, unsigned __int64);
246void __cdecl _xsave(void *, unsigned __int64);
247void __cdecl _xsaveopt(void *, unsigned __int64);
248void __cdecl _xsetbv(unsigned int, unsigned __int64);
249unsigned char _xtest(void);
250
251/* These additional intrinsics are turned on in x64/amd64/x86_64 mode. */
252#ifdef __X86_64__
253void __addgsbyte(unsigned long, unsigned char);
254void __addgsdword(unsigned long, unsigned long);
255void __addgsqword(unsigned long, unsigned __int64);
256void __addgsword(unsigned long, unsigned short);
257void __faststorefence(void);
258void __incgsbyte(unsigned long);
259void __incgsdword(unsigned long);
260void __incgsqword(unsigned long);
261void __incgsword(unsigned long);
262unsigned __int64 __popcnt64(unsigned __int64);
263unsigned __int64 __shiftleft128(unsigned __int64 _LowPart,
264 unsigned __int64 _HighPart,
265 unsigned char _Shift);
266unsigned __int64 __shiftright128(unsigned __int64 _LowPart,
267 unsigned __int64 _HighPart,
268 unsigned char _Shift);
269void __stosq(unsigned __int64 *, unsigned __int64, size_t);
270unsigned __int64 _andn_u64(unsigned __int64, unsigned __int64);
271unsigned __int64 _bextr_u64(unsigned __int64, unsigned int, unsigned int);
272unsigned __int64 _bextri_u64(unsigned __int64, unsigned int);
273unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask);
274unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask);
275unsigned char _bittest64(__int64 const *, __int64);
276unsigned char _bittestandcomplement64(__int64 *, __int64);
277unsigned char _bittestandreset64(__int64 *, __int64);
278unsigned char _bittestandset64(__int64 *, __int64);
279unsigned __int64 _blcfill_u64(unsigned __int64);
280unsigned __int64 _blci_u64(unsigned __int64);
281unsigned __int64 _blcic_u64(unsigned __int64);
282unsigned __int64 _blcmsk_u64(unsigned __int64);
283unsigned __int64 _blcs_u64(unsigned __int64);
284unsigned __int64 _blsfill_u64(unsigned __int64);
285unsigned __int64 _blsi_u64(unsigned __int64);
286unsigned __int64 _blsic_u64(unsigned __int64);
287unsigned __int64 _blmsk_u64(unsigned __int64);
288unsigned __int64 _blsr_u64(unsigned __int64);
289unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64);
290unsigned __int64 _bzhi_u64(unsigned __int64, unsigned int);
291void __cdecl _fxrstor64(void const *);
292void __cdecl _fxsave64(void *);
293long _InterlockedAnd_np(long volatile *_Value, long _Mask);
294short _InterlockedAnd16_np(short volatile *_Value, short _Mask);
295__int64 _InterlockedAnd64_np(__int64 volatile *_Value, __int64 _Mask);
296char _InterlockedAnd8_np(char volatile *_Value, char _Mask);
297unsigned char _interlockedbittestandreset64(__int64 volatile *, __int64);
298unsigned char _interlockedbittestandset64(__int64 volatile *, __int64);
299long _InterlockedCompareExchange_np(long volatile *_Destination, long _Exchange,
300 long _Comparand);
301unsigned char _InterlockedCompareExchange128(__int64 volatile *_Destination,
302 __int64 _ExchangeHigh,
303 __int64 _ExchangeLow,
304 __int64 *_CompareandResult);
305unsigned char _InterlockedCompareExchange128_np(__int64 volatile *_Destination,
306 __int64 _ExchangeHigh,
307 __int64 _ExchangeLow,
308 __int64 *_ComparandResult);
309short _InterlockedCompareExchange16_np(short volatile *_Destination,
310 short _Exchange, short _Comparand);
311__int64 _InterlockedCompareExchange64_np(__int64 volatile *_Destination,
312 __int64 _Exchange, __int64 _Comparand);
313void *_InterlockedCompareExchangePointer_np(void *volatile *_Destination,
314 void *_Exchange, void *_Comparand);
315long _InterlockedOr_np(long volatile *_Value, long _Mask);
316short _InterlockedOr16_np(short volatile *_Value, short _Mask);
317__int64 _InterlockedOr64_np(__int64 volatile *_Value, _int64 _Mask);
318char _InterlockedOr8_np(char volatile *_Value, char _Mask);
319long _InterlockedXor_np(long volatile *_Value, long _Mask);
320short _InterlockedXor16_np(short volatile *_Value, short _Mask);
321__int64 _InterlockedXor64_np(__int64 volatile *_Value, __int64 _Mask);
322char _InterlockedXor8_np(char volatile *_Value, char _Mask);
323unsigned __int64 _lzcnt_u64(unsigned __int64);
324__int64 _mul128(__int64 _Multiplier, __int64 _Multiplicand,
325 __int64 *_HighProduct);
326unsigned int __cdecl _readfsbase_u32(void);
327unsigned __int64 __cdecl _readfsbase_u64(void);
328unsigned int __cdecl _readgsbase_u32(void);
329unsigned __int64 __cdecl _readgsbase_u64(void);
330unsigned __int64 _rorx_u64(unsigned __int64, const unsigned int);
331unsigned __int64 _tzcnt_u64(unsigned __int64);
332unsigned __int64 _tzmsk_u64(unsigned __int64);
333unsigned __int64 _umul128(unsigned __int64 _Multiplier,
334 unsigned __int64 _Multiplicand,
335 unsigned __int64 *_HighProduct);
336void __cdecl _writefsbase_u32(unsigned int);
337void _cdecl _writefsbase_u64(unsigned __int64);
338void __cdecl _writegsbase_u32(unsigned int);
339void __cdecl _writegsbase_u64(unsigned __int64);
340void __cdecl _xrstor64(void const *, unsigned __int64);
341void __cdecl _xsave64(void *, unsigned __int64);
342void __cdecl _xsaveopt64(void *, unsigned __int64);
Eric Christopher0db88a72013-09-18 22:24:01 +0000343
Reid Klecknerf0e23222013-09-19 00:19:53 +0000344#endif /* __X86_64__ */
345
Eric Christophercc872532013-09-18 22:40:18 +0000346#ifdef __cplusplus
Eric Christopher0db88a72013-09-18 22:24:01 +0000347}
Eric Christopherd1428bf2013-08-31 00:22:48 +0000348#endif
Reid Klecknerf0e23222013-09-19 00:19:53 +0000349
350#endif /* __INTRIN_H */
351#endif /* _MSC_VER */