9#ifndef MLIR_CONVERSION_ARITHCOMMON_ATTRTOLLVMCONVERTER_H
10#define MLIR_CONVERSION_ARITHCOMMON_ATTRTOLLVMCONVERTER_H
27LLVM::FastmathFlagsAttr
31LLVM::IntegerOverflowFlags
45LLVM::FPExceptionBehaviorAttr
51template <
typename SourceOp,
typename TargetOp>
58 StringRef arithFMFAttrName = SourceOp::getFastMathAttrName();
60 auto arithFMFAttr = dyn_cast_if_present<arith::FastMathFlagsAttr>(
61 convertedAttr.erase(arithFMFAttrName));
63 StringRef targetAttrName = TargetOp::getFastmathAttrName();
64 convertedAttr.set(targetAttrName,
71 return LLVM::IntegerOverflowFlags::none;
81template <
typename SourceOp,
typename TargetOp>
88 StringRef arithAttrName = SourceOp::getIntegerOverflowAttrName();
90 if (
auto arithAttr = dyn_cast_if_present<arith::IntegerOverflowFlagsAttr>(
91 convertedAttr.erase(arithAttrName))) {
101 LLVM::IntegerOverflowFlags overflowFlags = LLVM::IntegerOverflowFlags::none;
104template <
typename SourceOp,
typename TargetOp>
106 static_assert(TargetOp::template hasTrait<
107 LLVM::FPExceptionBehaviorOpInterface::Trait>(),
108 "Target constrained FP operations must implement "
109 "LLVM::FPExceptionBehaviorOpInterface");
116 if constexpr (TargetOp::template hasTrait<
117 LLVM::RoundingModeOpInterface::Trait>()) {
119 StringRef arithAttrName = srcOp.getRoundingModeAttrName();
122 cast<arith::RoundingModeAttr>(convertedAttr.erase(arithAttrName));
124 convertedAttr.set(TargetOp::getRoundingModeAttrName(),
127 convertedAttr.
set(TargetOp::getFPExceptionBehaviorAttrName(),
133 return LLVM::IntegerOverflowFlags::none;
MLIRContext is the top-level object for a collection of MLIR operations.
NamedAttrList is array of NamedAttributes that tracks whether it is sorted and does some basic work t...
Attribute set(StringAttr name, Attribute value)
If the an attribute exists with the specified name, change it to the new value.
LLVM::IntegerOverflowFlags getOverflowFlags() const
ArrayRef< NamedAttribute > getAttrs() const
AttrConvertFastMathToLLVM(SourceOp srcOp)
AttrConvertOverflowToLLVM(SourceOp srcOp)
ArrayRef< NamedAttribute > getAttrs() const
LLVM::IntegerOverflowFlags getOverflowFlags() const
AttrConverterConstrainedFPToLLVM(SourceOp srcOp)
ArrayRef< NamedAttribute > getAttrs() const
LLVM::IntegerOverflowFlags getOverflowFlags() const
LLVM::FPExceptionBehaviorAttr getLLVMDefaultFPExceptionBehavior(MLIRContext &context)
Returns an attribute for the default LLVM FP exception behavior.
LLVM::FastmathFlagsAttr convertArithFastMathAttrToLLVM(arith::FastMathFlagsAttr fmfAttr)
Creates an LLVM fastmath attribute from a given arithmetic fastmath attribute.
LLVM::RoundingMode convertArithRoundingModeToLLVM(arith::RoundingMode roundingMode)
Creates an LLVM rounding mode enum value from a given arithmetic rounding mode enum value.
LLVM::IntegerOverflowFlags convertArithOverflowFlagsToLLVM(arith::IntegerOverflowFlags arithFlags)
Maps arithmetic overflow enum values to LLVM enum values.
LLVM::FastmathFlags convertArithFastMathFlagsToLLVM(arith::FastMathFlags arithFMF)
Maps arithmetic fastmath enum values to LLVM enum values.
LLVM::RoundingModeAttr convertArithRoundingModeAttrToLLVM(arith::RoundingModeAttr roundingModeAttr)
Creates an LLVM rounding mode attribute from a given arithmetic rounding mode attribute.
Include the generated interface declarations.