Sean Callanan | 8ed9f51 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 1 | //===- X86DisassemblerShared.h - Emitter shared header ----------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Benjamin Kramer | 00e08fc | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 10 | #ifndef LLVM_UTILS_TABLEGEN_X86DISASSEMBLERSHARED_H |
| 11 | #define LLVM_UTILS_TABLEGEN_X86DISASSEMBLERSHARED_H |
Sean Callanan | 8ed9f51 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 12 | |
Craig Topper | a0400a7 | 2015-04-08 06:03:17 +0000 | [diff] [blame] | 13 | #include <cstring> |
Chandler Carruth | 4ffd89f | 2012-12-04 10:37:14 +0000 | [diff] [blame] | 14 | #include <string> |
Sean Callanan | 8ed9f51 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 15 | |
David Blaikie | cb6b3af | 2018-03-23 23:58:20 +0000 | [diff] [blame] | 16 | #include "llvm/Support/X86DisassemblerDecoderCommon.h" |
Sean Callanan | 8ed9f51 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 17 | |
Richard Smith | 5aacafc | 2014-04-20 21:35:26 +0000 | [diff] [blame] | 18 | struct InstructionSpecifier { |
Richard Smith | 4c09131 | 2014-04-20 22:10:16 +0000 | [diff] [blame] | 19 | llvm::X86Disassembler::OperandSpecifier |
| 20 | operands[llvm::X86Disassembler::X86_MAX_OPERANDS]; |
Richard Smith | 5aacafc | 2014-04-20 21:35:26 +0000 | [diff] [blame] | 21 | llvm::X86Disassembler::InstructionContext insnContext; |
| 22 | std::string name; |
| 23 | |
| 24 | InstructionSpecifier() { |
| 25 | insnContext = llvm::X86Disassembler::IC; |
| 26 | name = ""; |
| 27 | memset(operands, 0, sizeof(operands)); |
| 28 | } |
| 29 | }; |
| 30 | |
Richard Smith | 6f37488 | 2014-04-20 21:52:16 +0000 | [diff] [blame] | 31 | /// Specifies whether a ModR/M byte is needed and (if so) which |
| 32 | /// instruction each possible value of the ModR/M byte corresponds to. Once |
| 33 | /// this information is known, we have narrowed down to a single instruction. |
| 34 | struct ModRMDecision { |
| 35 | uint8_t modrm_type; |
| 36 | llvm::X86Disassembler::InstrUID instructionIDs[256]; |
| 37 | }; |
| 38 | |
| 39 | /// Specifies which set of ModR/M->instruction tables to look at |
| 40 | /// given a particular opcode. |
| 41 | struct OpcodeDecision { |
| 42 | ModRMDecision modRMDecisions[256]; |
| 43 | }; |
| 44 | |
| 45 | /// Specifies which opcode->instruction tables to look at given |
| 46 | /// a particular context (set of attributes). Since there are many possible |
| 47 | /// contexts, the decoder first uses CONTEXTS_SYM to determine which context |
| 48 | /// applies given a specific set of attributes. Hence there are only IC_max |
| 49 | /// entries in this table, rather than 2^(ATTR_max). |
| 50 | struct ContextDecision { |
| 51 | OpcodeDecision opcodeDecisions[llvm::X86Disassembler::IC_max]; |
Craig Topper | 2280dbe | 2018-03-24 07:15:47 +0000 | [diff] [blame] | 52 | |
| 53 | ContextDecision() { |
| 54 | memset(opcodeDecisions, 0, sizeof(opcodeDecisions)); |
| 55 | } |
Richard Smith | 6f37488 | 2014-04-20 21:52:16 +0000 | [diff] [blame] | 56 | }; |
| 57 | |
Sean Callanan | 8ed9f51 | 2009-12-19 02:59:52 +0000 | [diff] [blame] | 58 | #endif |