Skip to content

Commit da37778

Browse files
[Conversion] Migrate away from PointerUnion::{is,get} (NFC)
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> I'm not touching PointerUnion::dyn_cast for now because it's a bit complicated; we could blindly migrate it to dyn_cast_if_present, but we should probably use dyn_cast when the operand is known to be non-null.
1 parent 48d0eb5 commit da37778

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

mlir/lib/Conversion/MemRefToSPIRV/MemRefToSPIRV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ LogicalResult ReinterpretCastPattern::matchAndRewrite(
911911
if (auto val = dyn_cast<Value>(offset))
912912
return val;
913913

914-
int64_t attrVal = cast<IntegerAttr>(offset.get<Attribute>()).getInt();
914+
int64_t attrVal = cast<IntegerAttr>(cast<Attribute>(offset)).getInt();
915915
Attribute attr = rewriter.getIntegerAttr(intType, attrVal);
916916
return rewriter.createOrFold<spirv::ConstantOp>(loc, intType, attr);
917917
}();

mlir/lib/Conversion/MeshToMPI/MeshToMPI.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,12 @@ struct ConvertUpdateHaloOp
241241

242242
// convert a OpFoldResult into a Value
243243
auto toValue = [&rewriter, &loc](OpFoldResult &v) {
244-
return v.is<Value>()
245-
? v.get<Value>()
244+
return isa<Value>(v)
245+
? cast<Value>(v)
246246
: rewriter.create<::mlir::arith::ConstantOp>(
247247
loc,
248248
rewriter.getIndexAttr(
249-
cast<IntegerAttr>(v.get<Attribute>()).getInt()));
249+
cast<IntegerAttr>(cast<Attribute>(v)).getInt()));
250250
};
251251

252252
auto dest = op.getDestination();
@@ -267,11 +267,11 @@ struct ConvertUpdateHaloOp
267267
getMixedValues(op.getStaticHaloSizes(), op.getHaloSizes(), rewriter);
268268
// subviews need Index values
269269
for (auto &sz : haloSizes) {
270-
if (sz.is<Value>()) {
271-
sz = rewriter
272-
.create<arith::IndexCastOp>(loc, rewriter.getIndexType(),
273-
sz.get<Value>())
274-
.getResult();
270+
if (auto value = dyn_cast<Value>(sz)) {
271+
sz =
272+
rewriter
273+
.create<arith::IndexCastOp>(loc, rewriter.getIndexType(), value)
274+
.getResult();
275275
}
276276
}
277277

mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static Value getAsLLVMValue(OpBuilder &builder, Location loc,
124124
return builder.create<LLVM::ConstantOp>(loc, intAttr).getResult();
125125
}
126126

127-
return foldResult.get<Value>();
127+
return cast<Value>(foldResult);
128128
}
129129

130130
namespace {

0 commit comments

Comments
 (0)