Skip to content

Commit

Permalink
[TableGen] Migrate away from PointerUnion::{is,get} (NFC) (llvm#122569)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kazutakahirata authored Jan 11, 2025
1 parent a3e62d8 commit 26d513d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions mlir/lib/TableGen/Operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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';
}
}

Expand Down
7 changes: 3 additions & 4 deletions mlir/lib/TableGen/Pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 26d513d

Please sign in to comment.