| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2011 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 /* Descriptors to model instructions, opcodes, and instruction operands. */ | 7 /* Descriptors to model instructions, opcodes, and instruction operands. */ |
| 8 | 8 |
| 9 #include "native_client/src/trusted/validator/x86/decoder/ncopcode_desc.h" | 9 #include "native_client/src/trusted/validator/x86/decoder/ncopcode_desc.h" |
| 10 | 10 |
| 11 #include <assert.h> | 11 #include <assert.h> |
| 12 #include <string.h> | 12 #include <string.h> |
| 13 | 13 |
| 14 #include "native_client/src/shared/utils/types.h" | 14 #include "native_client/src/shared/utils/types.h" |
| 15 #include "native_client/src/trusted/validator/x86/decoder/gen/ncopcode_prefix_im
pl.h" | 15 #include "native_client/src/trusted/validator/x86/decoder/gen/ncopcode_prefix_im
pl.h" |
| 16 #include "native_client/src/trusted/validator/x86/decoder/gen/ncopcode_insts_imp
l.h" | 16 #include "native_client/src/trusted/validator/x86/decoder/gen/ncopcode_insts_imp
l.h" |
| 17 #include "native_client/src/trusted/validator/x86/decoder/gen/ncopcode_opcode_fl
ags_impl.h" | 17 #include "native_client/src/trusted/validator/x86/decoder/gen/ncopcode_opcode_fl
ags_impl.h" |
| 18 #include "native_client/src/trusted/validator/x86/decoder/gen/ncopcode_operand_k
ind_impl.h" | 18 #include "native_client/src/trusted/validator/x86/decoder/gen/ncopcode_operand_k
ind_impl.h" |
| 19 #include "native_client/src/trusted/validator/x86/decoder/gen/ncopcode_operand_f
lag_impl.h" | 19 #include "native_client/src/trusted/validator/x86/decoder/gen/ncopcode_operand_f
lag_impl.h" |
| 20 #include "native_client/src/trusted/validator/x86/decoder/nc_decode_tables.h" | 20 #include "native_client/src/trusted/validator/x86/decoder/nc_decode_tables.h" |
| 21 | 21 |
| 22 #include "native_client/src/trusted/validator/x86/decoder/ncopcode_desc_inl.c" |
| 23 |
| 22 uint8_t NaClGetOpcodeInModRm(uint8_t opcode_ext) { | 24 uint8_t NaClGetOpcodeInModRm(uint8_t opcode_ext) { |
| 23 return opcode_ext & 0x0F; | 25 return opcode_ext & 0x0F; |
| 24 } | 26 } |
| 25 | 27 |
| 26 uint8_t NaClGetOpcodeInModRmRm(uint8_t opcode_ext) { | 28 uint8_t NaClGetOpcodeInModRmRm(uint8_t opcode_ext) { |
| 27 return (opcode_ext >> 4) & 0x0F; | 29 return (opcode_ext >> 4) & 0x0F; |
| 28 } | 30 } |
| 29 | 31 |
| 30 uint8_t NaClGetOpcodePlusR(uint8_t opcode_ext) { | 32 uint8_t NaClGetOpcodePlusR(uint8_t opcode_ext) { |
| 31 return opcode_ext & 0x0F; | 33 return opcode_ext & 0x0F; |
| 32 } | 34 } |
| 33 | 35 |
| 34 uint8_t NaClGetInstNumberOperands(const NaClInst* inst) { | 36 uint8_t NaClGetInstNumberOperands(const NaClInst* inst) { |
| 35 return inst->num_operands; | 37 return NaClGetInstNumberOperandsInline(inst); |
| 36 } | 38 } |
| 37 | 39 |
| 38 const NaClOp* NaClGetInstOperand(const NaClDecodeTables* tables, | 40 const NaClOp* NaClGetInstOperand(const NaClDecodeTables* tables, |
| 39 const NaClInst* inst, uint8_t index) { | 41 const NaClInst* inst, uint8_t index) { |
| 40 assert(index < inst->num_operands); | 42 return NaClGetInstOperandInline(tables, inst, index); |
| 41 return &tables->operands_table[inst->operands_offset + index]; | |
| 42 } | 43 } |
| 43 | 44 |
| 44 /* Print out the opcode operand flags in a simplified (i.e. more human readable) | 45 /* Print out the opcode operand flags in a simplified (i.e. more human readable) |
| 45 * form. | 46 * form. |
| 46 */ | 47 */ |
| 47 void NaClOpFlagsPrint(struct Gio* f, NaClOpFlags flags) { | 48 void NaClOpFlagsPrint(struct Gio* f, NaClOpFlags flags) { |
| 48 NaClOpFlag i; | 49 NaClOpFlag i; |
| 49 Bool first = TRUE; | 50 Bool first = TRUE; |
| 50 for (i = 0; i < NaClOpFlagEnumSize; ++i) { | 51 for (i = 0; i < NaClOpFlagEnumSize; ++i) { |
| 51 if (flags & NACL_OPFLAG(i)) { | 52 if (flags & NACL_OPFLAG(i)) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 case PrefixF20F38: | 115 case PrefixF20F38: |
| 115 return "f2"; | 116 return "f2"; |
| 116 case PrefixF30F: | 117 case PrefixF30F: |
| 117 return "f3"; | 118 return "f3"; |
| 118 case Prefix660F: | 119 case Prefix660F: |
| 119 case Prefix660F38: | 120 case Prefix660F38: |
| 120 case Prefix660F3A: | 121 case Prefix660F3A: |
| 121 return "66"; | 122 return "66"; |
| 122 } | 123 } |
| 123 } | 124 } |
| OLD | NEW |