MLIR  18.0.0git
Classes | Functions
mlir::arith Namespace Reference

Classes

class  AttrConvertFastMathToLLVM
 
class  ConstantIntOp
 Specialization of arith.constant op that returns an integer value. More...
 
class  ConstantFloatOp
 Specialization of arith.constant op that returns a floating point value. More...
 
class  ConstantIndexOp
 Specialization of arith.constant op that returns an integer of index type. More...
 
class  NarrowTypeEmulationConverter
 Converts narrow integer or float types that are not supported by the target hardware to wider types. More...
 
class  WideIntEmulationConverter
 Converts integer types that are too wide for the target by splitting them in two halves and thus turning into supported ones, i.e., i2*N --> iN, where N is the widest integer bitwidth supported by the target. More...
 

Functions

LLVM::FastmathFlags convertArithFastMathFlagsToLLVM (arith::FastMathFlags arithFMF)
 
LLVM::FastmathFlagsAttr convertArithFastMathAttrToLLVM (arith::FastMathFlagsAttr fmfAttr)
 
void populateArithToAMDGPUConversionPatterns (RewritePatternSet &patterns)
 
void populateArithToLLVMConversionPatterns (LLVMTypeConverter &converter, RewritePatternSet &patterns)
 
void registerConvertArithToLLVMInterface (DialectRegistry &registry)
 
void populateArithToSPIRVPatterns (SPIRVTypeConverter &typeConverter, RewritePatternSet &patterns)
 
std::unique_ptr< OperationPass<> > createConvertArithToSPIRVPass ()
 
bool applyCmpPredicate (arith::CmpIPredicate predicate, const APInt &lhs, const APInt &rhs)
 Compute lhs pred rhs, where pred is one of the known integer comparison predicates. More...
 
bool applyCmpPredicate (arith::CmpFPredicate predicate, const APFloat &lhs, const APFloat &rhs)
 Compute lhs pred rhs, where pred is one of the known floating point comparison predicates. More...
 
TypedAttr getIdentityValueAttr (AtomicRMWKind kind, Type resultType, OpBuilder &builder, Location loc, bool useOnlyFiniteValue=false)
 Returns the identity value attribute associated with an AtomicRMWKind op. More...
 
std::optional< TypedAttr > getNeutralElement (Operation *op)
 Return the identity numeric value associated to the give op. More...
 
Value getIdentityValue (AtomicRMWKind op, Type resultType, OpBuilder &builder, Location loc, bool useOnlyFiniteValue=false)
 Returns the identity value associated with an AtomicRMWKind op. More...
 
Value getReductionOp (AtomicRMWKind op, OpBuilder &builder, Location loc, Value lhs, Value rhs)
 Returns the value obtained by applying the reduction operation kind associated with a binary AtomicRMWKind op to lhs and rhs. More...
 
arith::CmpIPredicate invertPredicate (arith::CmpIPredicate pred)
 Invert an integer comparison predicate. More...
 
void registerValueBoundsOpInterfaceExternalModels (DialectRegistry &registry)
 
void registerBufferDeallocationOpInterfaceExternalModels (DialectRegistry &registry)
 
void registerBufferizableOpInterfaceExternalModels (DialectRegistry &registry)
 
std::unique_ptr< PasscreateConstantBufferizePass (uint64_t alignment=0)
 Create a pass to bufferize arith.constant ops. More...
 
void populateArithWideIntEmulationPatterns (WideIntEmulationConverter &typeConverter, RewritePatternSet &patterns)
 Adds patterns to emulate wide Arith and Function ops over integer types into supported ones. More...
 
void populateArithNarrowTypeEmulationPatterns (NarrowTypeEmulationConverter &typeConverter, RewritePatternSet &patterns)
 Adds patterns to emulate narrow Arith and Function ops into wide supported types. More...
 
void populateEmulateUnsupportedFloatsConversions (TypeConverter &converter, ArrayRef< Type > sourceTypes, Type targetType)
 Populate the type conversions needed to emulate the unsupported sourceTypes with destType More...
 
void populateEmulateUnsupportedFloatsPatterns (RewritePatternSet &patterns, TypeConverter &converter)
 Add rewrite patterns for converting operations that use illegal float types to ones that use legal ones. More...
 
void populateEmulateUnsupportedFloatsLegality (ConversionTarget &target, TypeConverter &converter)
 Set up a dialect conversion to reject arithmetic operations on unsupported float types. More...
 
void populateCeilFloorDivExpandOpsPatterns (RewritePatternSet &patterns)
 Add patterns to expand Arith ceil/floor division ops. More...
 
