MLIR  16.0.0git
Typedefs | Functions
OneShotModuleBufferize.cpp File Reference
#include "mlir/Dialect/Bufferization/Transforms/OneShotModuleBufferize.h"
#include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h"
#include "mlir/Dialect/Bufferization/IR/Bufferization.h"
#include "mlir/Dialect/Bufferization/Transforms/Bufferize.h"
#include "mlir/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.h"
#include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h"
#include "mlir/Dialect/Bufferization/Transforms/TensorCopyInsertion.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/IR/Operation.h"
+ Include dependency graph for OneShotModuleBufferize.cpp:

Go to the source code of this file.


using FuncCallerMap = DenseMap< func::FuncOp, DenseSet< Operation * > >
 A mapping of FuncOps to their callers. More...


static const FuncAnalysisStategetFuncAnalysisState (const AnalysisState &state)
 Get FuncAnalysisState. More...
static FuncAnalysisStategetFuncAnalysisState (AnalysisState &state)
 Get or create FuncAnalysisState. More...
static LLVM_ATTRIBUTE_UNUSED FuncOpAnalysisState getFuncOpAnalysisState (const AnalysisState &state, func::FuncOp funcOp)
 Return the state (phase) of analysis of the FuncOp. More...
static func::ReturnOp getAssumedUniqueReturnOp (func::FuncOp funcOp)
 Return the unique ReturnOp that terminates funcOp. More...
static void removeBufferizationAttributes (BlockArgument bbArg)
 Remove bufferization attributes on FuncOp arguments. More...
static func::FuncOp getCalledFunction (CallOpInterface callOp)
 Return the func::FuncOp called by callOp. More...
static void equivalenceAnalysis (func::FuncOp funcOp, BufferizationAliasInfo &aliasInfo, OneShotAnalysisState &state)
 Gather equivalence info of CallOps. More...
static LogicalResult getFuncOpsOrderedByCalls (ModuleOp moduleOp, SmallVectorImpl< func::FuncOp > &orderedFuncOps, FuncCallerMap &callerMap)
 Store all functions of the moduleOp in orderedFuncOps, sorted by callee-caller order (i.e. More...
static void foldMemRefCasts (func::FuncOp funcOp)
 Fold return values that are memref casts and update function return types. More...

Typedef Documentation

◆ FuncCallerMap

using FuncCallerMap = DenseMap<func::FuncOp, DenseSet<Operation *> >

A mapping of FuncOps to their callers.

Definition at line 77 of file OneShotModuleBufferize.cpp.

Function Documentation

◆ equivalenceAnalysis()

static void equivalenceAnalysis ( func::FuncOp  funcOp,
BufferizationAliasInfo aliasInfo,
OneShotAnalysisState state 

◆ foldMemRefCasts()

static void foldMemRefCasts ( func::FuncOp  funcOp)

Fold return values that are memref casts and update function return types.

During FuncOp bufferization, the exact type of the returned memrefs (if any) is not known yet. Therefore, the bufferization uses memref types with the most generic layout map as function return types. After bufferizing the entire function body, a more concise memref type can potentially be used for the return type of the function.

Definition at line 335 of file OneShotModuleBufferize.cpp.

References mlir::bufferization::func_ext::getAssumedUniqueReturnOp().

Referenced by mlir::bufferization::bufferizeModuleOp().

◆ getAssumedUniqueReturnOp()

static func::ReturnOp getAssumedUniqueReturnOp ( func::FuncOp  funcOp)

◆ getCalledFunction()

static func::FuncOp getCalledFunction ( CallOpInterface  callOp)

Return the func::FuncOp called by callOp.

Definition at line 235 of file OneShotModuleBufferize.cpp.

References mlir::SymbolTable::lookupNearestSymbolFrom().

◆ getFuncAnalysisState() [1/2]

static const FuncAnalysisState& getFuncAnalysisState ( const AnalysisState state)

Get FuncAnalysisState.

Definition at line 81 of file OneShotModuleBufferize.cpp.

◆ getFuncAnalysisState() [2/2]

static FuncAnalysisState& getFuncAnalysisState ( AnalysisState state)

Get or create FuncAnalysisState.

Definition at line 90 of file OneShotModuleBufferize.cpp.

◆ getFuncOpAnalysisState()

static LLVM_ATTRIBUTE_UNUSED FuncOpAnalysisState getFuncOpAnalysisState ( const AnalysisState state,
func::FuncOp  funcOp 

Return the state (phase) of analysis of the FuncOp.

Used for debug modes.

Definition at line 98 of file OneShotModuleBufferize.cpp.

References mlir::bufferization::func_ext::FuncAnalysisState::analyzedFuncOps, mlir::bufferization::func_ext::getFuncAnalysisState(), and mlir::bufferization::func_ext::NotAnalyzed.

◆ getFuncOpsOrderedByCalls()

static LogicalResult getFuncOpsOrderedByCalls ( ModuleOp  moduleOp,
SmallVectorImpl< func::FuncOp > &  orderedFuncOps,
FuncCallerMap callerMap 

Store all functions of the moduleOp in orderedFuncOps, sorted by callee-caller order (i.e.

callees without callers first). Store the map of FuncOp to all its callers in callerMap. Return failure() if a cycle of calls is detected or if we are unable to retrieve the called FuncOp from any CallOpInterface.

Definition at line 279 of file OneShotModuleBufferize.cpp.

Referenced by mlir::bufferization::analyzeModuleOp(), and mlir::bufferization::bufferizeModuleOp().

◆ removeBufferizationAttributes()

static void removeBufferizationAttributes ( BlockArgument  bbArg)

Remove bufferization attributes on FuncOp arguments.

Definition at line 226 of file OneShotModuleBufferize.cpp.

References mlir::BlockArgument::getArgNumber(), mlir::BlockArgument::getOwner(), and mlir::Block::getParentOp().

Referenced by mlir::bufferization::bufferizeModuleOp().