[PATCH] D113662: [fir] Add placeholder conversion pattern for disptach operations
Valentin Clement via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 11 03:39:33 PST 2021
clementval created this revision.
clementval added reviewers: jeanPerier, svedanayagam, sscalpone, kiranchandramohan, jdoerfert, schweitz, pmccormick, rovka, AlexisPerry, PeteSteinfeld, awarzynski.
Herald added a subscriber: mehdi_amini.
Herald added a project: Flang.
clementval requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
`fir.dispatch`, `fir.dispatch_table` and `fir.dt_entry` are operations
for type-bound procedures. This patch just adds placeholder conversion
pattern that currently fails since F2003 <https://reviews.llvm.org/F2003> is not implemented yet.
This patch is part of the upstreaming effort from fir-dev branch.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113662
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
@@ -8,3 +8,22 @@
return
}
+// -----
+
+// Test that `fir.dispatch` fails to be legalized. Not implemented yet.
+
+func @dispatch(%arg0: !fir.box<!fir.type<derived3{f:f32}>>) {
+ // expected-error at +1{{failed to legalize operation 'fir.dispatch'}}
+ %0 = fir.dispatch "method"(%arg0) : (!fir.box<!fir.type<derived3{f:f32}>>) -> i32
+ return
+}
+
+// -----
+
+// Test that `fir.dispatch_table`/`fir.dt_entry` fails to be legalized.
+// Not implemented yet.
+
+// expected-error at +1{{failed to legalize operation 'fir.dispatch_table'}}
+fir.dispatch_table @dispatch_tbl {
+ fir.dt_entry "method", @method_impl
+}
Index: flang/lib/Optimizer/CodeGen/CodeGen.cpp
===================================================================
--- flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -371,6 +371,49 @@
}
};
+/// Lower of `fir.dispatch` operation. A virtual call to a method in a dispatch
+/// table.
+/// TODO: F2003 features.
+struct DispatchOpConversion : public FIROpConversion<fir::DispatchOp> {
+ using FIROpConversion::FIROpConversion;
+
+ mlir::LogicalResult
+ matchAndRewrite(fir::DispatchOp dispatch, OpAdaptor adaptor,
+ mlir::ConversionPatternRewriter &rewriter) const override {
+ return rewriter.notifyMatchFailure(
+ dispatch, "fir.dispatch codegen is not implemented yet");
+ }
+};
+
+/// Lower of `fir.dispatch_table` operation. The dispatch table for a Fortran
+/// derived type.
+/// TODO: F2003 features.
+struct DispatchTableOpConversion
+ : public FIROpConversion<fir::DispatchTableOp> {
+ using FIROpConversion::FIROpConversion;
+
+ mlir::LogicalResult
+ matchAndRewrite(fir::DispatchTableOp dispTab, OpAdaptor adaptor,
+ mlir::ConversionPatternRewriter &rewriter) const override {
+ return rewriter.notifyMatchFailure(
+ dispTab, "fir.dispatch_table codegen is not implemented yet");
+ }
+};
+
+/// Lower of `fir.dt_entry` operation. An entry in a dispatch table; binds a
+/// method-name to a function.
+/// TODO: F2003 features.
+struct DTEntryOpConversion : public FIROpConversion<fir::DTEntryOp> {
+ using FIROpConversion::FIROpConversion;
+
+ mlir::LogicalResult
+ matchAndRewrite(fir::DTEntryOp dtEnt, OpAdaptor adaptor,
+ mlir::ConversionPatternRewriter &rewriter) const override {
+ return rewriter.notifyMatchFailure(
+ dtEnt, "fir.dt_entry codegen is not implemented yet");
+ }
+};
+
/// Lower `fir.has_value` operation to `llvm.return` operation.
struct HasValueOpConversion : public FIROpConversion<fir::HasValueOp> {
using FIROpConversion::FIROpConversion;
@@ -999,6 +1042,7 @@
AddcOpConversion, AddrOfOpConversion, BoxAddrOpConversion,
BoxDimsOpConversion, BoxEleSizeOpConversion, BoxRankOpConversion,
CallOpConversion, ConvertOpConversion, DivcOpConversion,
+ DispatchOpConversion, DispatchTableOpConversion, DTEntryOpConversion,
ExtractValueOpConversion, HasValueOpConversion, GlobalOpConversion,
InsertOnRangeOpConversion, InsertValueOpConversion, LoadOpConversion,
NegcOpConversion, MulcOpConversion, SelectOpConversion,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113662.386471.patch
Type: text/x-patch
Size: 3382 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211111/311efe18/attachment.bin>
More information about the llvm-commits
mailing list