19 #define GEN_PASS_DEF_CONVERTOPENACCTOSCF
20 #include "mlir/Conversion/Passes.h.inc"
32 template <
typename OpTy>
36 LogicalResult matchAndRewrite(OpTy op,
42 IntegerAttr constAttr;
45 op.getIfCond(),
false);
46 rewriter.
modifyOpInPlace(op, [&]() { op.getIfCondMutable().erase(0); });
47 auto thenBodyBuilder = ifOp.getThenBodyBuilder(rewriter.
getListener());
48 thenBodyBuilder.clone(*op.getOperation());
51 if (constAttr.getInt())
52 rewriter.
modifyOpInPlace(op, [&]() { op.getIfCondMutable().erase(0); });
68 struct ConvertOpenACCToSCFPass
69 :
public impl::ConvertOpenACCToSCFBase<ConvertOpenACCToSCFPass> {
70 void runOnOperation()
override;
74 void ConvertOpenACCToSCFPass::runOnOperation() {
75 auto op = getOperation();
76 auto *context = op.getContext();
82 target.addLegalDialect<scf::SCFDialect>();
83 target.addLegalDialect<acc::OpenACCDialect>();
85 target.addDynamicallyLegalOp<acc::EnterDataOp>(
86 [](acc::EnterDataOp op) {
return !op.getIfCond(); });
88 target.addDynamicallyLegalOp<acc::ExitDataOp>(
89 [](acc::ExitDataOp op) {
return !op.getIfCond(); });
91 target.addDynamicallyLegalOp<acc::UpdateOp>(
92 [](acc::UpdateOp op) {
return !op.getIfCond(); });
99 return std::make_unique<ConvertOpenACCToSCFPass>();
This class describes a specific conversion target.
Listener * getListener() const
Returns the current listener of this builder, or nullptr if this builder doesn't have a listener.
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
virtual void eraseOp(Operation *op)
This method erases an operation that is known to have no uses.
void modifyOpInPlace(Operation *root, CallableT &&callable)
This method is a utility wrapper around an in-place modification of an operation.
This class provides an abstraction over the various different ranges of value types.
Include the generated interface declarations.
bool matchPattern(Value value, const Pattern &pattern)
Entry point for matching a pattern over a Value.
std::unique_ptr< OperationPass< ModuleOp > > createConvertOpenACCToSCFPass()
Create a pass to convert the OpenACC dialect into the LLVMIR dialect.
void populateOpenACCToSCFConversionPatterns(RewritePatternSet &patterns)
Collect the patterns to convert from the OpenACC dialect to OpenACC with SCF dialect.
const FrozenRewritePatternSet & patterns
detail::constant_op_matcher m_Constant()
Matches a constant foldable operation.
LogicalResult applyPartialConversion(ArrayRef< Operation * > ops, const ConversionTarget &target, const FrozenRewritePatternSet &patterns, ConversionConfig config=ConversionConfig())
Below we define several entry points for operation conversion.
OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an...