|
|
|
1 |
|
/** |
2 |
|
*** Copyright (C) 1985-1999 Intel Corporation. All rights reserved. |
3 |
|
*** |
4 |
|
*** The information and source code contained herein is the exclusive |
5 |
|
*** property of Intel Corporation and may not be disclosed, examined |
6 |
|
*** or reproduced in whole or in part without explicit written authorization |
7 |
|
*** from the company. |
8 |
|
*** |
9 |
|
**/ |
10 |
|
|
11 |
|
/* |
12 |
|
* xmmintrin.h |
13 |
|
* |
14 |
|
* Principal header file for Streaming SIMD Extensions intrinsics |
15 |
|
* |
16 |
|
* The intrinsics package can be used in 2 ways, based whether or not |
17 |
|
* _MM_FUNCTIONALITY is defined; if it is, the C/x87 implementation |
18 |
|
* will be used (the "faux intrinsics"). |
19 |
|
* |
20 |
|
* |
21 |
|
* Note that the m128 datatype provided using _MM2_FUNCTIONALITY mode is |
22 |
|
* implemented as struct, will not be 128b aligned, will be passed |
23 |
|
* via the stack, etc. MM_FUNCTIONALITY mode is not intended for |
24 |
|
* performance, just semantics. |
25 |
|
* |
26 |
|
*/ |
27 |
|
|
28 |
|
#pragma once |
29 |
|
#ifndef __midl |
30 |
|
#ifndef _INCLUDED_MM2 |
31 |
|
#define _INCLUDED_MM2 |
32 |
|
|
33 |
|
#include <crtdefs.h> |
34 |
|
|
35 |
|
#if defined(_M_CEE_PURE) |
36 |
|
#error ERROR: XMM intrinsics not supported in the pure mode! |
37 |
|
#else |
38 |
|
|
39 |
|
/* |
40 |
|
* the m64 type is required for the integer Streaming SIMD Extensions intrinsics |
41 |
|
*/ |
42 |
|
#ifndef _MMINTRIN_H_INCLUDED |
43 |
|
#include <mmintrin.h> |
44 |
|
#endif |
45 |
|
|
46 |
|
#ifdef _MM2_FUNCTIONALITY |
47 |
|
/* support old notation */ |
48 |
|
#ifndef _MM_FUNCTIONALITY |
49 |
|
#define _MM_FUNCTIONALITY |
50 |
|
#endif |
51 |
|
#endif |
52 |
|
|
53 |
|
#ifdef __ICL |
54 |
|
#ifdef _MM_FUNCTIONALITY |
55 |
|
#include "xmm_func.h" |
56 |
|
#else |
57 |
|
/* using real intrinsics */ |
58 |
|
typedef long long __m128; |
59 |
|
#endif |
60 |
|
#else |
61 |
|
|
62 |
|
typedef union __declspec(intrin_type) _CRT_ALIGN(16) __m128 { |
63 |
|
float m128_f32[4]; |
64 |
|
unsigned __int64 m128_u64[2]; |
65 |
|
__int8 m128_i8[16]; |
66 |
|
__int16 m128_i16[8]; |
67 |
|
__int32 m128_i32[4]; |
68 |
|
__int64 m128_i64[2]; |
69 |
|
unsigned __int8 m128_u8[16]; |
70 |
|
unsigned __int16 m128_u16[8]; |
71 |
|
unsigned __int32 m128_u32[4]; |
72 |
|
} __m128; |
73 |
|
|
74 |
|
#ifndef _INC_MALLOC |
75 |
|
/* pick up _mm_malloc() and _mm_free() */ |
76 |
|
#include <malloc.h> |
77 |
|
#endif |
78 |
|
#endif |
79 |
|
|
80 |
|
/*******************************************************/ |
81 |
|
/* MACRO for shuffle parameter for _mm_shuffle_ps(). */ |
82 |
|
/* Argument fp3 is a digit[0123] that represents the fp*/ |
83 |
|
/* from argument "b" of mm_shuffle_ps that will be */ |
84 |
|
/* placed in fp3 of result. fp2 is the same for fp2 in */ |
85 |
|
/* result. fp1 is a digit[0123] that represents the fp */ |
86 |
|
/* from argument "a" of mm_shuffle_ps that will be */ |
87 |
|
/* places in fp1 of result. fp0 is the same for fp0 of */ |
88 |
|
/* result */ |
89 |
|
/*******************************************************/ |
90 |
|
#define _MM_SHUFFLE(fp3,fp2,fp1,fp0) (((fp3) << 6) | ((fp2) << 4) | \ |
91 |
|
((fp1) << 2) | ((fp0))) |
92 |
|
|
93 |
|
|
94 |
|
/*******************************************************/ |
95 |
|
/* MACRO for performing the transpose of a 4x4 matrix */ |
96 |
|
/* of single precision floating point values. */ |
97 |
|
/* Arguments row0, row1, row2, and row3 are __m128 */ |
98 |
|
/* values whose elements form the corresponding rows */ |
99 |
|
/* of a 4x4 matrix. The matrix transpose is returned */ |
100 |
|
/* in arguments row0, row1, row2, and row3 where row0 */ |
101 |
|
/* now holds column 0 of the original matrix, row1 now */ |
102 |
|
/* holds column 1 of the original matrix, etc. */ |
103 |
|
/*******************************************************/ |
104 |
|
#define _MM_TRANSPOSE4_PS(row0, row1, row2, row3) { \ |
105 |
|
__m128 tmp3, tmp2, tmp1, tmp0; \ |
106 |
|
\ |
107 |
|
tmp0 = _mm_shuffle_ps((row0), (row1), 0x44); \ |
108 |
|
tmp2 = _mm_shuffle_ps((row0), (row1), 0xEE); \ |
109 |
|
tmp1 = _mm_shuffle_ps((row2), (row3), 0x44); \ |
110 |
|
tmp3 = _mm_shuffle_ps((row2), (row3), 0xEE); \ |
111 |
|
\ |
112 |
|
(row0) = _mm_shuffle_ps(tmp0, tmp1, 0x88); \ |
113 |
|
(row1) = _mm_shuffle_ps(tmp0, tmp1, 0xDD); \ |
114 |
|
(row2) = _mm_shuffle_ps(tmp2, tmp3, 0x88); \ |
115 |
|
(row3) = _mm_shuffle_ps(tmp2, tmp3, 0xDD); \ |
116 |
|
} |
117 |
|
|
118 |
|
|
119 |
|
/* constants for use with _mm_prefetch */ |
120 |
|
#define _MM_HINT_T0 1 |
121 |
|
#define _MM_HINT_T1 2 |
122 |
|
#define _MM_HINT_T2 3 |
123 |
|
#define _MM_HINT_NTA 0 |
124 |
|
|
125 |
|
/* (this declspec not supported with 0.A or 0.B) */ |
126 |
|
#define _MM_ALIGN16 _CRT_ALIGN(16) |
127 |
|
|
128 |
|
/* MACRO functions for setting and reading the MXCSR */ |
129 |
|
#define _MM_EXCEPT_MASK 0x003f |
130 |
|
#define _MM_EXCEPT_INVALID 0x0001 |
131 |
|
#define _MM_EXCEPT_DENORM 0x0002 |
132 |
|
#define _MM_EXCEPT_DIV_ZERO 0x0004 |
133 |
|
#define _MM_EXCEPT_OVERFLOW 0x0008 |
134 |
|
#define _MM_EXCEPT_UNDERFLOW 0x0010 |
135 |
|
#define _MM_EXCEPT_INEXACT 0x0020 |
136 |
|
|
137 |
|
#define _MM_MASK_MASK 0x1f80 |
138 |
|
#define _MM_MASK_INVALID 0x0080 |
139 |
|
#define _MM_MASK_DENORM 0x0100 |
140 |
|
#define _MM_MASK_DIV_ZERO 0x0200 |
141 |
|
#define _MM_MASK_OVERFLOW 0x0400 |
142 |
|
#define _MM_MASK_UNDERFLOW 0x0800 |
143 |
|
#define _MM_MASK_INEXACT 0x1000 |
144 |
|
|
145 |
|
#define _MM_ROUND_MASK 0x6000 |
146 |
|
#define _MM_ROUND_NEAREST 0x0000 |
147 |
|
#define _MM_ROUND_DOWN 0x2000 |
148 |
|
#define _MM_ROUND_UP 0x4000 |
149 |
|
#define _MM_ROUND_TOWARD_ZERO 0x6000 |
150 |
|
|
151 |
|
#define _MM_FLUSH_ZERO_MASK 0x8000 |
152 |
|
#define _MM_FLUSH_ZERO_ON 0x8000 |
153 |
|
#define _MM_FLUSH_ZERO_OFF 0x0000 |
154 |
|
|
155 |
|
#define _MM_SET_EXCEPTION_STATE(mask) \ |
156 |
|
_mm_setcsr((_mm_getcsr() & ~_MM_EXCEPT_MASK) | (mask)) |
157 |
|
#define _MM_GET_EXCEPTION_STATE() \ |
158 |
|
(_mm_getcsr() & _MM_EXCEPT_MASK) |
159 |
|
|
160 |
|
#define _MM_SET_EXCEPTION_MASK(mask) \ |
161 |
|
_mm_setcsr((_mm_getcsr() & ~_MM_MASK_MASK) | (mask)) |
162 |
|
#define _MM_GET_EXCEPTION_MASK() \ |
163 |
|
(_mm_getcsr() & _MM_MASK_MASK) |
164 |
|
|
165 |
|
#define _MM_SET_ROUNDING_MODE(mode) \ |
166 |
|
_mm_setcsr((_mm_getcsr() & ~_MM_ROUND_MASK) | (mode)) |
167 |
|
#define _MM_GET_ROUNDING_MODE() \ |
168 |
|
(_mm_getcsr() & _MM_ROUND_MASK) |
169 |
|
|
170 |
|
#define _MM_SET_FLUSH_ZERO_MODE(mode) \ |
171 |
|
_mm_setcsr((_mm_getcsr() & ~_MM_FLUSH_ZERO_MASK) | (mode)) |
172 |
|
#define _MM_GET_FLUSH_ZERO_MODE(mode) \ |
173 |
|
(_mm_getcsr() & _MM_FLUSH_ZERO_MASK) |
446 |
|
/* IN : __m64 a */ |
447 |
|
/* OUT : none */ |
448 |
|
/* RETURN : __m128 : (float)a */ |
449 |
|
/******************************************************/ |
450 |
|
__inline __m128 _mm_cvtpu8_ps(__m64 a) |
451 |
|
{ |
452 |
|
return _mm_cvtpu16_ps(_mm_unpacklo_pi8(a, _mm_setzero_si64())); |
453 |
|
} |
454 |
|
|
455 |
|
|
456 |
|
/******************************************************/ |
457 |
|
/* NAME : _mm_cvtps_pi8 */ |
458 |
|
/* DESCRIPTION : Convert 4 single-precision float */ |
459 |
|
/* values to 4 8-bit integer values */ |
460 |
|
/* IN : __m128 a */ |
461 |
|
/* OUT : none */ |
462 |
|
/* RETURN : __m64 : (char)a */ |
463 |
|
/******************************************************/ |
464 |
|
__inline __m64 _mm_cvtps_pi8(__m128 a) |
465 |
|
{ |
466 |
|
return _mm_packs_pi16(_mm_cvtps_pi16(a), _mm_setzero_si64()); |
467 |
|
} |
468 |
|
|
469 |
|
|
470 |
|
/******************************************************/ |
471 |
|
/* NAME : _mm_cvtpi32x2_ps */ |
472 |
|
/* DESCRIPTION : Convert 4 32-bit integer values */ |
473 |
|
/* to 4 single-precision float values */ |
474 |
|
/* IN : __m64 a : operand 1 */ |
475 |
|
/* __m64 b : operand 2 */ |
476 |
|
/* OUT : none */ |
477 |
|
/* RETURN : __m128 : (float)a,(float)b */ |
478 |
|
/******************************************************/ |
479 |
|
__inline __m128 _mm_cvtpi32x2_ps(__m64 a, __m64 b) |
480 |
|
{ |
481 |
|
return _mm_movelh_ps(_mm_cvt_pi2ps(_mm_setzero_ps(), a), |
482 |
|
_mm_cvt_pi2ps(_mm_setzero_ps(), b)); |
483 |
|
} |
484 |
|
|
485 |
|
|
486 |
|
#if defined __cplusplus |
487 |
|
}; /* End "C" */ |
488 |
|
#endif /* __cplusplus */ |
489 |
|
|
490 |
|
#endif /* defined(_M_CEE_PURE) */ |
491 |
|
|
492 |
|
#endif |
493 |
|
#endif |
494 |
|
|
|
|
|