[flang-commits] [flang] 3124618 - [fir] Add fir.gentypedesc conversion
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Tue Nov 16 05:41:08 PST 2021
Author: Valentin Clement
Date: 2021-11-16T14:41:00+01:00
New Revision: 3124618704c5a9d1442b75d6372307654fea0827
URL: https://github.com/llvm/llvm-project/commit/3124618704c5a9d1442b75d6372307654fea0827
DIFF: https://github.com/llvm/llvm-project/commit/3124618704c5a9d1442b75d6372307654fea0827.diff
LOG: [fir] Add fir.gentypedesc conversion
Add conversion pattern for the GenTypeDescOp.
Convert to a global constant with an addressof.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D113766
Co-authored-by: Eric Schweitz <eschweitz at nvidia.com>
Co-authored-by: Jean Perier <jperier at nvidia.com>
Added:
Modified:
flang/lib/Optimizer/CodeGen/CodeGen.cpp
flang/test/Fir/convert-to-llvm-invalid.fir
Removed:
################################################################################
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index 87827dcf2795..8cf335294718 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -694,6 +694,18 @@ struct GlobalLenOpConversion : public FIROpConversion<fir::GlobalLenOp> {
}
};
+/// Lower `fir.gentypedesc` to a global constant.
+struct GenTypeDescOpConversion : public FIROpConversion<fir::GenTypeDescOp> {
+ using FIROpConversion::FIROpConversion;
+
+ mlir::LogicalResult
+ matchAndRewrite(fir::GenTypeDescOp gentypedesc, OpAdaptor adaptor,
+ mlir::ConversionPatternRewriter &rewriter) const override {
+ return rewriter.notifyMatchFailure(
+ gentypedesc, "fir.fir.gentypedesc codegen is not implemented yet");
+ }
+};
+
/// Lower `fir.has_value` operation to `llvm.return` operation.
struct HasValueOpConversion : public FIROpConversion<fir::HasValueOp> {
using FIROpConversion::FIROpConversion;
@@ -1563,14 +1575,13 @@ class FIRToLLVMLowering : public fir::FIRToLLVMLoweringBase<FIRToLLVMLowering> {
CmpcOpConversion, ConvertOpConversion, DispatchOpConversion,
DispatchTableOpConversion, DTEntryOpConversion, DivcOpConversion,
EmboxCharOpConversion, ExtractValueOpConversion, HasValueOpConversion,
- GlobalLenOpConversion, GlobalOpConversion, InsertOnRangeOpConversion,
- InsertValueOpConversion, IsPresentOpConversion, LoadOpConversion,
- NegcOpConversion, MulcOpConversion, SelectCaseOpConversion,
- SelectOpConversion, SelectRankOpConversion, SelectTypeOpConversion,
- StoreOpConversion, SubcOpConversion, UnboxCharOpConversion,
- UndefOpConversion, UnreachableOpConversion, ZeroOpConversion>(
- typeConverter);
-
+ GenTypeDescOpConversion, GlobalLenOpConversion, GlobalOpConversion,
+ InsertOnRangeOpConversion, InsertValueOpConversion,
+ IsPresentOpConversion, LoadOpConversion, NegcOpConversion,
+ MulcOpConversion, SelectCaseOpConversion, SelectOpConversion,
+ SelectRankOpConversion, SelectTypeOpConversion, StoreOpConversion,
+ SubcOpConversion, UnboxCharOpConversion, UndefOpConversion,
+ UnreachableOpConversion, ZeroOpConversion>(typeConverter);
mlir::populateStdToLLVMConversionPatterns(typeConverter, pattern);
mlir::arith::populateArithmeticToLLVMConversionPatterns(typeConverter,
pattern);
diff --git a/flang/test/Fir/convert-to-llvm-invalid.fir b/flang/test/Fir/convert-to-llvm-invalid.fir
index 88175a84eb56..632293988ca3 100644
--- a/flang/test/Fir/convert-to-llvm-invalid.fir
+++ b/flang/test/Fir/convert-to-llvm-invalid.fir
@@ -83,3 +83,13 @@ fir.global @global_derived : !fir.type<minez(f:i32)> {
%0 = fir.undefined !fir.type<minez>
fir.has_value %0 : !fir.type<minez>
}
+
+// -----
+
+// Test `fir.gentypedesc` conversion failure. Not implemented yet.
+
+func @gentypedesc() {
+ // expected-error at +1{{failed to legalize operation 'fir.gentypedesc'}}
+ %0 = fir.gentypedesc !fir.type<derived3>
+ return
+}
More information about the flang-commits
mailing list