@@ -29,6 +29,12 @@ using namespace mlir::detail;
2929
3030#define DEBUG_TYPE " dialect-conversion"
3131
32+ // / Debugging flag. If set to "true", the materialization kind is attached as
33+ // / an attribute to builtin.unrealized_conversion_cast ops. This flag takes
34+ // / effect only if ConversionConfig::buildMaterialization = false. (Otherwise,
35+ // / the annotated ops are replaced with materializations.)
36+ static const bool kDumpMaterializationKind = false ;
37+
3238// / A utility function to log a successful result for the given reason.
3339template <typename ... Args>
3440static void logSuccess (llvm::ScopedPrinter &os, StringRef fmt, Args &&...args) {
@@ -650,7 +656,7 @@ class CreateOperationRewrite : public OperationRewrite {
650656};
651657
652658// / The type of materialization.
653- enum MaterializationKind {
659+ enum MaterializationKind : int8_t {
654660 // / This materialization materializes a conversion for an illegal block
655661 // / argument type, to the original one.
656662 Argument,
@@ -1417,6 +1423,8 @@ ValueRange ConversionPatternRewriterImpl::buildUnresolvedMaterialization(
14171423 builder.setInsertionPoint (ip.getBlock (), ip.getPoint ());
14181424 auto convertOp =
14191425 builder.create <UnrealizedConversionCastOp>(loc, outputTypes, inputs);
1426+ if (kDumpMaterializationKind )
1427+ convertOp->setAttr (" kind" , builder.getI32IntegerAttr (kind));
14201428 if (valueToMap) {
14211429 assert (outputTypes.size () == 1 && " 1:N mapping is not supported" );
14221430 mapping.map (valueToMap, convertOp.getResult (0 ));
0 commit comments