Skip to content

[NFC][TableGen][GlobalISel] Move MIR Pattern Parsing out of Combiner Impl #80257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion llvm/utils/TableGen/GlobalISel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ set(LLVM_LINK_COMPONENTS

add_llvm_library(LLVMTableGenGlobalISel STATIC DISABLE_LLVM_LINK_LLVM_DYLIB
CodeExpander.cpp
CombinerUtils.cpp
CXXPredicates.cpp
MatchDataInfo.cpp
PatternParser.cpp
Patterns.cpp

DEPENDS
Expand All @@ -15,6 +17,6 @@ add_llvm_library(LLVMTableGenGlobalISel STATIC DISABLE_LLVM_LINK_LLVM_DYLIB

# Users may include its headers as "GlobalISel/*.h"
target_include_directories(LLVMTableGenGlobalISel
INTERFACE
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
)
23 changes: 23 additions & 0 deletions llvm/utils/TableGen/GlobalISel/CombinerUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//===- CombinerUtils.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "CombinerUtils.h"
#include "llvm/ADT/StringSet.h"

namespace llvm {

StringRef insertStrRef(StringRef S) {
if (S.empty())
return {};

static StringSet<> Pool;
auto [It, Inserted] = Pool.insert(S);
return It->getKey();
}

} // namespace llvm
4 changes: 4 additions & 0 deletions llvm/utils/TableGen/GlobalISel/CombinerUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ inline const DagInit *getDagWithOperatorOfSubClass(const Init &N,
return I;
return nullptr;
}

/// Copies a StringRef into a static pool to preserve it.
StringRef insertStrRef(StringRef S);

} // namespace llvm

#endif
Loading