Skip to content

Commit dae2e99

Browse files
committed
[flang] Register and lower SECNDS (stubbed implementation)
1 parent 9f102a9 commit dae2e99

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

flang/include/flang/Optimizer/Builder/IntrinsicCall.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@ struct IntrinsicLibrary {
405405
llvm::ArrayRef<fir::ExtendedValue>);
406406
mlir::Value genScale(mlir::Type, llvm::ArrayRef<mlir::Value>);
407407
fir::ExtendedValue genScan(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
408+
fir::ExtendedValue genSecnds(mlir::Type resultType,
409+
llvm::ArrayRef<fir::ExtendedValue> args);
408410
fir::ExtendedValue genSecond(std::optional<mlir::Type>,
409411
mlir::ArrayRef<fir::ExtendedValue>);
410412
fir::ExtendedValue genSelectedCharKind(mlir::Type,

flang/lib/Evaluate/intrinsics.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,11 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
921921
{"back", AnyLogical, Rank::elemental, Optionality::optional},
922922
DefaultingKIND},
923923
KINDInt},
924+
{"secnds",
925+
{{"x", TypePattern{RealType, KindCode::exactKind, 4}, Rank::scalar,
926+
Optionality::required, common::Intent::In}},
927+
TypePattern{RealType, KindCode::exactKind, 4}, Rank::scalar,
928+
IntrinsicClass::impureSubroutine},
924929
{"second", {}, DefaultReal, Rank::scalar},
925930
{"selected_char_kind", {{"name", DefaultChar, Rank::scalar}}, DefaultInt,
926931
Rank::scalar, IntrinsicClass::transformationalFunction},

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,10 @@ static constexpr IntrinsicHandler handlers[]{
864864
{"back", asValue, handleDynamicOptional},
865865
{"kind", asValue}}},
866866
/*isElemental=*/true},
867+
{"secnds",
868+
&I::genSecnds,
869+
{{{"x", asValue}}},
870+
/*isElemental=*/false},
867871
{"second",
868872
&I::genSecond,
869873
{{{"time", asAddr}}},
@@ -7813,6 +7817,14 @@ IntrinsicLibrary::genScan(mlir::Type resultType,
78137817
return readAndAddCleanUp(resultMutableBox, resultType, "SCAN");
78147818
}
78157819

7820+
// SECNDS
7821+
// Lowering is registered, runtime not yet implemented
7822+
fir::ExtendedValue
7823+
IntrinsicLibrary::genSecnds(mlir::Type resultType,
7824+
llvm::ArrayRef<fir::ExtendedValue> args) {
7825+
TODO(loc, "not yet implemented: SECNDS");
7826+
}
7827+
78167828
// SECOND
78177829
fir::ExtendedValue
78187830
IntrinsicLibrary::genSecond(std::optional<mlir::Type> resultType,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
!---------------------------------------------------------------------
2+
! RUN: %flang_fc1 -emit-fir %s -o - 2>&1 | FileCheck %s
3+
! XFAIL: *
4+
!---------------------------------------------------------------------
5+
6+
program test_secnds
7+
real :: x
8+
x = secnds(1.0)
9+
end program
10+
11+
! CHECK: not yet implemented: SECNDS
12+

0 commit comments

Comments
 (0)