Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mlir/lib/IR/AffineMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ AffineMap mlir::foldAttributesIntoMap(Builder &b, AffineMap map,
b.getAffineConstantExpr(cast<IntegerAttr>(attr).getInt()));
} else {
dimReplacements.push_back(b.getAffineDimExpr(numDims++));
remainingValues.push_back(operands[i].get<Value>());
remainingValues.push_back(cast<Value>(operands[i]));
}
}
int64_t numSymbols = 0;
Expand All @@ -763,7 +763,7 @@ AffineMap mlir::foldAttributesIntoMap(Builder &b, AffineMap map,
b.getAffineConstantExpr(cast<IntegerAttr>(attr).getInt()));
} else {
symReplacements.push_back(b.getAffineSymbolExpr(numSymbols++));
remainingValues.push_back(operands[i + map.getNumDims()].get<Value>());
remainingValues.push_back(cast<Value>(operands[i + map.getNumDims()]));
}
}
return map.replaceDimsAndSymbols(dimReplacements, symReplacements, numDims,
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/IR/Builders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>();
Attribute attr = cast<Attribute>(foldResult);
auto *constOp = dialect->materializeConstant(cstBuilder, attr, expectedType,
op->getLoc());
if (!constOp) {
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/IR/OperationSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,15 +657,15 @@ ValueRange::OwnerT ValueRange::offset_base(const OwnerT &owner,
return {value + index};
if (auto *operand = llvm::dyn_cast_if_present<OpOperand *>(owner))
return {operand + index};
return owner.get<detail::OpResultImpl *>()->getNextResultAtOffset(index);
return cast<detail::OpResultImpl *>(owner)->getNextResultAtOffset(index);
}
/// See `llvm::detail::indexed_accessor_range_base` for details.
Value ValueRange::dereference_iterator(const OwnerT &owner, ptrdiff_t index) {
if (const auto *value = llvm::dyn_cast_if_present<const Value *>(owner))
return value[index];
if (auto *operand = llvm::dyn_cast_if_present<OpOperand *>(owner))
return operand[index].get();
return owner.get<detail::OpResultImpl *>()->getNextResultAtOffset(index);
return cast<detail::OpResultImpl *>(owner)->getNextResultAtOffset(index);
}

//===----------------------------------------------------------------------===//
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/IR/Region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ RegionRange::OwnerT RegionRange::offset_base(const OwnerT &owner,
return region + index;
if (auto **region = llvm::dyn_cast_if_present<Region **>(owner))
return region + index;
return &owner.get<Region *>()[index];
return &cast<Region *>(owner)[index];
}
/// See `llvm::detail::indexed_accessor_range_base` for details.
Region *RegionRange::dereference_iterator(const OwnerT &owner,
Expand All @@ -280,5 +280,5 @@ Region *RegionRange::dereference_iterator(const OwnerT &owner,
return region[index].get();
if (auto **region = llvm::dyn_cast_if_present<Region **>(owner))
return region[index];
return &owner.get<Region *>()[index];
return &cast<Region *>(owner)[index];
}
4 changes: 2 additions & 2 deletions mlir/lib/IR/SymbolTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ struct SymbolScope {
std::optional<WalkResult> walk(CallbackT cback) {
if (Region *region = llvm::dyn_cast_if_present<Region *>(limit))
return walkSymbolUses(*region, cback);
return walkSymbolUses(limit.get<Operation *>(), cback);
return walkSymbolUses(cast<Operation *>(limit), cback);
}
/// This variant is used when the callback type matches a stripped down type:
/// void(SymbolTable::SymbolUse use)
Expand All @@ -643,7 +643,7 @@ struct SymbolScope {
std::optional<WalkResult> walkSymbolTable(CallbackT &&cback) {
if (Region *region = llvm::dyn_cast_if_present<Region *>(limit))
return ::walkSymbolTable(*region, cback);
return ::walkSymbolTable(limit.get<Operation *>(), cback);
return ::walkSymbolTable(cast<Operation *>(limit), cback);
}

/// The representation of the symbol within this scope.
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/IR/TypeRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TypeRange::TypeRange(ValueRange values) : TypeRange(OwnerT(), values.size()) {
else if (auto *operand = llvm::dyn_cast_if_present<OpOperand *>(owner))
this->base = operand;
else
this->base = owner.get<const Value *>();
this->base = cast<const Value *>(owner);
}

/// See `llvm::detail::indexed_accessor_range_base` for details.
Expand Down
13 changes: 6 additions & 7 deletions mlir/lib/IR/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ LogicalResult OperationVerifier::verifyOperation(Operation &op) {
WorkItemEntry &top = worklist.back();

auto visit = [](auto &&visitor, WorkItem w) {
if (w.is<Operation *>())
return visitor(w.get<Operation *>());
return visitor(w.get<Block *>());
if (auto *o = dyn_cast<Operation *>(w))
return visitor(o);
return visitor(cast<Block *>(w));
};

const bool isExit = top.getInt();
Expand All @@ -299,18 +299,17 @@ LogicalResult OperationVerifier::verifyOperation(Operation &op) {
item)))
return failure();

if (item.is<Block *>()) {
Block &currentBlock = *item.get<Block *>();
if (Block *currentBlock = dyn_cast<Block *>(item)) {
// Skip "isolated from above operations".
for (Operation &o : llvm::reverse(currentBlock)) {
for (Operation &o : llvm::reverse(*currentBlock)) {
if (o.getNumRegions() == 0 ||
!o.hasTrait<OpTrait::IsIsolatedFromAbove>())
worklist.emplace_back(&o);
}
continue;
}

Operation &currentOp = *item.get<Operation *>();
Operation &currentOp = *cast<Operation *>(item);
if (verifyRecursively)
for (Region &region : llvm::reverse(currentOp.getRegions()))
for (Block &block : llvm::reverse(region))
Expand Down
Loading