| 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/trusted/validator/x86/decoder/nc_decode_tables.h" | 14 #include "native_client/src/trusted/validator/x86/decoder/nc_decode_tables.h" |
| 15 | 15 |
| 16 #include "native_client/src/trusted/validator/x86/decoder/ncopcode_desc_inl.c" |
| 17 |
| 16 void NaClInstPrint(struct Gio* f, | 18 void NaClInstPrint(struct Gio* f, |
| 17 const NaClDecodeTables* tables, | 19 const NaClDecodeTables* tables, |
| 18 const NaClInst* inst) { | 20 const NaClInst* inst) { |
| 19 { /* Print out instruction type less the NACLi_ prefix. */ | 21 { /* Print out instruction type less the NACLi_ prefix. */ |
| 20 const char* name = NaClInstTypeString(inst->insttype); | 22 const char* name = NaClInstTypeString(inst->insttype); |
| 21 gprintf(f, "%s ", name + strlen("NACLi_")); | 23 gprintf(f, "%s ", name + strlen("NACLi_")); |
| 22 } | 24 } |
| 23 if (inst->flags) NaClIFlagsPrint(f, inst->flags); | 25 if (inst->flags) NaClIFlagsPrint(f, inst->flags); |
| 24 gprintf(f, "\n"); | 26 gprintf(f, "\n"); |
| 25 | 27 |
| 26 /* If instruction type is invalid, and doesn't have | 28 /* If instruction type is invalid, and doesn't have |
| 27 * special translation purposes, then don't print additional | 29 * special translation purposes, then don't print additional |
| 28 * (ignored) information stored in the modeled instruction. | 30 * (ignored) information stored in the modeled instruction. |
| 29 */ | 31 */ |
| 30 if ((NACLi_INVALID != inst->insttype) || | 32 if ((NACLi_INVALID != inst->insttype) || |
| 31 ((inst->flags & NACL_IFLAG(Opcode0F0F)))) { | 33 ((inst->flags & NACL_IFLAG(Opcode0F0F)))) { |
| 32 Bool is_first = TRUE; | 34 Bool is_first = TRUE; |
| 33 int i; | 35 int i; |
| 34 gprintf(f, " %s", NaClMnemonicName(inst->name)); | 36 gprintf(f, " %s", NaClMnemonicName(inst->name)); |
| 35 for (i = 0; i < inst->num_operands; ++i) { | 37 for (i = 0; i < inst->num_operands; ++i) { |
| 36 const NaClOp* op = NaClGetInstOperand(tables, inst, i); | 38 const NaClOp* op = NaClGetInstOperandInline(tables, inst, i); |
| 37 if (NULL == op->format_string) continue; | 39 if (NULL == op->format_string) continue; |
| 38 if (is_first) { | 40 if (is_first) { |
| 39 is_first = FALSE; | 41 is_first = FALSE; |
| 40 } else { | 42 } else { |
| 41 gprintf(f, ","); | 43 gprintf(f, ","); |
| 42 } | 44 } |
| 43 gprintf(f, " %s", op->format_string); | 45 gprintf(f, " %s", op->format_string); |
| 44 } | 46 } |
| 45 gprintf(f, "\n"); | 47 gprintf(f, "\n"); |
| 46 /* Now print actual encoding of each operand. */ | 48 /* Now print actual encoding of each operand. */ |
| 47 for (i = 0; i < inst->num_operands; ++i) { | 49 for (i = 0; i < inst->num_operands; ++i) { |
| 48 gprintf(f, " "); | 50 gprintf(f, " "); |
| 49 NaClOpPrint(f, NaClGetInstOperand(tables, inst, i)); | 51 NaClOpPrint(f, NaClGetInstOperand(tables, inst, i)); |
| 50 } | 52 } |
| 51 } | 53 } |
| 52 } | 54 } |
| 55 |
| 56 /* Dummy routine to allow unreferenced NaClGetInstNumberOperandsInline |
| 57 * inline. |
| 58 */ |
| 59 uint8_t NaClNcopcodeDescVerboseDummyNaClGetInstNumberOperands( |
| 60 const NaClInst* inst) { |
| 61 return NaClGetInstNumberOperandsInline(inst); |
| 62 } |
| OLD | NEW |