Files
clang-p2996/mlir/test/lib/Pass/TestSPIRVCPURunnerPipeline.cpp
Andrea Faulds 9f6c632ecd [mlir][mlir-spirv-cpu-runner] Move MLIR pass pipeline to mlir-opt (#113594)
Adds a new mlir-opt test-only pass, -test-spirv-cpu-runner-pipeline,
which runs the set of MLIR passes needed for the mlir-spirv-cpu-runner,
and removes them from the runner. The tests are changed to invoke
mlir-opt with this flag before running the runner. The eventual goal is
to move all host/device code generation steps out of the runner, like
with some of the other runners.

Recommit of 17e9752267. It was reverted
due to a build failure, but the build failure had in fact already been
fixed in e7302319b5.
2024-10-25 07:21:59 -07:00

48 lines
1.7 KiB
C++

//===------------------ TestSPIRVCPURunnerPipeline.cpp --------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Implements a pipeline for use by mlir-spirv-cpu-runner tests.
//
//===----------------------------------------------------------------------===//
#include "mlir/Conversion/GPUToSPIRV/GPUToSPIRVPass.h"
#include "mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h"
#include "mlir/Dialect/GPU/Transforms/Passes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/Transforms/Passes.h"
#include "mlir/Pass/PassManager.h"
using namespace mlir;
namespace {
void buildTestSPIRVCPURunnerPipeline(OpPassManager &passManager) {
passManager.addPass(createGpuKernelOutliningPass());
passManager.addPass(createConvertGPUToSPIRVPass(/*mapMemorySpace=*/true));
OpPassManager &nestedPM = passManager.nest<spirv::ModuleOp>();
nestedPM.addPass(spirv::createSPIRVLowerABIAttributesPass());
nestedPM.addPass(spirv::createSPIRVUpdateVCEPass());
passManager.addPass(createLowerHostCodeToLLVMPass());
passManager.addPass(createConvertSPIRVToLLVMPass());
}
} // namespace
namespace mlir {
namespace test {
void registerTestSPIRVCPURunnerPipeline() {
PassPipelineRegistration<>(
"test-spirv-cpu-runner-pipeline",
"Runs a series of passes for lowering SPIR-V-dialect MLIR to "
"LLVM-dialect MLIR intended for mlir-spirv-cpu-runner.",
buildTestSPIRVCPURunnerPipeline);
}
} // namespace test
} // namespace mlir