19 #define GEN_PASS_DEF_CONVERTOPENACCTOSCF
20 #include "mlir/Conversion/Passes.h.inc"
32 template <
typename OpTy>
42 IntegerAttr constAttr;
45 op.getIfCond(),
false);
47 auto thenBodyBuilder = ifOp.getThenBodyBuilder(rewriter.
getListener());
48 thenBodyBuilder.clone(*op.getOperation());
51 if (constAttr.getInt())
62 patterns.
add<ExpandIfCondition<acc::EnterDataOp>>(patterns.
getContext());
63 patterns.
add<ExpandIfCondition<acc::ExitDataOp>>(patterns.
getContext());
64 patterns.
add<ExpandIfCondition<acc::UpdateOp>>(patterns.
getContext());
68 struct ConvertOpenACCToSCFPass
69 :
public impl::ConvertOpenACCToSCFBase<ConvertOpenACCToSCFPass> {
70 void runOnOperation()
override;
74 void ConvertOpenACCToSCFPass::runOnOperation() {
75 auto op = getOperation();
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.
MLIRContext * getContext()
Return the context this operation is associated with.
Location getLoc()
The source location the operation was defined or derived from.
void erase()
Remove this operation from its parent block and delete it.
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
MLIRContext * getContext() const
RewritePatternSet & add(ConstructorArg &&arg, ConstructorArgs &&...args)
Add an instance of each of the pattern types 'Ts' to the pattern list with the given arguments.
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.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
std::unique_ptr< OperationPass< ModuleOp > > createConvertOpenACCToSCFPass()
Create a pass to convert the OpenACC dialect into the LLVMIR dialect.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
void populateOpenACCToSCFConversionPatterns(RewritePatternSet &patterns)
Collect the patterns to convert from the OpenACC dialect to OpenACC with SCF dialect.
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.
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
This class represents an efficient way to signal success or failure.
OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an...