| //===-- Passes.td - Math pass definition file --------------*- tablegen -*-===// |
| // |
| // 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 |
| // |
| //===----------------------------------------------------------------------===// |
| |
| #ifndef MLIR_DIALECT_MATH_TRANSFORMS_PASSES |
| #define MLIR_DIALECT_MATH_TRANSFORMS_PASSES |
| |
| include "mlir/Pass/PassBase.td" |
| |
| def MathUpliftToFMA : Pass<"math-uplift-to-fma"> { |
| let summary = "Uplift arith ops to math.fma."; |
| let description = [{ |
| Uplift sequence of addf and mulf ops to math.fma if fastmath flags allows it. |
| }]; |
| let dependentDialects = ["math::MathDialect"]; |
| } |
| |
| def MathLegalizeToF32 : Pass<"math-legalize-to-f32"> { |
| let summary = "Legalize floating-point math ops on low-precision floats"; |
| let description = [{ |
| On many targets, the math functions are not implemented for floating-point |
| types less precise than IEEE single-precision (aka f32), such as half-floats, |
| bfloat16, or 8-bit floats. |
| |
| This pass explicitly legalizes these math functions by inserting |
| `arith.extf` and `arith.truncf` pairs around said op, which preserves |
| the original semantics while enabling lowering. |
| |
| As an exception, this pass does not legalize `math.fma`, because |
| that is an operation frequently implemented at low precisions. |
| }]; |
| let dependentDialects = ["math::MathDialect", "arith::ArithDialect"]; |
| } |
| |
| #endif // MLIR_DIALECT_MATH_TRANSFORMS_PASSES |