forked from OSchip/llvm-project
[MLIR,OpenMP] : Add Conversion pattern for Critical Op
The Conversion pattern enables conversion of Critical Op with block arguments. Fixes https://github.com/llvm/llvm-project/issues/56629 Reviewed By: shraiysh Differential Revision: https://reviews.llvm.org/D130343
This commit is contained in:
parent
5ab077f911
commit
4ee9f3d59e
|
@ -81,13 +81,14 @@ struct RegionLessOpWithVarOperandsConversion
|
|||
|
||||
void mlir::configureOpenMPToLLVMConversionLegality(
|
||||
ConversionTarget &target, LLVMTypeConverter &typeConverter) {
|
||||
target.addDynamicallyLegalOp<mlir::omp::ParallelOp, mlir::omp::WsLoopOp,
|
||||
mlir::omp::MasterOp, mlir::omp::SectionsOp,
|
||||
mlir::omp::SingleOp>([&](Operation *op) {
|
||||
return typeConverter.isLegal(&op->getRegion(0)) &&
|
||||
typeConverter.isLegal(op->getOperandTypes()) &&
|
||||
typeConverter.isLegal(op->getResultTypes());
|
||||
});
|
||||
target.addDynamicallyLegalOp<mlir::omp::CriticalOp, mlir::omp::ParallelOp,
|
||||
mlir::omp::WsLoopOp, mlir::omp::MasterOp,
|
||||
mlir::omp::SectionsOp, mlir::omp::SingleOp>(
|
||||
[&](Operation *op) {
|
||||
return typeConverter.isLegal(&op->getRegion(0)) &&
|
||||
typeConverter.isLegal(op->getOperandTypes()) &&
|
||||
typeConverter.isLegal(op->getResultTypes());
|
||||
});
|
||||
target
|
||||
.addDynamicallyLegalOp<mlir::omp::AtomicReadOp, mlir::omp::AtomicWriteOp,
|
||||
mlir::omp::FlushOp, mlir::omp::ThreadprivateOp>(
|
||||
|
@ -100,9 +101,9 @@ void mlir::configureOpenMPToLLVMConversionLegality(
|
|||
void mlir::populateOpenMPToLLVMConversionPatterns(LLVMTypeConverter &converter,
|
||||
RewritePatternSet &patterns) {
|
||||
patterns.add<
|
||||
RegionOpConversion<omp::MasterOp>, RegionOpConversion<omp::ParallelOp>,
|
||||
RegionOpConversion<omp::WsLoopOp>, RegionOpConversion<omp::SectionsOp>,
|
||||
RegionOpConversion<omp::SingleOp>,
|
||||
RegionOpConversion<omp::CriticalOp>, RegionOpConversion<omp::MasterOp>,
|
||||
RegionOpConversion<omp::ParallelOp>, RegionOpConversion<omp::WsLoopOp>,
|
||||
RegionOpConversion<omp::SectionsOp>, RegionOpConversion<omp::SingleOp>,
|
||||
RegionLessOpWithVarOperandsConversion<omp::AtomicReadOp>,
|
||||
RegionLessOpWithVarOperandsConversion<omp::AtomicWriteOp>,
|
||||
RegionLessOpWithVarOperandsConversion<omp::FlushOp>,
|
||||
|
|
|
@ -1,5 +1,23 @@
|
|||
// RUN: mlir-opt -convert-openmp-to-llvm -split-input-file %s | FileCheck %s
|
||||
|
||||
// CHECK-LABEL: llvm.func @foo(i64, i64)
|
||||
func.func private @foo(index, index)
|
||||
|
||||
// CHECK-LABEL: llvm.func @critical_block_arg
|
||||
func.func @critical_block_arg() {
|
||||
// CHECK: omp.critical
|
||||
omp.critical {
|
||||
// CHECK-NEXT: ^[[BB0:.*]](%[[ARG1:.*]]: i64, %[[ARG2:.*]]: i64):
|
||||
^bb0(%arg1: index, %arg2: index):
|
||||
// CHECK-NEXT: llvm.call @foo(%[[ARG1]], %[[ARG2]]) : (i64, i64) -> ()
|
||||
func.call @foo(%arg1, %arg2) : (index, index) -> ()
|
||||
omp.terminator
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// CHECK-LABEL: llvm.func @master_block_arg
|
||||
func.func @master_block_arg() {
|
||||
// CHECK: omp.master
|
||||
|
|
Loading…
Reference in New Issue