[Mlir-commits] [mlir] 223dcdc - [mlir] Add optional TypeConverter for materializations.
Sean Silva
llvmlistbot at llvm.org
Fri Apr 2 13:39:47 PDT 2021
Author: Sean Silva
Date: 2021-04-02T13:39:06-07:00
New Revision: 223dcdcfbe23affdf17ada7f023ee1872fd76160
URL: https://github.com/llvm/llvm-project/commit/223dcdcfbe23affdf17ada7f023ee1872fd76160
DIFF: https://github.com/llvm/llvm-project/commit/223dcdcfbe23affdf17ada7f023ee1872fd76160.diff
LOG: [mlir] Add optional TypeConverter for materializations.
`ConversionPatternRewriter::applySignatureConversion` did not have a way
to apply a signature conversion that involved materializations.
Differential Revision: https://reviews.llvm.org/D99782
Added:
Modified:
mlir/include/mlir/Transforms/DialectConversion.h
mlir/lib/Transforms/Utils/DialectConversion.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h
index d1bb6bc1033d..c7598ca4f577 100644
--- a/mlir/include/mlir/Transforms/DialectConversion.h
+++ b/mlir/include/mlir/Transforms/DialectConversion.h
@@ -479,9 +479,12 @@ class ConversionPatternRewriter final : public PatternRewriter {
/// Apply a signature conversion to the entry block of the given region. This
/// replaces the entry block with a new block containing the updated
/// signature. The new entry block to the region is returned for convenience.
+ ///
+ /// If provided, `converter` will be used for any materializations.
Block *
applySignatureConversion(Region *region,
- TypeConverter::SignatureConversion &conversion);
+ TypeConverter::SignatureConversion &conversion,
+ TypeConverter *converter = nullptr);
/// Convert the types of block arguments within the given region. This
/// replaces each block with a new block containing the updated signature. The
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 7036ccd3b28e..bbdaec68364c 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -741,10 +741,12 @@ struct ConversionPatternRewriterImpl {
Block *block, TypeConverter &converter,
TypeConverter::SignatureConversion *conversion = nullptr);
- /// Apply a signature conversion on the given region.
+ /// Apply a signature conversion on the given region, using `converter` for
+ /// materializations if not null.
Block *
applySignatureConversion(Region *region,
- TypeConverter::SignatureConversion &conversion);
+ TypeConverter::SignatureConversion &conversion,
+ TypeConverter *converter);
/// Convert the types of block arguments within the given region.
FailureOr<Block *>
@@ -1145,9 +1147,11 @@ FailureOr<Block *> ConversionPatternRewriterImpl::convertBlockSignature(
}
Block *ConversionPatternRewriterImpl::applySignatureConversion(
- Region *region, TypeConverter::SignatureConversion &conversion) {
+ Region *region, TypeConverter::SignatureConversion &conversion,
+ TypeConverter *converter) {
if (!region->empty()) {
- return *convertBlockSignature(®ion->front(), defaultTypeConverter,
+ return *convertBlockSignature(®ion->front(),
+ converter ? *converter : defaultTypeConverter,
&conversion);
}
return nullptr;
@@ -1335,8 +1339,9 @@ void ConversionPatternRewriter::eraseBlock(Block *block) {
}
Block *ConversionPatternRewriter::applySignatureConversion(
- Region *region, TypeConverter::SignatureConversion &conversion) {
- return impl->applySignatureConversion(region, conversion);
+ Region *region, TypeConverter::SignatureConversion &conversion,
+ TypeConverter *converter) {
+ return impl->applySignatureConversion(region, conversion, converter);
}
FailureOr<Block *> ConversionPatternRewriter::convertRegionTypes(
More information about the Mlir-commits
mailing list