|
| 1 | +//===------------------ TestVulkanRunnerPipeline.cpp --------------------===// |
| 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 | +// Implements a pipeline for use by mlir-vulkan-runner tests. |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +#include "mlir/Conversion/ConvertToSPIRV/ConvertToSPIRVPass.h" |
| 14 | +#include "mlir/Conversion/GPUToSPIRV/GPUToSPIRVPass.h" |
| 15 | +#include "mlir/Dialect/GPU/Transforms/Passes.h" |
| 16 | +#include "mlir/Dialect/MemRef/Transforms/Passes.h" |
| 17 | +#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h" |
| 18 | +#include "mlir/Dialect/SPIRV/Transforms/Passes.h" |
| 19 | +#include "mlir/Pass/PassManager.h" |
| 20 | + |
| 21 | +using namespace mlir; |
| 22 | + |
| 23 | +namespace { |
| 24 | + |
| 25 | +void buildTestVulkanRunnerPipeline(OpPassManager &passManager) { |
| 26 | + passManager.addPass(createGpuKernelOutliningPass()); |
| 27 | + passManager.addPass(memref::createFoldMemRefAliasOpsPass()); |
| 28 | + |
| 29 | + ConvertToSPIRVPassOptions convertToSPIRVOptions{}; |
| 30 | + convertToSPIRVOptions.convertGPUModules = true; |
| 31 | + passManager.addPass(createConvertToSPIRVPass(convertToSPIRVOptions)); |
| 32 | + OpPassManager &modulePM = passManager.nest<spirv::ModuleOp>(); |
| 33 | + modulePM.addPass(spirv::createSPIRVLowerABIAttributesPass()); |
| 34 | + modulePM.addPass(spirv::createSPIRVUpdateVCEPass()); |
| 35 | +} |
| 36 | + |
| 37 | +} // namespace |
| 38 | + |
| 39 | +namespace mlir::test { |
| 40 | +void registerTestVulkanRunnerPipeline() { |
| 41 | + PassPipelineRegistration<>( |
| 42 | + "test-vulkan-runner-pipeline", |
| 43 | + "Runs a series of passes for lowering GPU-dialect MLIR to " |
| 44 | + "SPIR-V-dialect MLIR intended for mlir-vulkan-runner.", |
| 45 | + buildTestVulkanRunnerPipeline); |
| 46 | +} |
| 47 | +} // namespace mlir::test |
0 commit comments