[Mlir-commits] [mlir] [TableGen] Migrate away from PointerUnion::{is, get} (NFC) (PR #122569)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Jan 10 20:10:08 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
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>
---
Full diff: https://github.com/llvm/llvm-project/pull/122569.diff
2 Files Affected:
- (modified) mlir/lib/TableGen/Operator.cpp (+2-2)
- (modified) mlir/lib/TableGen/Pattern.cpp (+3-4)
``````````diff
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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/122569
More information about the Mlir-commits
mailing list