xref: /llvm-project/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.td (revision a35a8f4b19a2b7c3f66ffcbdb863448ff87053e7)
1//===-- Passes.td - SPIRV pass definition file -------------*- tablegen -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef MLIR_DIALECT_SPIRV_TRANSFORMS_PASSES
10#define MLIR_DIALECT_SPIRV_TRANSFORMS_PASSES
11
12include "mlir/Pass/PassBase.td"
13
14def SPIRVCanonicalizeGLPass : Pass<"spirv-canonicalize-gl", ""> {
15  let summary = "Canonicalize GLSL ops";
16  let description = [{
17    Pass to run canoncalization patterns that involve GL ops.
18    These patterns cannot be run in default canonicalization because GL ops
19    aren't always available. So they should be involed specifically when needed.
20  }];
21}
22
23def SPIRVCompositeTypeLayoutPass
24    : Pass<"decorate-spirv-composite-type-layout", "mlir::ModuleOp"> {
25  let summary = "Decorate SPIR-V composite type with layout info";
26  let description = [{
27    Module pass that converts composite types used by objects in the
28    StorageBuffer, PhysicalStorageBuffer, Uniform, and PushConstant storage
29    classes to attatch layout information.
30    Right now this pass only supports Vulkan layout rules.
31  }];
32}
33
34def SPIRVLowerABIAttributesPass : Pass<"spirv-lower-abi-attrs", "spirv::ModuleOp"> {
35  let summary = "Decorate SPIR-V composite type with layout info";
36  let description = [{
37    Operation pass that lowers the ABI attributes specified during
38    SPIR-V Lowering. Specifically:
39    1. Creates the global variables for arguments of entry point function using
40      the specification in the `spirv.interface_var_abi` attribute for each
41      argument.
42    2. Inserts the EntryPointOp and the ExecutionModeOp for entry point
43      functions using the specification in the `spirv.entry_point_abi`
44      attribute.
45  }];
46}
47
48def SPIRVRewriteInsertsPass : Pass<"spirv-rewrite-inserts", "spirv::ModuleOp"> {
49  let summary = "Rewrite sequential chains of `spirv.CompositeInsert` operations "
50                "into `spirv.CompositeConstruct` operations";
51}
52
53def SPIRVUnifyAliasedResourcePass
54    : Pass<"spirv-unify-aliased-resource", "spirv::ModuleOp"> {
55  let summary = "Unify access of multiple aliased resources into access of one "
56                "single resource";
57  let constructor = "mlir::spirv::createUnifyAliasedResourcePass()";
58}
59
60def SPIRVUpdateVCEPass : Pass<"spirv-update-vce", "spirv::ModuleOp"> {
61  let summary = "Deduce and attach minimal (version, capabilities, extensions) "
62                "requirements to spirv.module ops";
63  let description = [{
64    Operation pass that deduces and attaches the minimal version/
65    capabilities/extensions requirements for spirv.module ops.
66    For each spirv.module op, this pass requires a `spirv.target_env` attribute
67    on it or an enclosing module-like op to drive the deduction. The reason is
68    that an op can be enabled by multiple extensions/capabilities. So we need
69    to know which one to pick. `spirv.target_env` gives the hard limit as for
70    what the target environment can support; this pass deduces what are
71    actually needed for a specific spirv.module op.
72  }];
73}
74
75def SPIRVWebGPUPreparePass : Pass<"spirv-webgpu-prepare", "spirv::ModuleOp"> {
76  let summary = "Prepare SPIR-V to target WebGPU by expanding unsupported ops "
77                "and replacing with supported ones";
78}
79
80#endif // MLIR_DIALECT_SPIRV_TRANSFORMS_PASSES
81