[flang-commits] [flang] db01b12 - [flang] Lower PAUSE statement
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Tue Feb 1 23:16:21 PST 2022
Author: Valentin Clement
Date: 2022-02-02T08:16:12+01:00
New Revision: db01b123d012df2f0e6acf7e90bf4ba63382587c
URL: https://github.com/llvm/llvm-project/commit/db01b123d012df2f0e6acf7e90bf4ba63382587c
DIFF: https://github.com/llvm/llvm-project/commit/db01b123d012df2f0e6acf7e90bf4ba63382587c.diff
LOG: [flang] Lower PAUSE statement
Lower the PAUSE statement to a runtime call.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: kiranchandramohan, schweitz
Differential Revision: https://reviews.llvm.org/D118699
Co-authored-by: Eric Schweitz <eschweitz at nvidia.com>
Co-authored-by: Jean Perier <jperier at nvidia.com>
Added:
flang/test/Lower/pause-statement.f90
Modified:
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/Runtime.cpp
Removed:
################################################################################
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index fd52a76cf2f65..7302f6c8ce663 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -547,7 +547,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
}
void genFIR(const Fortran::parser::PauseStmt &stmt) {
- TODO(toLocation(), "PauseStmt lowering");
+ genPauseStatement(*this, stmt);
}
void genFIR(const Fortran::parser::FailImageStmt &stmt) {
diff --git a/flang/lib/Lower/Runtime.cpp b/flang/lib/Lower/Runtime.cpp
index 7156a8851f1dc..a49b0911d1a1a 100644
--- a/flang/lib/Lower/Runtime.cpp
+++ b/flang/lib/Lower/Runtime.cpp
@@ -68,3 +68,13 @@ void Fortran::lower::genStopStatement(
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);
+}
diff --git a/flang/test/Lower/pause-statement.f90 b/flang/test/Lower/pause-statement.f90
new file mode 100644
index 0000000000000..e4cba98dc8a79
--- /dev/null
+++ b/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
More information about the flang-commits
mailing list