21#include "llvm/ADT/SmallVector.h"
48struct RemoveEmptyKernelEnvironment
50 using OpRewritePattern<acc::KernelEnvironmentOp>::OpRewritePattern;
52 LogicalResult matchAndRewrite(acc::KernelEnvironmentOp op,
53 PatternRewriter &rewriter)
const override {
54 assert(op->getNumRegions() == 1 &&
"expected op to have one region");
56 Block &block = op.getRegion().front();
65 if (
auto deviceTypeAttr = op.getWaitOperandsDeviceTypeAttr()) {
66 for (
auto attr : deviceTypeAttr) {
67 if (
auto dtAttr = mlir::dyn_cast<acc::DeviceTypeAttr>(attr)) {
68 if (dtAttr.getValue() != mlir::acc::DeviceType::None)
75 if (
auto hasDevnumAttr = op.getHasWaitDevnumAttr()) {
76 for (
auto attr : hasDevnumAttr) {
77 if (
auto boolAttr = mlir::dyn_cast<mlir::BoolAttr>(attr)) {
78 if (boolAttr.getValue())
85 if (
auto segmentsAttr = op.getWaitOperandsSegmentsAttr()) {
86 if (segmentsAttr.size() > 1)
92 if (!op.getWaitOperands().empty() || op.getWaitOnlyAttr())
105template <
typename EffectTy>
110 for (
unsigned i = 0, e = operand.
size(); i < e; ++i)
111 effects.emplace_back(EffectTy::get(), &operand[i]);
114template <
typename EffectTy>
119 effects.emplace_back(EffectTy::get(), mlir::cast<mlir::OpResult>(
result));
128void KernelEnvironmentOp::getSuccessorRegions(
138void KernelEnvironmentOp::getCanonicalizationPatterns(
140 results.
add<RemoveEmptyKernelEnvironment>(context);
147LogicalResult FirstprivateMapInitialOp::verify() {
149 return emitError(
"data clause associated with firstprivate operation must "
152 return emitError(
"must have var operand");
153 if (!mlir::isa<mlir::acc::PointerLikeType>(
getVar().
getType()) &&
155 return emitError(
"var must be mappable or pointer-like");
156 if (mlir::isa<mlir::acc::PointerLikeType>(
getVar().
getType()) &&
158 return emitError(
"varType must capture the element type of var");
159 if (getModifiers() != acc::DataClauseModifier::none)
160 return emitError(
"no data clause modifiers are allowed");
164void FirstprivateMapInitialOp::getEffects(
177void ReductionCombineOp::getEffects(
static void addOperandEffect(SmallVectorImpl< SideEffects::EffectInstance< MemoryEffects::Effect > > &effects, MutableOperandRange operand)
Helper to add an effect on an operand, referenced by its mutable range.
static void addResultEffect(SmallVectorImpl< SideEffects::EffectInstance< MemoryEffects::Effect > > &effects, Value result)
Helper to add an effect on a result value.
static void getSingleRegionOpSuccessorRegions(Operation *op, Region ®ion, RegionBranchPoint point, SmallVectorImpl< RegionSuccessor > ®ions)
Generic helper for single-region OpenACC ops that execute their body once and then return to the pare...
static ValueRange getSingleRegionSuccessorInputs(Operation *op, RegionSuccessor successor)
MLIRContext is the top-level object for a collection of MLIR operations.
This class provides a mutable adaptor for a range of operands.
unsigned size() const
Returns the current size of the range.
Operation is the basic unit of execution within MLIR.
result_range getResults()
This class represents a point being branched from in the methods of the RegionBranchOpInterface.
bool isParent() const
Returns true if branching from the parent op.
This class represents a successor of a region.
static RegionSuccessor parent()
Initialize a successor that branches after/out of the parent operation.
bool isParent() const
Return true if the successor is the parent operation.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
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.
OpTy replaceOpWithNewOp(Operation *op, Args &&...args)
Replace the results of the given (original) op with a new op that is created without verification (re...
This class represents a specific instance of an effect.
static DerivedEffect * get()
static CurrentDeviceIdResource * get()
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...
mlir::Value getAccVar(mlir::Operation *accDataClauseOp)
Used to obtain the accVar from a data clause operation.
mlir::Value getVar(mlir::Operation *accDataClauseOp)
Used to obtain the var from a data clause operation.
std::optional< mlir::acc::DataClause > getDataClause(mlir::Operation *accDataEntryOp)
Used to obtain the dataClause from a data entry operation.
mlir::Type getVarType(mlir::Operation *accDataClauseOp)
Used to obtains the varType from a data clause operation which records the type of variable.
Include the generated interface declarations.
Type getType(OpFoldResult ofr)
Returns the int type of the integer in ofr.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an...