[PATCH] D118699: [flang] Lower PAUSE statement
Valentin Clement via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 1 05:52:20 PST 2022
clementval created this revision.
clementval added reviewers: jeanPerier, kiranchandramohan, PeteSteinfeld, schweitz, svedanayagam.
Herald added a subscriber: mehdi_amini.
Herald added a project: Flang.
clementval requested review of this revision.
Herald added subscribers: llvm-commits, jdoerfert.
Herald added a project: LLVM.
Lower the PAUSE statement to a runtime call.
This patch is part of the upstreaming effort from fir-dev branch.
Co-authored-by: Eric Schweitz <eschweitz at nvidia.com>
Co-authored-by: Jean Perier <jperier at nvidia.com>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D118699
Files:
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/Runtime.cpp
flang/test/Lower/pause-statement.f90
Index: flang/test/Lower/pause-statement.f90
===================================================================
--- /dev/null
+++ flang/test/Lower/pause-statement.f90
@@ -0,0 +1,8 @@
+! RUN: bbc %s -emit-fir --canonicalize -o - | FileCheck %s
+
+! CHECK-LABEL pause_test
+subroutine pause_test()
+ ! CHECK: fir.call @_Fortran{{.*}}PauseStatement()
+ ! CHECK-NEXT: return
+ pause
+end subroutine
Index: flang/lib/Lower/Runtime.cpp
===================================================================
--- flang/lib/Lower/Runtime.cpp
+++ flang/lib/Lower/Runtime.cpp
@@ -73,3 +73,13 @@
builder.create<fir::CallOp>(loc, callee, operands);
genUnreachable(builder, loc);
}
+
+void Fortran::lower::genPauseStatement(
+ Fortran::lower::AbstractConverter &converter,
+ const Fortran::parser::PauseStmt &) {
+ fir::FirOpBuilder &builder = converter.getFirOpBuilder();
+ mlir::Location loc = converter.getCurrentLocation();
+ mlir::FuncOp callee =
+ fir::runtime::getRuntimeFunc<mkRTKey(PauseStatement)>(loc, builder);
+ builder.create<fir::CallOp>(loc, callee, llvm::None);
+}
Index: flang/lib/Lower/Bridge.cpp
===================================================================
--- flang/lib/Lower/Bridge.cpp
+++ flang/lib/Lower/Bridge.cpp
@@ -554,7 +554,7 @@
}
void genFIR(const Fortran::parser::PauseStmt &stmt) {
- TODO(toLocation(), "PauseStmt lowering");
+ genPauseStatement(*this, stmt);
}
void genFIR(const Fortran::parser::FailImageStmt &stmt) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118699.404902.patch
Type: text/x-patch
Size: 1490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220201/683a64fb/attachment.bin>
More information about the llvm-commits
mailing list