1*9880d681SAndroid Build Coastguard Worker //===- X86DisassemblerShared.h - Emitter shared header ----------*- C++ -*-===// 2*9880d681SAndroid Build Coastguard Worker // 3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker // 5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker // 8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker 10*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_UTILS_TABLEGEN_X86DISASSEMBLERSHARED_H 11*9880d681SAndroid Build Coastguard Worker #define LLVM_UTILS_TABLEGEN_X86DISASSEMBLERSHARED_H 12*9880d681SAndroid Build Coastguard Worker 13*9880d681SAndroid Build Coastguard Worker #include <cstring> 14*9880d681SAndroid Build Coastguard Worker #include <string> 15*9880d681SAndroid Build Coastguard Worker 16*9880d681SAndroid Build Coastguard Worker #include "../../lib/Target/X86/Disassembler/X86DisassemblerDecoderCommon.h" 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker struct InstructionSpecifier { 19*9880d681SAndroid Build Coastguard Worker llvm::X86Disassembler::OperandSpecifier 20*9880d681SAndroid Build Coastguard Worker operands[llvm::X86Disassembler::X86_MAX_OPERANDS]; 21*9880d681SAndroid Build Coastguard Worker llvm::X86Disassembler::InstructionContext insnContext; 22*9880d681SAndroid Build Coastguard Worker std::string name; 23*9880d681SAndroid Build Coastguard Worker InstructionSpecifierInstructionSpecifier24*9880d681SAndroid Build Coastguard Worker InstructionSpecifier() { 25*9880d681SAndroid Build Coastguard Worker insnContext = llvm::X86Disassembler::IC; 26*9880d681SAndroid Build Coastguard Worker name = ""; 27*9880d681SAndroid Build Coastguard Worker memset(operands, 0, sizeof(operands)); 28*9880d681SAndroid Build Coastguard Worker } 29*9880d681SAndroid Build Coastguard Worker }; 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Worker /// Specifies whether a ModR/M byte is needed and (if so) which 32*9880d681SAndroid Build Coastguard Worker /// instruction each possible value of the ModR/M byte corresponds to. Once 33*9880d681SAndroid Build Coastguard Worker /// this information is known, we have narrowed down to a single instruction. 34*9880d681SAndroid Build Coastguard Worker struct ModRMDecision { 35*9880d681SAndroid Build Coastguard Worker uint8_t modrm_type; 36*9880d681SAndroid Build Coastguard Worker llvm::X86Disassembler::InstrUID instructionIDs[256]; 37*9880d681SAndroid Build Coastguard Worker }; 38*9880d681SAndroid Build Coastguard Worker 39*9880d681SAndroid Build Coastguard Worker /// Specifies which set of ModR/M->instruction tables to look at 40*9880d681SAndroid Build Coastguard Worker /// given a particular opcode. 41*9880d681SAndroid Build Coastguard Worker struct OpcodeDecision { 42*9880d681SAndroid Build Coastguard Worker ModRMDecision modRMDecisions[256]; 43*9880d681SAndroid Build Coastguard Worker }; 44*9880d681SAndroid Build Coastguard Worker 45*9880d681SAndroid Build Coastguard Worker /// Specifies which opcode->instruction tables to look at given 46*9880d681SAndroid Build Coastguard Worker /// a particular context (set of attributes). Since there are many possible 47*9880d681SAndroid Build Coastguard Worker /// contexts, the decoder first uses CONTEXTS_SYM to determine which context 48*9880d681SAndroid Build Coastguard Worker /// applies given a specific set of attributes. Hence there are only IC_max 49*9880d681SAndroid Build Coastguard Worker /// entries in this table, rather than 2^(ATTR_max). 50*9880d681SAndroid Build Coastguard Worker struct ContextDecision { 51*9880d681SAndroid Build Coastguard Worker OpcodeDecision opcodeDecisions[llvm::X86Disassembler::IC_max]; 52*9880d681SAndroid Build Coastguard Worker }; 53*9880d681SAndroid Build Coastguard Worker 54*9880d681SAndroid Build Coastguard Worker #endif 55