void populateExpandBFloat16Patterns (RewritePatternSet &patterns)
 Add patterns to expand Arith bf16 patterns to lower level bitcasts/shifts. More...
 
void populateArithExpandOpsPatterns (RewritePatternSet &patterns)
 Add patterns to expand Arith ops. More...
 
std::unique_ptr< PasscreateArithUnsignedWhenEquivalentPass ()
 Create a pass to replace signed ops with unsigned ones where they are proven equivalent. More...
 
void populateIntRangeOptimizationsPatterns (RewritePatternSet &patterns, DataFlowSolver &solver)
 Add patterns for int range based optimizations. More...
 
std::unique_ptr< PasscreateIntRangeOptimizationsPass ()
 Create a pass which do optimizations based on integer range analysis. More...
 
void populateArithIntNarrowingPatterns (RewritePatternSet &patterns, const ArithIntNarrowingOptions &options)
 Add patterns for integer bitwidth narrowing. More...
 
FailureOr< OpFoldResultreifyIndexValueBound (OpBuilder &b, Location loc, presburger::BoundType type, Value value, ValueBoundsConstraintSet::StopConditionFn stopCondition=nullptr, bool closedUB=false)
 Reify a bound for the given index-typed value in terms of SSA values for which stopCondition is met. More...
 
FailureOr< OpFoldResultreifyShapedValueDimBound (OpBuilder &b, Location loc, presburger::BoundType type, Value value, int64_t dim, ValueBoundsConstraintSet::StopConditionFn stopCondition=nullptr, bool closedUB=false)
 Reify a bound for the specified dimension of the given shaped value in terms of SSA values for which stopCondition is met. More...
 

Function Documentation

◆ applyCmpPredicate() [1/2]

bool mlir::arith::applyCmpPredicate ( arith::CmpFPredicate  predicate,
const APFloat &  lhs,
const APFloat &  rhs 
)

Compute lhs pred rhs, where pred is one of the known floating point comparison predicates.

Definition at line 1792 of file ArithOps.cpp.

◆ applyCmpPredicate() [2/2]

bool mlir::arith::applyCmpPredicate ( arith::CmpIPredicate  predicate,
const APInt &  lhs,
const APInt &  rhs 
)

Compute lhs pred rhs, where pred is one of the known integer comparison predicates.

Definition at line 1661 of file ArithOps.cpp.

◆ convertArithFastMathAttrToLLVM()

LLVM::FastmathFlagsAttr mlir::arith::convertArithFastMathAttrToLLVM ( arith::FastMathFlagsAttr  fmfAttr)

◆ convertArithFastMathFlagsToLLVM()

LLVM::FastmathFlags mlir::arith::convertArithFastMathFlagsToLLVM ( arith::FastMathFlags  arithFMF)

Definition at line 15 of file AttrToLLVMConverter.cpp.

References contract().

Referenced by convertArithFastMathAttrToLLVM().

◆ createArithUnsignedWhenEquivalentPass()

std::unique_ptr< Pass > mlir::arith::createArithUnsignedWhenEquivalentPass ( )

Create a pass to replace signed ops with unsigned ones where they are proven equivalent.

Definition at line 156 of file UnsignedWhenEquivalent.cpp.

◆ createConstantBufferizePass()

std::unique_ptr< Pass > mlir::arith::createConstantBufferizePass ( uint64_t  alignment = 0)

Create a pass to bufferize arith.constant ops.

Definition at line 64 of file Bufferize.cpp.

◆ createConvertArithToSPIRVPass()

std::unique_ptr< OperationPass<> > mlir::arith::createConvertArithToSPIRVPass ( )

Definition at line 1255 of file ArithToSPIRV.cpp.

◆ createIntRangeOptimizationsPass()

std::unique_ptr< Pass > mlir::arith::createIntRangeOptimizationsPass ( )

Create a pass which do optimizations based on integer range analysis.

Definition at line 184 of file IntRangeOptimizations.cpp.

◆ getIdentityValue()

Value mlir::arith::getIdentityValue ( AtomicRMWKind  op,
Type  resultType,
OpBuilder builder,
Location  loc,
bool  useOnlyFiniteValue = false 
)

Returns the identity value associated with an AtomicRMWKind op.

See also
getIdentityValueAttr for a description of what useOnlyFiniteValue does.

Definition at line 2503 of file ArithOps.cpp.

◆ getIdentityValueAttr()

