10b57cec5SDimitry Andric //===-- X86InstrFoldTables.h - X86 Instruction Folding Tables ---*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file contains the interface to query the X86 memory folding tables. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_X86_X86INSTRFOLDTABLES_H 140b57cec5SDimitry Andric #define LLVM_LIB_TARGET_X86_X86INSTRFOLDTABLES_H 150b57cec5SDimitry Andric 165ffd83dbSDimitry Andric #include <cstdint> 17*06c3fb27SDimitry Andric #include "llvm/Support/X86FoldTablesUtils.h" 180b57cec5SDimitry Andric 190b57cec5SDimitry Andric namespace llvm { 200b57cec5SDimitry Andric 210b57cec5SDimitry Andric // This struct is used for both the folding and unfold tables. They KeyOp 220b57cec5SDimitry Andric // is used to determine the sorting order. 230b57cec5SDimitry Andric struct X86MemoryFoldTableEntry { 24*06c3fb27SDimitry Andric unsigned KeyOp; 25*06c3fb27SDimitry Andric unsigned DstOp; 260b57cec5SDimitry Andric uint16_t Flags; 270b57cec5SDimitry Andric 280b57cec5SDimitry Andric bool operator<(const X86MemoryFoldTableEntry &RHS) const { 290b57cec5SDimitry Andric return KeyOp < RHS.KeyOp; 300b57cec5SDimitry Andric } 310b57cec5SDimitry Andric bool operator==(const X86MemoryFoldTableEntry &RHS) const { 320b57cec5SDimitry Andric return KeyOp == RHS.KeyOp; 330b57cec5SDimitry Andric } 340b57cec5SDimitry Andric friend bool operator<(const X86MemoryFoldTableEntry &TE, unsigned Opcode) { 350b57cec5SDimitry Andric return TE.KeyOp < Opcode; 360b57cec5SDimitry Andric } 370b57cec5SDimitry Andric }; 380b57cec5SDimitry Andric 390b57cec5SDimitry Andric // Look up the memory folding table entry for folding a load and a store into 400b57cec5SDimitry Andric // operand 0. 410b57cec5SDimitry Andric const X86MemoryFoldTableEntry *lookupTwoAddrFoldTable(unsigned RegOp); 420b57cec5SDimitry Andric 430b57cec5SDimitry Andric // Look up the memory folding table entry for folding a load or store with 440b57cec5SDimitry Andric // operand OpNum. 450b57cec5SDimitry Andric const X86MemoryFoldTableEntry *lookupFoldTable(unsigned RegOp, unsigned OpNum); 460b57cec5SDimitry Andric 470b57cec5SDimitry Andric // Look up the memory unfolding table entry for this instruction. 480b57cec5SDimitry Andric const X86MemoryFoldTableEntry *lookupUnfoldTable(unsigned MemOp); 490b57cec5SDimitry Andric 50*06c3fb27SDimitry Andric // Look up the broadcast memory folding table entry for this instruction from 51*06c3fb27SDimitry Andric // the regular memory instruction. 52*06c3fb27SDimitry Andric const X86MemoryFoldTableEntry *lookupBroadcastFoldTable(unsigned MemOp, 53*06c3fb27SDimitry Andric unsigned BroadcastBits); 54*06c3fb27SDimitry Andric 550b57cec5SDimitry Andric } // namespace llvm 560b57cec5SDimitry Andric 570b57cec5SDimitry Andric #endif 58