Skip to content

Commit ad27f5f

Browse files
[mlir][Transforms] Dialect conversion: Add flag to dump materialization kind
1 parent 2dc2261 commit ad27f5f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

mlir/lib/Transforms/Utils/DialectConversion.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.
3339
template <typename... Args>
3440
static 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

Comments
 (0)