1 //===- Passes.h - SPIR-V pass entry points ----------------------*- C++ -*-===//
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 // This header file defines prototypes that expose pass constructors.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_DIALECT_SPIRV_PASSES_H_
14 #define MLIR_DIALECT_SPIRV_PASSES_H_
15 
16 #include "mlir/Pass/Pass.h"
17 
18 namespace mlir {
19 namespace spirv {
20 
21 class ModuleOp;
22 /// Creates a module pass that converts composite types used by objects in the
23 /// StorageBuffer, PhysicalStorageBuffer, Uniform, and PushConstant storage
24 /// classes with layout information.
25 /// Right now this pass only supports Vulkan layout rules.
26 std::unique_ptr<OperationPass<mlir::ModuleOp>>
27 createDecorateSPIRVCompositeTypeLayoutPass();
28 
29 /// Creates an operation pass that deduces and attaches the minimal version/
30 /// capabilities/extensions requirements for spv.module ops.
31 /// For each spv.module op, this pass requires a `spv.target_env` attribute on
32 /// it or an enclosing module-like op to drive the deduction. The reason is
33 /// that an op can be enabled by multiple extensions/capabilities. So we need
34 /// to know which one to pick. `spv.target_env` gives the hard limit as for
35 /// what the target environment can support; this pass deduces what are
36 /// actually needed for a specific spv.module op.
37 std::unique_ptr<OperationPass<spirv::ModuleOp>>
38 createUpdateVersionCapabilityExtensionPass();
39 
40 /// Creates an operation pass that lowers the ABI attributes specified during
41 /// SPIR-V Lowering. Specifically,
42 /// 1. Creates the global variables for arguments of entry point function using
43 ///    the specification in the `spv.interface_var_abi` attribute for each
44 ///    argument.
45 /// 2. Inserts the EntryPointOp and the ExecutionModeOp for entry point
46 ///    functions using the specification in the `spv.entry_point_abi` attribute.
47 std::unique_ptr<OperationPass<spirv::ModuleOp>> createLowerABIAttributesPass();
48 
49 /// Creates an operation pass that rewrites sequential chains of
50 /// spv.CompositeInsert into spv.CompositeConstruct.
51 std::unique_ptr<OperationPass<spirv::ModuleOp>> createRewriteInsertsPass();
52 
53 //===----------------------------------------------------------------------===//
54 // Registration
55 //===----------------------------------------------------------------------===//
56 
57 /// Generate the code for registering passes.
58 #define GEN_PASS_REGISTRATION
59 #include "mlir/Dialect/SPIRV/Passes.h.inc"
60 
61 } // namespace spirv
62 } // namespace mlir
63 
64 #endif // MLIR_DIALECT_SPIRV_PASSES_H_
65