diff --git a/mlir/lib/IR/AffineMap.cpp b/mlir/lib/IR/AffineMap.cpp index 719a81ec057f9..8e8a433f331df 100644 --- a/mlir/lib/IR/AffineMap.cpp +++ b/mlir/lib/IR/AffineMap.cpp @@ -753,7 +753,7 @@ AffineMap mlir::foldAttributesIntoMap(Builder &b, AffineMap map, b.getAffineConstantExpr(cast(attr).getInt())); } else { dimReplacements.push_back(b.getAffineDimExpr(numDims++)); - remainingValues.push_back(operands[i].get()); + remainingValues.push_back(cast(operands[i])); } } int64_t numSymbols = 0; @@ -763,7 +763,7 @@ AffineMap mlir::foldAttributesIntoMap(Builder &b, AffineMap map, b.getAffineConstantExpr(cast(attr).getInt())); } else { symReplacements.push_back(b.getAffineSymbolExpr(numSymbols++)); - remainingValues.push_back(operands[i + map.getNumDims()].get()); + remainingValues.push_back(cast(operands[i + map.getNumDims()])); } } return map.replaceDimsAndSymbols(dimReplacements, symReplacements, numDims, diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp index 5397fbabc5c95..edc4709ec3c6e 100644 --- a/mlir/lib/IR/Builders.cpp +++ b/mlir/lib/IR/Builders.cpp @@ -553,7 +553,7 @@ LogicalResult OpBuilder::tryFold(Operation *op, return cleanupFailure(); // Ask the dialect to materialize a constant operation for this value. - Attribute attr = foldResult.get(); + Attribute attr = cast(foldResult); auto *constOp = dialect->materializeConstant(cstBuilder, attr, expectedType, op->getLoc()); if (!constOp) { diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp index bda96509e4c0a..957195202d78d 100644 --- a/mlir/lib/IR/OperationSupport.cpp +++ b/mlir/lib/IR/OperationSupport.cpp @@ -657,7 +657,7 @@ ValueRange::OwnerT ValueRange::offset_base(const OwnerT &owner, return {value + index}; if (auto *operand = llvm::dyn_cast_if_present(owner)) return {operand + index}; - return owner.get()->getNextResultAtOffset(index); + return cast(owner)->getNextResultAtOffset(index); } /// See `llvm::detail::indexed_accessor_range_base` for details. Value ValueRange::dereference_iterator(const OwnerT &owner, ptrdiff_t index) { @@ -665,7 +665,7 @@ Value ValueRange::dereference_iterator(const OwnerT &owner, ptrdiff_t index) { return value[index]; if (auto *operand = llvm::dyn_cast_if_present(owner)) return operand[index].get(); - return owner.get()->getNextResultAtOffset(index); + return cast(owner)->getNextResultAtOffset(index); } //===----------------------------------------------------------------------===// diff --git a/mlir/lib/IR/Region.cpp b/mlir/lib/IR/Region.cpp index e1caa8979eb41..99ca6c5013c11 100644 --- a/mlir/lib/IR/Region.cpp +++ b/mlir/lib/IR/Region.cpp @@ -271,7 +271,7 @@ RegionRange::OwnerT RegionRange::offset_base(const OwnerT &owner, return region + index; if (auto **region = llvm::dyn_cast_if_present(owner)) return region + index; - return &owner.get()[index]; + return &cast(owner)[index]; } /// See `llvm::detail::indexed_accessor_range_base` for details. Region *RegionRange::dereference_iterator(const OwnerT &owner, @@ -280,5 +280,5 @@ Region *RegionRange::dereference_iterator(const OwnerT &owner, return region[index].get(); if (auto **region = llvm::dyn_cast_if_present(owner)) return region[index]; - return &owner.get()[index]; + return &cast(owner)[index]; } diff --git a/mlir/lib/IR/SymbolTable.cpp b/mlir/lib/IR/SymbolTable.cpp index e83d19553d62c..71adfc467611b 100644 --- a/mlir/lib/IR/SymbolTable.cpp +++ b/mlir/lib/IR/SymbolTable.cpp @@ -623,7 +623,7 @@ struct SymbolScope { std::optional walk(CallbackT cback) { if (Region *region = llvm::dyn_cast_if_present(limit)) return walkSymbolUses(*region, cback); - return walkSymbolUses(limit.get(), cback); + return walkSymbolUses(cast(limit), cback); } /// This variant is used when the callback type matches a stripped down type: /// void(SymbolTable::SymbolUse use) @@ -643,7 +643,7 @@ struct SymbolScope { std::optional walkSymbolTable(CallbackT &&cback) { if (Region *region = llvm::dyn_cast_if_present(limit)) return ::walkSymbolTable(*region, cback); - return ::walkSymbolTable(limit.get(), cback); + return ::walkSymbolTable(cast(limit), cback); } /// The representation of the symbol within this scope. diff --git a/mlir/lib/IR/TypeRange.cpp b/mlir/lib/IR/TypeRange.cpp index c05c0ce0d2544..f8878303727d4 100644 --- a/mlir/lib/IR/TypeRange.cpp +++ b/mlir/lib/IR/TypeRange.cpp @@ -32,7 +32,7 @@ TypeRange::TypeRange(ValueRange values) : TypeRange(OwnerT(), values.size()) { else if (auto *operand = llvm::dyn_cast_if_present(owner)) this->base = operand; else - this->base = owner.get(); + this->base = cast(owner); } /// See `llvm::detail::indexed_accessor_range_base` for details. diff --git a/mlir/lib/IR/Verifier.cpp b/mlir/lib/IR/Verifier.cpp index 90ff8ef3b497f..961ab75ad118f 100644 --- a/mlir/lib/IR/Verifier.cpp +++ b/mlir/lib/IR/Verifier.cpp @@ -274,9 +274,9 @@ LogicalResult OperationVerifier::verifyOperation(Operation &op) { WorkItemEntry &top = worklist.back(); auto visit = [](auto &&visitor, WorkItem w) { - if (w.is()) - return visitor(w.get()); - return visitor(w.get()); + if (auto *o = dyn_cast(w)) + return visitor(o); + return visitor(cast(w)); }; const bool isExit = top.getInt(); @@ -299,10 +299,9 @@ LogicalResult OperationVerifier::verifyOperation(Operation &op) { item))) return failure(); - if (item.is()) { - Block ¤tBlock = *item.get(); + if (Block *currentBlock = dyn_cast(item)) { // Skip "isolated from above operations". - for (Operation &o : llvm::reverse(currentBlock)) { + for (Operation &o : llvm::reverse(*currentBlock)) { if (o.getNumRegions() == 0 || !o.hasTrait()) worklist.emplace_back(&o); @@ -310,7 +309,7 @@ LogicalResult OperationVerifier::verifyOperation(Operation &op) { continue; } - Operation ¤tOp = *item.get(); + Operation ¤tOp = *cast(item); if (verifyRecursively) for (Region ®ion : llvm::reverse(currentOp.getRegions())) for (Block &block : llvm::reverse(region))