TypedAttr mlir::arith::getIdentityValueAttr ( AtomicRMWKind  kind,
Type  resultType,
OpBuilder builder,
Location  loc,
bool  useOnlyFiniteValue = false 
)

Returns the identity value attribute associated with an AtomicRMWKind op.

useOnlyFiniteValue defines whether the identity value should steer away from infinity representations or anything that is not a proper finite number. E.g., The identity value for maxf is in theory -Inf, but if we want to stay in the finite range, it would be BiggestRepresentableNegativeFloat. The purpose of this boolean is to offer constants that will play nice with fast math related optimizations.

Definition at line 2407 of file ArithOps.cpp.

◆ getNeutralElement()

std::optional< TypedAttr > mlir::arith::getNeutralElement ( Operation op)

Return the identity numeric value associated to the give op.

Return std::nullopt if there is no known neutral element. If op has FastMathFlags::ninf, only finite values will be used as neutral element.

Definition at line 2462 of file ArithOps.cpp.

◆ getReductionOp()

Value mlir::arith::getReductionOp ( AtomicRMWKind  op,
OpBuilder builder,
Location  loc,
Value  lhs,
Value  rhs 
)

Returns the value obtained by applying the reduction operation kind associated with a binary AtomicRMWKind op to lhs and rhs.

Return the value obtained by applying the reduction operation kind associated with a binary AtomicRMWKind op to lhs and rhs.

Definition at line 2513 of file ArithOps.cpp.

Referenced by mlir::affine::loopUnrollJamByFactor().

◆ invertPredicate()

arith::CmpIPredicate mlir::arith::invertPredicate ( arith::CmpIPredicate  pred)

Invert an integer comparison predicate.

Definition at line 65 of file ArithOps.cpp.

Referenced by invertPredicate().

◆ populateArithExpandOpsPatterns()

void mlir::arith::populateArithExpandOpsPatterns ( RewritePatternSet patterns)

Add patterns to expand Arith ops.

Definition at line 363 of file ExpandOps.cpp.

References mlir::RewritePatternSet::add(), mlir::RewritePatternSet::getContext(), and populateCeilFloorDivExpandOpsPatterns().

◆ populateArithIntNarrowingPatterns()

void mlir::arith::populateArithIntNarrowingPatterns ( RewritePatternSet patterns,
const ArithIntNarrowingOptions &  options 
)

Add patterns for integer bitwidth narrowing.

Definition at line 773 of file IntNarrowing.cpp.

References mlir::RewritePatternSet::add(), mlir::RewritePatternSet::getContext(), and options.

◆ populateArithNarrowTypeEmulationPatterns()

void mlir::arith::populateArithNarrowTypeEmulationPatterns ( NarrowTypeEmulationConverter typeConverter,
RewritePatternSet patterns 
)

Adds patterns to emulate narrow Arith and Function ops into wide supported types.

Users need to add conversions about the computation domain of narrow types.

Definition at line 54 of file EmulateNarrowType.cpp.

References mlir::populateCallOpTypeConversionPattern(), and mlir::populateReturnOpTypeConversionPattern().

◆ populateArithToAMDGPUConversionPatterns()

void mlir::arith::populateArithToAMDGPUConversionPatterns ( RewritePatternSet patterns)

◆ populateArithToLLVMConversionPatterns()

void mlir::arith::populateArithToLLVMConversionPatterns ( LLVMTypeConverter converter,
RewritePatternSet patterns 
)

Definition at line 482 of file ArithToLLVM.cpp.

References mlir::RewritePatternSet::add().

◆ populateArithToSPIRVPatterns()

void mlir::arith::populateArithToSPIRVPatterns ( SPIRVTypeConverter typeConverter,
RewritePatternSet patterns 
)

◆ populateArithWideIntEmulationPatterns()

void mlir::arith::populateArithWideIntEmulationPatterns ( WideIntEmulationConverter typeConverter,
RewritePatternSet patterns 
)

Adds patterns to emulate wide Arith and Function ops over integer types into supported ones.

This is done by splitting original power-of-two i2N integer types into two iN halves.

Definition at line 1153 of file EmulateWideInt.cpp.

References mlir::RewritePatternSet::add(), mlir::RewritePatternSet::getContext(), mlir::populateCallOpTypeConversionPattern(), and mlir::populateReturnOpTypeConversionPattern().

◆ populateCeilFloorDivExpandOpsPatterns()

void mlir::arith::populateCeilFloorDivExpandOpsPatterns ( RewritePatternSet patterns)

Add patterns to expand Arith ceil/floor division ops.

Definition at line 351 of file ExpandOps.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

