Skip to content

[mlir][Transforms][NFC] Rename MaterializationCallbackFn #138814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mlir/docs/DialectConversion.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class TypeConverter {
typename T = typename llvm::function_traits<FnT>::template arg_t<1>>
void addSourceMaterialization(FnT &&callback) {
sourceMaterializations.emplace_back(
wrapMaterialization<T>(std::forward<FnT>(callback)));
wrapSourceMaterialization<T>(std::forward<FnT>(callback)));
}

/// This method registers a materialization that will be called when
Expand All @@ -362,7 +362,7 @@ class TypeConverter {
typename T = typename llvm::function_traits<FnT>::template arg_t<1>>
void addTargetMaterialization(FnT &&callback) {
targetMaterializations.emplace_back(
wrapMaterialization<T>(std::forward<FnT>(callback)));
wrapTargetMaterialization<T>(std::forward<FnT>(callback)));
}
};
```
Expand Down
21 changes: 10 additions & 11 deletions mlir/include/mlir/Transforms/DialectConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class TypeConverter {
std::decay_t<FnT>>::template arg_t<1>>
void addSourceMaterialization(FnT &&callback) {
sourceMaterializations.emplace_back(
wrapMaterialization<T>(std::forward<FnT>(callback)));
wrapSourceMaterialization<T>(std::forward<FnT>(callback)));
}

/// This method registers a materialization that will be called when
Expand Down Expand Up @@ -330,11 +330,10 @@ class TypeConverter {
using ConversionCallbackFn = std::function<std::optional<LogicalResult>(
Type, SmallVectorImpl<Type> &)>;

/// The signature of the callback used to materialize a source/argument
/// conversion.
/// The signature of the callback used to materialize a source conversion.
///
/// Arguments: builder, result type, inputs, location
using MaterializationCallbackFn =
using SourceMaterializationCallbackFn =
std::function<Value(OpBuilder &, Type, ValueRange, Location)>;

/// The signature of the callback used to materialize a target conversion.
Expand Down Expand Up @@ -387,12 +386,12 @@ class TypeConverter {
cachedMultiConversions.clear();
}

/// Generate a wrapper for the given argument/source materialization
/// callback. The callback may take any subclass of `Type` and the
/// wrapper will check for the target type to be of the expected class
/// before calling the callback.
/// Generate a wrapper for the given source materialization callback. The
/// callback may take any subclass of `Type` and the wrapper will check for
/// the target type to be of the expected class before calling the callback.
template <typename T, typename FnT>
MaterializationCallbackFn wrapMaterialization(FnT &&callback) const {
SourceMaterializationCallbackFn
wrapSourceMaterialization(FnT &&callback) const {
return [callback = std::forward<FnT>(callback)](
OpBuilder &builder, Type resultType, ValueRange inputs,
Location loc) -> Value {
Expand Down Expand Up @@ -491,7 +490,7 @@ class TypeConverter {
SmallVector<ConversionCallbackFn, 4> conversions;

/// The list of registered materialization functions.
SmallVector<MaterializationCallbackFn, 2> sourceMaterializations;
SmallVector<SourceMaterializationCallbackFn, 2> sourceMaterializations;
SmallVector<TargetMaterializationCallbackFn, 2> targetMaterializations;

/// The list of registered type attribute conversion functions.
Expand Down Expand Up @@ -740,7 +739,7 @@ class ConversionPatternRewriter final : public PatternRewriter {
///
/// Optionally, a type converter can be provided to build materializations.
/// Note: If no type converter was provided or the type converter does not
/// specify any suitable argument/target materialization rules, the dialect
/// specify any suitable source/target materialization rules, the dialect
/// conversion may fail to legalize unresolved materializations.
Block *
applySignatureConversion(Block *block,
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Transforms/Utils/DialectConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2959,7 +2959,7 @@ TypeConverter::convertSignatureArgs(TypeRange types,
Value TypeConverter::materializeSourceConversion(OpBuilder &builder,
Location loc, Type resultType,
ValueRange inputs) const {
for (const MaterializationCallbackFn &fn :
for (const SourceMaterializationCallbackFn &fn :
llvm::reverse(sourceMaterializations))
if (Value result = fn(builder, resultType, inputs, loc))
return result;
Expand Down