//===- AttrToLLVMConverter.h - Arith attributes conversion ------*- C++ -*-===// // // 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_CONVERSION_ARITHCOMMON_ATTRTOLLVMCONVERTER_H #define MLIR_CONVERSION_ARITHCOMMON_ATTRTOLLVMCONVERTER_H #include "mlir/Dialect/Arith/IR/Arith.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" //===----------------------------------------------------------------------===// // Support for converting Arith FastMathFlags to LLVM FastmathFlags //===----------------------------------------------------------------------===// namespace mlir { namespace arith { /// Maps arithmetic fastmath enum values to LLVM enum values. LLVM::FastmathFlags convertArithFastMathFlagsToLLVM(arith::FastMathFlags arithFMF); /// Creates an LLVM fastmath attribute from a given arithmetic fastmath /// attribute. LLVM::FastmathFlagsAttr convertArithFastMathAttrToLLVM(arith::FastMathFlagsAttr fmfAttr); /// Maps arithmetic overflow enum values to LLVM enum values. LLVM::IntegerOverflowFlags convertArithOverflowFlagsToLLVM(arith::IntegerOverflowFlags arithFlags); /// Creates an LLVM rounding mode enum value from a given arithmetic rounding /// mode enum value. LLVM::RoundingMode convertArithRoundingModeToLLVM(arith::RoundingMode roundingMode); /// Creates an LLVM rounding mode attribute from a given arithmetic rounding /// mode attribute. LLVM::RoundingModeAttr convertArithRoundingModeAttrToLLVM(arith::RoundingModeAttr roundingModeAttr); /// Returns an attribute for the default LLVM FP exception behavior. LLVM::FPExceptionBehaviorAttr getLLVMDefaultFPExceptionBehavior(MLIRContext &context); // Attribute converter that populates a NamedAttrList by removing the fastmath // attribute from the source operation attributes, and replacing it with an // equivalent LLVM fastmath attribute. template <typename SourceOp, typename TargetOp> class AttrConvertFastMathToLLVM { … }; // Attribute converter that populates a NamedAttrList by removing the overflow // attribute from the source operation attributes, and replacing it with an // equivalent LLVM overflow attribute. template <typename SourceOp, typename TargetOp> class AttrConvertOverflowToLLVM { … }; template <typename SourceOp, typename TargetOp> class AttrConverterConstrainedFPToLLVM { … }; } // namespace arith } // namespace mlir #endif // MLIR_CONVERSION_ARITHCOMMON_ATTRTOLLVMCONVERTER_H