[OpenACC][CIR] Implement enter-data + clause lowering (#146146)
'enter data' is a new construct type that requires one of the data clauses, so we had to wait for all clauses to be ready before we could commit this. Most of the clauses are simple, but there is a little bit of work to get 'async' and 'wait' to have similar interfaces in the ACC dialect, where helpers were added.
This commit is contained in:
@@ -2010,6 +2010,25 @@ def OpenACC_EnterDataOp : OpenACC_Op<"enter_data",
|
||||
|
||||
/// The i-th data operand passed.
|
||||
Value getDataOperand(unsigned i);
|
||||
|
||||
/// Add an entry to the 'async-only' attribute (clause spelled without
|
||||
/// arguments). DeviceType array is supplied even though it should always be
|
||||
/// empty, so this can mirror other versions of this function.
|
||||
void addAsyncOnly(MLIRContext *, llvm::ArrayRef<DeviceType>);
|
||||
/// Add a value to the 'async'. DeviceType array is supplied even though it
|
||||
/// should always be empty, so this can mirror other versions of this
|
||||
/// function.
|
||||
void addAsyncOperand(MLIRContext *, mlir::Value,
|
||||
llvm::ArrayRef<DeviceType>);
|
||||
/// Add an entry to the 'wait-only' attribute (clause spelled without
|
||||
/// arguments). DeviceType array is supplied even though it should always be
|
||||
/// empty, so this can mirror other versions of this function.
|
||||
void addWaitOnly(MLIRContext *, llvm::ArrayRef<DeviceType>);
|
||||
/// Add an array-like entry to the 'wait'. DeviceType array is supplied
|
||||
/// even though it should always be empty, so this can mirror other versions
|
||||
/// of this function.
|
||||
void addWaitOperands(MLIRContext *, bool hasDevnum, mlir::ValueRange,
|
||||
llvm::ArrayRef<DeviceType>);
|
||||
}];
|
||||
|
||||
let assemblyFormat = [{
|
||||
|
||||
@@ -3218,6 +3218,53 @@ void EnterDataOp::getCanonicalizationPatterns(RewritePatternSet &results,
|
||||
results.add<RemoveConstantIfCondition<EnterDataOp>>(context);
|
||||
}
|
||||
|
||||
void EnterDataOp::addAsyncOnly(
|
||||
MLIRContext *context, llvm::ArrayRef<DeviceType> effectiveDeviceTypes) {
|
||||
assert(effectiveDeviceTypes.empty());
|
||||
assert(!getAsyncAttr());
|
||||
assert(!getAsyncOperand());
|
||||
|
||||
setAsyncAttr(mlir::UnitAttr::get(context));
|
||||
}
|
||||
|
||||
void EnterDataOp::addAsyncOperand(
|
||||
MLIRContext *context, mlir::Value newValue,
|
||||
llvm::ArrayRef<DeviceType> effectiveDeviceTypes) {
|
||||
assert(effectiveDeviceTypes.empty());
|
||||
assert(!getAsyncAttr());
|
||||
assert(!getAsyncOperand());
|
||||
|
||||
getAsyncOperandMutable().append(newValue);
|
||||
}
|
||||
|
||||
void EnterDataOp::addWaitOnly(MLIRContext *context,
|
||||
llvm::ArrayRef<DeviceType> effectiveDeviceTypes) {
|
||||
assert(effectiveDeviceTypes.empty());
|
||||
assert(!getWaitAttr());
|
||||
assert(getWaitOperands().empty());
|
||||
assert(!getWaitDevnum());
|
||||
|
||||
setWaitAttr(mlir::UnitAttr::get(context));
|
||||
}
|
||||
|
||||
void EnterDataOp::addWaitOperands(
|
||||
MLIRContext *context, bool hasDevnum, mlir::ValueRange newValues,
|
||||
llvm::ArrayRef<DeviceType> effectiveDeviceTypes) {
|
||||
assert(effectiveDeviceTypes.empty());
|
||||
assert(!getWaitAttr());
|
||||
assert(getWaitOperands().empty());
|
||||
assert(!getWaitDevnum());
|
||||
|
||||
// if hasDevnum, the first value is the devnum. The 'rest' go into the
|
||||
// operands list.
|
||||
if (hasDevnum) {
|
||||
getWaitDevnumMutable().append(newValues.front());
|
||||
newValues = newValues.drop_front();
|
||||
}
|
||||
|
||||
getWaitOperandsMutable().append(newValues);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// AtomicReadOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
Reference in New Issue
Block a user