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 31 ENCODER_NAMESPACE_START 32 typedef 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 */ 59 typedef 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 //========================================================================================================= 85 typedef enum Mnemonic { 86 87 Mnemonic_NULL=0, Mnemonic_Null=Mnemonic_NULL, 88 Mnemonic_ADC, // Add with Carry 89 Mnemonic_ADD, // Add 90 Mnemonic_ADDSD, // Add Scalar Double-Precision Floating-Point Values 91 Mnemonic_ADDSS, // Add Scalar Single-Precision Floating-Point Values 92 Mnemonic_AND, // Logical AND 93 94 Mnemonic_BSF, // Bit scan forward 95 Mnemonic_BSR, // Bit scan reverse 96 97 Mnemonic_CALL, // Call Procedure 98 Mnemonic_CMC, // Complement Carry Flag 99 Mnemonic_CWD, Mnemonic_CDQ=Mnemonic_CWD,// Convert Word to Doubleword/Convert Doubleword to Qua T dword 100 Mnemonic_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 119 Mnemonic_CMP, // Compare Two Operands 120 Mnemonic_CMPXCHG, // Compare and exchange 121 Mnemonic_CMPXCHG8B, // Compare and Exchange 8 Bytes 122 Mnemonic_CMPSB, // Compare Two Bytes at DS:ESI and ES:EDI 123 Mnemonic_CMPSW, // Compare Two Words at DS:ESI and ES:EDI 124 Mnemonic_CMPSD, // Compare Two Doublewords at DS:ESI and ES:EDI 125 // 126 // double -> float 127 Mnemonic_CVTSD2SS, // Convert Scalar Double-Precision Floating-Point Value to Scalar Single-Precision Floating-Point Value 128 // double -> I_32 129 Mnemonic_CVTSD2SI, // Convert Scalar Double-Precision Floating-Point Value to Doubleword Integer 130 // double [truncated] -> I_32 131 Mnemonic_CVTTSD2SI, // Convert with Truncation Scalar Double-Precision Floating-Point Value to Signed Doubleword Integer 132 // 133 // float -> double 134 Mnemonic_CVTSS2SD, // Convert Scalar Single-Precision Floating-Point Value to Scalar Double-Precision Floating-Point Value 135 // float -> I_32 136 Mnemonic_CVTSS2SI, // Convert Scalar Single-Precision Floating-Point Value to Doubleword Integer 137 // float [truncated] -> I_32 138 Mnemonic_CVTTSS2SI, // Convert with Truncation Scalar Single-Precision Floating-Point Value to Doubleword Integer 139 // 140 // I_32 -> double 141 Mnemonic_CVTSI2SD, // Convert Doubleword Integer to Scalar Double-Precision Floating-Point Value 142 // I_32 -> float 143 Mnemonic_CVTSI2SS, // Convert Doubleword Integer to Scalar Single-Precision Floating-Point Value 144 145 Mnemonic_COMISD, // Compare Scalar Ordered Double-Precision Floating-Point Values and Set EFLAGS 146 Mnemonic_COMISS, // Compare Scalar Ordered Single-Precision Floating-Point Values and Set EFLAGS 147 Mnemonic_DEC, // Decrement by 1 148 //Mnemonic_DIV, // Unsigned Divide 149 Mnemonic_DIVSD, // Divide Scalar Double-Precision Floating-Point Values 150 Mnemonic_DIVSS, // Divide Scalar Single-Precision Floating-Point Values 151 152 #ifdef _HAVE_MMX_ 153 Mnemonic_EMMS, // Empty MMX Technology State 154 #endif 155 156 Mnemonic_ENTER, // ENTER-Make Stack Frame for Procedure Parameters 157 Mnemonic_FLDCW, // Load FPU control word 158 Mnemonic_FADDP, 159 Mnemonic_FLDZ, 160 Mnemonic_FADD, 161 Mnemonic_FSUBP, 162 Mnemonic_FSUB, 163 Mnemonic_FISUB, 164 Mnemonic_FMUL, 165 Mnemonic_FMULP, 166 Mnemonic_FDIVP, 167 Mnemonic_FDIV, 168 Mnemonic_FUCOM, 169 Mnemonic_FUCOMI, 170 Mnemonic_FUCOMP, 171 Mnemonic_FUCOMIP, 172 Mnemonic_FUCOMPP, 173 Mnemonic_FRNDINT, 174 Mnemonic_FNSTCW, // Store FPU control word 175 Mnemonic_FSTSW, // Store FPU status word 176 Mnemonic_FNSTSW, // Store FPU status word 177 //Mnemonic_FDECSTP, // Decrement Stack-Top Pointer 178 Mnemonic_FILD, // Load Integer 179 Mnemonic_FLD, // Load Floating Point Value 180 Mnemonic_FLDLG2, 181 Mnemonic_FLDLN2, 182 Mnemonic_FLD1, 183 184 Mnemonic_FCLEX, // Clear Exceptions 185 Mnemonic_FCHS, // Change sign of ST0 186 Mnemonic_FNCLEX, // Clear Exceptions 187 188 //Mnemonic_FINCSTP, // Increment Stack-Top Pointer 189 Mnemonic_FIST, // Store Integer 190 Mnemonic_FISTP, // Store Integer, pop FPU stack 191 Mnemonic_FISTTP, // Store Integer with Truncation 192 Mnemonic_FPREM, // Partial Remainder 193 Mnemonic_FPREM1, // Partial Remainder 194 Mnemonic_FST, // Store Floating Point Value 195 Mnemonic_FSTP, // Store Floating Point Value and pop the FP stack 196 Mnemonic_FSQRT, //Computes the square root of the source value in the stack and pop the FP stack 197 Mnemonic_FABS, //Computes the absolute value of the source value in the stack and pop the FP stack 198 Mnemonic_FSIN, //Computes the sine of the source value in the stack and pop the FP stack 199 Mnemonic_FCOS, //Computes the cosine of the source value in the stack and pop the FP stack 200 Mnemonic_FPTAN, //Computes the tangent of the source value in the stack and pop the FP stack 201 Mnemonic_FYL2X, 202 Mnemonic_FYL2XP1, 203 Mnemonic_F2XM1, 204 Mnemonic_FPATAN, 205 Mnemonic_FXCH, 206 Mnemonic_FSCALE, 207 208 Mnemonic_XCHG, 209 Mnemonic_DIV, // Unsigned Divide 210 Mnemonic_IDIV, // Signed Divide 211 Mnemonic_MUL, // Unsigned Multiply 212 Mnemonic_IMUL, // Signed Multiply 213 Mnemonic_INC, // Increment by 1 214 Mnemonic_INT3, // Call break point 215 Mnemonic_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), 232 Mnemonic_JMP, // Jump 233 Mnemonic_LEA, // Load Effective Address 234 Mnemonic_LEAVE, // High Level Procedure Exit 235 Mnemonic_LOOP, // Loop according to ECX counter 236 Mnemonic_LOOPE, // Loop according to ECX counter 237 Mnemonic_LOOPNE, Mnemonic_LOOPNZ = Mnemonic_LOOPNE, // Loop according to ECX 238 Mnemonic_LAHF, // Load Flags into AH 239 Mnemonic_MOV, // Move 240 Mnemonic_MOVD, // Move Double word 241 Mnemonic_MOVQ, // Move Quadword 242 /*Mnemonic_MOVS, // Move Data from String to String*/ 243 // MOVS is a special case: see encoding table for more details, 244 Mnemonic_MOVS8, Mnemonic_MOVS16, Mnemonic_MOVS32, Mnemonic_MOVS64, 245 // 246 Mnemonic_MOVAPD, // Move Scalar Double-Precision Floating-Point Value 247 Mnemonic_MOVSD, // Move Scalar Double-Precision Floating-Point Value 248 Mnemonic_MOVSS, // Move Scalar Single-Precision Floating-Point Values 249 Mnemonic_MOVSX, // Move with Sign-Extension 250 Mnemonic_MOVZX, // Move with Zero-Extend 251 //Mnemonic_MUL, // Unsigned Multiply 252 Mnemonic_MULSD, // Multiply Scalar Double-Precision Floating-Point Values 253 Mnemonic_MULSS, // Multiply Scalar Single-Precision Floating-Point Values 254 Mnemonic_NEG, // Two's Complement Negation 255 Mnemonic_NOP, // No Operation 256 Mnemonic_NOT, // One's Complement Negation 257 Mnemonic_OR, // Logical Inclusive OR 258 Mnemonic_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 266 Mnemonic_PANDN, 267 Mnemonic_PSLLQ, 268 Mnemonic_PSRLQ, 269 Mnemonic_PXOR, // Logical Exclusive OR 270 Mnemonic_POP, // Pop a Value from the Stack 271 Mnemonic_POPFD, // Pop a Value of EFLAGS register from the Stack 272 Mnemonic_PUSH, // Push Word or Doubleword Onto the Stack 273 Mnemonic_PUSHFD, // Push EFLAGS Doubleword Onto the Stack 274 Mnemonic_RET, // Return from Procedure 275 276 Mnemonic_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 294 Mnemonic_SAL, Mnemonic_SHL=Mnemonic_SAL,// Shift left 295 Mnemonic_SAR, // Unsigned shift right 296 Mnemonic_ROR, // Rotate right 297 Mnemonic_RCR, // Rotate right through CARRY flag 298 Mnemonic_ROL, // Rotate left 299 Mnemonic_RCL, // Rotate left through CARRY flag 300 Mnemonic_SHR, // Signed shift right 301 Mnemonic_SHRD, // Double Precision Shift Right 302 Mnemonic_SHLD, // Double Precision Shift Left 303 304 Mnemonic_SBB, // Integer Subtraction with Borrow 305 Mnemonic_SUB, // Subtract 306 Mnemonic_SUBSD, // Subtract Scalar Double-Precision Floating-Point Values 307 Mnemonic_SUBSS, // Subtract Scalar Single-Precision Floating-Point Values 308 309 Mnemonic_TEST, // Logical Compare 310 311 Mnemonic_UCOMISD, // Unordered Compare Scalar Double-Precision Floating-Point Values and Set EFLAGS 312 Mnemonic_UCOMISS, // Unordered Compare Scalar Single-Precision Floating-Point Values and Set EFLAGS 313 314 Mnemonic_XOR, // Logical Exclusive OR 315 // 316 // packed things, 317 // 318 Mnemonic_XORPD, // Bitwise Logical XOR for Double-Precision Floating-Point Values 319 Mnemonic_XORPS, // Bitwise Logical XOR for Single-Precision Floating-Point Values 320 321 Mnemonic_CVTDQ2PD, // Convert Packed Doubleword Integers to Packed Double-Precision Floating-Point Values 322 Mnemonic_CVTTPD2DQ, // Convert with Truncation Packed Double-Precision Floating-Point Values to Packed Doubleword Integers 323 324 Mnemonic_CVTDQ2PS, // Convert Packed Doubleword Integers to Packed Single-Precision Floating-Point Values 325 Mnemonic_CVTTPS2DQ, // Convert with Truncation Packed Single-Precision Floating-Point Values to Packed Doubleword Integers 326 // 327 // String operations 328 // 329 Mnemonic_STD, // Set direction flag 330 Mnemonic_CLD, // Clear direction flag 331 Mnemonic_SCAS, // Scan string 332 Mnemonic_STOS, // Store string 333 334 // 335 Mnemonic_WAIT, // Check pending pending unmasked floating-point exception 336 // 337 Mnemonic_Count 338 } Mnemonic; 339 340 #undef CCM 341 342 ENCODER_NAMESPACE_END 343 344 #endif // ifndef _ENCODER_DEFS_EXT_H_ 345