2020-10-24 19:33:19 +08:00
|
|
|
|
|
|
|
!--------------------------
|
|
|
|
! FLANG DRIVER (flang-new)
|
|
|
|
!--------------------------
|
2021-04-09 18:32:31 +08:00
|
|
|
! RUN: %flang --help-hidden 2>&1 | FileCheck %s
|
|
|
|
! RUN: not %flang -help-hidden 2>&1 | FileCheck %s --check-prefix=ERROR-FLANG
|
2020-10-24 19:33:19 +08:00
|
|
|
|
|
|
|
!----------------------------------------
|
|
|
|
! FLANG FRONTEND DRIVER (flang-new -fc1)
|
|
|
|
!----------------------------------------
|
2021-04-09 18:32:31 +08:00
|
|
|
! RUN: not %flang_fc1 --help-hidden 2>&1 | FileCheck %s --check-prefix=ERROR-FLANG-FC1
|
|
|
|
! RUN: not %flang_fc1 -help-hidden 2>&1 | FileCheck %s --check-prefix=ERROR-FLANG-FC1
|
2020-10-24 19:33:19 +08:00
|
|
|
|
|
|
|
!----------------------------------------------------
|
|
|
|
! EXPECTED OUTPUT FOR FLANG DRIVER (flang-new)
|
|
|
|
!----------------------------------------------------
|
|
|
|
! CHECK:USAGE: flang-new
|
|
|
|
! CHECK-EMPTY:
|
|
|
|
! CHECK-NEXT:OPTIONS:
|
2020-11-11 16:45:54 +08:00
|
|
|
! CHECK-NEXT: -### Print (but do not run) the commands to run for this compilation
|
2021-04-07 19:42:37 +08:00
|
|
|
! CHECK-NEXT: -cpp Enable predefined and command line preprocessor macros
|
[flang][driver] Add support for `-c` and `-emit-obj`
This patch adds a frontend action for emitting object files. While Flang
does not support code-generation, this action remains a placeholder.
This patch simply provides glue-code to connect the compiler driver
with the appropriate frontend action.
The new action is triggered with the `-c` compiler driver flag, i.e.
`flang-new -c`. This is then translated to `flang-new -fc1 -emit-obj`,
so `-emit-obj` has to be marked as supported as well.
As code-generation is not available yet, `flang-new -c` results in a
driver error:
```
error: code-generation is not available yet
```
Hopefully this will help communicating the level of available
functionality within Flang.
The definition of `emit-obj` is updated so that it can be shared between
Clang and Flang. As the original definition was enclosed within a
Clang-specific TableGen `let` statement, it is extracted into a new `let`
statement. That felt like the cleanest option.
I also commented out `-triple` in Flang::ConstructJob and updated some
comments there. This is similar to https://reviews.llvm.org/D93027. I
wanted to make sure that it's clear that we can't support `-triple`
until we have code-generation. However, once code-generation is
available we _will need_ `-triple`.
As this patch adds `-emit-obj`, the emit-obj.f90 becomes irrelevant and
is deleted. Instead, phases.f90 is added to demonstrate that users can
control compilation phases (indeed, `-c` is a phase control flag).
Reviewed By: SouraVX, clementval
Differential Revision: https://reviews.llvm.org/D93301
2021-01-07 17:08:54 +08:00
|
|
|
! CHECK-NEXT: -c Only run preprocess, compile, and assemble steps
|
2021-01-06 23:42:24 +08:00
|
|
|
! CHECK-NEXT: -D <macro>=<value> Define <macro> to <value> (or 1 if <value> omitted)
|
[flang][driver] Add support for `--target`/`--triple`
This patch adds support for:
* `--target` in the compiler driver (`flang-new`)
* `--triple` in the frontend driver (`flang-new -fc1`)
The semantics of these flags are inherited from `clangDriver`, i.e.
consistent with `clang --target` and `clang -cc1 --triple`,
respectively.
A new structure is defined, `TargetOptions`, that will hold various
Frontend options related to the target. Currently, this is mostly a
placeholder that contains the target triple. In the future, it will be
used for storing e.g. the CPU to tune for or the target features to
enable.
Additionally, the following target/triple related options are enabled
[*]: `-print-effective-triple`, `-print-target-triple`. Definitions in
Options.td are updated accordingly and, to facilated testing,
`-emit-llvm` is added to the list of options available in `flang-new`
(previously it was only enabled in `flang-new -fc1`).
[*] These options were actually available before (like all other options
defined in `clangDriver`), but not included in `flang-new --help`.
Before this change, `flang-new` would just use `native` for defining the
target, so these options were of little value.
Differential Revision: https://reviews.llvm.org/D120246
2022-02-21 19:51:32 +08:00
|
|
|
! CHECK-NEXT: -emit-llvm Use the LLVM representation for assembler and object files
|
2020-10-27 20:26:47 +08:00
|
|
|
! CHECK-NEXT: -E Only run the preprocessor
|
2021-02-05 05:11:22 +08:00
|
|
|
! CHECK-NEXT: -falternative-parameter-statement
|
|
|
|
! CHECK-NEXT: Enable the old style PARAMETER statement
|
|
|
|
! CHECK-NEXT: -fbackslash Specify that backslash in string introduces an escape character
|
2020-10-24 19:33:19 +08:00
|
|
|
! CHECK-NEXT: -fcolor-diagnostics Enable colors in diagnostics
|
2021-03-04 00:28:11 +08:00
|
|
|
! CHECK-NEXT: -fdefault-double-8 Set the default double precision kind to an 8 byte wide type
|
|
|
|
! CHECK-NEXT: -fdefault-integer-8 Set the default integer kind to an 8 byte wide type
|
|
|
|
! CHECK-NEXT: -fdefault-real-8 Set the default real kind to an 8 byte wide type
|
2021-01-27 00:27:30 +08:00
|
|
|
! CHECK-NEXT: -ffixed-form Process source files in fixed form
|
|
|
|
! CHECK-NEXT: -ffixed-line-length=<value>
|
|
|
|
! CHECK-NEXT: Use <value> as character line width in fixed mode
|
|
|
|
! CHECK-NEXT: -ffree-form Process source files in free form
|
2021-02-05 05:11:22 +08:00
|
|
|
! CHECK-NEXT: -fimplicit-none No implicit typing allowed unless overridden by IMPLICIT statements
|
|
|
|
! CHECK-NEXT: -finput-charset=<value> Specify the default character set for source files
|
2021-03-24 00:24:57 +08:00
|
|
|
! CHECK-NEXT: -fintrinsic-modules-path <dir>
|
|
|
|
! CHECK-NEXT: Specify where to find the compiled intrinsic modules
|
2021-03-04 00:28:11 +08:00
|
|
|
! CHECK-NEXT: -flarge-sizes Use INTEGER(KIND=8) for the result type in size-related intrinsics
|
2021-02-05 05:11:22 +08:00
|
|
|
! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
|
[flang] Add -fno-automatic, refine IsSaved()
This legacy option (available in other Fortran compilers with various
spellings) implies the SAVE attribute for local variables on subprograms
that are not explicitly RECURSIVE. The SAVE attribute essentially implies
static rather than stack storage. This was the default setting in Fortran
until surprisingly recently, so explicit SAVE statements & attributes
could be and often were omitted from older codes. Note that initialized
objects already have an implied SAVE attribute, and objects in COMMON
effectively do too, as data overlays are extinct; and since objects that are
expected to survive from one invocation of a procedure to the next in static
storage should probably be explicit initialized in the first place, so the
use cases for this option are somewhat rare, and all of them could be
handled with explicit SAVE statements or attributes.
This implicit SAVE attribute must not apply to automatic (in the Fortran sense)
local objects, whose sizes cannot be known at compilation time. To get the
semantics of IsSaved() right, the IsAutomatic() predicate was moved into
Evaluate/tools.cpp to allow for dynamic linking of the compiler. The
redundant predicate IsAutomatic() was noticed, removed, and its uses replaced.
GNU Fortran's spelling of the option (-fno-automatic) was added to
the clang-based driver and used for basic sanity testing.
Differential Revision: https://reviews.llvm.org/D114209
2021-11-19 03:48:42 +08:00
|
|
|
! CHECK-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
|
[flang][driver] Refactor boolean options
For boolean options, e.g. `-fxor-operator`/`-fno-xor-operator`, we ought
to be using TableGen multi-classes. This way, we only have to write one
definition to have both forms auto-generated. This patch refactors all
of Flang's boolean options to use two new multi-classes:
`OptInFC1FFOption` and `OptOutFC1FFOption`. These multi-classes are
based on `OptInFFOption`/`OptOutFFOption`, respectively. I've also
simplified the processing of the updated options in
CompilerInvocation.cpp.
With the new approach, "empty" help text (i.e. no `HelpText`) is now
replaced with an empty string (i.e. HelpText<"">). When running
flang-new --help, that's considered as non-empty help messages, which is
then printed (that's controlled by `printHelp` from
llvm/lib/Option/OptTable.cpp). This means that with this patch,
flang-new --help will start printing e.g. -fno-backslash, even though
there is no actual help text to print for this option (apart from the
empty string ""). Tests are updated accordingly.
Note that with this patch, both `-fxor-operator` and `-fno-xor-operator`
(and other boolean options refactored here) remain available in
`flang-new` and `flang-new -fc1`. In this respect, nothing changes. In a
forthcoming patch, I will refine this so that `flang-new -fc1` only
accepts `-ffoo` (`OptInFC1FFOption`) or `-fno-foo` (`OptOutCC1FFOption`).
For clarity, `OptInFFOption`/`OptOutFFOption` are renamed as
`OptInCC1FFOption`/`OptOutCC1FFOption`, respectively. Otherwise, this is
an NFC from Clang's perspective.
Differential Revision: https://reviews.llvm.org/D105881
2021-06-30 18:57:48 +08:00
|
|
|
! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
|
2021-02-10 17:24:45 +08:00
|
|
|
! CHECK-NEXT: -fopenacc Enable OpenACC
|
|
|
|
! CHECK-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code.
|
2021-02-05 05:11:22 +08:00
|
|
|
! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
|
2020-10-24 19:33:19 +08:00
|
|
|
! CHECK-NEXT: -help Display available options
|
2021-01-19 18:01:38 +08:00
|
|
|
! CHECK-NEXT: -I <dir> Add directory to the end of the list of include search paths
|
2022-03-02 23:40:16 +08:00
|
|
|
! CHECK-NEXT: -mllvm <value> Additional arguments to forward to LLVM's option processing
|
2021-02-05 00:13:04 +08:00
|
|
|
! CHECK-NEXT: -module-dir <dir> Put MODULE files in <dir>
|
2021-04-07 19:42:37 +08:00
|
|
|
! CHECK-NEXT: -nocpp Disable predefined and command line preprocessor macros
|
2020-10-24 19:33:19 +08:00
|
|
|
! CHECK-NEXT: -o <file> Write output to <file>
|
2021-03-26 01:02:05 +08:00
|
|
|
! CHECK-NEXT: -pedantic Warn on language extensions
|
[flang][driver] Add support for `--target`/`--triple`
This patch adds support for:
* `--target` in the compiler driver (`flang-new`)
* `--triple` in the frontend driver (`flang-new -fc1`)
The semantics of these flags are inherited from `clangDriver`, i.e.
consistent with `clang --target` and `clang -cc1 --triple`,
respectively.
A new structure is defined, `TargetOptions`, that will hold various
Frontend options related to the target. Currently, this is mostly a
placeholder that contains the target triple. In the future, it will be
used for storing e.g. the CPU to tune for or the target features to
enable.
Additionally, the following target/triple related options are enabled
[*]: `-print-effective-triple`, `-print-target-triple`. Definitions in
Options.td are updated accordingly and, to facilated testing,
`-emit-llvm` is added to the list of options available in `flang-new`
(previously it was only enabled in `flang-new -fc1`).
[*] These options were actually available before (like all other options
defined in `clangDriver`), but not included in `flang-new --help`.
Before this change, `flang-new` would just use `native` for defining the
target, so these options were of little value.
Differential Revision: https://reviews.llvm.org/D120246
2022-02-21 19:51:32 +08:00
|
|
|
! CHECK-NEXT: -print-effective-triple Print the effective target triple
|
|
|
|
! CHECK-NEXT: -print-target-triple Print the normalized target triple
|
2021-07-24 07:41:04 +08:00
|
|
|
! CHECK-NEXT: -P Disable linemarker output in -E mode
|
2021-03-26 01:02:05 +08:00
|
|
|
! CHECK-NEXT: -std=<value> Language standard to compile for
|
2022-02-25 01:34:27 +08:00
|
|
|
! CHECK-NEXT: -S Only run preprocess and compilation steps
|
[flang][driver] Add support for `--target`/`--triple`
This patch adds support for:
* `--target` in the compiler driver (`flang-new`)
* `--triple` in the frontend driver (`flang-new -fc1`)
The semantics of these flags are inherited from `clangDriver`, i.e.
consistent with `clang --target` and `clang -cc1 --triple`,
respectively.
A new structure is defined, `TargetOptions`, that will hold various
Frontend options related to the target. Currently, this is mostly a
placeholder that contains the target triple. In the future, it will be
used for storing e.g. the CPU to tune for or the target features to
enable.
Additionally, the following target/triple related options are enabled
[*]: `-print-effective-triple`, `-print-target-triple`. Definitions in
Options.td are updated accordingly and, to facilated testing,
`-emit-llvm` is added to the list of options available in `flang-new`
(previously it was only enabled in `flang-new -fc1`).
[*] These options were actually available before (like all other options
defined in `clangDriver`), but not included in `flang-new --help`.
Before this change, `flang-new` would just use `native` for defining the
target, so these options were of little value.
Differential Revision: https://reviews.llvm.org/D120246
2022-02-21 19:51:32 +08:00
|
|
|
! CHECK-NEXT: --target=<value> Generate code for the given target
|
2021-01-06 23:42:24 +08:00
|
|
|
! CHECK-NEXT: -U <macro> Undefine macro <macro>
|
2020-10-24 19:33:19 +08:00
|
|
|
! CHECK-NEXT: --version Print version information
|
2021-04-06 00:41:46 +08:00
|
|
|
! CHECK-NEXT: -W<warning> Enable the specified warning
|
2021-02-17 22:13:29 +08:00
|
|
|
! CHECK-NEXT: -Xflang <arg> Pass <arg> to the flang compiler
|
2020-10-24 19:33:19 +08:00
|
|
|
|
|
|
|
!-------------------------------------------------------------
|
|
|
|
! EXPECTED OUTPUT FOR FLANG DRIVER (flang-new)
|
|
|
|
!-------------------------------------------------------------
|
|
|
|
! ERROR-FLANG: error: unknown argument '-help-hidden'; did you mean '--help-hidden'?
|
|
|
|
|
|
|
|
!-------------------------------------------------------------
|
|
|
|
! EXPECTED OUTPUT FOR FLANG FRONTEND DRIVER (flang-new -fc1)
|
|
|
|
!-------------------------------------------------------------
|
|
|
|
! Frontend driver -help-hidden is not supported
|
|
|
|
! ERROR-FLANG-FC1: error: unknown argument: '{{.*}}'
|
|
|
|
|