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 14 #ifndef LLVM_LIB_TARGET_X86_X86INSTRRELAXTABLES_H 15 #define LLVM_LIB_TARGET_X86_X86INSTRRELAXTABLES_H 16 17 #include <cstdint> 18 19 namespace llvm { 20 21 // This struct is used for both the relaxed and short tables. The KeyOp is used 22 // to determine the sorting order. 23 struct X86InstrRelaxTableEntry { 24 uint16_t KeyOp; 25 uint16_t DstOp; 26 27 bool operator<(const X86InstrRelaxTableEntry &RHS) const { 28 return KeyOp < RHS.KeyOp; 29 } 30 bool operator==(const X86InstrRelaxTableEntry &RHS) const { 31 return KeyOp == RHS.KeyOp; 32 } 33 friend bool operator<(const X86InstrRelaxTableEntry &TE, unsigned Opcode) { 34 return TE.KeyOp < Opcode; 35 } 36 }; 37 38 /// Look up the relaxed form table entry for a given \p ShortOp. 39 const X86InstrRelaxTableEntry *lookupRelaxTable(unsigned ShortOp); 40 41 /// Look up the short form table entry for a given \p RelaxOp. 42 const X86InstrRelaxTableEntry *lookupShortTable(unsigned RelaxOp); 43 44 namespace X86 { 45 46 /// Get the short instruction opcode for a given relaxed opcode. 47 unsigned getShortOpcodeArith(unsigned RelaxOp); 48 49 /// Get the relaxed instruction opcode for a given short opcode. 50 unsigned getRelaxedOpcodeArith(unsigned ShortOp); 51 } // namespace X86 52 } // namespace llvm 53 54 #endif 55