1 //===-- X86InstrFoldTables.h - X86 Instruction Folding Tables ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the interface to query the X86 memory folding tables.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_X86_X86INSTRFOLDTABLES_H
15 #define LLVM_LIB_TARGET_X86_X86INSTRFOLDTABLES_H
17 #include "llvm/Support/DataTypes.h"
22 // Select which memory operand is being unfolded.
23 // (stored in bits 0 - 3)
31 // Do not insert the reverse map (MemOp -> RegOp) into the table.
32 // This may be needed because there is a many -> one mapping.
33 TB_NO_REVERSE = 1 << 4,
35 // Do not insert the forward map (RegOp -> MemOp) into the table.
36 // This is needed for Native Client, which prohibits branch
37 // instructions from using a memory operand.
38 TB_NO_FORWARD = 1 << 5,
40 TB_FOLDED_LOAD = 1 << 6,
41 TB_FOLDED_STORE = 1 << 7,
43 // Minimum alignment required for load/store.
44 // Used for RegOp->MemOp conversion.
45 // (stored in bits 8 - 15)
47 TB_ALIGN_NONE = 0 << TB_ALIGN_SHIFT,
48 TB_ALIGN_16 = 16 << TB_ALIGN_SHIFT,
49 TB_ALIGN_32 = 32 << TB_ALIGN_SHIFT,
50 TB_ALIGN_64 = 64 << TB_ALIGN_SHIFT,
51 TB_ALIGN_MASK = 0xff << TB_ALIGN_SHIFT
54 // This struct is used for both the folding and unfold tables. They KeyOp
55 // is used to determine the sorting order.
56 struct X86MemoryFoldTableEntry {
61 bool operator<(const X86MemoryFoldTableEntry &RHS) const {
62 return KeyOp < RHS.KeyOp;
64 bool operator==(const X86MemoryFoldTableEntry &RHS) const {
65 return KeyOp == RHS.KeyOp;
67 friend bool operator<(const X86MemoryFoldTableEntry &TE, unsigned Opcode) {
68 return TE.KeyOp < Opcode;
72 // Look up the memory folding table entry for folding a load and a store into
74 const X86MemoryFoldTableEntry *lookupTwoAddrFoldTable(unsigned RegOp);
76 // Look up the memory folding table entry for folding a load or store with
78 const X86MemoryFoldTableEntry *lookupFoldTable(unsigned RegOp, unsigned OpNum);
80 // Look up the memory unfolding table entry for this instruction.
81 const X86MemoryFoldTableEntry *lookupUnfoldTable(unsigned MemOp);