X86DisassemblerShared.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #ifndef LLVM_UTILS_TABLEGEN_X86DISASSEMBLERSHARED_H
  9. #define LLVM_UTILS_TABLEGEN_X86DISASSEMBLERSHARED_H
  10. #include <cstring>
  11. #include <string>
  12. #include "llvm/Support/X86DisassemblerDecoderCommon.h"
  13. struct InstructionSpecifier {
  14. llvm::X86Disassembler::OperandSpecifier
  15. operands[llvm::X86Disassembler::X86_MAX_OPERANDS];
  16. llvm::X86Disassembler::InstructionContext insnContext;
  17. std::string name;
  18. InstructionSpecifier() {
  19. insnContext = llvm::X86Disassembler::IC;
  20. name = "";
  21. memset(operands, 0, sizeof(operands));
  22. }
  23. };
  24. /// Specifies whether a ModR/M byte is needed and (if so) which
  25. /// instruction each possible value of the ModR/M byte corresponds to. Once
  26. /// this information is known, we have narrowed down to a single instruction.
  27. struct ModRMDecision {
  28. uint8_t modrm_type;
  29. llvm::X86Disassembler::InstrUID instructionIDs[256];
  30. };
  31. /// Specifies which set of ModR/M->instruction tables to look at
  32. /// given a particular opcode.
  33. struct OpcodeDecision {
  34. ModRMDecision modRMDecisions[256];
  35. };
  36. /// Specifies which opcode->instruction tables to look at given
  37. /// a particular context (set of attributes). Since there are many possible
  38. /// contexts, the decoder first uses CONTEXTS_SYM to determine which context
  39. /// applies given a specific set of attributes. Hence there are only IC_max
  40. /// entries in this table, rather than 2^(ATTR_max).
  41. struct ContextDecision {
  42. OpcodeDecision opcodeDecisions[llvm::X86Disassembler::IC_max];
  43. ContextDecision() {
  44. memset(opcodeDecisions, 0, sizeof(opcodeDecisions));
  45. }
  46. };
  47. #endif