[PATCH] D113295: [flang] Transform `fir.end` to an empty statement

Andrzej Warzynski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 8 02:20:48 PST 2021


awarzynski updated this revision to Diff 385429.
awarzynski marked an inline comment as done.
awarzynski added a comment.

Remove the pretty printer and adjust the test accordingly


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113295/new/

https://reviews.llvm.org/D113295

Files:
  flang/lib/Optimizer/CodeGen/CodeGen.cpp
  flang/test/Fir/convert-to-llvm.fir


Index: flang/test/Fir/convert-to-llvm.fir
===================================================================
--- flang/test/Fir/convert-to-llvm.fir
+++ flang/test/Fir/convert-to-llvm.fir
@@ -323,3 +323,13 @@
 // CHECK-SAME:                     %[[TUPLE:.*]]: !llvm.struct<(i32, f32)>
 // CHECK:         %{{.*}} = llvm.insertvalue %{{.*}}, %[[TUPLE]][1 : index] : !llvm.struct<(i32, f32)>
 // CHECK:         llvm.return
+
+// -----
+
+// Test fir.end. As there is no "pretty printer" for this operation, use the
+// generic assembly format.
+
+"fir.end"() : () -> ()
+
+// CHECK-LABEL: module  {
+// CHECK-NEXT: }
Index: flang/lib/Optimizer/CodeGen/CodeGen.cpp
===================================================================
--- flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -79,6 +79,18 @@
   }
 };
 
+/// `fir.end` -> ``
+struct FirEndOpConversion : public FIROpConversion<fir::FirEndOp> {
+  using FIROpConversion::FIROpConversion;
+
+  mlir::LogicalResult
+  matchAndRewrite(fir::FirEndOp op, OpAdaptor,
+                  mlir::ConversionPatternRewriter &rewriter) const override {
+    rewriter.replaceOp(op, {});
+    return success();
+  }
+};
+
 /// Lower `fir.has_value` operation to `llvm.return` operation.
 struct HasValueOpConversion : public FIROpConversion<fir::HasValueOp> {
   using FIROpConversion::FIROpConversion;
@@ -488,11 +500,12 @@
     auto *context = getModule().getContext();
     fir::LLVMTypeConverter typeConverter{getModule()};
     mlir::OwningRewritePatternList pattern(context);
-    pattern.insert<
-        AddrOfOpConversion, ExtractValueOpConversion, HasValueOpConversion,
-        GlobalOpConversion, InsertOnRangeOpConversion, InsertValueOpConversion,
-        SelectOpConversion, SelectRankOpConversion, UndefOpConversion,
-        UnreachableOpConversion, ZeroOpConversion>(typeConverter);
+    pattern
+        .insert<AddrOfOpConversion, ExtractValueOpConversion,
+                FirEndOpConversion, HasValueOpConversion, GlobalOpConversion,
+                InsertOnRangeOpConversion, InsertValueOpConversion,
+                SelectOpConversion, SelectRankOpConversion, UndefOpConversion,
+                UnreachableOpConversion, ZeroOpConversion>(typeConverter);
     mlir::populateStdToLLVMConversionPatterns(typeConverter, pattern);
     mlir::arith::populateArithmeticToLLVMConversionPatterns(typeConverter,
                                                             pattern);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113295.385429.patch
Type: text/x-patch
Size: 2477 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211108/967f8116/attachment.bin>


More information about the llvm-commits mailing list