[flang-commits] [flang] [flang][NFC] Expose FIR to LLVM patterns (PR #83492)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Thu Feb 29 19:17:47 PST 2024
https://github.com/clementval updated https://github.com/llvm/llvm-project/pull/83492
>From be0ab503c867ea32a70d9fc566f7c72caac93fa3 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Thu, 29 Feb 2024 13:51:43 -0800
Subject: [PATCH] [flang][NFC] Expose FIR to LLVM patterns
---
.../include/flang/Optimizer/CodeGen/CodeGen.h | 7 +++
flang/lib/Optimizer/CodeGen/CodeGen.cpp | 54 ++++++++++---------
2 files changed, 37 insertions(+), 24 deletions(-)
diff --git a/flang/include/flang/Optimizer/CodeGen/CodeGen.h b/flang/include/flang/Optimizer/CodeGen/CodeGen.h
index 5ea96c900bc630..cbf02ec3912363 100644
--- a/flang/include/flang/Optimizer/CodeGen/CodeGen.h
+++ b/flang/include/flang/Optimizer/CodeGen/CodeGen.h
@@ -18,6 +18,8 @@
namespace fir {
+class LLVMTypeConverter;
+
struct NameUniquer;
#define GEN_PASS_DECL_FIRTOLLVMLOWERING
@@ -80,6 +82,11 @@ std::unique_ptr<mlir::Pass> createLLVMDialectToLLVMPass(
std::unique_ptr<mlir::Pass> createBoxedProcedurePass();
std::unique_ptr<mlir::Pass> createBoxedProcedurePass(bool useThunks);
+/// Populate the given list with patterns that convert from FIR to LLVM.
+void populateFIRToLLVMConversionPatterns(fir::LLVMTypeConverter &converter,
+ mlir::RewritePatternSet &patterns,
+ fir::FIRToLLVMPassOptions &options);
+
// declarative passes
#define GEN_PASS_REGISTRATION
#include "flang/Optimizer/CodeGen/CGPasses.h.inc"
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index 7fdf39a1af731c..f81a08388da722 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -3937,30 +3937,7 @@ class FIRToLLVMLowering
options.applyTBAA || applyTBAA,
options.forceUnifiedTBAATree, *dl};
mlir::RewritePatternSet pattern(context);
- pattern.insert<
- AbsentOpConversion, AddcOpConversion, AddrOfOpConversion,
- AllocaOpConversion, AllocMemOpConversion, BoxAddrOpConversion,
- BoxCharLenOpConversion, BoxDimsOpConversion, BoxEleSizeOpConversion,
- BoxIsAllocOpConversion, BoxIsArrayOpConversion, BoxIsPtrOpConversion,
- BoxOffsetOpConversion, BoxProcHostOpConversion, BoxRankOpConversion,
- BoxTypeCodeOpConversion, BoxTypeDescOpConversion, CallOpConversion,
- CmpcOpConversion, ConstcOpConversion, ConvertOpConversion,
- CoordinateOpConversion, DTEntryOpConversion, DivcOpConversion,
- EmboxOpConversion, EmboxCharOpConversion, EmboxProcOpConversion,
- ExtractValueOpConversion, FieldIndexOpConversion, FirEndOpConversion,
- FreeMemOpConversion, GlobalLenOpConversion, GlobalOpConversion,
- HasValueOpConversion, InsertOnRangeOpConversion,
- InsertValueOpConversion, IsPresentOpConversion,
- LenParamIndexOpConversion, LoadOpConversion, MulcOpConversion,
- NegcOpConversion, NoReassocOpConversion, SelectCaseOpConversion,
- SelectOpConversion, SelectRankOpConversion, SelectTypeOpConversion,
- ShapeOpConversion, ShapeShiftOpConversion, ShiftOpConversion,
- SliceOpConversion, StoreOpConversion, StringLitOpConversion,
- SubcOpConversion, TypeDescOpConversion, TypeInfoOpConversion,
- UnboxCharOpConversion, UnboxProcOpConversion, UndefOpConversion,
- UnreachableOpConversion, UnrealizedConversionCastOpConversion,
- XArrayCoorOpConversion, XEmboxOpConversion, XReboxOpConversion,
- ZeroOpConversion>(typeConverter, options);
+ fir::populateFIRToLLVMConversionPatterns(typeConverter, pattern, options);
mlir::populateFuncToLLVMConversionPatterns(typeConverter, pattern);
mlir::populateOpenMPToLLVMConversionPatterns(typeConverter, pattern);
mlir::arith::populateArithToLLVMConversionPatterns(typeConverter, pattern);
@@ -4072,3 +4049,32 @@ fir::createLLVMDialectToLLVMPass(llvm::raw_ostream &output,
fir::LLVMIRLoweringPrinter printer) {
return std::make_unique<LLVMIRLoweringPass>(output, printer);
}
+
+void fir::populateFIRToLLVMConversionPatterns(
+ fir::LLVMTypeConverter &converter, mlir::RewritePatternSet &patterns,
+ fir::FIRToLLVMPassOptions &options) {
+ patterns.insert<
+ AbsentOpConversion, AddcOpConversion, AddrOfOpConversion,
+ AllocaOpConversion, AllocMemOpConversion, BoxAddrOpConversion,
+ BoxCharLenOpConversion, BoxDimsOpConversion, BoxEleSizeOpConversion,
+ BoxIsAllocOpConversion, BoxIsArrayOpConversion, BoxIsPtrOpConversion,
+ BoxOffsetOpConversion, BoxProcHostOpConversion, BoxRankOpConversion,
+ BoxTypeCodeOpConversion, BoxTypeDescOpConversion, CallOpConversion,
+ CmpcOpConversion, ConstcOpConversion, ConvertOpConversion,
+ CoordinateOpConversion, DTEntryOpConversion, DivcOpConversion,
+ EmboxOpConversion, EmboxCharOpConversion, EmboxProcOpConversion,
+ ExtractValueOpConversion, FieldIndexOpConversion, FirEndOpConversion,
+ FreeMemOpConversion, GlobalLenOpConversion, GlobalOpConversion,
+ HasValueOpConversion, InsertOnRangeOpConversion, InsertValueOpConversion,
+ IsPresentOpConversion, LenParamIndexOpConversion, LoadOpConversion,
+ MulcOpConversion, NegcOpConversion, NoReassocOpConversion,
+ SelectCaseOpConversion, SelectOpConversion, SelectRankOpConversion,
+ SelectTypeOpConversion, ShapeOpConversion, ShapeShiftOpConversion,
+ ShiftOpConversion, SliceOpConversion, StoreOpConversion,
+ StringLitOpConversion, SubcOpConversion, TypeDescOpConversion,
+ TypeInfoOpConversion, UnboxCharOpConversion, UnboxProcOpConversion,
+ UndefOpConversion, UnreachableOpConversion,
+ UnrealizedConversionCastOpConversion, XArrayCoorOpConversion,
+ XEmboxOpConversion, XReboxOpConversion, ZeroOpConversion>(converter,
+ options);
+}
More information about the flang-commits
mailing list