1201360Srdivacky//===- X86DisassemblerShared.h - Emitter shared header ----------*- C++ -*-===//
2201360Srdivacky//
3201360Srdivacky//                     The LLVM Compiler Infrastructure
4201360Srdivacky//
5201360Srdivacky// This file is distributed under the University of Illinois Open Source
6201360Srdivacky// License. See LICENSE.TXT for details.
7201360Srdivacky//
8201360Srdivacky//===----------------------------------------------------------------------===//
9201360Srdivacky
10280031Sdim#ifndef LLVM_UTILS_TABLEGEN_X86DISASSEMBLERSHARED_H
11280031Sdim#define LLVM_UTILS_TABLEGEN_X86DISASSEMBLERSHARED_H
12201360Srdivacky
13288943Sdim#include <cstring>
14201360Srdivacky#include <string>
15201360Srdivacky
16276479Sdim#include "../../lib/Target/X86/Disassembler/X86DisassemblerDecoderCommon.h"
17276479Sdim
18276479Sdimstruct InstructionSpecifier {
19276479Sdim  llvm::X86Disassembler::OperandSpecifier
20276479Sdim      operands[llvm::X86Disassembler::X86_MAX_OPERANDS];
21276479Sdim  llvm::X86Disassembler::InstructionContext insnContext;
22276479Sdim  std::string name;
23276479Sdim
24276479Sdim  InstructionSpecifier() {
25276479Sdim    insnContext = llvm::X86Disassembler::IC;
26276479Sdim    name = "";
27276479Sdim    memset(operands, 0, sizeof(operands));
28201360Srdivacky  }
29276479Sdim};
30201360Srdivacky
31276479Sdim/// Specifies whether a ModR/M byte is needed and (if so) which
32276479Sdim/// instruction each possible value of the ModR/M byte corresponds to. Once
33276479Sdim/// this information is known, we have narrowed down to a single instruction.
34276479Sdimstruct ModRMDecision {
35276479Sdim  uint8_t modrm_type;
36276479Sdim  llvm::X86Disassembler::InstrUID instructionIDs[256];
37276479Sdim};
38201360Srdivacky
39276479Sdim/// Specifies which set of ModR/M->instruction tables to look at
40276479Sdim/// given a particular opcode.
41276479Sdimstruct OpcodeDecision {
42276479Sdim  ModRMDecision modRMDecisions[256];
43276479Sdim};
44201360Srdivacky
45276479Sdim/// Specifies which opcode->instruction tables to look at given
46276479Sdim/// a particular context (set of attributes).  Since there are many possible
47276479Sdim/// contexts, the decoder first uses CONTEXTS_SYM to determine which context
48276479Sdim/// applies given a specific set of attributes.  Hence there are only IC_max
49276479Sdim/// entries in this table, rather than 2^(ATTR_max).
50276479Sdimstruct ContextDecision {
51276479Sdim  OpcodeDecision opcodeDecisions[llvm::X86Disassembler::IC_max];
52276479Sdim};
53201360Srdivacky
54201360Srdivacky#endif
55