Referenced by populateArithExpandOpsPatterns().

◆ populateEmulateUnsupportedFloatsConversions()

void mlir::arith::populateEmulateUnsupportedFloatsConversions ( TypeConverter converter,
ArrayRef< Type sourceTypes,
Type  targetType 
)

Populate the type conversions needed to emulate the unsupported sourceTypes with destType

Definition at line 103 of file EmulateUnsupportedFloats.cpp.

References mlir::TypeConverter::addConversion(), mlir::TypeConverter::addTargetMaterialization(), mlir::OpBuilder::create(), and mlir::Type::dyn_cast().

◆ populateEmulateUnsupportedFloatsLegality()

void mlir::arith::populateEmulateUnsupportedFloatsLegality ( ConversionTarget target,
TypeConverter converter 
)

Set up a dialect conversion to reject arithmetic operations on unsupported float types.

Definition at line 126 of file EmulateUnsupportedFloats.cpp.

References mlir::ConversionTarget::markUnknownOpDynamicallyLegal().

◆ populateEmulateUnsupportedFloatsPatterns()

void mlir::arith::populateEmulateUnsupportedFloatsPatterns ( RewritePatternSet patterns,
TypeConverter converter 
)

Add rewrite patterns for converting operations that use illegal float types to ones that use legal ones.

Definition at line 121 of file EmulateUnsupportedFloats.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ populateExpandBFloat16Patterns()

void mlir::arith::populateExpandBFloat16Patterns ( RewritePatternSet patterns)

Add patterns to expand Arith bf16 patterns to lower level bitcasts/shifts.

Definition at line 358 of file ExpandOps.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ populateIntRangeOptimizationsPatterns()

void mlir::arith::populateIntRangeOptimizationsPatterns ( RewritePatternSet patterns,
DataFlowSolver solver 
)

Add patterns for int range based optimizations.

Definition at line 179 of file IntRangeOptimizations.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ registerBufferDeallocationOpInterfaceExternalModels()

void mlir::arith::registerBufferDeallocationOpInterfaceExternalModels ( DialectRegistry registry)

◆ registerBufferizableOpInterfaceExternalModels()

void mlir::arith::registerBufferizableOpInterfaceExternalModels ( DialectRegistry registry)

◆ registerConvertArithToLLVMInterface()

void mlir::arith::registerConvertArithToLLVMInterface ( DialectRegistry registry)

Definition at line 471 of file ArithToLLVM.cpp.

References mlir::DialectRegistry::addExtension().

Referenced by mlir::registerAllExtensions().

◆ registerValueBoundsOpInterfaceExternalModels()

void mlir::arith::registerValueBoundsOpInterfaceExternalModels ( DialectRegistry registry)

◆ reifyIndexValueBound()

FailureOr< OpFoldResult > mlir::arith::reifyIndexValueBound ( OpBuilder b,
Location  loc,
presburger::BoundType  type,
Value  value,
ValueBoundsConstraintSet::StopConditionFn  stopCondition = nullptr,
bool  closedUB = false 
)

Reify a bound for the given index-typed value in terms of SSA values for which stopCondition is met.

If no stop condition is specified, reify in terms of the operands of the owner op.

By default, lower/equal bounds are closed and upper bounds are open. If closedUB is set to "true", upper bounds are also closed.

Example: %0 = arith.addi a, b : index %1 = arith.addi %0, c : index

  • If stopCondition evaluates to "true" for %0 and c, "%0 + %c" is an EQ bound for %1.
  • If stopCondition evaluates to "true" for a, b and c, "%a + %b + %c" is an EQ bound for %1.
  • Otherwise, if the owners of a, b or c do not implement the ValueBoundsOpInterface, no bound can be computed.

Definition at line 135 of file ReifyValueBounds.cpp.

References reifyValueBound().

◆ reifyShapedValueDimBound()

FailureOr< OpFoldResult > mlir::arith::reifyShapedValueDimBound ( OpBuilder b,
Location  loc,
presburger::BoundType  type,
Value  value,
int64_t  dim,
ValueBoundsConstraintSet::StopConditionFn  stopCondition = nullptr,
bool  closedUB = false 
)

Reify a bound for the specified dimension of the given shaped value in terms of SSA values for which stopCondition is met.

If no stop condition is specified, reify in terms of the operands of the owner op.

By default, lower/equal bounds are closed and upper bounds are open. If closedUB is set to "true", upper bounds are also closed.

Definition at line 118 of file ReifyValueBounds.cpp.

References reifyValueBound().