This is an archive of the discontinued LLVM Phabricator instance.

[mlir][spirv] Define spv.Image Operation
ClosedPublic

Authored by Weiwei-2021 on Mar 9 2021, 9:48 AM.

Details

Summary

Define spv.Image Operantion.

Create SPIRVImageOps.td for image related operations since there is no .td file for image operations in spirv.

co-authered-by: Alan Liu <alanliu.yf@gmail.com>

Diff Detail

Event Timeline

Weiwei-2021 created this revision.Mar 9 2021, 9:48 AM
Weiwei-2021 requested review of this revision.Mar 9 2021, 9:48 AM

One thing I noticed that if we define the operation's type format as "type($sampledimage) -> type($result)", the operation seems a little bit log due to the image type. Please let me know whether it is a problem.

antiagainst requested changes to this revision.Mar 9 2021, 1:10 PM
antiagainst added inline comments.
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVImageOps.td
37

Ah this is fairly verbose: we don't want both the image and sampled image to appear. Given the sampled image it's very clear what would be the resultant image. I think for this case we want to avoid use assemblyFormat and manually write the parser/printer to have an assembly format like %1 = spv.Image %0 : !spv.sampled_image<...> (so omitting the -> !spv.image<...> part).

This revision now requires changes to proceed.Mar 9 2021, 1:10 PM
rriddle added inline comments.Mar 9 2021, 1:15 PM
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVImageOps.td
37

You could use TypesMatchWith and still use the assembly format. IMO, these days there are only rare situations that you should switch to C++.

Weiwei-2021 marked 2 inline comments as done.Mar 10 2021, 10:06 AM
Weiwei-2021 added inline comments.
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVImageOps.td
37

I aremove the '-> spiv.image<...>" . As @rriddle mentioend, I don't need to add verify as C++ by using typesMatchWith. Therefore, I also remove the expected-error check.

antiagainst accepted this revision.Mar 10 2021, 12:42 PM
antiagainst added inline comments.
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVImageOps.td
37

You could use TypesMatchWith and still use the assembly format. IMO, these days there are only rare situations that you should switch to C++.

Oh nice! Didn't know about that trick. :)

This revision is now accepted and ready to land.Mar 10 2021, 12:42 PM
This revision was landed with ongoing or failed builds.Mar 10 2021, 12:48 PM
This revision was automatically updated to reflect the committed changes.