forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang] Lower system_clock intrinsic
This patch adds lowering ofr the `system_clock` intrinsic. The call is lowered to runtime function call. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D121776 Co-authored-by: V Donaldson <[email protected]> Co-authored-by: Jean Perier <[email protected]>
- Loading branch information
1 parent
7fb2d9f
commit 264d966
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
! RUN: bbc -emit-fir %s -o - | FileCheck %s | ||
|
||
! CHECK-LABEL: system_clock_test | ||
subroutine system_clock_test() | ||
integer(4) :: c | ||
integer(8) :: m | ||
real :: r | ||
! CHECK-DAG: %[[c:.*]] = fir.alloca i32 {bindc_name = "c" | ||
! CHECK-DAG: %[[m:.*]] = fir.alloca i64 {bindc_name = "m" | ||
! CHECK-DAG: %[[r:.*]] = fir.alloca f32 {bindc_name = "r" | ||
! CHECK: %[[c4:.*]] = arith.constant 4 : i32 | ||
! CHECK: %[[Count:.*]] = fir.call @_FortranASystemClockCount(%[[c4]]) : (i32) -> i64 | ||
! CHECK: %[[Count1:.*]] = fir.convert %[[Count]] : (i64) -> i32 | ||
! CHECK: fir.store %[[Count1]] to %[[c]] : !fir.ref<i32> | ||
! CHECK: %[[c8:.*]] = arith.constant 8 : i32 | ||
! CHECK: %[[Rate:.*]] = fir.call @_FortranASystemClockCountRate(%[[c8]]) : (i32) -> i64 | ||
! CHECK: %[[Rate1:.*]] = fir.convert %[[Rate]] : (i64) -> f32 | ||
! CHECK: fir.store %[[Rate1]] to %[[r]] : !fir.ref<f32> | ||
! CHECK: %[[c8_2:.*]] = arith.constant 8 : i32 | ||
! CHECK: %[[Max:.*]] = fir.call @_FortranASystemClockCountMax(%[[c8_2]]) : (i32) -> i64 | ||
! CHECK: fir.store %[[Max]] to %[[m]] : !fir.ref<i64> | ||
call system_clock(c, r, m) | ||
! print*, c, r, m | ||
! CHECK-NOT: fir.call | ||
! CHECK: %[[c8_3:.*]] = arith.constant 8 : i32 | ||
! CHECK: %[[Rate:.*]] = fir.call @_FortranASystemClockCountRate(%[[c8_3]]) : (i32) -> i64 | ||
! CHECK: fir.store %[[Rate]] to %[[m]] : !fir.ref<i64> | ||
call system_clock(count_rate=m) | ||
! CHECK-NOT: fir.call | ||
! print*, m | ||
end subroutine |