blob: 093f220fda5e64198713eb81610eea6abf3036aa [file] [log] [blame]
Sean Callanan04cc3072009-12-19 02:59:52 +00001//===- X86DisassemblerShared.h - Emitter shared header ----------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Sean Callanan04cc3072009-12-19 02:59:52 +00006//
7//===----------------------------------------------------------------------===//
8
Benjamin Kramera7c40ef2014-08-13 16:26:38 +00009#ifndef LLVM_UTILS_TABLEGEN_X86DISASSEMBLERSHARED_H
10#define LLVM_UTILS_TABLEGEN_X86DISASSEMBLERSHARED_H
Sean Callanan04cc3072009-12-19 02:59:52 +000011
Craig Topper08f4bd22015-04-08 06:03:17 +000012#include <cstring>
Chandler Carruth91d19d82012-12-04 10:37:14 +000013#include <string>
Sean Callanan04cc3072009-12-19 02:59:52 +000014
David Blaikieab7f17f2018-03-23 23:58:20 +000015#include "llvm/Support/X86DisassemblerDecoderCommon.h"
Sean Callanan04cc3072009-12-19 02:59:52 +000016
Richard Smith82b47d52014-04-20 21:35:26 +000017struct InstructionSpecifier {
Richard Smith6a6967e2014-04-20 22:10:16 +000018 llvm::X86Disassembler::OperandSpecifier
19 operands[llvm::X86Disassembler::X86_MAX_OPERANDS];
Richard Smith82b47d52014-04-20 21:35:26 +000020 llvm::X86Disassembler::InstructionContext insnContext;
21 std::string name;
22
23 InstructionSpecifier() {
24 insnContext = llvm::X86Disassembler::IC;
25 name = "";
26 memset(operands, 0, sizeof(operands));
27 }
28};
29
Richard Smithac15f1c2014-04-20 21:52:16 +000030/// Specifies whether a ModR/M byte is needed and (if so) which
31/// instruction each possible value of the ModR/M byte corresponds to. Once
32/// this information is known, we have narrowed down to a single instruction.
33struct ModRMDecision {
34 uint8_t modrm_type;
35 llvm::X86Disassembler::InstrUID instructionIDs[256];
36};
37
38/// Specifies which set of ModR/M->instruction tables to look at
39/// given a particular opcode.
40struct OpcodeDecision {
41 ModRMDecision modRMDecisions[256];
42};
43
44/// Specifies which opcode->instruction tables to look at given
45/// a particular context (set of attributes). Since there are many possible
46/// contexts, the decoder first uses CONTEXTS_SYM to determine which context
47/// applies given a specific set of attributes. Hence there are only IC_max
48/// entries in this table, rather than 2^(ATTR_max).
49struct ContextDecision {
50 OpcodeDecision opcodeDecisions[llvm::X86Disassembler::IC_max];
Craig Topperc0e18802018-03-24 07:15:47 +000051
52 ContextDecision() {
53 memset(opcodeDecisions, 0, sizeof(opcodeDecisions));
54 }
Richard Smithac15f1c2014-04-20 21:52:16 +000055};
56
Sean Callanan04cc3072009-12-19 02:59:52 +000057#endif