Skip to content

Commit 7bd2871

Browse files
committed
Add assembly format for wrapper and add test
1 parent d443b23 commit 7bd2871

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,10 @@ def WorkshareLoopWrapperOp : OpenMP_Op<"workshare_loop_wrapper", traits = [
314314
RecursiveMemoryEffects, SingleBlock
315315
], singleRegion = true> {
316316
let summary = "contains loop nests to be parallelized by workshare";
317-
318317
let builders = [
319318
OpBuilder<(ins), [{ build($_builder, $_state, {}); }]>
320319
];
320+
let assemblyFormat = "$region attr-dict";
321321
}
322322

323323
//===----------------------------------------------------------------------===//

mlir/test/Dialect/OpenMP/ops.mlir

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2810,3 +2810,64 @@ func.func @omp_target_private(%map1: memref<?xi32>, %map2: memref<?xi32>, %priv_
28102810

28112811
return
28122812
}
2813+
2814+
// CHECK-LABEL: func @omp_workshare
2815+
func.func @omp_workshare() {
2816+
// CHECK: omp.workshare {
2817+
omp.workshare {
2818+
"test.payload"() : () -> ()
2819+
// CHECK: omp.terminator
2820+
omp.terminator
2821+
}
2822+
return
2823+
}
2824+
2825+
// CHECK-LABEL: func @omp_workshare_nowait
2826+
func.func @omp_workshare_nowait() {
2827+
// CHECK: omp.workshare nowait {
2828+
omp.workshare nowait {
2829+
"test.payload"() : () -> ()
2830+
// CHECK: omp.terminator
2831+
omp.terminator
2832+
}
2833+
return
2834+
}
2835+
2836+
// CHECK-LABEL: func @omp_workshare_multiple_blocks
2837+
func.func @omp_workshare_multiple_blocks() {
2838+
// CHECK: omp.workshare {
2839+
omp.workshare {
2840+
cf.br ^bb2
2841+
^bb2:
2842+
// CHECK: omp.terminator
2843+
omp.terminator
2844+
}
2845+
return
2846+
}
2847+
2848+
// CHECK-LABEL: func @omp_workshare_loop_wrapper
2849+
func.func @omp_workshare_loop_wrapper(%idx : index) {
2850+
// CHECK-NEXT: omp.workshare_loop_wrapper
2851+
omp.workshare_loop_wrapper {
2852+
// CHECK-NEXT: omp.loop_nest
2853+
omp.loop_nest (%iv) : index = (%idx) to (%idx) step (%idx) {
2854+
omp.yield
2855+
}
2856+
omp.terminator
2857+
}
2858+
return
2859+
}
2860+
2861+
// CHECK-LABEL: func @omp_workshare_loop_wrapper_attrs
2862+
func.func @omp_workshare_loop_wrapper_attrs(%idx : index) {
2863+
// CHECK-NEXT: omp.workshare_loop_wrapper {
2864+
omp.workshare_loop_wrapper {
2865+
// CHECK-NEXT: omp.loop_nest
2866+
omp.loop_nest (%iv) : index = (%idx) to (%idx) step (%idx) {
2867+
omp.yield
2868+
}
2869+
omp.terminator
2870+
// CHECK: } {attr_in_dict}
2871+
} {attr_in_dict}
2872+
return
2873+
}

0 commit comments

Comments
 (0)