@@ -1316,43 +1316,37 @@ Block *ConversionPatternRewriterImpl::applySignatureConversion(
1316
1316
continue ;
1317
1317
}
1318
1318
1319
- // This is a 1->1+ mapping.
1319
+ // This is a 1->1+ mapping. 1->N mappings are not fully supported in the
1320
+ // dialect conversion. Therefore, we need an argument materialization to
1321
+ // turn the replacement block arguments into a single SSA value that can be
1322
+ // used as a replacement.
1320
1323
auto replArgs =
1321
1324
newBlock->getArguments ().slice (inputMap->inputNo , inputMap->size );
1322
-
1323
- // When there is no type converter, assume that the new block argument
1324
- // types are legal. This is reasonable to assume because they were
1325
- // specified by the user.
1326
- // FIXME: This won't work for 1->N conversions because multiple output
1327
- // types are not supported in parts of the dialect conversion. In such a
1328
- // case, we currently use the original block argument type (produced by
1329
- // the argument materialization).
1330
- if (!converter && replArgs.size () == 1 ) {
1331
- mapping.map (origArg, replArgs[0 ]);
1332
- appendRewrite<ReplaceBlockArgRewrite>(block, origArg);
1333
- continue ;
1334
- }
1335
-
1336
- // 1->N mappings are not fully supported in the dialect conversion.
1337
- // Therefore, we need an argument materialization to turn the replacement
1338
- // block arguments into a single SSA value (of the original type) that can
1339
- // be used as a replacement.
1340
1325
Value argMat = buildUnresolvedMaterialization (
1341
1326
MaterializationKind::Argument, newBlock, newBlock->begin (),
1342
1327
origArg.getLoc (), /* inputs=*/ replArgs, origArgType, converter);
1343
1328
mapping.map (origArg, argMat);
1344
1329
appendRewrite<ReplaceBlockArgRewrite>(block, origArg);
1345
1330
1346
- // Now legalize the type by building a target materialization.
1347
1331
Type legalOutputType;
1348
- if (converter)
1332
+ if (converter) {
1349
1333
legalOutputType = converter->convertType (origArgType);
1334
+ } else if (replArgs.size () == 1 ) {
1335
+ // When there is no type converter, assume that the new block argument
1336
+ // types are legal. This is reasonable to assume because they were
1337
+ // specified by the user.
1338
+ // FIXME: This won't work for 1->N conversions because multiple output
1339
+ // types are not supported in parts of the dialect conversion. In such a
1340
+ // case, we currently use the original block argument type (produced by
1341
+ // the argument materialization).
1342
+ legalOutputType = replArgs[0 ].getType ();
1343
+ }
1350
1344
if (legalOutputType && legalOutputType != origArgType) {
1351
1345
Value targetMat = buildUnresolvedTargetMaterialization (
1352
1346
origArg.getLoc (), argMat, legalOutputType, converter);
1353
1347
mapping.map (argMat, targetMat);
1354
- appendRewrite<ReplaceBlockArgRewrite>(block, origArg);
1355
1348
}
1349
+ appendRewrite<ReplaceBlockArgRewrite>(block, origArg);
1356
1350
}
1357
1351
1358
1352
appendRewrite<BlockTypeConversionRewrite>(newBlock, block, converter);
0 commit comments