[PATCH] D94228: [flang][driver] Support fixed form detection

Andrzej Warzynski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 12 03:49:21 PST 2021


awarzynski added a subscriber: PeteSteinfeld.
awarzynski added a comment.

@sscalpone @sameeranjoshi Let me just point out that currently Flang does not differentiate between different versions of Fortran. So `file.f95` and `file.f03` is internally simply treated as `Language::Fortran`.

In D94228#2490643 <https://reviews.llvm.org/D94228#2490643>, @sscalpone wrote:

> 



> I believe the "-x" option allows different language types to be supported.  Do we think -x will differentiate between free/fixed, or do we anticipate adding special options to instruct the compiler to handle fixed/free source?

`gfortran` uses `-ffixed-form` & `-ffree-form` and that's what we proposed for Flang [1] [2].  The table below effectively lists all options supported by `-x`. For Fortran we differentiate between `TY_Fortran` (regular Fortran input, not preprocessed) and `TY_PP_Fortran` (regular Fortran input, preprocessed). In order to differentiate fixed and free form source file with `-x` we'd have to extend `clang::driver::types::ID`. IMO such change is not yet required.

- https://github.com/llvm/llvm-project/blob/80dee7965dffdfb866afa9d74f3a4a97453708b2/clang/include/clang/Driver/Types.h#L23

> More information about other compilers is available here:
> https://github.com/llvm/llvm-project/blob/main/flang/docs/OptionComparison.md

This document was very helpful when compiling [1] and [2]. Kudos to @PeteSteinfeld for preparing it!

[1] https://docs.google.com/spreadsheets/d/1JRe39lP_KhtkYxFEIvwrCFlE5v1Ofa_krOHI-XXXWPY/edit#gid=0
[2] https://lists.llvm.org/pipermail/flang-dev/2020-November/000588.html



================
Comment at: flang/lib/Frontend/FrontendOptions.cpp:16
   return llvm::StringSwitch<InputKind>(extension)
-      // TODO: Should match the list in flang/test/lit.cfg.py
+      // Note: keep this list in-sync with flang/test/lit.cfg.py
+      // TODO: Add Cuda Fortan files (i.e. `*.cuf` and `*.CUF`).
----------------
sameeranjoshi wrote:
> What about `.f08` extension or maybe `f03`?
> It seems to be in one of the popular compilers[1]
> 
> [1]https://github.com/llvm/llvm-project/blob/master/flang/docs/OptionComparison.md#notes
Thanks for the comment. I just wanted to point out that currently Flang does not differentiate between different versions of Fortran. Indeed, only F2018 grammar is mentioned in the docs: https://github.com/llvm/llvm-project/blob/main/flang/docs/f2018-grammar.md

So, whether other file extension are added or not, internally we are using `Language::Fortran`. That's unlikely to change any time soon. Adding more file extensions here is just a _syntactic_ sugar at this stage.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94228/new/

https://reviews.llvm.org/D94228



More information about the llvm-commits mailing list