MLIR
20.0.0git
|
Base class for AffineExpr visitors/walkers. More...
#include "mlir/IR/AffineExprVisitor.h"
Public Member Functions | |
RetTy | visit (AffineExpr expr) |
RetTy | visitAffineBinaryOpExpr (AffineBinaryOpExpr expr) |
RetTy | visitAddExpr (AffineBinaryOpExpr expr) |
RetTy | visitMulExpr (AffineBinaryOpExpr expr) |
RetTy | visitModExpr (AffineBinaryOpExpr expr) |
RetTy | visitFloorDivExpr (AffineBinaryOpExpr expr) |
RetTy | visitCeilDivExpr (AffineBinaryOpExpr expr) |
RetTy | visitConstantExpr (AffineConstantExpr expr) |
RetTy | visitDimExpr (AffineDimExpr expr) |
RetTy | visitSymbolExpr (AffineSymbolExpr expr) |
Base class for AffineExpr visitors/walkers.
AffineExpr visitors are used when you want to perform different actions for different kinds of AffineExprs without having to use lots of casts and a big switch instruction.
To define your own visitor, inherit from this class, specifying your new type for the 'SubClass' template parameter, and "override" visitXXX functions in your class. This class is defined in terms of statically resolved overloading, not virtual functions.
The visitor is templated on its return type (RetTy
). With a WalkResult return type, the visitor supports interrupting walks.
For example, here is a visitor that counts the number of for AffineDimExprs in an AffineExpr.
/// Declare the class. Note that we derive from AffineExprVisitor /// instantiated with our new subclasses_ type.
struct DimExprCounter : public AffineExprVisitor<DimExprCounter> { unsigned numDimExprs; DimExprCounter() : numDimExprs(0) {} void visitDimExpr(AffineDimExpr expr) { ++numDimExprs; } };
And this class would be used like this: DimExprCounter dec; dec.visit(affineExpr); numDimExprs = dec.numDimExprs;
AffineExprVisitor provides visit methods for the following binary affine op expressions: AffineBinaryAddOpExpr, AffineBinaryMulOpExpr, AffineBinaryModOpExpr, AffineBinaryFloorDivOpExpr, AffineBinaryCeilDivOpExpr. Note that default implementations of these methods will call the general AffineBinaryOpExpr method.
In addition, visit methods are provided for the following affine Note that if you don't implement visitXXX for some affine expression type, the visitXXX method for Instruction superclass will be invoked.
Note that this class is specifically designed as a template to avoid virtual function call overhead. Defining and using a AffineExprVisitor is just as efficient as having your own switch instruction over the instruction opcode.
Definition at line 72 of file AffineExprVisitor.h.
|
inline |
Definition at line 75 of file AffineExprVisitor.h.
References mlir::Add, mlir::CeilDiv, mlir::Constant, mlir::DimId, mlir::FloorDiv, mlir::AffineExpr::getKind(), mlir::Mod, mlir::Mul, and mlir::SymbolId.
|
inline |
Definition at line 121 of file AffineExprVisitor.h.
References mlir::AffineExprVisitorBase< SubClass, RetTy >::visitAffineBinaryOpExpr().
|
inline |
Definition at line 120 of file AffineExprVisitor.h.
Referenced by mlir::AffineExprVisitorBase< SubClass, RetTy >::visitAddExpr(), mlir::AffineExprVisitorBase< SubClass, RetTy >::visitCeilDivExpr(), mlir::AffineExprVisitorBase< SubClass, RetTy >::visitFloorDivExpr(), mlir::AffineExprVisitorBase< SubClass, RetTy >::visitModExpr(), and mlir::AffineExprVisitorBase< SubClass, RetTy >::visitMulExpr().
|
inline |
Definition at line 133 of file AffineExprVisitor.h.
References mlir::AffineExprVisitorBase< SubClass, RetTy >::visitAffineBinaryOpExpr().
|
inline |
Definition at line 136 of file AffineExprVisitor.h.
|
inline |
Definition at line 137 of file AffineExprVisitor.h.
|
inline |
Definition at line 130 of file AffineExprVisitor.h.
References mlir::AffineExprVisitorBase< SubClass, RetTy >::visitAffineBinaryOpExpr().
|
inline |
Definition at line 127 of file AffineExprVisitor.h.
References mlir::AffineExprVisitorBase< SubClass, RetTy >::visitAffineBinaryOpExpr().
|
inline |
Definition at line 124 of file AffineExprVisitor.h.
References mlir::AffineExprVisitorBase< SubClass, RetTy >::visitAffineBinaryOpExpr().
|
inline |
Definition at line 138 of file AffineExprVisitor.h.