MLIR  16.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
mlir::AffineExpr Class Reference

Base type for affine expression. More...

#include "mlir/IR/AffineExpr.h"

+ Inheritance diagram for mlir::AffineExpr:
+ Collaboration diagram for mlir::AffineExpr:

Public Types

using ImplType = detail::AffineExprStorage
 

Public Member Functions

constexpr AffineExpr ()
 
 AffineExpr (const ImplType *expr)
 
bool operator== (AffineExpr other) const
 
bool operator!= (AffineExpr other) const
 
bool operator== (int64_t v) const
 
bool operator!= (int64_t v) const
 
 operator bool () const
 
bool operator! () const
 
template<typename U >
bool isa () const
 
template<typename U >
dyn_cast () const
 
template<typename U >
dyn_cast_or_null () const
 
template<typename U >
cast () const
 
MLIRContextgetContext () const
 
AffineExprKind getKind () const
 Return the classification for this type. More...
 
void print (raw_ostream &os) const
 
void dump () const
 
bool isSymbolicOrConstant () const
 Returns true if this expression is made out of only symbols and constants, i.e., it does not involve dimensional identifiers. More...
 
bool isPureAffine () const
 Returns true if this is a pure affine expression, i.e., multiplication, floordiv, ceildiv, and mod is only allowed w.r.t constants. More...
 
int64_t getLargestKnownDivisor () const
 Returns the greatest known integral divisor of this affine expression. More...
 
bool isMultipleOf (int64_t factor) const
 Return true if the affine expression is a multiple of 'factor'. More...
 
bool isFunctionOfDim (unsigned position) const
 Return true if the affine expression involves AffineDimExpr position. More...
 
bool isFunctionOfSymbol (unsigned position) const
 Return true if the affine expression involves AffineSymbolExpr position. More...
 
void walk (std::function< void(AffineExpr)> callback) const
 Walk all of the AffineExpr's in this expression in postorder. More...
 
