OLD | NEW |
| (Empty) |
1 /* | |
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 | |
4 * found in the LICENSE file. | |
5 */ | |
6 | |
7 /* Descriptors to model instructions, opcodes, and instruction operands. */ | |
8 | |
9 #include "native_client/src/trusted/validator/x86/decoder/ncopcode_desc.h" | |
10 | |
11 #include <assert.h> | |
12 #include <string.h> | |
13 | |
14 #include "native_client/src/trusted/validator/x86/decoder/nc_decode_tables.h" | |
15 | |
16 #include "native_client/src/trusted/validator/x86/decoder/ncopcode_desc_inl.c" | |
17 | |
18 void NaClInstPrint(struct Gio* f, | |
19 const NaClDecodeTables* tables, | |
20 const NaClInst* inst) { | |
21 { /* Print out instruction type less the NACLi_ prefix. */ | |
22 const char* name = NaClInstTypeString(inst->insttype); | |
23 gprintf(f, "%s ", name + strlen("NACLi_")); | |
24 } | |
25 if (inst->flags) NaClIFlagsPrint(f, inst->flags); | |
26 gprintf(f, "\n"); | |
27 | |
28 /* If instruction type is invalid, and doesn't have | |
29 * special translation purposes, then don't print additional | |
30 * (ignored) information stored in the modeled instruction. | |
31 */ | |
32 if ((NACLi_INVALID != inst->insttype) || | |
33 ((inst->flags & NACL_IFLAG(Opcode0F0F)))) { | |
34 Bool is_first = TRUE; | |
35 int i; | |
36 gprintf(f, " %s", NaClMnemonicName(inst->name)); | |
37 for (i = 0; i < inst->num_operands; ++i) { | |
38 const NaClOp* op = NaClGetInstOperandInline(tables, inst, i); | |
39 if (NULL == op->format_string) continue; | |
40 if (is_first) { | |
41 is_first = FALSE; | |
42 } else { | |
43 gprintf(f, ","); | |
44 } | |
45 gprintf(f, " %s", op->format_string); | |
46 } | |
47 gprintf(f, "\n"); | |
48 /* Now print actual encoding of each operand. */ | |
49 for (i = 0; i < inst->num_operands; ++i) { | |
50 gprintf(f, " "); | |
51 NaClOpPrint(f, NaClGetInstOperand(tables, inst, i)); | |
52 } | |
53 } | |
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 |