[Mlir-commits] [mlir] [TableGen] Migrate away from PointerUnion::{is, get} (NFC) (PR #122569)
Kazu Hirata
llvmlistbot at llvm.org
Fri Jan 10 20:09:36 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/122569
Note that PointerUnion::{is,get} have been soft deprecated in
PointerUnion.h:
// FIXME: Replace the uses of is(), get() and dyn_cast() with
// isa<T>, cast<T> and the llvm::dyn_cast<T>
>From 77f8bc64b52da92e3d3768537d391983e83c964f Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 10 Jan 2025 12:48:54 -0800
Subject: [PATCH] [TableGen] Migrate away from PointerUnion::{is,get} (NFC)
Note that PointerUnion::{is,get} have been soft deprecated in
PointerUnion.h:
// FIXME: Replace the uses of is(), get() and dyn_cast() with
// isa<T>, cast<T> and the llvm::dyn_cast<T>
---
mlir/lib/TableGen/Operator.cpp | 4 ++--
mlir/lib/TableGen/Pattern.cpp | 7 +++----
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/mlir/lib/TableGen/Operator.cpp b/mlir/lib/TableGen/Operator.cpp
index 904cc6637d53ff..c360c61afd27bd 100644
--- a/mlir/lib/TableGen/Operator.cpp
+++ b/mlir/lib/TableGen/Operator.cpp
@@ -231,7 +231,7 @@ unsigned Operator::getNumVariableLengthOperands() const {
}
bool Operator::hasSingleVariadicArg() const {
- return getNumArgs() == 1 && getArg(0).is<NamedTypeConstraint *>() &&
+ return getNumArgs() == 1 && isa<NamedTypeConstraint *>(getArg(0)) &&
getOperand(0).isVariadic();
}
@@ -829,7 +829,7 @@ void Operator::print(llvm::raw_ostream &os) const {
if (auto *attr = llvm::dyn_cast_if_present<NamedAttribute *>(arg))
os << "[attribute] " << attr->name << '\n';
else
- os << "[operand] " << arg.get<NamedTypeConstraint *>()->name << '\n';
+ os << "[operand] " << cast<NamedTypeConstraint *>(arg)->name << '\n';
}
}
diff --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp
index ffa0c067b02858..ac8c49c72d384a 100644
--- a/mlir/lib/TableGen/Pattern.cpp
+++ b/mlir/lib/TableGen/Pattern.cpp
@@ -254,8 +254,7 @@ std::string SymbolInfoMap::SymbolInfo::getVarTypeStr(StringRef name) const {
switch (kind) {
case Kind::Attr: {
if (op)
- return op->getArg(getArgIndex())
- .get<NamedAttribute *>()
+ return cast<NamedAttribute *>(op->getArg(getArgIndex()))
->attr.getStorageType()
.str();
// TODO(suderman): Use a more exact type when available.
@@ -305,7 +304,7 @@ std::string SymbolInfoMap::SymbolInfo::getValueAndRangeUse(
}
case Kind::Operand: {
assert(index < 0);
- auto *operand = op->getArg(getArgIndex()).get<NamedTypeConstraint *>();
+ auto *operand = cast<NamedTypeConstraint *>(op->getArg(getArgIndex()));
// If this operand is variadic and this SymbolInfo doesn't have a range
// index, then return the full variadic operand_range. Otherwise, return
// the value itself.
@@ -447,7 +446,7 @@ bool SymbolInfoMap::bindOpArgument(DagNode node, StringRef symbol,
}
auto symInfo =
- op.getArg(argIndex).is<NamedAttribute *>()
+ isa<NamedAttribute *>(op.getArg(argIndex))
? SymbolInfo::getAttr(&op, argIndex)
: SymbolInfo::getOperand(node, &op, argIndex, variadicSubIndex);
More information about the Mlir-commits
mailing list