@@ -339,7 +339,13 @@ class CIRGetMemberOpLowering
339
339
mlir::cast<mlir::named_tuple::NamedTupleType>(memref.getElementType ());
340
340
// The lowered type of the element to access in the named_tuple.
341
341
auto loweredMemberType = namedTupleType.getType (memberIndex);
342
- auto elementMemRefTy = mlir::MemRefType::get ({}, loweredMemberType);
342
+ // memref.view can only cast to another memref. Wrap the target type if it
343
+ // is not already a memref (like with a struct with an array member)
344
+ mlir::MemRefType elementMemRefTy;
345
+ if (mlir::isa<mlir::MemRefType>(loweredMemberType))
346
+ elementMemRefTy = mlir::cast<mlir::MemRefType>(loweredMemberType);
347
+ else
348
+ elementMemRefTy = mlir::MemRefType::get ({}, loweredMemberType);
343
349
auto offset = structLayout->getElementOffset (memberIndex);
344
350
// Synthesize the byte access to right lowered type.
345
351
auto byteShift =
@@ -690,7 +696,8 @@ class CIRConstantOpLowering
690
696
} else if (auto intAttr = mlir::dyn_cast<cir::IntAttr>(cirAttr)) {
691
697
return rewriter.getIntegerAttr (mlirType, intAttr.getValue ());
692
698
} else {
693
- llvm_unreachable (" NYI: unsupported attribute kind lowering to MLIR" );
699
+ cirAttr.dump ();
700
+ // llvm_unreachable("NYI: unsupported attribute kind lowering to MLIR");
694
701
return {};
695
702
}
696
703
}
@@ -720,8 +727,11 @@ class CIRFuncOpLowering : public mlir::OpConversionPattern<cir::FuncOp> {
720
727
721
728
for (const auto &argType : enumerate(fnType.getInputs ())) {
722
729
auto convertedType = typeConverter->convertType (argType.value ());
723
- if (!convertedType)
730
+ if (!convertedType) {
731
+ op.emitError (" CIRFuncOpLowering cannot convert argType " )
732
+ << argType.value ();
724
733
return mlir::failure ();
734
+ }
725
735
signatureConversion.addInputs (argType.index (), convertedType);
726
736
}
727
737
@@ -734,8 +744,11 @@ class CIRFuncOpLowering : public mlir::OpConversionPattern<cir::FuncOp> {
734
744
: mlir::TypeRange ()));
735
745
736
746
if (failed (rewriter.convertRegionTypes (&op.getBody (), *typeConverter,
737
- &signatureConversion)))
747
+ &signatureConversion))) {
748
+ op.emitError (" CIRFuncOpLowering cannot convertRegionTypes to " )
749
+ << resultType;
738
750
return mlir::failure ();
751
+ }
739
752
rewriter.inlineRegionBefore (op.getBody (), fn.getBody (), fn.end ());
740
753
741
754
rewriter.eraseOp (op);
@@ -1368,7 +1381,7 @@ class CIRPtrStrideOpLowering
1368
1381
1369
1382
// Return true if all the PtrStrideOp users are load, store or cast
1370
1383
// with array_to_ptrdecay kind and they are in the same block.
1371
- inline bool isLoadStoreOrCastArrayToPtrProduer (cir::PtrStrideOp op) const {
1384
+ inline bool isLoadStoreOrCastArrayToPtrProducer (cir::PtrStrideOp op) const {
1372
1385
if (op.use_empty ())
1373
1386
return false ;
1374
1387
for (auto *user : op->getUsers ()) {
@@ -1400,14 +1413,16 @@ class CIRPtrStrideOpLowering
1400
1413
mlir::LogicalResult
1401
1414
matchAndRewrite (cir::PtrStrideOp op, OpAdaptor adaptor,
1402
1415
mlir::ConversionPatternRewriter &rewriter) const override {
1403
- if (!isCastArrayToPtrConsumer (op))
1404
- return mlir::failure ();
1405
- if (!isLoadStoreOrCastArrayToPtrProduer (op))
1406
- return mlir::failure ();
1416
+ op.emitRemark (" CIRPtrStrideOpLowering matchAndRewrite cir::PtrStrideOp" );
1417
+ /* if (false && !isCastArrayToPtrConsumer(op))
1418
+ return mlir::failure();
1419
+ if (false && !!isLoadStoreOrCastArrayToPtrProducer(op))
1420
+ return mlir::failure();
1421
+ */
1407
1422
auto baseOp = adaptor.getBase ().getDefiningOp ();
1408
1423
if (!baseOp)
1409
1424
return mlir::failure ();
1410
- if (!isa<mlir::memref::ReinterpretCastOp>(baseOp))
1425
+ if (false && !isa<mlir::memref::ReinterpretCastOp>(baseOp))
1411
1426
return mlir::failure ();
1412
1427
auto base = baseOp->getOperand (0 );
1413
1428
auto dstType = op.getResult ().getType ();
@@ -1465,6 +1480,14 @@ mlir::TypeConverter prepareTypeConverter(mlir::DataLayout &dataLayout) {
1465
1480
[&](mlir::IntegerType type) -> mlir::Type { return type; });
1466
1481
converter.addConversion (
1467
1482
[&](mlir::FloatType type) -> mlir::Type { return type; });
1483
+ #if 0
1484
+ converter.addConversion([&](cir::VoidType type) -> mlir::Type {
1485
+ // cir.void should be used concretely only for pointers, so, point to char
1486
+ // TODO: function returning void hit this!
1487
+ return mlir::IntegerType::get(
1488
+ type.getContext(), 8, mlir::IntegerType::SignednessSemantics::Signless);
1489
+ });
1490
+ #endif
1468
1491
converter.addConversion ([&](cir::VoidType type) -> mlir::Type { return {}; });
1469
1492
converter.addConversion ([&](cir::IntType type) -> mlir::Type {
1470
1493
// arith dialect ops doesn't take signed integer -- drop cir sign here
0 commit comments