This commit shuffles SPIR-V code around to better follow MLIR
convention. Specifically,
* Created IR/, Transforms/, Linking/, and Utils/ subdirectories and
moved suitable code inside.
* Created SPIRVEnums.{h|cpp} for SPIR-V C/C++ enums generated from
SPIR-V spec. Previously they are cluttered inside SPIRVTypes.{h|cpp}.
* Fixed include guards in various header files (both .h and .td).
* Moved serialization tests under test/Target/SPIRV.
* Renamed TableGen backend -gen-spirv-op-utils into -gen-spirv-attr-utils
as it is only generating utility functions for attributes.
Reviewed By: mravishankar
Differential Revision: https://reviews.llvm.org/D93407
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
//===- TestModuleCombiner.cpp - Pass to test SPIR-V module combiner lib ---===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
|
|
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
|
|
#include "mlir/Dialect/SPIRV/Linking/ModuleCombiner.h"
|
|
#include "mlir/IR/Builders.h"
|
|
#include "mlir/IR/BuiltinOps.h"
|
|
#include "mlir/Pass/Pass.h"
|
|
|
|
using namespace mlir;
|
|
|
|
namespace {
|
|
class TestModuleCombinerPass
|
|
: public PassWrapper<TestModuleCombinerPass,
|
|
OperationPass<mlir::ModuleOp>> {
|
|
public:
|
|
TestModuleCombinerPass() = default;
|
|
TestModuleCombinerPass(const TestModuleCombinerPass &) {}
|
|
void runOnOperation() override;
|
|
|
|
private:
|
|
mlir::spirv::OwningSPIRVModuleRef combinedModule;
|
|
};
|
|
} // namespace
|
|
|
|
void TestModuleCombinerPass::runOnOperation() {
|
|
auto modules = llvm::to_vector<4>(getOperation().getOps<spirv::ModuleOp>());
|
|
|
|
OpBuilder combinedModuleBuilder(modules[0]);
|
|
combinedModule = spirv::combine(modules, combinedModuleBuilder, nullptr);
|
|
|
|
for (spirv::ModuleOp module : modules)
|
|
module.erase();
|
|
}
|
|
|
|
namespace mlir {
|
|
void registerTestSpirvModuleCombinerPass() {
|
|
PassRegistration<TestModuleCombinerPass> registration(
|
|
"test-spirv-module-combiner", "Tests SPIR-V module combiner library");
|
|
}
|
|
} // namespace mlir
|