/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/X86/X86InstrFoldTables.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===-- X86InstrFoldTables.h - X86 Instruction Folding 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 memory folding tables. |
10 | | // |
11 | | //===----------------------------------------------------------------------===// |
12 | | |
13 | | #ifndef LLVM_LIB_TARGET_X86_X86INSTRFOLDTABLES_H |
14 | | #define LLVM_LIB_TARGET_X86_X86INSTRFOLDTABLES_H |
15 | | |
16 | | #include "llvm/Support/DataTypes.h" |
17 | | |
18 | | namespace llvm { |
19 | | |
20 | | enum { |
21 | | // Select which memory operand is being unfolded. |
22 | | // (stored in bits 0 - 3) |
23 | | TB_INDEX_0 = 0, |
24 | | TB_INDEX_1 = 1, |
25 | | TB_INDEX_2 = 2, |
26 | | TB_INDEX_3 = 3, |
27 | | TB_INDEX_4 = 4, |
28 | | TB_INDEX_MASK = 0xf, |
29 | | |
30 | | // Do not insert the reverse map (MemOp -> RegOp) into the table. |
31 | | // This may be needed because there is a many -> one mapping. |
32 | | TB_NO_REVERSE = 1 << 4, |
33 | | |
34 | | // Do not insert the forward map (RegOp -> MemOp) into the table. |
35 | | // This is needed for Native Client, which prohibits branch |
36 | | // instructions from using a memory operand. |
37 | | TB_NO_FORWARD = 1 << 5, |
38 | | |
39 | | TB_FOLDED_LOAD = 1 << 6, |
40 | | TB_FOLDED_STORE = 1 << 7, |
41 | | |
42 | | // Minimum alignment required for load/store. |
43 | | // Used for RegOp->MemOp conversion. |
44 | | // (stored in bits 8 - 15) |
45 | | TB_ALIGN_SHIFT = 8, |
46 | | TB_ALIGN_NONE = 0 << TB_ALIGN_SHIFT, |
47 | | TB_ALIGN_16 = 16 << TB_ALIGN_SHIFT, |
48 | | TB_ALIGN_32 = 32 << TB_ALIGN_SHIFT, |
49 | | TB_ALIGN_64 = 64 << TB_ALIGN_SHIFT, |
50 | | TB_ALIGN_MASK = 0xff << TB_ALIGN_SHIFT |
51 | | }; |
52 | | |
53 | | // This struct is used for both the folding and unfold tables. They KeyOp |
54 | | // is used to determine the sorting order. |
55 | | struct X86MemoryFoldTableEntry { |
56 | | uint16_t KeyOp; |
57 | | uint16_t DstOp; |
58 | | uint16_t Flags; |
59 | | |
60 | 65.9M | bool operator<(const X86MemoryFoldTableEntry &RHS) const { |
61 | 65.9M | return KeyOp < RHS.KeyOp; |
62 | 65.9M | } |
63 | 0 | bool operator==(const X86MemoryFoldTableEntry &RHS) const { |
64 | 0 | return KeyOp == RHS.KeyOp; |
65 | 0 | } |
66 | 1.32M | friend bool operator<(const X86MemoryFoldTableEntry &TE, unsigned Opcode) { |
67 | 1.32M | return TE.KeyOp < Opcode; |
68 | 1.32M | } |
69 | | }; |
70 | | |
71 | | // Look up the memory folding table entry for folding a load and a store into |
72 | | // operand 0. |
73 | | const X86MemoryFoldTableEntry *lookupTwoAddrFoldTable(unsigned RegOp); |
74 | | |
75 | | // Look up the memory folding table entry for folding a load or store with |
76 | | // operand OpNum. |
77 | | const X86MemoryFoldTableEntry *lookupFoldTable(unsigned RegOp, unsigned OpNum); |
78 | | |
79 | | // Look up the memory unfolding table entry for this instruction. |
80 | | const X86MemoryFoldTableEntry *lookupUnfoldTable(unsigned MemOp); |
81 | | |
82 | | } // namespace llvm |
83 | | |
84 | | #endif |