15 LLVM::FastmathFlags llvmFMF{};
16 const std::pair<arith::FastMathFlags, LLVM::FastmathFlags> flags[] = {
17 {arith::FastMathFlags::nnan, LLVM::FastmathFlags::nnan},
18 {arith::FastMathFlags::ninf, LLVM::FastmathFlags::ninf},
19 {arith::FastMathFlags::nsz, LLVM::FastmathFlags::nsz},
20 {arith::FastMathFlags::arcp, LLVM::FastmathFlags::arcp},
22 {arith::FastMathFlags::afn, LLVM::FastmathFlags::afn},
23 {arith::FastMathFlags::reassoc, LLVM::FastmathFlags::reassoc}};
24 for (
auto [arithFlag, llvmFlag] : flags) {
25 if (bitEnumContainsAny(arithFMF, arithFlag))
26 llvmFMF = llvmFMF | llvmFlag;
31 LLVM::FastmathFlagsAttr
33 arith::FastMathFlags arithFMF = fmfAttr.getValue();
39 arith::IntegerOverflowFlags arithFlags) {
40 LLVM::IntegerOverflowFlags llvmFlags{};
41 const std::pair<arith::IntegerOverflowFlags, LLVM::IntegerOverflowFlags>
43 {arith::IntegerOverflowFlags::nsw, LLVM::IntegerOverflowFlags::nsw},
44 {arith::IntegerOverflowFlags::nuw, LLVM::IntegerOverflowFlags::nuw}};
45 for (
auto [arithFlag, llvmFlag] : flags) {
46 if (bitEnumContainsAny(arithFlags, arithFlag))
47 llvmFlags = llvmFlags | llvmFlag;
54 switch (roundingMode) {
55 case arith::RoundingMode::downward:
56 return LLVM::RoundingMode::TowardNegative;
57 case arith::RoundingMode::to_nearest_away:
58 return LLVM::RoundingMode::NearestTiesToAway;
59 case arith::RoundingMode::to_nearest_even:
60 return LLVM::RoundingMode::NearestTiesToEven;
61 case arith::RoundingMode::toward_zero:
62 return LLVM::RoundingMode::TowardZero;
63 case arith::RoundingMode::upward:
64 return LLVM::RoundingMode::TowardPositive;
66 llvm_unreachable(
"Unhandled rounding mode");
70 arith::RoundingModeAttr roundingModeAttr) {
71 assert(roundingModeAttr &&
"Expecting valid attribute");
73 roundingModeAttr.getContext(),
77 LLVM::FPExceptionBehaviorAttr
80 LLVM::FPExceptionBehavior::Ignore);
static void contract(RootOrderingGraph &graph, ArrayRef< Value > cycle, const DenseMap< Value, unsigned > &parentDepths, DenseMap< Value, Value > &actualSource, DenseMap< Value, Value > &actualTarget)
Contracts the specified cycle in the given graph in-place.
MLIRContext is the top-level object for a collection of MLIR operations.
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.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...