X86InstrRelaxTables.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //===-- X86InstrRelaxTables.h - X86 Instruction Relaxation Tables -*- 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. //
  9. // This file contains the interface to query the X86 instruction relaxation
  10. // tables.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_LIB_TARGET_X86_X86INSTRRELAXTABLES_H
  14. #define LLVM_LIB_TARGET_X86_X86INSTRRELAXTABLES_H
  15. #include <cstdint>
  16. namespace llvm {
  17. // This struct is used for both the relaxed and short tables. The KeyOp is used
  18. // to determine the sorting order.
  19. struct X86InstrRelaxTableEntry {
  20. uint16_t KeyOp;
  21. uint16_t DstOp;
  22. bool operator<(const X86InstrRelaxTableEntry &RHS) const {
  23. return KeyOp < RHS.KeyOp;
  24. }
  25. bool operator==(const X86InstrRelaxTableEntry &RHS) const {
  26. return KeyOp == RHS.KeyOp;
  27. }
  28. friend bool operator<(const X86InstrRelaxTableEntry &TE, unsigned Opcode) {
  29. return TE.KeyOp < Opcode;
  30. }
  31. };
  32. /// Look up the relaxed form table entry for a given \p ShortOp.
  33. const X86InstrRelaxTableEntry *lookupRelaxTable(unsigned ShortOp);
  34. /// Look up the short form table entry for a given \p RelaxOp.
  35. const X86InstrRelaxTableEntry *lookupShortTable(unsigned RelaxOp);
  36. namespace X86 {
  37. /// Get the short instruction opcode for a given relaxed opcode.
  38. unsigned getShortOpcodeArith(unsigned RelaxOp);
  39. /// Get the relaxed instruction opcode for a given short opcode.
  40. unsigned getRelaxedOpcodeArith(unsigned ShortOp);
  41. } // namespace X86
  42. } // namespace llvm
  43. #endif