Page MenuHomePhabricator

Implementation for COMPILER_VERSION intrinsic procedure
Needs ReviewPublic

Authored by hussainjk on Dec 21 2022, 9:33 PM.

Details

Summary

Besides adding the intrinsic handlers, also added some version querying boilerplate based on how Clang does it.

Diff Detail

Event Timeline

hussainjk created this revision.Dec 21 2022, 9:33 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
hussainjk requested review of this revision.Dec 21 2022, 9:33 PM

There's something wonky about this patch. I was unable to apply it against the latest sources. Can you please rebase?

ktras added a comment.Jan 4 2023, 10:22 AM

Is there a test you could add to this patch to show that the changes work as expected?

klausler added inline comments.
flang/include/flang/Common/Version.h
22

Don't indent the contents of a namespace.

Use capitalized names.

flang/lib/Lower/IntrinsicCall.cpp
747

This intrinsic function must be folded during semantics, not implemented in code generation.

rouson added inline comments.Jan 30 2023, 11:54 AM
flang/lib/Lower/IntrinsicCall.cpp
747

@klausler could you explain how one knows whether an intrinsic function must be folded during semantics or implemented in code generation?

klausler added inline comments.Jan 30 2023, 12:12 PM
flang/lib/Lower/IntrinsicCall.cpp
747

F'2018 subclause "10.1.12 Constant expression" reads:

A constant expression is an expression with limitations that make it suitable for use as a kind type parameter, initializer, or named constant. It is an expression in which each operation is intrinsic, and each primary is ...

... (6) a reference to a standard intrinsic function that is transformational, other than COMMAND_ARGUMENT_COUNT, GET_TEAM, NULL, NUM_IMAGES, TEAM_NUMBER, THIS_IMAGE, or TRANSFER, where each argument is a constant expression,

16.10.2.7 COMPILER_VERSION ( )
1 Description. Processor-dependent string identifying the program translation phase.
2 Class. Transformational function.
3 Argument. None.

A reference to COMPILER_VERSION() is a primary that is a reference to a standard intrinsic transformational function other than COMMAND_ARGUMENT_COUNT, GET_TEAM, NULL, NUM_IMAGES, TEAM_NUMBER, THIS_IMAGE, or TRANSFER, and it has no argument that is not a constant expression, so it satisfies the requirements of point (6) in the definition of a constant expression, and so it is a constant expression.