Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions clang/lib/CIR/CodeGen/CIRGenDeclOpenACC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,12 @@ class OpenACCRoutineClauseEmitter final
void VisitSeqClause(const OpenACCSeqClause &clause) {
routineOp.addSeq(builder.getContext(), lastDeviceTypeValues);
}
void VisitWorkerClause(const OpenACCWorkerClause &clause) {
routineOp.addWorker(builder.getContext(), lastDeviceTypeValues);
}
void VisitVectorClause(const OpenACCVectorClause &clause) {
routineOp.addVector(builder.getContext(), lastDeviceTypeValues);
}
};
} // namespace

Expand Down
38 changes: 38 additions & 0 deletions clang/test/CIR/CodeGenOpenACC/routine-clauses.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// RUN: %clang_cc1 -fopenacc -Wno-openacc-self-if-potential-conflict -emit-cir -fclangir %s -o - | FileCheck %s

#pragma acc routine seq
void Func1() {}

void Func2() {}
#pragma acc routine(Func2) seq

#pragma acc routine worker
void Func3() {}

void Func4() {}
#pragma acc routine(Func4) worker

#pragma acc routine vector
void Func5() {}

void Func6() {}
#pragma acc routine(Func6) vector

// CHECK: cir.func{{.*}} @[[F1_NAME:.*Func1[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[F1_R_NAME:.*]]]>}
// CHECK: acc.routine @[[F1_R_NAME]] func(@[[F1_NAME]]) seq

// CHECK: cir.func{{.*}} @[[F2_NAME:.*Func2[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[F2_R_NAME:.*]]]>}

// CHECK: cir.func{{.*}} @[[F3_NAME:.*Func3[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[F3_R_NAME:.*]]]>}
// CHECK: acc.routine @[[F3_R_NAME]] func(@[[F3_NAME]]) worker

// CHECK: cir.func{{.*}} @[[F4_NAME:.*Func4[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[F4_R_NAME:.*]]]>}

// CHECK: cir.func{{.*}} @[[F5_NAME:.*Func5[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[F5_R_NAME:.*]]]>}
// CHECK: acc.routine @[[F5_R_NAME]] func(@[[F5_NAME]]) vector

// CHECK: cir.func{{.*}} @[[F6_NAME:.*Func6[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[F6_R_NAME:.*]]]>}

// CHECK: acc.routine @[[F2_R_NAME]] func(@[[F2_NAME]]) seq
// CHECK: acc.routine @[[F4_R_NAME]] func(@[[F4_NAME]]) worker
// CHECK: acc.routine @[[F6_R_NAME]] func(@[[F6_NAME]]) vector
4 changes: 4 additions & 0 deletions mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -3282,6 +3282,10 @@ def OpenACC_RoutineOp : OpenACC_Op<"routine", [IsolatedFromAbove]> {

// Add an entry to the 'seq' attribute for each additional device types.
void addSeq(MLIRContext *, llvm::ArrayRef<DeviceType>);
// Add an entry to the 'vector' attribute for each additional device types.
void addVector(MLIRContext *, llvm::ArrayRef<DeviceType>);
// Add an entry to the 'worker' attribute for each additional device types.
void addWorker(MLIRContext *, llvm::ArrayRef<DeviceType>);
}];

let assemblyFormat = [{
Expand Down
12 changes: 12 additions & 0 deletions mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4299,6 +4299,18 @@ void RoutineOp::addSeq(MLIRContext *context,
effectiveDeviceTypes));
}

void RoutineOp::addVector(MLIRContext *context,
llvm::ArrayRef<DeviceType> effectiveDeviceTypes) {
setVectorAttr(addDeviceTypeAffectedOperandHelper(context, getVectorAttr(),
effectiveDeviceTypes));
}

void RoutineOp::addWorker(MLIRContext *context,
llvm::ArrayRef<DeviceType> effectiveDeviceTypes) {
setWorkerAttr(addDeviceTypeAffectedOperandHelper(context, getWorkerAttr(),
effectiveDeviceTypes));
}

//===----------------------------------------------------------------------===//
// InitOp
//===----------------------------------------------------------------------===//
Expand Down