MLIR 22.0.0git
OneShotModuleBufferize.cpp File Reference

Go to the source code of this file.

Typedefs

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

Functions

static FuncAnalysisStategetOrCreateFuncAnalysisState (OneShotAnalysisState &state)
 Get or create FuncAnalysisState.
static void removeBufferizationAttributes (BlockArgument bbArg)
 Remove bufferization attributes on FuncOp arguments.
static func::FuncOp getCalledFunction (func::CallOp callOp, mlir::SymbolTableCollection &symbolTable)
 Return the func::FuncOp called by callOp.
static bool hasTensorSignature (func::FuncOp funcOp)
 Return "true" if the given function signature has tensor semantics.
static LogicalResult getFuncOpsOrderedByCalls (Operation *moduleOp, SmallVectorImpl< func::FuncOp > &orderedFuncOps, SmallVectorImpl< func::FuncOp > &remainingFuncOps, FuncCallerMap &callerMap, SymbolTableCollection &symbolTables)
 Store all functions of the moduleOp in orderedFuncOps, sorted by callee-caller order (i.e., callees without callers first).
static Value unpackCast (Value v)
 Helper function that extracts the source from a memref.cast.
static SmallVector< TypegetReturnTypes (SmallVector< func::ReturnOp > returnOps)
 Helper function that returns the return types (skipping casts) of the given func.return ops.
static void foldMemRefCasts (func::FuncOp funcOp)
 Fold return values that are memref casts and update function return types.

Typedef Documentation

◆ FuncCallerMap

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

A mapping of FuncOps to their callers.

Definition at line 80 of file OneShotModuleBufferize.cpp.

Function Documentation

◆ foldMemRefCasts()

void foldMemRefCasts ( func::FuncOp funcOp)
static

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 417 of file OneShotModuleBufferize.cpp.

References mlir::bufferization::getReturnOps(), getReturnTypes(), and unpackCast().

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

◆ getCalledFunction()

func::FuncOp getCalledFunction ( func::CallOp callOp,
mlir::SymbolTableCollection & symbolTable )
static

Return the func::FuncOp called by callOp.

Definition at line 286 of file OneShotModuleBufferize.cpp.

◆ getFuncOpsOrderedByCalls()

LogicalResult getFuncOpsOrderedByCalls ( Operation * moduleOp,
SmallVectorImpl< func::FuncOp > & orderedFuncOps,
SmallVectorImpl< func::FuncOp > & remainingFuncOps,
FuncCallerMap & callerMap,
SymbolTableCollection & symbolTables )
static

Store all functions of the moduleOp in orderedFuncOps, sorted by callee-caller order (i.e., callees without callers first).

Store all remaining functions (i.e., the ones that call each other recursively) in remainingFuncOps. Does not traverse nested symbol tables.

Store the map of FuncOp to all its callers in callerMap.

Return failure() if we are unable to retrieve the called FuncOp from any func::CallOp.

Definition at line 309 of file OneShotModuleBufferize.cpp.

References mlir::WalkResult::advance(), mlir::bufferization::func_ext::getCalledFunction(), mlir::Operation::getRegions(), hasTensorSignature(), mlir::WalkResult::skip(), success(), and mlir::WalkResult::wasInterrupted().

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

◆ getOrCreateFuncAnalysisState()

◆ getReturnTypes()

SmallVector< Type > getReturnTypes ( SmallVector< func::ReturnOp > returnOps)
static

Helper function that returns the return types (skipping casts) of the given func.return ops.

This function returns as many types as the return ops have operands. If the i-th operand is not the same for all func.return ops, then the i-th returned type is an "empty" type.

Definition at line 387 of file OneShotModuleBufferize.cpp.

References mlir::Value::getType(), result, and unpackCast().

Referenced by foldMemRefCasts().

◆ hasTensorSignature()

bool hasTensorSignature ( func::FuncOp funcOp)
static

Return "true" if the given function signature has tensor semantics.

Definition at line 293 of file OneShotModuleBufferize.cpp.

Referenced by getFuncOpsOrderedByCalls().

◆ removeBufferizationAttributes()

void removeBufferizationAttributes ( BlockArgument bbArg)
static

Remove bufferization attributes on FuncOp arguments.

Definition at line 276 of file OneShotModuleBufferize.cpp.

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

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

◆ unpackCast()

Value unpackCast ( Value v)
static

Helper function that extracts the source from a memref.cast.

If the given value is not a memref.cast result, simply returns the given value.

Definition at line 376 of file OneShotModuleBufferize.cpp.

References mlir::Value::getDefiningOp().

Referenced by foldMemRefCasts(), and getReturnTypes().