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,
78template <
typename SourceOp,
typename TargetOp>
82 using IntegerOverflowFlagsAttr = LLVM::IntegerOverflowFlagsAttr;
87 StringRef arithAttrName = SourceOp::getIntegerOverflowAttrName();
90 if (
auto arithAttr = dyn_cast_if_present<arith::IntegerOverflowFlagsAttr>(
91 convertedAttr.erase(arithAttrName))) {
96 MLIRContext *ctx = srcOp.getOperation()->getContext();
98 auto llvmFlagAttr = IntegerOverflowFlagsAttr::get(ctx, llvmFlag);
99 StringRef llvmAttrName = TargetOp::getOverflowFlagsAttrName();
103 propertiesAttr =
b.getDictionaryAttr(
ArrayRef(attr));
111 DictionaryAttr propertiesAttr;
114template <
typename SourceOp,
typename TargetOp>
116 static_assert(TargetOp::template hasTrait<
117 LLVM::FPExceptionBehaviorOpInterface::Trait>(),
118 "Target constrained FP operations must implement "
119 "LLVM::FPExceptionBehaviorOpInterface");
126 if constexpr (TargetOp::template hasTrait<
127 LLVM::RoundingModeOpInterface::Trait>()) {
129 StringRef arithAttrName = srcOp.getRoundingModeAttrName();
132 cast<arith::RoundingModeAttr>(convertedAttr.erase(arithAttrName));
134 convertedAttr.set(TargetOp::getRoundingModeAttrName(),
137 convertedAttr.
set(TargetOp::getFPExceptionBehaviorAttrName(),
Attributes are known-constant values of operations.
This class is a general helper class for creating context-global objects like types,...
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.
NamedAttribute represents a combination of a name and an Attribute value.
ArrayRef< NamedAttribute > getAttrs() const
Attribute getPropAttr() const
AttrConvertFastMathToLLVM(SourceOp srcOp)
AttrConvertOverflowToLLVM(SourceOp srcOp)
Attribute getPropAttr() const
ArrayRef< NamedAttribute > getAttrs() const
AttrConverterConstrainedFPToLLVM(SourceOp srcOp)
ArrayRef< NamedAttribute > getAttrs() const
Attribute getPropAttr() 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.