[mlir][spirv] Add a pass to unify aliased resource variables
authorLei Zhang <antiagainst@google.com>
Thu, 17 Feb 2022 14:08:15 +0000 (09:08 -0500)
committerLei Zhang <antiagainst@google.com>
Thu, 17 Feb 2022 14:08:58 +0000 (09:08 -0500)
commitc9b36807beaf120f4e06d9da3b7df7625e440825
tree3675b944ececd0b0b0542f96c2ec6f6694e3a085
parentd1cd64ffdd832220dbe1829c2f09b880be67be31
[mlir][spirv] Add a pass to unify aliased resource variables

In SPIR-V, resources are represented as global variables that
are bound to certain descriptor. SPIR-V requires those global
variables to be declared as aliased if multiple ones are bound
to the same slot. Such aliased decorations can cause issues
for transcompilers like SPIRV-Cross when converting to source
shading languages like MSL.

So this commit adds a pass to perform analysis of aliased
resources and see if we can unify them into one.

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D119872
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td
mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h
mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.td
mlir/lib/Dialect/SPIRV/Transforms/CMakeLists.txt
mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp [new file with mode: 0644]
mlir/test/Dialect/SPIRV/Transforms/unify-aliased-resource.mlir [new file with mode: 0644]