1//===- X86DisassemblerShared.h - Emitter shared header ----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_UTILS_TABLEGEN_X86DISASSEMBLERSHARED_H
10#define LLVM_UTILS_TABLEGEN_X86DISASSEMBLERSHARED_H
11
12#include <cstring>
13#include <string>
14
15#include "llvm/Support/X86DisassemblerDecoderCommon.h"
16
17namespace llvm::X86Disassembler {
18
19struct InstructionSpecifier {
20 llvm::X86Disassembler::OperandSpecifier
21 operands[llvm::X86Disassembler::X86_MAX_OPERANDS];
22 llvm::X86Disassembler::InstructionContext insnContext;
23 std::string name;
24
25 InstructionSpecifier() {
26 insnContext = llvm::X86Disassembler::IC;
27 name = "";
28 memset(s: operands, c: 0, n: sizeof(operands));
29 }
30};
31
32/// Specifies whether a ModR/M byte is needed and (if so) which
33/// instruction each possible value of the ModR/M byte corresponds to. Once
34/// this information is known, we have narrowed down to a single instruction.
35struct ModRMDecision {
36 uint8_t modrm_type;
37 llvm::X86Disassembler::InstrUID instructionIDs[256];
38};
39
40/// Specifies which set of ModR/M->instruction tables to look at
41/// given a particular opcode.
42struct OpcodeDecision {
43 ModRMDecision modRMDecisions[256];
44};
45
46/// Specifies which opcode->instruction tables to look at given
47/// a particular context (set of attributes). Since there are many possible
48/// contexts, the decoder first uses CONTEXTS_SYM to determine which context
49/// applies given a specific set of attributes. Hence there are only IC_max
50/// entries in this table, rather than 2^(ATTR_max).
51struct ContextDecision {
52 OpcodeDecision opcodeDecisions[llvm::X86Disassembler::IC_max];
53
54 ContextDecision() { memset(s: opcodeDecisions, c: 0, n: sizeof(opcodeDecisions)); }
55};
56
57} // namespace llvm::X86Disassembler
58
59#endif
60