32 if (
auto mod = llvm::dyn_cast<ModuleOp>(current)) {
33 if (mod.getDataLayoutSpec())
35 }
else if (
auto dataLayoutOp =
36 llvm::dyn_cast<DataLayoutOpInterface>(current)) {
38 if (dataLayoutOp.getDataLayoutSpec())
47 if (
auto mod = llvm::dyn_cast<ModuleOp>(op))
59 llvm::StringRef origin,
Region ®ionToClone,
64 for (
auto val : output)
65 resultTypes.push_back(val.getType());
67 ComputeRegionOp::create(rewriter, loc, resultTypes, launchArgs, inputArgs,
68 stream, origin, kernelFuncName, kernelModuleName);
70 assert(!regionToClone.
getBlocks().empty() &&
71 "empty region for acc.compute_region");
74 auto parWidthType = ParWidthType::get(rewriter.
getContext());
76 for (
size_t i = 0; i < launchArgs.size(); ++i)
78 for (
Value input : inputArgs)
80 for (
size_t i = 0; i < inputArgs.size(); ++i)
81 mapping.
map(inputArgs[i], entryBlock->
getArgument(launchArgs.size() + i));
83 if (regionToClone.
getBlocks().size() == 1) {
87 rewriter.
clone(op, mapping);
91 regionToClone, mapping, loc, rewriter);
93 rewriter.
eraseOp(computeRegion);
99 for (
auto val : output)
100 yieldOperands.push_back(mapping.
lookup(val));
102 YieldOp::create(rewriter, loc, yieldOperands);
104 return computeRegion;
Block represents an ordered list of Operations.
BlockArgument getArgument(unsigned i)
OpListType & getOperations()
BlockArgument addArgument(Type type, Location loc)
Add one value to the argument list.
MLIRContext * getContext() const
The main mechanism for performing data layout queries.
A symbol reference with a reference path containing a single element.
This is a utility class for mapping one set of IR entities to another.
auto lookup(T from) const
Lookup a mapped value within the map.
void map(Value from, Value to)
Inserts a new mapping for 'from' to 'to'.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
RAII guard to reset the insertion point of the builder when destroyed.
Block * createBlock(Region *parent, Region::iterator insertPt={}, TypeRange argTypes={}, ArrayRef< Location > locs={})
Add new block with 'argTypes' arguments and set the insertion point to the end of it.
Operation * clone(Operation &op, IRMapping &mapper)
Creates a deep copy of the specified operation, remapping any operands that use values outside of the...
void setInsertionPointToStart(Block *block)
Sets the insertion point to the start of the specified block.
void setInsertionPointToEnd(Block *block)
Sets the insertion point to the end of the specified block.
This class provides the API for ops that are known to be terminators.
Operation is the basic unit of execution within MLIR.
Operation * getParentOp()
Returns the closest surrounding operation that contains this operation or nullptr if this is a top-le...
OpTy getParentOfType()
Return the closest surrounding parent operation that is of type 'OpTy'.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
BlockListType & getBlocks()
This class coordinates the application of a rewrite on a set of IR, providing a way for clients to tr...
virtual void eraseOp(Operation *op)
This method erases an operation that is known to have no uses.
This class provides an abstraction over the different types of ranges over Values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
std::optional< DataLayout > getDataLayout(Operation *op, bool allowDefault=true)
Get the data layout for an operation.
scf::ExecuteRegionOp wrapMultiBlockRegionWithSCFExecuteRegion(Region ®ion, IRMapping &mapping, Location loc, RewriterBase &rewriter, bool convertFuncReturn=false)
Wrap a multi-block region in an scf.execute_region.
ComputeRegionOp buildComputeRegion(Location loc, ValueRange launchArgs, ValueRange inputArgs, llvm::StringRef origin, Region ®ionToClone, RewriterBase &rewriter, IRMapping &mapping, ValueRange output={}, FlatSymbolRefAttr kernelFuncName={}, FlatSymbolRefAttr kernelModuleName={}, Value stream={})
Build an acc.compute_region operation by cloning a source region.
Include the generated interface declarations.