| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* | 7 /* |
| 8 * This file contains common parts of x86-32 and x86-64 internals (inline | 8 * This file contains common parts of x86-32 and x86-64 internals (inline |
| 9 * functions and defines). | 9 * functions and defines). |
| 10 */ | 10 */ |
| 11 | 11 |
| 12 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_DECODER_INTERNAL_H_ | 12 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_DECODER_INTERNAL_H_ |
| 13 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_DECODER_INTERNAL_H_ | 13 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_DECODER_INTERNAL_H_ |
| 14 | 14 |
| 15 #include "native_client/src/trusted/validator_ragel/unreviewed/decoding.h" | 15 #include "native_client/src/trusted/validator_ragel/decoding.h" |
| 16 | 16 |
| 17 /* | 17 /* |
| 18 * Set of macroses used in actions defined in parse_instruction.rl to pull | 18 * Set of macroses used in actions defined in parse_instruction.rl to pull |
| 19 * parts of the instruction from a byte stream and store them for future use. | 19 * parts of the instruction from a byte stream and store them for future use. |
| 20 */ | 20 */ |
| 21 #define GET_REX_PREFIX() instruction.prefix.rex | |
| 22 #define GET_VEX_PREFIX2() vex_prefix2 | |
| 23 #define GET_VEX_PREFIX3() vex_prefix3 | 21 #define GET_VEX_PREFIX3() vex_prefix3 |
| 24 #define SET_VEX_PREFIX3(P) vex_prefix3 = (P) | 22 #define SET_VEX_PREFIX3(PREFIX_BYTE) vex_prefix3 = (PREFIX_BYTE) |
| 25 #define SET_DATA16_PREFIX(S) instruction.prefix.data16 = (S) | 23 #define SET_DATA16_PREFIX(STATUS) instruction.prefix.data16 = (STATUS) |
| 26 #define SET_LOCK_PREFIX(S) instruction.prefix.lock = (S) | 24 #define SET_LOCK_PREFIX(STATUS) instruction.prefix.lock = (STATUS) |
| 27 #define SET_REPZ_PREFIX(S) instruction.prefix.repz = (S) | 25 #define SET_REPZ_PREFIX(STATUS) instruction.prefix.repz = (STATUS) |
| 28 #define SET_REPNZ_PREFIX(S) instruction.prefix.repnz = (S) | 26 #define SET_REPNZ_PREFIX(STATUS) instruction.prefix.repnz = (STATUS) |
| 29 #define SET_BRANCH_TAKEN(S) instruction.prefix.branch_taken = (S) | 27 #define SET_BRANCH_TAKEN(STATUS) instruction.prefix.branch_taken = (STATUS) |
| 30 #define SET_BRANCH_NOT_TAKEN(S) instruction.prefix.branch_not_taken = (S) | 28 #define SET_BRANCH_NOT_TAKEN(STATUS) \ |
| 31 #define SET_INSTRUCTION_NAME(N) instruction.name = (N) | 29 instruction.prefix.branch_not_taken = (STATUS) |
| 32 #define GET_OPERAND_NAME(N) instruction.operands[(N)].name | 30 #define SET_INSTRUCTION_NAME(NAME) instruction.name = (NAME) |
| 33 #define SET_OPERAND_NAME(N, S) instruction.operands[(N)].name = (S) | 31 #define GET_OPERAND_NAME(INDEX) instruction.operands[(INDEX)].name |
| 34 #define SET_OPERAND_FORMAT(N, S) instruction.operands[(N)].format = (S) | 32 #define SET_OPERAND_NAME(INDEX, NAME) \ |
| 35 #define SET_OPERANDS_COUNT(N) instruction.operands_count = (N) | 33 instruction.operands[(INDEX)].name = (NAME) |
| 36 #define SET_MODRM_BASE(N) instruction.rm.base = (N) | 34 #define SET_OPERAND_FORMAT(INDEX, FORMAT) \ |
| 37 #define SET_MODRM_INDEX(N) instruction.rm.index = (N) | 35 instruction.operands[(INDEX)].format = (FORMAT) |
| 38 #define SET_MODRM_SCALE(S) instruction.rm.scale = (S) | 36 #define SET_OPERANDS_COUNT(COUNT) instruction.operands_count = (COUNT) |
| 39 #define SET_DISP_TYPE(T) instruction.rm.disp_type = (T) | 37 #define SET_MODRM_BASE(REG_NUMBER) instruction.rm.base = (REG_NUMBER) |
| 40 #define SET_DISP_PTR(P) \ | 38 #define SET_MODRM_INDEX(REG_NUMBER) instruction.rm.index = (REG_NUMBER) |
| 41 instruction.rm.offset = DecodeDisplacementValue(instruction.rm.disp_type, (P)) | 39 #define SET_MODRM_SCALE(VALUE) instruction.rm.scale = (VALUE) |
| 42 #define SET_IMM_TYPE(T) imm_operand = (T) | 40 #define SET_DISPLACEMENT_FORMAT(FORMAT) instruction.rm.disp_type = (FORMAT) |
| 43 #define SET_IMM_PTR(P) \ | 41 #define SET_DISPLACEMENT_POINTER(POINTER) \ |
| 44 instruction.imm[0] = DecodeImmediateValue(imm_operand, (P)) | 42 instruction.rm.offset = \ |
| 45 #define SET_IMM2_TYPE(T) imm2_operand = (T) | 43 DecodeDisplacementValue(instruction.rm.disp_type, (POINTER)) |
| 46 #define SET_IMM2_PTR(P) \ | 44 #define SET_IMMEDIATE_FORMAT(FORMAT) imm_operand = (FORMAT) |
| 47 instruction.imm[1] = DecodeImmediateValue(imm2_operand, (P)) | 45 #define SET_IMMEDIATE_POINTER(POINTER) \ |
| 48 #define SET_CPU_FEATURE(F) | 46 instruction.imm[0] = DecodeImmediateValue(imm_operand, (POINTER)) |
| 49 #define SET_ATT_INSTRUCTION_SUFFIX(S) instruction.att_instruction_suffix = (S) | 47 #define SET_SECOND_IMMEDIATE_FORMAT(FORMAT) imm2_operand = (FORMAT) |
| 48 #define SET_SECOND_IMMEDIATE_POINTER(POINTER) \ |
| 49 instruction.imm[1] = DecodeImmediateValue(imm2_operand, (POINTER)) |
| 50 /* We don't support CPUID feature detection in decoder. */ |
| 51 #define SET_CPU_FEATURE(FEATURE) |
| 52 #define SET_ATT_INSTRUCTION_SUFFIX(SUFFIX_STRING) \ |
| 53 instruction.att_instruction_suffix = (SUFFIX_STRING) |
| 50 | 54 |
| 51 /* | 55 /* |
| 52 * Immediate mode: size of the instruction's immediate operand. Note that there | 56 * Immediate mode: size of the instruction's immediate operand. Note that there |
| 53 * IMMNONE (which means there are no immediate operand) and IMM2 (which is | 57 * IMMNONE (which means there are no immediate operand) and IMM2 (which is |
| 54 * two-bit immediate which shares it's byte with other operands). | 58 * two-bit immediate which shares it's byte with other operands). |
| 55 */ | 59 */ |
| 56 enum ImmediateMode { | 60 enum ImmediateMode { |
| 57 IMMNONE, | 61 IMMNONE, |
| 58 IMM2, | 62 IMM2, |
| 59 IMM8, | 63 IMM8, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 84 case IMM8: return AnyFieldValue8bit(imm_ptr); | 88 case IMM8: return AnyFieldValue8bit(imm_ptr); |
| 85 case IMM16: return AnyFieldValue16bit(imm_ptr); | 89 case IMM16: return AnyFieldValue16bit(imm_ptr); |
| 86 case IMM32: return AnyFieldValue32bit(imm_ptr); | 90 case IMM32: return AnyFieldValue32bit(imm_ptr); |
| 87 case IMM64: return AnyFieldValue64bit(imm_ptr); | 91 case IMM64: return AnyFieldValue64bit(imm_ptr); |
| 88 } | 92 } |
| 89 assert(FALSE); | 93 assert(FALSE); |
| 90 return 0; | 94 return 0; |
| 91 } | 95 } |
| 92 | 96 |
| 93 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_DECODER_INTERNAL_H_ */ | 97 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_DECODER_INTERNAL_H_ */ |
| OLD | NEW |