[llvm-exegesis][NFC] Pass Instruction instead of bare Opcode
[llvm-core.git] / lib / Target / X86 / X86InstrFoldTables.h
blob90016baead96d7b81cb13f33b376613160670fde
1 //===-- X86InstrFoldTables.h - X86 Instruction Folding Tables ---*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
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"
19 namespace llvm {
21 enum {
22 // Select which memory operand is being unfolded.
23 // (stored in bits 0 - 3)
24 TB_INDEX_0 = 0,
25 TB_INDEX_1 = 1,
26 TB_INDEX_2 = 2,
27 TB_INDEX_3 = 3,
28 TB_INDEX_4 = 4,
29 TB_INDEX_MASK = 0xf,
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)
46 TB_ALIGN_SHIFT = 8,
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 {
57 uint16_t KeyOp;
58 uint16_t DstOp;
59 uint16_t Flags;
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
73 // operand 0.
74 const X86MemoryFoldTableEntry *lookupTwoAddrFoldTable(unsigned RegOp);
76 // Look up the memory folding table entry for folding a load or store with
77 // operand OpNum.
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);
83 } // namespace llvm
85 #endif