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> 1706c3fb27SDimitry 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. 235f757f3fSDimitry Andric struct X86FoldTableEntry { 2406c3fb27SDimitry Andric unsigned KeyOp; 2506c3fb27SDimitry Andric unsigned DstOp; 260b57cec5SDimitry Andric uint16_t Flags; 270b57cec5SDimitry Andric 285f757f3fSDimitry Andric bool operator<(const X86FoldTableEntry &RHS) const { 290b57cec5SDimitry Andric return KeyOp < RHS.KeyOp; 300b57cec5SDimitry Andric } 315f757f3fSDimitry Andric bool operator==(const X86FoldTableEntry &RHS) const { 320b57cec5SDimitry Andric return KeyOp == RHS.KeyOp; 330b57cec5SDimitry Andric } 345f757f3fSDimitry Andric friend bool operator<(const X86FoldTableEntry &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. 415f757f3fSDimitry Andric const X86FoldTableEntry *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. 455f757f3fSDimitry Andric const X86FoldTableEntry *lookupFoldTable(unsigned RegOp, unsigned OpNum); 460b57cec5SDimitry Andric 47*0fca6ea1SDimitry Andric // Look up the broadcast folding table entry for folding a broadcast with 48*0fca6ea1SDimitry Andric // operand OpNum. 49*0fca6ea1SDimitry Andric const X86FoldTableEntry *lookupBroadcastFoldTable(unsigned RegOp, 50*0fca6ea1SDimitry Andric unsigned OpNum); 51*0fca6ea1SDimitry Andric 520b57cec5SDimitry Andric // Look up the memory unfolding table entry for this instruction. 535f757f3fSDimitry Andric const X86FoldTableEntry *lookupUnfoldTable(unsigned MemOp); 540b57cec5SDimitry Andric 555f757f3fSDimitry Andric // Look up the broadcast folding table entry for this instruction from 5606c3fb27SDimitry Andric // the regular memory instruction. 57*0fca6ea1SDimitry Andric const X86FoldTableEntry *lookupBroadcastFoldTableBySize(unsigned MemOp, 5806c3fb27SDimitry Andric unsigned BroadcastBits); 5906c3fb27SDimitry Andric 60*0fca6ea1SDimitry Andric bool matchBroadcastSize(const X86FoldTableEntry &Entry, unsigned BroadcastBits); 610b57cec5SDimitry Andric } // namespace llvm 620b57cec5SDimitry Andric 630b57cec5SDimitry Andric #endif 64