This is an archive of the discontinued LLVM Phabricator instance.

[mlir][spirv] Replace SPIRVOpLowering with OpConversionPattern
ClosedPublic

Authored by antiagainst on Jan 5 2021, 4:58 AM.

Details

Summary

The dialect conversion framework was enhanced to handle type
conversion automatically. OpConversionPattern already contains
a pointer to the TypeConverter. There is no need to duplicate it
in a separate subclass. This removes the only reason for a
SPIRVOpLowering subclass. It adapts to use core infrastructure
and simplifies the code.

Also added a utility function to OpConversionPattern for getting
TypeConverter as a certain subclass.

Diff Detail

Event Timeline

antiagainst created this revision.Jan 5 2021, 4:58 AM
antiagainst requested review of this revision.Jan 5 2021, 4:58 AM
hanchung added inline comments.Jan 5 2021, 7:50 AM
mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp
162

Why do we use TypeConverter here, not SPIRVTypeConverter? This makes things not consistent. E.g., in l.1014

Value adjustedPtr = adjustAccessChainForBitwidth(
    *getTypeConverter(), accessChainOp, srcBits, dstBits, rewriter);

We actually captured the type convert in l.968:

auto *typeConverter = getTypeConverter<SPIRVTypeConverter>();

I guess the reason is spirv::getElementPtr is taking SPIRVTypeConverter, but this method is not. I would prefer to keep both method taking a same type of TypeConverter, so things will look consistently. E.g., the modification in IntLoadOpPattern and IntStoreOpPattern can be the same, but they are not now.

Address comments

antiagainst marked an inline comment as done.Jan 6 2021, 6:01 AM
antiagainst added inline comments.
mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp
162

I typically prefer to use the more general type when possible. But not a big issue for me here. So fixed.

hanchung accepted this revision.Jan 7 2021, 11:08 AM
This revision is now accepted and ready to land.Jan 7 2021, 11:08 AM
antiagainst marked an inline comment as done.

Rebase

This revision was landed with ongoing or failed builds.Jan 9 2021, 5:08 AM
This revision was automatically updated to reflect the committed changes.