[all-commits] [llvm/llvm-project] 0d7ff2: [mlir] Refactor TypeConverter to add conversions w...
River Riddle via All-commits
all-commits at lists.llvm.org
Tue Feb 18 16:18:47 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 0d7ff220ed0eeffda3839546ac1f30e98f60128e
https://github.com/llvm/llvm-project/commit/0d7ff220ed0eeffda3839546ac1f30e98f60128e
Author: River Riddle <riddleriver at gmail.com>
Date: 2020-02-18 (Tue, 18 Feb 2020)
Changed paths:
M mlir/docs/DialectConversion.md
M mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h
M mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
M mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
M mlir/include/mlir/Support/STLExtras.h
M mlir/include/mlir/Transforms/DialectConversion.h
M mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
M mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
M mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp
M mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
M mlir/lib/Transforms/DialectConversion.cpp
M mlir/test/lib/TestDialect/TestPatterns.cpp
Log Message:
-----------
[mlir] Refactor TypeConverter to add conversions without inheritance
Summary:
This revision refactors the TypeConverter class to not use inheritance to add type conversions. It instead moves to a registration based system, where conversion callbacks are added to the converter with `addConversion`. This method takes a conversion callback, which must be convertible to any of the following forms(where `T` is a class derived from `Type`:
* Optional<Type> (T type)
- This form represents a 1-1 type conversion. It should return nullptr
or `llvm::None` to signify failure. If `llvm::None` is returned, the
converter is allowed to try another conversion function to perform
the conversion.
* Optional<LogicalResult>(T type, SmallVectorImpl<Type> &results)
- This form represents a 1-N type conversion. It should return
`failure` or `llvm::None` to signify a failed conversion. If the new
set of types is empty, the type is removed and any usages of the
existing value are expected to be removed during conversion. If
`llvm::None` is returned, the converter is allowed to try another
conversion function to perform the conversion.
When attempting to convert a type, the TypeConverter walks each of the registered converters starting with the one registered most recently.
Differential Revision: https://reviews.llvm.org/D74584
More information about the All-commits
mailing list