-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flang][cuda][NFC] Expose conversion patterns from CUF to FIR calls #109465
Conversation
Expose conversion patterns so they can be reused outside of this pass.
@llvm/pr-subscribers-flang-fir-hlfir Author: Valentin Clement (バレンタイン クレメン) (clementval) ChangesExpose conversion patterns so they can be reused outside of this pass. Full diff: https://github.com/llvm/llvm-project/pull/109465.diff 2 Files Affected:
diff --git a/flang/include/flang/Optimizer/Transforms/CufOpConversion.h b/flang/include/flang/Optimizer/Transforms/CufOpConversion.h
new file mode 100644
index 00000000000000..1a0f943b20237f
--- /dev/null
+++ b/flang/include/flang/Optimizer/Transforms/CufOpConversion.h
@@ -0,0 +1,26 @@
+//===------- Optimizer/Transforms/CufOpConversion.h -------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef FORTRAN_OPTIMIZER_TRANSFORMS_CUFOPCONVERSION_H_
+#define FORTRAN_OPTIMIZER_TRANSFORMS_CUFOPCONVERSION_H_
+
+#include "mlir/Pass/Pass.h"
+#include "mlir/Pass/PassRegistry.h"
+
+namespace fir {
+class LLVMTypeConverter;
+}
+
+namespace cuf {
+
+void populateCUFToFIRConversionPatterns(fir::LLVMTypeConverter &converter,
+ mlir::DataLayout &dl, mlir::RewritePatternSet &patterns);
+
+} // namespace cuf
+
+#endif // FORTRAN_OPTIMIZER_TRANSFORMS_CUFOPCONVERSION_H_
diff --git a/flang/lib/Optimizer/Transforms/CufOpConversion.cpp b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
index ac796e83b07078..f8ace2dd96a0d8 100644
--- a/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "flang/Optimizer/Transforms/CufOpConversion.h"
#include "flang/Common/Fortran.h"
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
#include "flang/Optimizer/CodeGen/TypeConverter.h"
@@ -473,9 +474,7 @@ class CufOpConversion : public fir::impl::CufOpConversionBase<CufOpConversion> {
!mlir::isa<fir::BaseBoxType>(dstTy);
});
target.addLegalDialect<fir::FIROpsDialect, mlir::arith::ArithDialect>();
- patterns.insert<CufAllocOpConversion>(ctx, &*dl, &typeConverter);
- patterns.insert<CufAllocateOpConversion, CufDeallocateOpConversion,
- CufFreeOpConversion, CufDataTransferOpConversion>(ctx);
+ cuf::populateCUFToFIRConversionPatterns(typeConverter, *dl, patterns);
if (mlir::failed(mlir::applyPartialConversion(getOperation(), target,
std::move(patterns)))) {
mlir::emitError(mlir::UnknownLoc::get(ctx),
@@ -485,3 +484,12 @@ class CufOpConversion : public fir::impl::CufOpConversionBase<CufOpConversion> {
}
};
} // namespace
+
+void cuf::populateCUFToFIRConversionPatterns(
+ fir::LLVMTypeConverter &converter, mlir::DataLayout &dl,
+ mlir::RewritePatternSet &patterns) {
+ patterns.insert<CufAllocOpConversion>(patterns.getContext(), &dl, &converter);
+ patterns.insert<CufAllocateOpConversion, CufDeallocateOpConversion,
+ CufFreeOpConversion, CufDataTransferOpConversion>(
+ patterns.getContext());
+}
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
nit: it can be marked as NFC
…lvm#109465) Expose conversion patterns so they can be reused outside of this pass.
…lvm#109465) Expose conversion patterns so they can be reused outside of this pass.
Expose conversion patterns so they can be reused outside of this pass.