[flang-commits] [flang] [flang] Register and lower SECNDS (stubbed implementation) (PR #151878)
Šárka Holendová via flang-commits
flang-commits at lists.llvm.org
Sun Aug 10 08:00:38 PDT 2025
================
@@ -921,6 +921,11 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
{"back", AnyLogical, Rank::elemental, Optionality::optional},
DefaultingKIND},
KINDInt},
+ {"secnds",
+ {{"x", TypePattern{RealType, KindCode::exactKind, 4}, Rank::scalar,
+ Optionality::required, common::Intent::In}},
+ TypePattern{RealType, KindCode::exactKind, 4}, Rank::scalar,
+ IntrinsicClass::impureSubroutine},
----------------
mlir-maiden wrote:
I went back and forth on the classification quite a bit.
SECNDS is a non-standard intrinsic, and GNU Fortran documents it simply as a function. But when mapping it to Flang’s IntrinsicClass, none of the available categories seem to fit perfectly. It is impure (as confirmed by GNU rejecting its use in PURE procedures), and while it has a scalar argument and a scalar return value, it cannot be classified as an elementalFunction. According to ISO/IEC 1539-1:2023 §15.9.1, “An elemental subprogram is a pure subprogram unless it has the prefix-spec IMPURE.” Since SECNDS has no ELEMENTAL or IMPURE prefix and is not pure, it doesn't qualify as elemental. I am assuming here that GNU Fortran would explicitly document those attributes if they were part of the intrinsic’s definition. ETIME is another non-standard intrinsic and is left unclassified in Flang. Based on that precedent and the lack of a defined category for impure functions, it seems best to leave SECNDS unclassified as well. I am open to suggestions if there is a more appropriate fit. Thank you :)
https://github.com/llvm/llvm-project/pull/151878
More information about the flang-commits
mailing list