Skip to content

Commit 4f9aab2

Browse files
authored
[NFC][TableGen][GlobalISel] Move MIR pattern parsing out of combiner (#86789)
Reland of cfa0833
1 parent b8cc838 commit 4f9aab2

File tree

6 files changed

+623
-465
lines changed

6 files changed

+623
-465
lines changed

llvm/utils/TableGen/Common/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ set(LLVM_LINK_COMPONENTS
1212

1313
add_llvm_library(LLVMTableGenCommon STATIC OBJECT EXCLUDE_FROM_ALL
1414
GlobalISel/CodeExpander.cpp
15+
GlobalISel/CombinerUtils.cpp
1516
GlobalISel/CXXPredicates.cpp
1617
GlobalISel/GlobalISelMatchTable.cpp
1718
GlobalISel/GlobalISelMatchTableExecutorEmitter.cpp
1819
GlobalISel/MatchDataInfo.cpp
20+
GlobalISel/PatternParser.cpp
1921
GlobalISel/Patterns.cpp
2022

2123
AsmWriterInst.cpp
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/Common/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)