This is an archive of the discontinued LLVM Phabricator instance.

[flang][driver] Add standard predefinitions
ClosedPublic

Authored by FarisRehman on Jan 12 2021, 9:37 AM.

Details

Summary

Add the following standard predefinitions that f18 supports: __flang__, __flang_major__, __flang__minor__, __flang_patchlevel__

Summary of changes:

  • Populate Fortran::parser::Options#predefinitions with the default supported predefinitions

Depends on: D94422

Diff Detail

Event Timeline

FarisRehman created this revision.Jan 12 2021, 9:37 AM
FarisRehman requested review of this revision.Jan 12 2021, 9:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2021, 9:37 AM
FarisRehman edited the summary of this revision. (Show Details)Jan 12 2021, 9:38 AM
sameeranjoshi added inline comments.Jan 14 2021, 7:18 AM
flang/lib/Frontend/CompilerInvocation.cpp
272

Why is this 1 here?
Also why only x86_64, why don't we add other architectures here?

flang/test/Flang-Driver/compiler-defined-macros.f90
24 ↗(On Diff #316137)

How do you test __x86_64__ ?
I think we can add architecture specific tests in lit based test cases, does that make sense to add them here?

Thank you for working on this @FarisRehman !

@FarisRehman Re __X86_64__, in my opinion it is too early for any target-specific predefinitions and I suggest that we remove it for now. Lets revisit in the future when code-generation is supported.

@sameeranjoshi How does it sound? I totally agree with you that once we start adding such predefinitions, we should provide a solution that will support multiple architectures.

flang/lib/Frontend/CompilerInvocation.cpp
263

[nit] IMO this is fine for now, but long term the list of standard predefinitions is likely to grow significantly. Could add a TODO here? e.g.

// TODO: When expanding this list of standard predefinitions, consider creating a dedicated API for this. Also, at some point we will need to differentiate between different targets.

Agreed. @awarzynski. Thank you for clarification.

FarisRehman updated this revision to Diff 317321.EditedJan 18 2021, 3:46 AM
FarisRehman marked 3 inline comments as done.

Remove target-specific predefinition

Remove a target-specific predefinition (__x86_64__), addressing review comments by @awarzynski and @sameeranjoshi

Summary of changes:

  • Remove predefinition __x86_64__
  • Add __flang__ to predefinitions regression test
FarisRehman edited the summary of this revision. (Show Details)Jan 18 2021, 3:47 AM
sameeranjoshi accepted this revision.Jan 18 2021, 5:11 AM

Thank you.
LGTM.

This revision is now accepted and ready to land.Jan 18 2021, 5:11 AM
awarzynski accepted this revision.Jan 19 2021, 5:10 AM

LGTM @FarisRehman , thank you!

flang/test/Flang-Driver/compiler-defined-macros.f90
1 ↗(On Diff #317321)

[nit] IMHO we shouldn't be making a reference to f18 here. This test simply verifies that flang-new correctly defines macro pre-definitions for the compiler version. Perhaps the file could be renamed to reflect that?

This revision was landed with ongoing or failed builds.Jan 19 2021, 5:23 AM
This revision was automatically updated to reflect the committed changes.