| 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 /* | |
| 8 * modeled_nacl_inst.h - Extends (runtime) model of instructions (NaClInst) | |
| 9 * to include information needed only during table generation. | |
| 10 */ | |
| 11 | |
| 12 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_DECODER_GENERATOR_NCOPCODE_DESC_
H__ | |
| 13 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_DECODER_GENERATOR_NCOPCODE_DESC_
H__ | |
| 14 | |
| 15 #include "native_client/src/trusted/validator/x86/decoder/ncopcode_desc.h" | |
| 16 | |
| 17 /* Models metadata about an instruction, defining a pattern. Note: Since the | |
| 18 * same sequence of opcode bytes may define more than one pattern (depending on | |
| 19 * other bytes in the parsed instruction), the patterns are | |
| 20 * modeled using a singly linked list. | |
| 21 */ | |
| 22 typedef struct NaClModeledInst { | |
| 23 /* The prefix associated with the instruction. */ | |
| 24 NaClInstPrefix prefix; | |
| 25 /* The number of opcode bytes in the instruction. */ | |
| 26 uint8_t num_opcode_bytes; | |
| 27 /* The actual opcode bytes. */ | |
| 28 uint8_t opcode[NACL_MAX_ALL_OPCODE_BYTES]; | |
| 29 /* Defines the origin of this instruction. */ | |
| 30 NaClInstType insttype; | |
| 31 /* Flags defining additional facts about the instruction. */ | |
| 32 NaClIFlags flags; | |
| 33 /* The instruction that this instruction implements. */ | |
| 34 NaClMnemonic name; | |
| 35 /* Defines opcode extentions, which encodes values for OpcodeInModRm, | |
| 36 * OpcodePlusR, and OpcodeInModRmRm. Note: to fit the possible 9 | |
| 37 * bits of information in 8 bits, we assume that OpcodeInModRm | |
| 38 * and OpcodePlusR do not happen in the same instruction. | |
| 39 */ | |
| 40 uint8_t opcode_ext; | |
| 41 /* The number of operands modeled for this instruction. */ | |
| 42 uint8_t num_operands; | |
| 43 /* The corresponding models of the operands. */ | |
| 44 NaClOp* operands; | |
| 45 /* Pointer to the next pattern to try and match for the | |
| 46 * given sequence of opcode bytes. | |
| 47 */ | |
| 48 struct NaClModeledInst* next_rule; | |
| 49 } NaClModeledInst; | |
| 50 | |
| 51 /* Sets the OpcodeInModRm value in the opcode_ext field. */ | |
| 52 void NaClSetOpcodeInModRm(uint8_t value, uint8_t *opcode_ext); | |
| 53 | |
| 54 /* Sets the OpcodeInModRmRm value in th opcode_ext field. */ | |
| 55 void NaClSetOpcodeInModRmRm(uint8_t value, uint8_t *opcode_ext); | |
| 56 | |
| 57 /* Sets the OpcodePlusR value in the opcode_ext field. */ | |
| 58 void NaClSetOpcodePlusR(uint8_t value, uint8_t *opcode_ext); | |
| 59 | |
| 60 /* Implements trie nodes for selecting instructions that must match | |
| 61 * a specific sequence of bytes. Used to model NOP cases. | |
| 62 */ | |
| 63 typedef struct NaClModeledInstNode { | |
| 64 /* The matching byte for the trie node. */ | |
| 65 uint8_t matching_byte; | |
| 66 /* The matching modeled instruction, if byte matched. */ | |
| 67 NaClModeledInst* matching_inst; | |
| 68 /* Node to match remaining bytes if matching_byte matches. */ | |
| 69 struct NaClModeledInstNode* success; | |
| 70 /* Node to try next if match_byte doesn't match. Note: | |
| 71 * The trie is generated in such a way that if the next input | |
| 72 * byte is > matching_byte, no node in the fail subtree will | |
| 73 * match the current input. That is, nodes in the trie are | |
| 74 * sorted by the sequence of matching bytes. | |
| 75 */ | |
| 76 struct NaClModeledInstNode* fail; | |
| 77 } NaClModeledInstNode; | |
| 78 | |
| 79 /* Print out the given instruction to the given file. However, always | |
| 80 * print the value NULL for next_rule, even if the value is non-null. This | |
| 81 * function should be used to print out an individual opcode (instruction) | |
| 82 * pattern. | |
| 83 */ | |
| 84 void NaClModeledInstPrint(struct Gio* f, const NaClModeledInst* inst); | |
| 85 | |
| 86 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_DECODER_GENERATOR_NCOPCODE_DE
SC_H__ */ | |
| OLD | NEW |