Skip to content

Commit 0666c59

Browse files
[RFC][X86][MemFold] Upgrade the mechanism of auto-generated Memory Folding Table
1. Align ManualMapSet with X86MemoryFoldTableEntry instead of using UnfoldStrategy 2. ManualMapSet able to update the existing record in auto-generated MemFold table Reviewed By: skan Differential Revision: https://reviews.llvm.org/D142084
1 parent 8d2885c commit 0666c59

File tree

5 files changed

+235
-134
lines changed

5 files changed

+235
-134
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//===-- X86FoldTablesUtils.h ------------------------------------*- 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+
#ifndef LLVM_SUPPORT_X86FOLDTABLESUTILS_H
10+
#define LLVM_SUPPORT_X86FOLDTABLESUTILS_H
11+
12+
namespace {
13+
enum {
14+
// Select which memory operand is being unfolded.
15+
// (stored in bits 0 - 2)
16+
TB_INDEX_0 = 0,
17+
TB_INDEX_1 = 1,
18+
TB_INDEX_2 = 2,
19+
TB_INDEX_3 = 3,
20+
TB_INDEX_4 = 4,
21+
TB_INDEX_MASK = 0x7,
22+
23+
// Do not insert the reverse map (MemOp -> RegOp) into the table.
24+
// This may be needed because there is a many -> one mapping.
25+
TB_NO_REVERSE = 1 << 3,
26+
27+
// Do not insert the forward map (RegOp -> MemOp) into the table.
28+
// This is needed for Native Client, which prohibits branch
29+
// instructions from using a memory operand.
30+
TB_NO_FORWARD = 1 << 4,
31+
32+
TB_FOLDED_LOAD = 1 << 5,
33+
TB_FOLDED_STORE = 1 << 6,
34+
TB_FOLDED_BCAST = 1 << 7,
35+
36+
// Minimum alignment required for load/store.
37+
// Used for RegOp->MemOp conversion. Encoded as Log2(Align) + 1 to allow 0
38+
// to mean align of 0.
39+
// (stored in bits 8 - 11)
40+
TB_ALIGN_SHIFT = 8,
41+
TB_ALIGN_NONE = 0 << TB_ALIGN_SHIFT,
42+
TB_ALIGN_16 = 5 << TB_ALIGN_SHIFT,
43+
TB_ALIGN_32 = 6 << TB_ALIGN_SHIFT,
44+
TB_ALIGN_64 = 7 << TB_ALIGN_SHIFT,
45+
TB_ALIGN_MASK = 0xf << TB_ALIGN_SHIFT,
46+
47+
// Broadcast type.
48+
// (stored in bits 12 - 13)
49+
TB_BCAST_TYPE_SHIFT = 12,
50+
TB_BCAST_D = 0 << TB_BCAST_TYPE_SHIFT,
51+
TB_BCAST_Q = 1 << TB_BCAST_TYPE_SHIFT,
52+
TB_BCAST_SS = 2 << TB_BCAST_TYPE_SHIFT,
53+
TB_BCAST_SD = 3 << TB_BCAST_TYPE_SHIFT,
54+
TB_BCAST_MASK = 0x3 << TB_BCAST_TYPE_SHIFT,
55+
56+
// Unused bits 14-15
57+
};
58+
}
59+
#endif // LLVM_SUPPORT_X86FOLDTABLESUTILS_H

llvm/lib/Target/X86/X86InstrFoldTables.h

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,55 +14,10 @@
1414
#define LLVM_LIB_TARGET_X86_X86INSTRFOLDTABLES_H
1515

1616
#include <cstdint>
17+
#include "llvm/Support/X86FoldTablesUtils.h"
1718

1819
namespace llvm {
1920

20-
enum {
21-
// Select which memory operand is being unfolded.
22-
// (stored in bits 0 - 2)
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 = 0x7,
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 << 3,
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 << 4,
38-
39-
TB_FOLDED_LOAD = 1 << 5,
40-
TB_FOLDED_STORE = 1 << 6,
41-
TB_FOLDED_BCAST = 1 << 7,
42-
43-
// Minimum alignment required for load/store.
44-
// Used for RegOp->MemOp conversion. Encoded as Log2(Align) + 1 to allow 0
45-
// to mean align of 0.
46-
// (stored in bits 8 - 11)
47-
TB_ALIGN_SHIFT = 8,
48-
TB_ALIGN_NONE = 0 << TB_ALIGN_SHIFT,
49-
TB_ALIGN_16 = 5 << TB_ALIGN_SHIFT,
50-
TB_ALIGN_32 = 6 << TB_ALIGN_SHIFT,
51-
TB_ALIGN_64 = 7 << TB_ALIGN_SHIFT,
52-
TB_ALIGN_MASK = 0xf << TB_ALIGN_SHIFT,
53-
54-
// Broadcast type.
55-
// (stored in bits 12 - 13)
56-
TB_BCAST_TYPE_SHIFT = 12,
57-
TB_BCAST_D = 0 << TB_BCAST_TYPE_SHIFT,
58-
TB_BCAST_Q = 1 << TB_BCAST_TYPE_SHIFT,
59-
TB_BCAST_SS = 2 << TB_BCAST_TYPE_SHIFT,
60-
TB_BCAST_SD = 3 << TB_BCAST_TYPE_SHIFT,
61-
TB_BCAST_MASK = 0x3 << TB_BCAST_TYPE_SHIFT,
62-
63-
// Unused bits 14-15
64-
};
65-
6621
// This struct is used for both the folding and unfold tables. They KeyOp
6722
// is used to determine the sorting order.
6823
struct X86MemoryFoldTableEntry {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// RUN: llvm-tblgen -gen-x86-fold-tables -asmwriternum=1 %p/../../lib/Target/X86/X86.td -I %p/../../include -I %p/../../lib/Target/X86/ -I %p/../../include/ -I %p/../../lib/Target/ --write-if-changed -o %t1
2+
// RUN: cmp --ignore-initial=0:568 %p/../../lib/Target/X86/X86MemFoldTables.inc %t1

0 commit comments

Comments
 (0)