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