From 26d513d197e14b824dd9d353aff38af1925c3770 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 11 Jan 2025 00:17:40 -0800 Subject: [PATCH] [TableGen] Migrate away from PointerUnion::{is,get} (NFC) (#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, cast and the llvm::dyn_cast --- 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 904cc6637d53ffd..c360c61afd27bd7 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() && + return getNumArgs() == 1 && isa(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(arg)) os << "[attribute] " << attr->name << '\n'; else - os << "[operand] " << arg.get()->name << '\n'; + os << "[operand] " << cast(arg)->name << '\n'; } } diff --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp index ffa0c067b02858d..ac8c49c72d384a5 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() + return cast(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(); + auto *operand = cast(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() + isa(op.getArg(argIndex)) ? SymbolInfo::getAttr(&op, argIndex) : SymbolInfo::getOperand(node, &op, argIndex, variadicSubIndex);