AffineExpr replaceDimsAndSymbols (ArrayRef< AffineExpr > dimReplacements, ArrayRef< AffineExpr > symReplacements) const
 This method substitutes any uses of dimensions and symbols (e.g. More...
 
AffineExpr replaceDims (ArrayRef< AffineExpr > dimReplacements) const
 Dim-only version of replaceDimsAndSymbols. More...
 
AffineExpr replaceSymbols (ArrayRef< AffineExpr > symReplacements) const
 Symbol-only version of replaceDimsAndSymbols. More...
 
AffineExpr replace (AffineExpr expr, AffineExpr replacement) const
 Sparse replace method. More...
 
AffineExpr replace (const DenseMap< AffineExpr, AffineExpr > &map) const
 Sparse replace method. More...
 
AffineExpr shiftDims (unsigned numDims, unsigned shift, unsigned offset=0) const
 Replace dims[offset ... More...
 
AffineExpr shiftSymbols (unsigned numSymbols, unsigned shift, unsigned offset=0) const
 Replace symbols[offset ... More...
 
AffineExpr operator+ (int64_t v) const
 
AffineExpr operator+ (AffineExpr other) const
 
AffineExpr operator- () const
 
AffineExpr operator- (int64_t v) const
 
AffineExpr operator- (AffineExpr other) const
 
AffineExpr operator* (int64_t v) const
 
AffineExpr operator* (AffineExpr other) const
 
AffineExpr floorDiv (uint64_t v) const
 
AffineExpr floorDiv (AffineExpr other) const
 
AffineExpr ceilDiv (uint64_t v) const
 
AffineExpr ceilDiv (AffineExpr other) const
 
AffineExpr operator% (uint64_t v) const
 
AffineExpr operator% (AffineExpr other) const
 
AffineExpr compose (AffineMap map) const
 Compose with an AffineMap. More...
 
const voidgetAsOpaquePointer () const
 Methods supporting C API. More...
 

Static Public Member Functions

static AffineExpr getFromOpaquePointer (const void *pointer)
 

Protected Attributes

ImplTypeexpr {nullptr}
 

Friends

::llvm::hash_code hash_value (AffineExpr arg)
 Make AffineExpr hashable. More...
 

Detailed Description

Base type for affine expression.

AffineExpr's are immutable value types with intuitive operators to operate on chainable, lightweight compositions. An AffineExpr is an interface to the underlying storage type pointer.

Definition at line 68 of file AffineExpr.h.

Member Typedef Documentation

◆ ImplType

Definition at line 70 of file AffineExpr.h.

Constructor & Destructor Documentation

◆ AffineExpr() [1/2]

constexpr mlir::AffineExpr::AffineExpr ( )
inline

Definition at line 72 of file AffineExpr.h.

◆ AffineExpr() [2/2]

mlir::AffineExpr::AffineExpr ( const ImplType expr)
inline

Definition at line 73 of file AffineExpr.h.

Member Function Documentation

◆ cast()

template<typename U >
U mlir::AffineExpr::cast ( ) const

◆ ceilDiv() [1/2]

AffineExpr AffineExpr::ceilDiv ( uint64_t  v) const

◆ ceilDiv() [2/2]

AffineExpr AffineExpr::ceilDiv ( AffineExpr  other) const

◆ compose()

AffineExpr AffineExpr::compose ( AffineMap  map) const

Compose with an AffineMap.

Returns the composition of this AffineExpr with map.

Prerequisites: this and map are composable, i.e. that the number of AffineDimExpr of this is smaller than the number of results of map. If a result of a map does not have a corresponding AffineDimExpr, that result simply does not appear in the produced AffineExpr.

Example: expr: d0 + d2 map: (d0, d1, d2)[s0, s1] -> (d0 + s1, d1 + s0, d0 + d1 + d2) returned expr: d0 * 2 + d1 + d2 + s1

Definition at line 875 of file AffineExpr.cpp.

References mlir::AffineMap::getResults(), and replaceDimsAndSymbols().

Referenced by mlir::AffineMap::compose().

◆ dump()

void AffineExpr::dump ( ) const

Definition at line 3321 of file AsmPrinter.cpp.

References print().

◆ dyn_cast()

template<typename U >
U mlir::AffineExpr::dyn_cast ( ) const

◆ dyn_cast_or_null()

template<typename U >
U mlir::AffineExpr::dyn_cast_or_null ( ) const

Definition at line 287 of file AffineExpr.h.

◆ floorDiv() [1/2]

AffineExpr AffineExpr::floorDiv ( uint64_t  v) const

◆ floorDiv() [2/2]

AffineExpr AffineExpr::floorDiv ( AffineExpr  other) const

◆ getAsOpaquePointer()

const void* mlir::AffineExpr::getAsOpaquePointer ( ) const
inline

Methods supporting C API.

Definition at line 189 of file AffineExpr.h.

◆ getContext()

MLIRContext * AffineExpr::getContext ( ) const

◆ getFromOpaquePointer()

static AffineExpr mlir::AffineExpr::getFromOpaquePointer ( const void pointer)
inlinestatic

Definition at line 192 of file AffineExpr.h.

◆ getKind()

AffineExprKind AffineExpr::getKind ( ) const

◆ getLargestKnownDivisor()

int64_t AffineExpr::getLargestKnownDivisor ( ) const

Returns the greatest known integral divisor of this affine expression.

The result is always positive.

Definition at line 219 of file AffineExpr.cpp.

References mlir::presburger::abs(), mlir::Add, mlir::CeilDiv, mlir::Constant, mlir::DimId, mlir::FloorDiv, mlir::presburger::gcd(), getLargestKnownDivisor(), mlir::AffineBinaryOpExpr::getLHS(), mlir::AffineBinaryOpExpr::getRHS(), mlir::Mod, mlir::Mul, and mlir::SymbolId.

Referenced by getLargestKnownDivisor(), and isMultipleOf().

◆ isa()

template<typename U >
bool mlir::AffineExpr::isa ( ) const

◆ isFunctionOfDim()

bool AffineExpr::isFunctionOfDim ( unsigned  position) const

Return true if the affine expression involves AffineDimExpr position.

Definition at line 279 of file AffineExpr.cpp.

References mlir::DimId, and mlir::getAffineDimExpr().

Referenced by denseUnitStrides(), mlir::AffineValueMap::isFunctionOf(), and mlir::AffineMap::isFunctionOfDim().

◆ isFunctionOfSymbol()

bool AffineExpr::isFunctionOfSymbol ( unsigned  position) const

Return true if the affine expression involves AffineSymbolExpr position.

Definition at line 290 of file AffineExpr.cpp.

References mlir::getAffineSymbolExpr(), and mlir::SymbolId.

Referenced by mlir::AffineMap::isFunctionOfSymbol().

◆ isMultipleOf()

bool AffineExpr::isMultipleOf ( int64_t  factor) const

◆ isPureAffine()

bool AffineExpr::isPureAffine ( ) const

Returns true if this is a pure affine expression, i.e., multiplication, floordiv, ceildiv, and mod is only allowed w.r.t constants.

Definition at line 188 of file AffineExpr.cpp.

References mlir::Add, mlir::CeilDiv, mlir::Constant, mlir::DimId, mlir::FloorDiv, mlir::Mod, mlir::Mul, and mlir::SymbolId.

Referenced by mlir::simplifyAffineExpr().

◆ isSymbolicOrConstant()

bool AffineExpr::isSymbolicOrConstant ( ) const

Returns true if this expression is made out of only symbols and constants, i.e., it does not involve dimensional identifiers.

Returns true if this expression is made out of only symbols and constants (no dimensional identifiers).

Definition at line 164 of file AffineExpr.cpp.

References mlir::Add, mlir::CeilDiv, mlir::Constant, mlir::DimId, mlir::FloorDiv, mlir::Mod, mlir::Mul, and mlir::SymbolId.

◆ operator bool()

mlir::AffineExpr::operator bool ( ) const
inlineexplicit

Definition at line 80 of file AffineExpr.h.

◆ operator!()

bool mlir::AffineExpr::operator! ( ) const
inline

◆ operator!=() [1/2]

bool mlir::AffineExpr::operator!= ( AffineExpr  other) const
inline

Definition at line 77 of file AffineExpr.h.

References mlir::operator==().

◆ operator!=() [2/2]

bool mlir::AffineExpr::operator!= ( int64_t  v) const
inline

Definition at line 79 of file AffineExpr.h.

◆ operator%() [1/2]

AffineExpr AffineExpr::operator% ( uint64_t  v) const

Definition at line 863 of file AffineExpr.cpp.

References mlir::getAffineConstantExpr(), and getContext().

◆ operator%() [2/2]

AffineExpr AffineExpr::operator% ( AffineExpr  other) const

◆ operator*() [1/2]

AffineExpr AffineExpr::operator* ( int64_t  v) const

Definition at line 698 of file AffineExpr.cpp.

References mlir::getAffineConstantExpr(), and getContext().

◆ operator*() [2/2]

AffineExpr AffineExpr::operator* ( AffineExpr  other) const

◆ operator+() [1/2]

AffineExpr AffineExpr::operator+ ( int64_t  v) const

Definition at line 638 of file AffineExpr.cpp.

References mlir::getAffineConstantExpr(), and getContext().

◆ operator+() [2/2]

AffineExpr AffineExpr::operator+ ( AffineExpr  other) const

◆ operator-() [1/3]

AffineExpr AffineExpr::operator- ( ) const

Definition at line 711 of file AffineExpr.cpp.

References mlir::getAffineConstantExpr(), and getContext().

◆ operator-() [2/3]

AffineExpr AffineExpr::operator- ( int64_t  v) const

Definition at line 716 of file AffineExpr.cpp.

◆ operator-() [3/3]

AffineExpr AffineExpr::operator- ( AffineExpr  other) const

Definition at line 717 of file AffineExpr.cpp.

◆ operator==() [1/2]

bool mlir::AffineExpr::operator== ( AffineExpr  other) const
inline

Definition at line 76 of file AffineExpr.h.

References expr.

◆ operator==() [2/2]

bool AffineExpr::operator== ( int64_t  v) const

Definition at line 509 of file AffineExpr.cpp.

References mlir::getAffineConstantExpr(), and getContext().

◆ print()

void AffineExpr::print ( raw_ostream &  os) const

Definition at line 3312 of file AsmPrinter.cpp.

References mlir::AsmState::getImpl().

Referenced by mlir::operator<<().

◆ replace() [1/2]

AffineExpr AffineExpr::replace ( AffineExpr  expr,
AffineExpr  replacement 
) const

Sparse replace method.

Sparse replace method. Return the modified expression tree.

Replace expr by replacement and return the modified expression tree.

Definition at line 157 of file AffineExpr.cpp.

◆ replace() [2/2]

AffineExpr AffineExpr::replace ( const DenseMap< AffineExpr, AffineExpr > &  map) const

Sparse replace method.

Sparse replace method. Return the modified expression tree.

If *this appears in map replaces it by map[*this] and return the modified expression tree. Otherwise traverse *this and apply replace with map on its subexpressions.

Definition at line 133 of file AffineExpr.cpp.

References mlir::Add, mlir::CeilDiv, mlir::FloorDiv, mlir::Mod, and mlir::Mul.

◆ replaceDims()

AffineExpr AffineExpr::replaceDims ( ArrayRef< AffineExpr dimReplacements) const

Dim-only version of replaceDimsAndSymbols.

Definition at line 98 of file AffineExpr.cpp.

◆ replaceDimsAndSymbols()

AffineExpr AffineExpr::replaceDimsAndSymbols ( ArrayRef< AffineExpr dimReplacements,
ArrayRef< AffineExpr symReplacements 
) const

This method substitutes any uses of dimensions and symbols (e.g.

dim#0 with dimReplacements[0]) and returns the modified expression tree. This is a dense replacement method: a replacement must be specified for every single dim and symbol.

dim#0 with dimReplacements[0]) and returns the modified expression tree.

Definition at line 65 of file AffineExpr.cpp.

References mlir::Add, mlir::CeilDiv, mlir::Constant, mlir::DimId, mlir::FloorDiv, mlir::Mod, mlir::Mul, and mlir::SymbolId.

Referenced by compose(), and mlir::AffineMap::replaceDimsAndSymbols().

◆ replaceSymbols()

AffineExpr AffineExpr::replaceSymbols ( ArrayRef< AffineExpr symReplacements) const

Symbol-only version of replaceDimsAndSymbols.

Definition at line 103 of file AffineExpr.cpp.

◆ shiftDims()

AffineExpr AffineExpr::shiftDims ( unsigned  numDims,
unsigned  shift,
unsigned  offset = 0 
) const

Replace dims[offset ...

numDims) by dims[offset + shift ... shift + numDims).

Definition at line 109 of file AffineExpr.cpp.

References mlir::getAffineDimExpr().

Referenced by mlir::AffineMap::shiftDims().

◆ shiftSymbols()

AffineExpr AffineExpr::shiftSymbols ( unsigned  numSymbols,
unsigned  shift,
unsigned  offset = 0 
) const

Replace symbols[offset ...

numSymbols) by symbols[offset + shift ... shift + numSymbols).

Definition at line 121 of file AffineExpr.cpp.

References mlir::getAffineSymbolExpr().

Referenced by mlir::AffineMap::shiftSymbols().

◆ walk()

void AffineExpr::walk ( std::function< void(AffineExpr)>  callback) const

Walk all of the AffineExpr's in this expression in postorder.

Walk all of the AffineExprs in this subgraph in postorder.

Definition at line 29 of file AffineExpr.cpp.

Referenced by isNormalizedMemRefDynamicDim(), and mlir::AffineMap::walkExprs().

Friends And Related Function Documentation

◆ hash_value

::llvm::hash_code hash_value ( AffineExpr  arg)
friend

Make AffineExpr hashable.

Definition at line 240 of file AffineExpr.h.

Member Data Documentation

◆ expr

ImplType* mlir::AffineExpr::expr {nullptr}
protected

The documentation for this class was generated from the following files: