MLIR  20.0.0git
Public Member Functions | List of all members
mlir::AffineExprVisitorBase< SubClass, RetTy > Class Template Reference

Base class for AffineExpr visitors/walkers. More...

#include "mlir/IR/AffineExprVisitor.h"

+ Inheritance diagram for mlir::AffineExprVisitorBase< SubClass, RetTy >:

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)
 

Detailed Description

template<typename SubClass, typename RetTy>
class mlir::AffineExprVisitorBase< SubClass, RetTy >

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.

Member Function Documentation

◆ visit()

template<typename SubClass , typename RetTy >
RetTy mlir::AffineExprVisitorBase< SubClass, RetTy >::visit ( AffineExpr  expr)
inline

◆ visitAddExpr()

template<typename SubClass , typename RetTy >
RetTy mlir::AffineExprVisitorBase< SubClass, RetTy >::visitAddExpr ( AffineBinaryOpExpr  expr)
inline

◆ visitAffineBinaryOpExpr()

template<typename SubClass , typename RetTy >
RetTy mlir::AffineExprVisitorBase< SubClass, RetTy >::visitAffineBinaryOpExpr ( AffineBinaryOpExpr  expr)
inline

◆ visitCeilDivExpr()

template<typename SubClass , typename RetTy >
RetTy mlir::AffineExprVisitorBase< SubClass, RetTy >::visitCeilDivExpr ( AffineBinaryOpExpr  expr)
inline

◆ visitConstantExpr()

template<typename SubClass , typename RetTy >
RetTy mlir::AffineExprVisitorBase< SubClass, RetTy >::visitConstantExpr ( AffineConstantExpr  expr)
inline

Definition at line 136 of file AffineExprVisitor.h.

◆ visitDimExpr()

template<typename SubClass , typename RetTy >
RetTy mlir::AffineExprVisitorBase< SubClass, RetTy >::visitDimExpr ( AffineDimExpr  expr)
inline

Definition at line 137 of file AffineExprVisitor.h.

◆ visitFloorDivExpr()

template<typename SubClass , typename RetTy >
RetTy mlir::AffineExprVisitorBase< SubClass, RetTy >::visitFloorDivExpr ( AffineBinaryOpExpr  expr)
inline

◆ visitModExpr()

template<typename SubClass , typename RetTy >
RetTy mlir::AffineExprVisitorBase< SubClass, RetTy >::visitModExpr ( AffineBinaryOpExpr  expr)
inline

◆ visitMulExpr()

template<typename SubClass , typename RetTy >
RetTy mlir::AffineExprVisitorBase< SubClass, RetTy >::visitMulExpr ( AffineBinaryOpExpr  expr)
inline

◆ visitSymbolExpr()

template<typename SubClass , typename RetTy >
RetTy mlir::AffineExprVisitorBase< SubClass, RetTy >::visitSymbolExpr ( AffineSymbolExpr  expr)
inline

Definition at line 138 of file AffineExprVisitor.h.


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