68#define GEN_PASS_DEF_ACCSPECIALIZEFORDEVICE
69#include "mlir/Dialect/OpenACC/Transforms/Passes.h.inc"
78class ACCSpecializeForDevice
79 :
public acc::impl::ACCSpecializeForDeviceBase<ACCSpecializeForDevice> {
81 using ACCSpecializeForDeviceBase<
82 ACCSpecializeForDevice>::ACCSpecializeForDeviceBase;
84 void runOnOperation()
override {
85 func::FuncOp func = getOperation();
89 GreedyRewriteConfig
config;
90 config.setUseTopDownTraversal(
true);
98 SmallVector<Operation *> opsToTransform;
99 func.walk([&](Operation *op) {
100 if (isa<ACC_COMPUTE_CONSTRUCT_OPS>(op)) {
102 op->
walk([&](Operation *innerOp) {
106 if (isa<acc::OpenACCDialect>(innerOp->
getDialect()))
107 opsToTransform.push_back(innerOp);
111 if (!opsToTransform.empty())
MLIRContext is the top-level object for a collection of MLIR operations.
Dialect * getDialect()
Return the dialect this operation is associated with, or nullptr if the associated dialect is not loa...
std::enable_if_t< llvm::function_traits< std::decay_t< FnT > >::num_args==1, RetT > walk(FnT &&callback)
Walk the operation by calling the callback for each nested operation (including this one),...
Pattern to erase acc.declare_enter and its associated acc.declare_exit.
Pattern to simply erase an ACC op (for ops with no results).
Pattern to replace an ACC op with its var operand.
Pattern to unwrap a region from an ACC op and erase the wrapper.
void populateACCSpecializeForDevicePatterns(RewritePatternSet &patterns)
Populates all patterns for device specialization.
bool isSpecializedAccRoutine(mlir::Operation *op)
Used to check whether this is a specialized accelerator version of acc routine function.
Include the generated interface declarations.
const FrozenRewritePatternSet GreedyRewriteConfig config
LogicalResult applyPatternsGreedily(Region ®ion, const FrozenRewritePatternSet &patterns, GreedyRewriteConfig config=GreedyRewriteConfig(), bool *changed=nullptr)
Rewrite ops in the given region, which must be isolated from above, by repeatedly applying the highes...
LogicalResult applyOpPatternsGreedily(ArrayRef< Operation * > ops, const FrozenRewritePatternSet &patterns, GreedyRewriteConfig config=GreedyRewriteConfig(), bool *changed=nullptr, bool *allErased=nullptr)
Rewrite the specified ops by repeatedly applying the highest benefit patterns in a greedy worklist dr...
const FrozenRewritePatternSet & patterns