The GNU extension intrinsic IARGC is equivalent to
COMMAND_ARGUMENT_COUNT, and the GETARG is similar to
GET_COMMAND_ARGUMENT, but with less arguments. Reuse the runtime of
COMMAND_ARGUMENT_COUNT and GET_COMMAND_ARGUMENT for IARGC and GETARG.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I think we need any entry for these two non-standard intrinsics in flang/docs/Extensions.md.
flang/lib/Evaluate/intrinsics.cpp | ||
---|---|---|
479 ↗ | (On Diff #458978) | This should be after the second iand? |
What is the current stand about extensions? Should we have RFC before introducing them?
Some old workloads/applications use these two non-standard intrinsics. I hit this when building PNetCDF 1.11.2. Should I submit one RFC for this?
flang/lib/Evaluate/intrinsics.cpp | ||
---|---|---|
479 ↗ | (On Diff #458978) | Thanks. Fixed. |
@klausler, has more experience in this area than anyone I know. It would be good to get his approval before submitting.
Why do these need to be intrinsic procedures, and not just entry points in a standard library?
- What do you mean by "entry points in a standard library"?Does it mean the implementation of c_sizoof and sizeof? There is only one module "__Fortran_builtins" implicitly used.
- GETARG and GET_COMMAND_ARGUMENT have different arguments. It seems they cannot be implemented using the same entry point.
I get what you mean. Add IARGC as the alias of COMMAND_ARGUMENT_COUNT since they have the same interface. GETARG and GET_COMMAND_ARGUMENT have different interfaces. If they have the same entry point, the following test case will pass. However, it is non-conforming in gfortran.
PROGRAM test_get_command_argument INTEGER :: i CHARACTER(len=32) :: arg i = 0 DO CALL GETARG(i, arg, length) IF (LEN_TRIM(arg) == 0) EXIT print *, i, " ", arg, " ", length i = i+1 END DO END PROGRAM
I am not suggesting that you simply establish some aliases.
IARGC and GETARG can be written in Fortran or C with code that calls the standard intrinsic procedures. Why not do that instead of creating new extension intrinsics?
I am sorry that I am still confused about what you mean. Do you mean that Fortran users should handle this instead of supporting them in the compiler?
No.
I mean that IARGC and GETARG can be defined in the runtime library without being intrinsics.
flang/include/flang/Runtime/extensions.h | ||
---|---|---|
16 | Would functions and subroutines ever have distinct name mangling conventions? I think that you could have just one macro here. |
flang/include/flang/Runtime/extensions.h | ||
---|---|---|
16 | Thanks. Fixed. |
flang/runtime/extensions.cpp | ||
---|---|---|
19 | Now that you are adding more definitions to the namespace Fortran::runtime, this comment should be moved down so that it applies to the definition of FLUSH only, not to the entire namespace. |
flang/runtime/extensions.cpp | ||
---|---|---|
35 | n could be a reference. arg could be const. |
Thanks @klausler. Addressed the comments.
flang/runtime/extensions.cpp | ||
---|---|---|
35 | Fix the *n to &n. arg should not be const since Descriptor::Create requires it to be non-const. I hit the following error when I change it. error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive] 36 | Descriptor value{*Descriptor::Create(1, length, arg, 0)}; | ^~~ | | | const void* |
Would functions and subroutines ever have distinct name mangling conventions? I think that you could have just one macro here.