Skip to content

Commit 35e8989

Browse files
[Dialect] Migrate away from PointerUnion::{is,get} (NFC) (#122568)
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>
1 parent dc2963c commit 35e8989

File tree

10 files changed

+14
-13
lines changed

10 files changed

+14
-13
lines changed

mlir/include/mlir/Dialect/Async/IR/AsyncOps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def Async_CallOp : Async_Op<"call",
256256

257257
/// Set the callee for this operation.
258258
void setCalleeFromCallable(CallInterfaceCallable callee) {
259-
(*this)->setAttr("callee", callee.get<SymbolRefAttr>());
259+
(*this)->setAttr("callee", cast<SymbolRefAttr>(callee));
260260
}
261261
}];
262262

mlir/include/mlir/Dialect/EmitC/IR/EmitC.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def EmitC_CallOp : EmitC_Op<"call",
580580

581581
/// Set the callee for this operation.
582582
void setCalleeFromCallable(CallInterfaceCallable callee) {
583-
(*this)->setAttr("callee", callee.get<SymbolRefAttr>());
583+
(*this)->setAttr("callee", cast<SymbolRefAttr>(callee));
584584
}
585585
}];
586586

mlir/include/mlir/Dialect/Func/IR/FuncOps.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def CallOp : Func_Op<"call",
9797

9898
/// Set the callee for this operation.
9999
void setCalleeFromCallable(CallInterfaceCallable callee) {
100-
(*this)->setAttr("callee", callee.get<SymbolRefAttr>());
100+
(*this)->setAttr("callee", cast<SymbolRefAttr>(callee));
101101
}
102102
}];
103103

@@ -168,7 +168,7 @@ def CallIndirectOp : Func_Op<"call_indirect", [
168168

169169
/// Set the callee for this operation.
170170
void setCalleeFromCallable(CallInterfaceCallable callee) {
171-
setOperand(0, callee.get<Value>());
171+
setOperand(0, cast<Value>(callee));
172172
}
173173
}];
174174

mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def LLVM_GEPOp : LLVM_Op<"getelementptr", [Pure,
339339
indices.push_back(value);
340340
else
341341
indices.push_back(
342-
builder.getInt32(valueOrAttr.get<IntegerAttr>().getInt()));
342+
builder.getInt32(cast<IntegerAttr>(valueOrAttr).getInt()));
343343
}
344344
Type baseElementType = op.getElemType();
345345
llvm::Type *elementType = moduleTranslation.convertType(baseElementType);

mlir/include/mlir/Dialect/Transform/IR/TransformOps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ def IncludeOp : TransformDialectOp<"include",
899899
}
900900

901901
void setCalleeFromCallable(::mlir::CallInterfaceCallable callee) {
902-
setTargetAttr(callee.get<SymbolRefAttr>());
902+
setTargetAttr(cast<SymbolRefAttr>(callee));
903903
}
904904

905905
::mlir::Operation::operand_range getArgOperands() {

mlir/lib/Dialect/Affine/IR/AffineOps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5069,7 +5069,7 @@ static OpFoldResult computeProduct(Location loc, OpBuilder &builder,
50695069
if (maybeConst) {
50705070
result = result * builder.getAffineConstantExpr(*maybeConst);
50715071
} else {
5072-
dynamicPart.push_back(term.get<Value>());
5072+
dynamicPart.push_back(cast<Value>(term));
50735073
result = result * builder.getAffineSymbolExpr(nDynamic++);
50745074
}
50755075
}

mlir/test/lib/Dialect/Affine/TestReifyValueBounds.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static LogicalResult testReifyValueBounds(FunctionOpInterface funcOp,
150150
return WalkResult::skip();
151151
}
152152
Value constOp = rewriter.create<arith::ConstantIndexOp>(
153-
op->getLoc(), cast<IntegerAttr>(reified->get<Attribute>()).getInt());
153+
op->getLoc(), cast<IntegerAttr>(cast<Attribute>(*reified)).getInt());
154154
rewriter.replaceOp(op, constOp);
155155
return WalkResult::skip();
156156
});

mlir/test/lib/Dialect/Test/TestOpDefs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ CallInterfaceCallable TestCallAndStoreOp::getCallableForCallee() {
10981098
}
10991099

11001100
void TestCallAndStoreOp::setCalleeFromCallable(CallInterfaceCallable callee) {
1101-
setCalleeAttr(callee.get<SymbolRefAttr>());
1101+
setCalleeAttr(cast<SymbolRefAttr>(callee));
11021102
}
11031103

11041104
Operation::operand_range TestCallAndStoreOp::getArgOperands() {
@@ -1117,7 +1117,7 @@ CallInterfaceCallable TestCallOnDeviceOp::getCallableForCallee() {
11171117
}
11181118

11191119
void TestCallOnDeviceOp::setCalleeFromCallable(CallInterfaceCallable callee) {
1120-
setCalleeAttr(callee.get<SymbolRefAttr>());
1120+
setCalleeAttr(cast<SymbolRefAttr>(callee));
11211121
}
11221122

11231123
Operation::operand_range TestCallOnDeviceOp::getArgOperands() {

mlir/test/lib/Dialect/Test/TestOps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ def ConversionCallOp : TEST_Op<"conversion_call_op",
566566
}
567567

568568
void $cppClass::setCalleeFromCallable(::mlir::CallInterfaceCallable callee) {
569-
(*this)->setAttr("callee", callee.get<SymbolRefAttr>());
569+
(*this)->setAttr("callee", cast<SymbolRefAttr>(callee));
570570
}
571571
}];
572572
}

mlir/test/lib/Dialect/Test/TestTypes.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,9 @@ TestTypeWithLayoutType::verifyEntries(DataLayoutEntryListRef params,
295295
for (DataLayoutEntryInterface entry : params) {
296296
// This is for testing purposes only, so assert well-formedness.
297297
assert(entry.isTypeEntry() && "unexpected identifier entry");
298-
assert(llvm::isa<TestTypeWithLayoutType>(entry.getKey().get<Type>()) &&
299-
"wrong type passed in");
298+
assert(
299+
llvm::isa<TestTypeWithLayoutType>(llvm::cast<Type>(entry.getKey())) &&
300+
"wrong type passed in");
300301
auto array = llvm::dyn_cast<ArrayAttr>(entry.getValue());
301302
assert(array && array.getValue().size() == 2 &&
302303
"expected array of two elements");

0 commit comments

Comments
 (0)