| 1 | //===- CanonicalizeGLPass.cpp - GLSL Related Canonicalization Pass ------===// |
|---|---|
| 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 | #include "mlir/Dialect/SPIRV/Transforms/Passes.h" |
| 10 | |
| 11 | #include "mlir/Dialect/SPIRV/IR/SPIRVGLCanonicalization.h" |
| 12 | #include "mlir/Dialect/SPIRV/IR/SPIRVOps.h" |
| 13 | #include "mlir/Pass/Pass.h" |
| 14 | #include "mlir/Transforms/GreedyPatternRewriteDriver.h" |
| 15 | |
| 16 | namespace mlir { |
| 17 | namespace spirv { |
| 18 | #define GEN_PASS_DEF_SPIRVCANONICALIZEGLPASS |
| 19 | #include "mlir/Dialect/SPIRV/Transforms/Passes.h.inc" |
| 20 | } // namespace spirv |
| 21 | } // namespace mlir |
| 22 | |
| 23 | using namespace mlir; |
| 24 | |
| 25 | namespace { |
| 26 | class CanonicalizeGLPass final |
| 27 | : public spirv::impl::SPIRVCanonicalizeGLPassBase<CanonicalizeGLPass> { |
| 28 | public: |
| 29 | void runOnOperation() override { |
| 30 | RewritePatternSet patterns(&getContext()); |
| 31 | spirv::populateSPIRVGLCanonicalizationPatterns(results&: patterns); |
| 32 | if (failed(applyPatternsGreedily(getOperation(), std::move(patterns)))) |
| 33 | return signalPassFailure(); |
| 34 | } |
| 35 | }; |
| 36 | } // namespace |
| 37 |
