[all-commits] [llvm/llvm-project] 2c438b: [mlir][Transforms] Dialect conversion: add `origin...
Matthias Springer via All-commits
all-commits at lists.llvm.org
Sun Oct 13 03:18:44 PDT 2024
Branch: refs/heads/users/matthias-springer/type_conv_original_type
Home: https://github.com/llvm/llvm-project
Commit: 2c438b0a4f7d01b43ec91f2248b6f29fe8199793
https://github.com/llvm/llvm-project/commit/2c438b0a4f7d01b43ec91f2248b6f29fe8199793
Author: Matthias Springer <mspringer at nvidia.com>
Date: 2024-10-13 (Sun, 13 Oct 2024)
Changed paths:
M flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp
M mlir/include/mlir/Transforms/DialectConversion.h
M mlir/include/mlir/Transforms/OneToNTypeConversion.h
M mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp
M mlir/lib/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRV.cpp
M mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
M mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
M mlir/lib/Dialect/Arith/Transforms/EmulateUnsupportedFloats.cpp
M mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
M mlir/lib/Dialect/EmitC/Transforms/TypeConversions.cpp
M mlir/lib/Dialect/Func/TransformOps/FuncTransformOps.cpp
M mlir/lib/Dialect/Func/Transforms/DecomposeCallGraphTypes.cpp
M mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
M mlir/lib/Dialect/Math/Transforms/ExtendToSupportedTypes.cpp
M mlir/lib/Dialect/Quant/Transforms/StripFuncQuantTypes.cpp
M mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp
M mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp
M mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
M mlir/lib/Dialect/SparseTensor/Transforms/SparseIterationToScf.cpp
M mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.cpp
M mlir/lib/Dialect/Tensor/TransformOps/TensorTransformOps.cpp
M mlir/lib/Dialect/Tosa/Transforms/TosaTypeConverters.cpp
M mlir/lib/Dialect/Vector/Transforms/VectorLinearize.cpp
M mlir/lib/Transforms/Utils/DialectConversion.cpp
M mlir/lib/Transforms/Utils/OneToNTypeConversion.cpp
M mlir/test/lib/Conversion/OneToNTypeConversion/TestOneToNTypeConversionPass.cpp
M mlir/test/lib/Dialect/Arith/TestEmulateWideInt.cpp
M mlir/test/lib/Dialect/Func/TestDecomposeCallGraphTypes.cpp
M mlir/test/lib/Dialect/Test/TestPatterns.cpp
M mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
M mlir/test/lib/Transforms/TestDialectConversion.cpp
Log Message:
-----------
[mlir][Transforms] Dialect conversion: add `originalType` param to materialization
This commit adds an `originalType` parameter to all materialization functions. Without this parameter, target materializations are underspecified.
Note: `originalType` is only needed for target materializations. For source/argument materializations, `originalType` always matches `outputType`. However, to keep the code base simple (i.e., reuse `MaterializationCallbackFn` for all three materializations), `originalType` is passed to all three materializations, even though it is only really needed for target materializations.
`originalType` is the original type of an SSA value. For argument materializations, it matches the original argument type (which is also the output type). For source materializations, it also matches the output type.
For target materializations, consider the following example: Let's assume that a conversion pattern "P1" replaced an SSA value "v1" (type "t1") with "v2" (type "t2"). Then a different conversion pattern "P2" matches an op that has "v1" as an operand. Let's furthermore assume that "P2" determines that the legalized type of "t1" is "t3", which may be different from "t2". In this example, the target materialization callback will be invoked with: outputType = "t3", inputs = "v2", originalType = "t1". Note that the original type "t1" cannot be recovered from just "t3" and "v2"; that's why the originalType parameter exists.
This commit also puts the `Location` parameter right after the `OpBuilder` parameter to be consistent with MLIR conventions.
This change is in preparation of merging the 1:1 and 1:N dialect conversion drivers. As part of that change, argument materializations will be removed (as they are no longer needed). The new `originalType` parameter is needed when lowering MemRef to LLVM. During that lowering, MemRef function block arguments are replaced with the elements that make up a MemRef descriptor. The type converter is set up in such a way that the legalized type of a MemRef type is an `!llvm.struct` that represents the MemRef descriptor. When the bare pointer calling convention is enabled, the function block arguments consist of just an LLVM pointer. In such a case, a target materialization will be invoked to construct a MemRef descriptor (output type = `!llvm.struct<...>`) from just the bare pointer (inputs = `!llvm.ptr`). The original MemRef type is required to construct the MemRef descriptor, as static sizes/strides/offset cannot be inferred from just the bare pointer.
Note for LLVM integration: For all argument/source/target materialization functions, move the `Location` parameter to the second position and add a `Type originalType` parameter to the lambda. No changes are needed to the body of the lambda. When an argument/source materialization is called in your code base, pass the output type as original type. When a target materialization is called, try to pass the original type of the SSA value, which may match `inputs.front().getType()`. If the original type cannot be recovered (which is unlikely), pass `Type()`.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list