enc_defs_ext.h revision 0c2dc522d0e120f346cf0a40c8cf0c93346131c2
1/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _ENCODER_DEFS_EXT_H_
18#define _ENCODER_DEFS_EXT_H_
19
20
21// Used to isolate experimental or being tuned encoder into a separate
22// namespace so it can coexist with a stable one in the same bundle.
23#ifdef ENCODER_ISOLATE
24    #define ENCODER_NAMESPACE_START namespace enc_ia32 {
25    #define ENCODER_NAMESPACE_END };
26#else
27    #define ENCODER_NAMESPACE_START
28    #define ENCODER_NAMESPACE_END
29#endif
30
31ENCODER_NAMESPACE_START
32typedef enum OpndSize {
33    /**
34     * A change must be balanced with at least the following places:
35     *              Ia32IRConstants.h :: getByteSize() uses some presumptions about OpndSize_ values
36     *              Ia32::Constraint-s use the OpndSize as a mask
37     *              encoder.cpp & encoder_master_info.cpp uses OpndSize as an index for hashing
38     *              - perhaps there are much more places
39     */
40    OpndSize_Null           = 0,
41    OpndSize_8             = 0x01,
42    OpndSize_16            = 0x02,
43    OpndSize_32            = 0x04,
44    OpndSize_64            = 0x08,
45#if !defined(TESTING_ENCODER)
46    OpndSize_80            = 0x10,
47    OpndSize_128           = 0x20,
48#endif
49    OpndSize_Max,
50    OpndSize_Any            = 0x3F,
51    OpndSize_Default        = OpndSize_Any
52} OpndSize;
53
54/**
55 * Conditional mnemonics.
56 * The values match the 'real' (==processor's) values of the appropriate
57 * condition values used in the opcodes.
58 */
59typedef enum ConditionMnemonic {
60
61    ConditionMnemonic_O=0,
62    ConditionMnemonic_NO=1,
63    ConditionMnemonic_B=2, ConditionMnemonic_NAE=ConditionMnemonic_B, ConditionMnemonic_C=ConditionMnemonic_B,
64    ConditionMnemonic_NB=3, ConditionMnemonic_AE=ConditionMnemonic_NB, ConditionMnemonic_NC=ConditionMnemonic_NB,
65    ConditionMnemonic_Z=4, ConditionMnemonic_E=ConditionMnemonic_Z,
66    ConditionMnemonic_NZ=5, ConditionMnemonic_NE=ConditionMnemonic_NZ,
67    ConditionMnemonic_BE=6, ConditionMnemonic_NA=ConditionMnemonic_BE,
68    ConditionMnemonic_NBE=7, ConditionMnemonic_A=ConditionMnemonic_NBE,
69
70    ConditionMnemonic_S=8,
71    ConditionMnemonic_NS=9,
72    ConditionMnemonic_P=10, ConditionMnemonic_PE=ConditionMnemonic_P,
73    ConditionMnemonic_NP=11, ConditionMnemonic_PO=ConditionMnemonic_NP,
74    ConditionMnemonic_L=12, ConditionMnemonic_NGE=ConditionMnemonic_L,
75    ConditionMnemonic_NL=13, ConditionMnemonic_GE=ConditionMnemonic_NL,
76    ConditionMnemonic_LE=14, ConditionMnemonic_NG=ConditionMnemonic_LE,
77    ConditionMnemonic_NLE=15, ConditionMnemonic_G=ConditionMnemonic_NLE,
78    ConditionMnemonic_Count=16
79} ConditionMnemonic;
80
81
82#define CCM(prefix,cond) Mnemonic_##prefix##cond=Mnemonic_##prefix##cc+ConditionMnemonic_##cond
83
84//=========================================================================================================
85typedef enum Mnemonic {
86
87Mnemonic_NULL=0, Mnemonic_Null=Mnemonic_NULL,
88Mnemonic_ADC,                           // Add with Carry
89Mnemonic_ADD,                           // Add
90Mnemonic_ADDSD,                         // Add Scalar Double-Precision Floating-Point Values
91Mnemonic_ADDSS,                         // Add Scalar Single-Precision Floating-Point Values
92Mnemonic_AND,                           // Logical AND
93
94Mnemonic_BSF,                           // Bit scan forward
95Mnemonic_BSR,                           // Bit scan reverse
96
97Mnemonic_CALL,                          // Call Procedure
98Mnemonic_CMC,                           // Complement Carry Flag
99Mnemonic_CWD, Mnemonic_CDQ=Mnemonic_CWD,// Convert Word to Doubleword/Convert Doubleword to Qua T dword
100Mnemonic_CMOVcc,                        // Conditional Move
101    CCM(CMOV,O),
102    CCM(CMOV,NO),
103    CCM(CMOV,B), CCM(CMOV,NAE), CCM(CMOV,C),
104    CCM(CMOV,NB), CCM(CMOV,AE), CCM(CMOV,NC),
105    CCM(CMOV,Z), CCM(CMOV,E),
106    CCM(CMOV,NZ), CCM(CMOV,NE),
107    CCM(CMOV,BE), CCM(CMOV,NA),
108    CCM(CMOV,NBE), CCM(CMOV,A),
109
110    CCM(CMOV,S),
111    CCM(CMOV,NS),
112    CCM(CMOV,P), CCM(CMOV,PE),
113    CCM(CMOV,NP), CCM(CMOV,PO),
114    CCM(CMOV,L), CCM(CMOV,NGE),
115    CCM(CMOV,NL), CCM(CMOV,GE),
116    CCM(CMOV,LE), CCM(CMOV,NG),
117    CCM(CMOV,NLE), CCM(CMOV,G),
118
119Mnemonic_CMP,                           // Compare Two Operands
120Mnemonic_CMPXCHG,                       // Compare and exchange
121Mnemonic_CMPXCHG8B,                     // Compare and Exchange 8 Bytes
122Mnemonic_CMPSB,                         // Compare Two Bytes at DS:ESI and ES:EDI
123Mnemonic_CMPSW,                         // Compare Two Words at DS:ESI and ES:EDI
124Mnemonic_CMPSD,                         // Compare Two Doublewords at DS:ESI and ES:EDI
125//
126// double -> float
127Mnemonic_CVTSD2SS,                      // Convert Scalar Double-Precision Floating-Point Value to Scalar Single-Precision Floating-Point Value
128// double -> I_32
129Mnemonic_CVTSD2SI,                      // Convert Scalar Double-Precision Floating-Point Value to Doubleword Integer
130// double [truncated] -> I_32
131Mnemonic_CVTTSD2SI,                     // Convert with Truncation Scalar Double-Precision Floating-Point Value to Signed Doubleword Integer
132//
133// float -> double
134Mnemonic_CVTSS2SD,                      // Convert Scalar Single-Precision Floating-Point Value to Scalar Double-Precision Floating-Point Value
135// float -> I_32
136Mnemonic_CVTSS2SI,                      // Convert Scalar Single-Precision Floating-Point Value to Doubleword Integer
137// float [truncated] -> I_32
138Mnemonic_CVTTSS2SI,                     // Convert with Truncation Scalar Single-Precision Floating-Point Value to Doubleword Integer
139//
140// I_32 -> double
141Mnemonic_CVTSI2SD,                      // Convert Doubleword Integer to Scalar Double-Precision Floating-Point Value
142// I_32 -> float
143Mnemonic_CVTSI2SS,                      // Convert Doubleword Integer to Scalar Single-Precision Floating-Point Value
144
145Mnemonic_COMISD,                        // Compare Scalar Ordered Double-Precision Floating-Point Values and Set EFLAGS
146Mnemonic_COMISS,                        // Compare Scalar Ordered Single-Precision Floating-Point Values and Set EFLAGS
147Mnemonic_DEC,                           // Decrement by 1
148//Mnemonic_DIV,                         // Unsigned Divide
149Mnemonic_DIVSD,                         // Divide Scalar Double-Precision Floating-Point Values
150Mnemonic_DIVSS,                         // Divide Scalar Single-Precision Floating-Point Values
151
152#ifdef _HAVE_MMX_
153Mnemonic_EMMS,                          // Empty MMX Technology State
154#endif
155
156Mnemonic_ENTER,                         // ENTER-Make Stack Frame for Procedure Parameters
157Mnemonic_FLDCW,                         // Load FPU control word
158Mnemonic_FADDP,
159Mnemonic_FLDZ,
160Mnemonic_FADD,
161Mnemonic_FSUBP,
162Mnemonic_FSUB,
163Mnemonic_FISUB,
164Mnemonic_FMUL,
165Mnemonic_FMULP,
166Mnemonic_FDIVP,
167Mnemonic_FDIV,
168Mnemonic_FUCOM,
169Mnemonic_FUCOMI,
170Mnemonic_FUCOMP,
171Mnemonic_FUCOMIP,
172Mnemonic_FUCOMPP,
173Mnemonic_FRNDINT,
174Mnemonic_FNSTCW,                        // Store FPU control word
175Mnemonic_FSTSW,                         // Store FPU status word
176Mnemonic_FNSTSW,                         // Store FPU status word
177//Mnemonic_FDECSTP,                     // Decrement Stack-Top Pointer
178Mnemonic_FILD,                          // Load Integer
179Mnemonic_FLD,                           // Load Floating Point Value
180Mnemonic_FLDLG2,
181Mnemonic_FLDLN2,
182Mnemonic_FLD1,
183
184Mnemonic_FCLEX,                         // Clear Exceptions
185Mnemonic_FCHS,                          // Change sign of ST0
186Mnemonic_FNCLEX,                        // Clear Exceptions
187
188//Mnemonic_FINCSTP,                     // Increment Stack-Top Pointer
189Mnemonic_FIST,                          // Store Integer
190Mnemonic_FISTP,                         // Store Integer, pop FPU stack
191Mnemonic_FISTTP,                        // Store Integer with Truncation
192Mnemonic_FPREM,                         // Partial Remainder
193Mnemonic_FPREM1,                        // Partial Remainder
194Mnemonic_FST,                           // Store Floating Point Value
195Mnemonic_FSTP,                          // Store Floating Point Value and pop the FP stack
196Mnemonic_FSQRT,                         //Computes the square root of the source value in the stack and pop the FP stack
197Mnemonic_FABS,                          //Computes the absolute value of the source value in the stack and pop the FP stack
198Mnemonic_FSIN,                          //Computes the sine of the source value in the stack and pop the FP stack
199Mnemonic_FCOS,                          //Computes the cosine of the source value in the stack and pop the FP stack
200Mnemonic_FPTAN,                         //Computes the tangent of the source value in the stack and pop the FP stack
201Mnemonic_FYL2X,
202Mnemonic_FYL2XP1,
203Mnemonic_F2XM1,
204Mnemonic_FPATAN,
205Mnemonic_FXCH,
206Mnemonic_FSCALE,
207
208Mnemonic_XCHG,
209Mnemonic_DIV,                           // Unsigned Divide
210Mnemonic_IDIV,                          // Signed Divide
211Mnemonic_MUL,                           // Unsigned Multiply
212Mnemonic_IMUL,                          // Signed Multiply
213Mnemonic_INC,                           // Increment by 1
214Mnemonic_INT3,                          // Call break point
215Mnemonic_Jcc,                           // Jump if Condition Is Met
216    CCM(J,O),
217    CCM(J,NO),
218    CCM(J,B), CCM(J,NAE), CCM(J,C),
219    CCM(J,NB), CCM(J,AE), CCM(J,NC),
220    CCM(J,Z), CCM(J,E),
221    CCM(J,NZ), CCM(J,NE),
222    CCM(J,BE), CCM(J,NA),
223    CCM(J,NBE), CCM(J,A),
224    CCM(J,S),
225    CCM(J,NS),
226    CCM(J,P), CCM(J,PE),
227    CCM(J,NP), CCM(J,PO),
228    CCM(J,L), CCM(J,NGE),
229    CCM(J,NL), CCM(J,GE),
230    CCM(J,LE), CCM(J,NG),
231    CCM(J,NLE), CCM(J,G),
232Mnemonic_JMP,                           // Jump
233Mnemonic_LEA,                           // Load Effective Address
234Mnemonic_LEAVE,                         // High Level Procedure Exit
235Mnemonic_LOOP,                          // Loop according to ECX counter
236Mnemonic_LOOPE,                          // Loop according to ECX counter
237Mnemonic_LOOPNE, Mnemonic_LOOPNZ = Mnemonic_LOOPNE, // Loop according to ECX
238Mnemonic_LAHF,                          // Load Flags into AH
239Mnemonic_MOV,                           // Move
240Mnemonic_MOVD,                          // Move Double word
241Mnemonic_MOVQ,                          // Move Quadword
242/*Mnemonic_MOVS,                        // Move Data from String to String*/
243// MOVS is a special case: see encoding table for more details,
244Mnemonic_MOVS8, Mnemonic_MOVS16, Mnemonic_MOVS32, Mnemonic_MOVS64,
245//
246Mnemonic_MOVAPD,                         // Move Scalar Double-Precision Floating-Point Value
247Mnemonic_MOVSD,                         // Move Scalar Double-Precision Floating-Point Value
248Mnemonic_MOVSS,                         // Move Scalar Single-Precision Floating-Point Values
249Mnemonic_MOVSX,                         // Move with Sign-Extension
250Mnemonic_MOVZX,                         // Move with Zero-Extend
251//Mnemonic_MUL,                         // Unsigned Multiply
252Mnemonic_MULSD,                         // Multiply Scalar Double-Precision Floating-Point Values
253Mnemonic_MULSS,                         // Multiply Scalar Single-Precision Floating-Point Values
254Mnemonic_NEG,                           // Two's Complement Negation
255Mnemonic_NOP,                           // No Operation
256Mnemonic_NOT,                           // One's Complement Negation
257Mnemonic_OR,                            // Logical Inclusive OR
258Mnemonic_PREFETCH,                      // prefetch
259
260#if 1 //def _HAVE_MMX_
261    Mnemonic_PADDQ,                     // Add Packed Quadword Integers
262    Mnemonic_PAND,                      // Logical AND
263    Mnemonic_POR,                       // Bitwise Logical OR
264    Mnemonic_PSUBQ,                     // Subtract Packed Quadword Integers
265#endif
266Mnemonic_PANDN,
267Mnemonic_PSLLQ,
268Mnemonic_PSRLQ,
269Mnemonic_PXOR,                          // Logical Exclusive OR
270Mnemonic_POP,                           // Pop a Value from the Stack
271Mnemonic_POPFD,                         // Pop a Value of EFLAGS register from the Stack
272Mnemonic_PUSH,                          // Push Word or Doubleword Onto the Stack
273Mnemonic_PUSHFD,                        // Push EFLAGS Doubleword Onto the Stack
274Mnemonic_RET,                           // Return from Procedure
275
276Mnemonic_SETcc,                         // Set Byte on Condition
277    CCM(SET,O),
278    CCM(SET,NO),
279    CCM(SET,B), CCM(SET,NAE), CCM(SET,C),
280    CCM(SET,NB), CCM(SET,AE), CCM(SET,NC),
281    CCM(SET,Z), CCM(SET,E),
282    CCM(SET,NZ), CCM(SET,NE),
283    CCM(SET,BE), CCM(SET,NA),
284    CCM(SET,NBE), CCM(SET,A),
285    CCM(SET,S),
286    CCM(SET,NS),
287    CCM(SET,P), CCM(SET,PE),
288    CCM(SET,NP), CCM(SET,PO),
289    CCM(SET,L), CCM(SET,NGE),
290    CCM(SET,NL), CCM(SET,GE),
291    CCM(SET,LE), CCM(SET,NG),
292    CCM(SET,NLE), CCM(SET,G),
293
294Mnemonic_SAL, Mnemonic_SHL=Mnemonic_SAL,// Shift left
295Mnemonic_SAR,                           // Unsigned shift right
296Mnemonic_ROR,                           // Rotate right
297Mnemonic_RCR,                           // Rotate right through CARRY flag
298Mnemonic_ROL,                           // Rotate left
299Mnemonic_RCL,                           // Rotate left through CARRY flag
300Mnemonic_SHR,                           // Signed shift right
301Mnemonic_SHRD,                          // Double Precision Shift Right
302Mnemonic_SHLD,                          // Double Precision Shift Left
303
304Mnemonic_SBB,                           // Integer Subtraction with Borrow
305Mnemonic_SUB,                           // Subtract
306Mnemonic_SUBSD,                         // Subtract Scalar Double-Precision Floating-Point Values
307Mnemonic_SUBSS,                         // Subtract Scalar Single-Precision Floating-Point Values
308
309Mnemonic_TEST,                          // Logical Compare
310
311Mnemonic_UCOMISD,                       // Unordered Compare Scalar Double-Precision Floating-Point Values and Set EFLAGS
312Mnemonic_UCOMISS,                       // Unordered Compare Scalar Single-Precision Floating-Point Values and Set EFLAGS
313
314Mnemonic_XOR,                           // Logical Exclusive OR
315//
316// packed things,
317//
318Mnemonic_XORPD,                         // Bitwise Logical XOR for Double-Precision Floating-Point Values
319Mnemonic_XORPS,                         // Bitwise Logical XOR for Single-Precision Floating-Point Values
320
321Mnemonic_CVTDQ2PD,                      // Convert Packed Doubleword Integers to Packed Double-Precision Floating-Point Values
322Mnemonic_CVTTPD2DQ,                     // Convert with Truncation Packed Double-Precision Floating-Point Values to Packed Doubleword Integers
323
324Mnemonic_CVTDQ2PS,                      // Convert Packed Doubleword Integers to Packed Single-Precision Floating-Point Values
325Mnemonic_CVTTPS2DQ,                     // Convert with Truncation Packed Single-Precision Floating-Point Values to Packed Doubleword Integers
326//
327// String operations
328//
329Mnemonic_STD,                           // Set direction flag
330Mnemonic_CLD,                           // Clear direction flag
331Mnemonic_SCAS,                          // Scan string
332Mnemonic_STOS,                          // Store string
333
334//
335Mnemonic_WAIT,                          // Check pending pending unmasked floating-point exception
336//
337Mnemonic_Count
338} Mnemonic;
339
340#undef CCM
341
342ENCODER_NAMESPACE_END
343
344#endif  // ifndef _ENCODER_DEFS_EXT_H_
345