[PATCH] D113766: [fir] Add fir.gentypedesc conversion
Valentin Clement via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 15 12:25:58 PST 2021
clementval updated this revision to Diff 387353.
clementval added a comment.
Replace the prototype lowering with not implmented yet.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113766/new/
https://reviews.llvm.org/D113766
Files:
flang/lib/Optimizer/CodeGen/CodeGen.cpp
flang/test/Fir/convert-to-llvm-invalid.fir
Index: flang/test/Fir/convert-to-llvm-invalid.fir
===================================================================
--- flang/test/Fir/convert-to-llvm-invalid.fir
+++ flang/test/Fir/convert-to-llvm-invalid.fir
@@ -50,3 +50,13 @@
^bb3:
return
}
+
+// -----
+
+// 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
+}
Index: flang/lib/Optimizer/CodeGen/CodeGen.cpp
===================================================================
--- flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -13,8 +13,10 @@
#include "flang/Optimizer/CodeGen/CodeGen.h"
#include "PassDetail.h"
#include "flang/ISO_Fortran_binding.h"
+#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Dialect/FIRAttr.h"
#include "flang/Optimizer/Dialect/FIROps.h"
+#include "flang/Optimizer/Support/InternalNames.h"
#include "mlir/Conversion/ArithmeticToLLVM/ArithmeticToLLVM.h"
#include "mlir/Conversion/LLVMCommon/Pattern.h"
#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
@@ -636,6 +638,18 @@
}
};
+/// 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;
@@ -1417,12 +1431,13 @@
BoxIsPtrOpConversion, BoxRankOpConversion, CallOpConversion,
ConvertOpConversion, DispatchOpConversion, DispatchTableOpConversion,
DTEntryOpConversion, DivcOpConversion, ExtractValueOpConversion,
- HasValueOpConversion, GlobalOpConversion, InsertOnRangeOpConversion,
- InsertValueOpConversion, IsPresentOpConversion, LoadOpConversion,
- NegcOpConversion, MulcOpConversion, SelectCaseOpConversion,
- SelectOpConversion, SelectRankOpConversion, StoreOpConversion,
- SubcOpConversion, UndefOpConversion, UnreachableOpConversion,
- ZeroOpConversion>(typeConverter);
+ HasValueOpConversion, GenTypeDescOpConversion, GlobalOpConversion,
+ InsertOnRangeOpConversion, InsertValueOpConversion,
+ IsPresentOpConversion, LoadOpConversion, NegcOpConversion,
+ MulcOpConversion, SelectCaseOpConversion, SelectOpConversion,
+ SelectRankOpConversion, StoreOpConversion, SubcOpConversion,
+ UndefOpConversion, UnreachableOpConversion, ZeroOpConversion>(
+ typeConverter);
mlir::populateStdToLLVMConversionPatterns(typeConverter, pattern);
mlir::arith::populateArithmeticToLLVMConversionPatterns(typeConverter,
pattern);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113766.387353.patch
Type: text/x-patch
Size: 3200 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211115/a9043c36/attachment.bin>
More information about the llvm-commits
mailing list