ReactOS 0.4.16-dev-237-gd6eebaa
simd.h
Go to the documentation of this file.
1/***********************************************************************************/
24/***********************************************************************************/
25
26/*
27******************************************************************************
28 * Source File : simd.h
29 * Archive File : $Archive: $
30 * Date : 6/04/01
31 * Description : The include file for the AMD SIMD exception filter routine
32 * for Microsoft Structured Exception Handling
33 *
34 *
35$Revision:$
36$Name:$
37$Date:$
38$Author:$
39$History: simd.h $
40 *
41 */
42
43#include <emmintrin.h>
44
45// simd.h
46// This file contains structure definitions to provide
47// convenient access to SIMD and MMX data as unsigned
48// integer data.
49
50// change the following define to a 1 to print terse output
51#define DO_PRINT 0
52
53// can't use the 3DNOW SDK as written with 64 bit tools
54#if !defined (_AMD64_)
55#define USE_3DNOW_SDK 1
56#define SUPPORTS_FTZ 1
57#endif
58
59
60/*****************************************************************/
61
62// Basic type definitions
63
64typedef UINT_PTR AWORD; // x86-64 safe
65
66typedef union
67{
68 float f;
69 unsigned long long l;
70} LFLOAT;
71
72//typedef struct
73//{
74// DWORD dw[2];
75//}
76typedef unsigned _int64 QWORD;
77
78typedef union
79{
80 double f;
81 unsigned long long l[2];
82} LDOUBLE;
83
85{
86 LFLOAT f0,f1,f2,f3;
88
89typedef __declspec(align(16)) struct
90{
91 LDOUBLE d0,d1;
93
94
95// this is the key data structure type used by the filter
96// and the test program. It will be aligned, since
97// the __m128 types are all aligned. It allows the
98// use of one variable to carry all the needed data
99// types.
100typedef union
101{
102 __m128 m;
103 __m128d md;
104 __m128i mi;
105 __m64 m64[2];
107 int i[4];
111} ML128;
112
113// this defined to provide a MMX type for the FXSTOR structure.
114typedef union
115{
116 unsigned short mmx[4]; // mmx regs are 64 bits
117 unsigned short fp[5]; // floating point regs are 80 bits
118} MMX80;
119
120/*****************************************************************/
121
122// define constants used by SIMD
123
124// define MXCSR rounding control bits.
125#define SDIMCW_RC 0x6000
126#define SDIRC_NEAR 0x0000
127#define SDIRC_DOWN 0x2000
128#define SDIRC_UP 0x4000
129#define SDIRC_CHOP 0x6000
130
131// define other MXCSR control bits
132#define SDDAZ 0x0040
133#define SDFTZ 0x8000
134
135#define opADD 0x58
136#define opAND 0x54
137#define opANDN 0x55
138#define opCMP 0xC2
139#define opCOMISS 0x2F
140#define opCVTPI2PS 0x2A
141#define opCVTTPS2PI 0x2C
142#define opCVTPS2PI 0x2D
143#define opCVTPS2PD 0x5A
144#define opCVTDQ2PS 0x5B
145#define opCVTTPD2DQ 0xE6
146#define opDIV 0x5E
147#define opMAX 0x5F
148#define opMIN 0x5D
149#define opMUL 0x59
150#define opSQRT 0x51
151#define opSUB 0x5C
152#define opUCOMISS 0x2E
153
154// define EFlags bits
155#define ZF (1 << 6)
156#define PF (1 << 2)
157#define CF (1 << 0)
158
159// define the REX prefix bits
160#define REX_PREFIX 0x40
161#define REX_W 0x8
162#define REX_R 0x4
163#define REX_X 0x2
164#define REX_B 0x1
165
166
167// define the exception information record
168
169// constants for the status bits
170#define IEM_INEXACT 0x20
171#define IEM_UNDERFLOW 0x10
172#define IEM_OVERFLOW 0x08
173#define IEM_ZERODIVIDE 0x04
174#define IEM_DENORMAL 0x02
175#define IEM_INVALID 0x01
176#define IEM_MASK 0x3F
177
178#define IMM_INEXACT 0x1000
179#define IMM_UNDERFLOW 0x0800
180#define IMM_OVERFLOW 0x0400
181#define IMM_ZERODIVIDE 0x0200
182#define IMM_DENORMAL 0x0100
183#define IMM_INVALID 0x0080
184#define IMM_MASK 0x1F80
185
186/*****************************************************************/
187
188// Instruction forms
189
190// Type enumerations
191//
192
193typedef enum
194{
220
221// operand types
222typedef enum
223{
224 oEd, //General register dword mod R/M
225 oGd, //General register dword
226 oQq, // MMX quadword mod R/M
227 oVpd, // XMM register
232 oWpd, // XMM mod R/M
236 oWss
238
239// operand class
240typedef enum
241{
248} OpClass;
249
250// data types
251typedef enum
252{
253 dDW, // integer DWORD
254 dPD, // packed double precision
255 dPDI, // packed integer DWORD
256 dPS, // packed single precision
257 dQ, // integer quadword
258 dSD, // scalar double precision
259 dSS // scalar single precision
261
262/*****************************************************************/
263
264// Structure definitions
265//
266
267
268// define the format of the data used by
269// the FXSAVE and FXRSTOR commands
270typedef struct
271{
272 MMX80 mmx; // the mmx/fp register
273 unsigned short reserved[3]; // floating point regs are 80 bits
274} FPMMX;
275
276#if defined (_AMD64_)
277// x86-64 version
278typedef struct _FXMM_SAVE_AREA {
282 WORD OpCode;
285 DWORD Mxcsr;
287 FPMMX FMMXreg[8];
288 ML128 XMMreg[16];
290#else
291// 32 bit x86 version
292typedef struct _FXMM_SAVE_AREA {
308#endif
310
311/* This structure is used to access the excepting opcode */
312typedef struct {
313 unsigned char opcode;
314 unsigned char rmbyte;
315 union {
316 unsigned long long offset; // this will need work for x86-64
317 unsigned char imm8;
319
321
322// Define a SIMD exception flag type.
323// This is just like the _FPIEEE_EXCEPTION_FLAGS
324// except that it adds the denormal field.
325typedef struct {
326 unsigned int Inexact : 1;
327 unsigned int Underflow : 1;
328 unsigned int Overflow : 1;
329 unsigned int ZeroDivide : 1;
330 unsigned int InvalidOperation : 1;
331 unsigned int Denormal : 1;
333
334
335/* define the local simd record structures */
336typedef struct {
337 unsigned int RoundingMode;
341 PSIMD_OP opaddress; // points to 0F xx opcode
342 int curAddr; // used when parsing mod R/M byte
343 unsigned char prefix;
344 unsigned char opcode;
345 unsigned char rmbyte;
346 unsigned char immediate8;
347 // add a rex field for x86-64
348 unsigned char rex;
349 int eopcode; // encoded opcode (index for tables)
351 int op1_class; // XMM, MMX, or gen register
352 int op1_type; // data format
357 unsigned int mxcsr; // value of mscsr from context record.
361
363
364/* define a record for the operand form table */
365typedef struct {
366 int op1; // form of operand 1
367 int op2; // form of operand 2
369
r l[0]
Definition: byte_order.h:168
r reserved
Definition: btrfs.c:3006
int align(int length, int align)
Definition: dsound8.c:36
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLfloat f
Definition: glext.h:7540
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define d
Definition: ke_i.h:81
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
@ mmx
Definition: optimize.h:103
#define f2(x, y, z)
Definition: sha1.c:31
#define f1(x, y, z)
Definition: sha1.c:30
#define f3(x, y, z)
Definition: sha1.c:32
UINT64 QWORD
Definition: shimdbg.c:104
OpClass
Definition: simd.h:241
@ oMMXreg
Definition: simd.h:244
@ oXMMreg
Definition: simd.h:242
@ oXMMmrm
Definition: simd.h:243
@ oMMXmrm
Definition: simd.h:245
@ oGENreg
Definition: simd.h:246
@ oGENmrm
Definition: simd.h:247
SSESINGLE
Definition: simd.h:87
typedef __declspec(align(16)) struct
Definition: simd.h:84
UINT_PTR AWORD
Definition: simd.h:64
FXMM_SAVE_AREA * PFXMM_SAVE_AREA
Definition: simd.h:309
struct _SIMD_RECORD * _PSIMD_RECORD
SSEDOUBLE
Definition: simd.h:92
struct SIMD_OP * PSIMD_OP
unsigned _int64 QWORD
Definition: simd.h:76
OpType
Definition: simd.h:223
@ oVss
Definition: simd.h:231
@ oWpd
Definition: simd.h:232
@ oVpd
Definition: simd.h:227
@ oQq
Definition: simd.h:226
@ oWss
Definition: simd.h:236
@ oVsd
Definition: simd.h:230
@ oWpdi
Definition: simd.h:233
@ oGd
Definition: simd.h:225
@ oEd
Definition: simd.h:224
@ oWsd
Definition: simd.h:235
@ oWps
Definition: simd.h:234
@ oVps
Definition: simd.h:229
@ oVpdi
Definition: simd.h:228
InstType
Definition: simd.h:194
@ fVpdWpd
Definition: simd.h:200
@ fVpsQq
Definition: simd.h:206
@ fVssWss
Definition: simd.h:217
@ fVpdWpdi
Definition: simd.h:202
@ fGdWsd
Definition: simd.h:195
@ fVpdiWps
Definition: simd.h:205
@ fQqWpd
Definition: simd.h:197
@ fVpdQq
Definition: simd.h:199
@ fVsdWsd
Definition: simd.h:212
@ fVssEd
Definition: simd.h:215
@ fVpsWps
Definition: simd.h:209
@ fVssWsd
Definition: simd.h:216
@ fVsdEd
Definition: simd.h:211
@ fVsdWss
Definition: simd.h:214
@ fVpdiWpd
Definition: simd.h:204
@ fGdWss
Definition: simd.h:196
@ fVpdWps
Definition: simd.h:203
@ fVpsWpd
Definition: simd.h:207
@ fVpdWpdIb
Definition: simd.h:201
@ fVpsWpdi
Definition: simd.h:208
@ fVssWssIb
Definition: simd.h:218
@ fVsdWsdIb
Definition: simd.h:213
@ fQqWps
Definition: simd.h:198
@ fVpsWpsIb
Definition: simd.h:210
DataType
Definition: simd.h:252
@ dSD
Definition: simd.h:258
@ dQ
Definition: simd.h:257
@ dPD
Definition: simd.h:254
@ dSS
Definition: simd.h:259
@ dDW
Definition: simd.h:253
@ dPDI
Definition: simd.h:255
@ dPS
Definition: simd.h:256
struct _FXMM_SAVE_AREA FXMM_SAVE_AREA
Definition: simd.h:271
MMX80 mmx
Definition: simd.h:272
Definition: simd.h:312
unsigned long long offset
Definition: simd.h:316
unsigned char rmbyte
Definition: simd.h:314
unsigned char imm8
Definition: simd.h:317
unsigned char opcode
Definition: simd.h:313
WORD DataSelector
Definition: simd.h:301
ML128 XMMreg[8]
Definition: simd.h:306
WORD OpCode
Definition: simd.h:296
FPMMX FMMXreg[8]
Definition: simd.h:305
WORD TagWord
Definition: simd.h:295
WORD reserved1
Definition: simd.h:299
WORD StatusWord
Definition: simd.h:294
DWORD ErrorOffset
Definition: simd.h:297
WORD ErrorSelector
Definition: simd.h:298
WORD ControlWord
Definition: simd.h:293
DWORD DataOffset
Definition: simd.h:300
DWORD reserved3
Definition: simd.h:304
WORD reserved2
Definition: simd.h:302
DWORD Mxcsr
Definition: simd.h:303
unsigned int Overflow
Definition: simd.h:328
unsigned int Underflow
Definition: simd.h:327
unsigned int Denormal
Definition: simd.h:331
unsigned int Inexact
Definition: simd.h:326
unsigned int ZeroDivide
Definition: simd.h:329
unsigned int InvalidOperation
Definition: simd.h:330
unsigned int RoundingMode
Definition: simd.h:337
int eopcode
Definition: simd.h:349
ML128 * op2_ptr
Definition: simd.h:360
int op_form
Definition: simd.h:350
unsigned char opcode
Definition: simd.h:344
_SIMD_EXCEPTION_FLAGS Cause
Definition: simd.h:338
ML128 op1_value
Definition: simd.h:358
int commiss_val
Definition: simd.h:356
int is_commiss
Definition: simd.h:355
int op1_class
Definition: simd.h:351
_SIMD_EXCEPTION_FLAGS Status
Definition: simd.h:340
unsigned char rmbyte
Definition: simd.h:345
ML128 op2_value
Definition: simd.h:359
int curAddr
Definition: simd.h:342
unsigned char prefix
Definition: simd.h:343
unsigned char immediate8
Definition: simd.h:346
int op2_type
Definition: simd.h:354
_SIMD_EXCEPTION_FLAGS Enable
Definition: simd.h:339
int op2_class
Definition: simd.h:353
int op1_type
Definition: simd.h:352
PSIMD_OP opaddress
Definition: simd.h:341
unsigned int mxcsr
Definition: simd.h:357
unsigned char rex
Definition: simd.h:348
Definition: simd.h:79
double f
Definition: simd.h:80
Definition: simd.h:67
unsigned long long l
Definition: simd.h:69
float f
Definition: simd.h:68
Definition: simd.h:101
__m128 m
Definition: simd.h:102
__m128i mi
Definition: simd.h:104
__m128d md
Definition: simd.h:103
Definition: simd.h:115