Skip to content

Commit cfa0833

Browse files
authored
[NFC][TableGen][GlobalISel] Move MIR Pattern Parsing out of Combiner Impl (#80257)
This just moves code around so the MIR pattern parsing logic is separated and reusable.
1 parent 0f8680b commit cfa0833

File tree

7 files changed

+624
-466
lines changed

7 files changed

+624
-466
lines changed

llvm/utils/TableGen/GlobalISel/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ set(LLVM_LINK_COMPONENTS
55

66
add_llvm_library(LLVMTableGenGlobalISel STATIC DISABLE_LLVM_LINK_LLVM_DYLIB
77
CodeExpander.cpp
8+
CombinerUtils.cpp
89
CXXPredicates.cpp
910
MatchDataInfo.cpp
11+
PatternParser.cpp
1012
Patterns.cpp
1113

1214
DEPENDS
@@ -15,6 +17,6 @@ add_llvm_library(LLVMTableGenGlobalISel STATIC DISABLE_LLVM_LINK_LLVM_DYLIB
1517

1618
# Users may include its headers as "GlobalISel/*.h"
1719
target_include_directories(LLVMTableGenGlobalISel
18-
INTERFACE
20+
PUBLIC
1921
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
2022
)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===- CombinerUtils.cpp --------------------------------------------------===//
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+
#include "CombinerUtils.h"
10+
#include "llvm/ADT/StringSet.h"
11+
12+
namespace llvm {
13+
14+
StringRef insertStrRef(StringRef S) {
15+
if (S.empty())
16+
return {};
17+
18+
static StringSet<> Pool;
19+
auto [It, Inserted] = Pool.insert(S);
20+
return It->getKey();
21+
}
22+
23+
} // namespace llvm

llvm/utils/TableGen/GlobalISel/CombinerUtils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ inline const DagInit *getDagWithOperatorOfSubClass(const Init &N,
6565
return I;
6666
return nullptr;
6767
}
68+
69+
/// Copies a StringRef into a static pool to preserve it.
70+
StringRef insertStrRef(StringRef S);
71+
6872
} // namespace llvm
6973

7074
#endif

0 commit comments

Comments
 (0)