60 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_UTILS_TABLEGEN_X86DISASSEMBLERSHARED_H10#define LLVM_UTILS_TABLEGEN_X86DISASSEMBLERSHARED_H11 12#include <cstring>13#include <string>14 15#include "llvm/Support/X86DisassemblerDecoderCommon.h"16 17namespace llvm::X86Disassembler {18 19struct InstructionSpecifier {20 llvm::X86Disassembler::OperandSpecifier21 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(operands, 0, sizeof(operands));29 }30};31 32/// Specifies whether a ModR/M byte is needed and (if so) which33/// instruction each possible value of the ModR/M byte corresponds to. Once34/// 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 at41/// given a particular opcode.42struct OpcodeDecision {43 ModRMDecision modRMDecisions[256];44};45 46/// Specifies which opcode->instruction tables to look at given47/// a particular context (set of attributes). Since there are many possible48/// contexts, the decoder first uses CONTEXTS_SYM to determine which context49/// applies given a specific set of attributes. Hence there are only IC_max50/// entries in this table, rather than 2^(ATTR_max).51struct ContextDecision {52 OpcodeDecision opcodeDecisions[llvm::X86Disassembler::IC_max];53 54 ContextDecision() { memset(opcodeDecisions, 0, sizeof(opcodeDecisions)); }55};56 57} // namespace llvm::X86Disassembler58 59#endif60