This is an archive of the discontinued LLVM Phabricator instance.

[mlir][spirv] Add a field for client API in target environment
ClosedPublic

Authored by antiagainst on Nov 25 2022, 12:21 PM.

Details

Summary

SPIR-V can be directly consumed by APIs like Vulkan and OpenCL,
where we can use the capability list to diffferentiate. It can
also be used as a compilation target to transcompile to shading
languages like WGSL to target WebGPU. We have no way to tell
that with just the capability list, so we cannot perform certain
transformations only applicable to those targets thus far. So
this commit add a field in the target environment to indicate
the client API for such purposes.

Diff Detail

Event Timeline

antiagainst created this revision.Nov 25 2022, 12:21 PM
antiagainst requested review of this revision.Nov 25 2022, 12:21 PM
kuhar accepted this revision.Nov 25 2022, 12:56 PM
kuhar added inline comments.
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
299

What happens when we need to move a new API in the future? Will it become case 5 while Unknown remains case 4? Instead, would it make sense to define Unknown as case 0 or -1?

This revision is now accepted and ready to land.Nov 25 2022, 12:56 PM
kuhar added inline comments.Nov 25 2022, 12:56 PM
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
299

s/move a new/add a new/

antiagainst marked 2 inline comments as done.

Address comments

antiagainst added inline comments.Nov 25 2022, 1:18 PM
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
299

Good questions. These are meant to be "StrEnumAttr" actually, where the exact number is not fixed and there is no guarantee it won't change in the future. Only the symbol is meaningful here. But we don't have StrEnumAttr anymore.

Using -1 for unknown makes sense. Changed.

kuhar accepted this revision.Nov 25 2022, 1:21 PM