| 1 | //===- SPIRVWebGPUTransforms.h - WebGPU-specific Transforms -*- C++ -----*-===// |
| 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 | // Defines SPIR-V transforms used when targetting WebGPU. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #ifndef MLIR_DIALECT_SPIRV_TRANSFORMS_SPIRV_WEBGPU_TRANSFORMS_H |
| 14 | #define MLIR_DIALECT_SPIRV_TRANSFORMS_SPIRV_WEBGPU_TRANSFORMS_H |
| 15 | |
| 16 | #include "mlir/IR/PatternMatch.h" |
| 17 | |
| 18 | namespace mlir { |
| 19 | namespace spirv { |
| 20 | |
| 21 | /// Appends patterns to expand extended multiplication and adition ops into |
| 22 | /// regular arithmetic ops. Extended arithmetic ops are not supported by the |
| 23 | /// WebGPU Shading Language (WGSL). |
| 24 | void populateSPIRVExpandExtendedMultiplicationPatterns( |
| 25 | RewritePatternSet &patterns); |
| 26 | |
| 27 | /// Appends patterns to expand non-finite arithmetic ops `IsNan` and `IsInf`. |
| 28 | /// These are not supported by the WebGPU Shading Language (WGSL). We follow |
| 29 | /// fast math assumptions and assume that all floating point values are finite. |
| 30 | void populateSPIRVExpandNonFiniteArithmeticPatterns( |
| 31 | RewritePatternSet &patterns); |
| 32 | |
| 33 | } // namespace spirv |
| 34 | } // namespace mlir |
| 35 | |
| 36 | #endif // MLIR_DIALECT_SPIRV_TRANSFORMS_SPIRV_WEBGPU_TRANSFORMS_H |
| 37 | |