2020-10-24 19:33:19 +08:00
|
|
|
|
|
|
|
!--------------------------
|
2021-04-09 18:32:31 +08:00
|
|
|
! FLANG DRIVER (flang)
|
2020-10-24 19:33:19 +08:00
|
|
|
!--------------------------
|
2021-04-09 18:32:31 +08:00
|
|
|
! RUN: %flang -help 2>&1 | FileCheck %s --check-prefix=HELP
|
|
|
|
! RUN: not %flang -helps 2>&1 | FileCheck %s --check-prefix=ERROR
|
2020-09-11 17:17:31 +08:00
|
|
|
|
2020-10-24 19:33:19 +08:00
|
|
|
!----------------------------------------
|
2021-04-09 18:32:31 +08:00
|
|
|
! FLANG FRONTEND DRIVER (flang -fc1)
|
2020-10-24 19:33:19 +08:00
|
|
|
!----------------------------------------
|
2021-04-09 18:32:31 +08:00
|
|
|
! RUN: %flang_fc1 -help 2>&1 | FileCheck %s --check-prefix=HELP-FC1
|
|
|
|
! RUN: not %flang_fc1 -helps 2>&1 | FileCheck %s --check-prefix=ERROR
|
2020-09-11 17:17:31 +08:00
|
|
|
|
2020-10-27 20:26:47 +08:00
|
|
|
!----------------------------------------------------
|
2021-04-09 18:32:31 +08:00
|
|
|
! EXPECTED OUTPUT FOR FLANG DRIVER (flang)
|
2020-10-27 20:26:47 +08:00
|
|
|
!----------------------------------------------------
|
2021-04-09 18:32:31 +08:00
|
|
|
! HELP:USAGE: flang
|
2020-10-06 00:42:00 +08:00
|
|
|
! HELP-EMPTY:
|
|
|
|
! HELP-NEXT:OPTIONS:
|
2020-11-11 16:45:54 +08:00
|
|
|
! HELP-NEXT: -### Print (but do not run) the commands to run for this compilation
|
2021-04-07 19:42:37 +08:00
|
|
|
! HELP-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
|
|
|
! HELP-NEXT: -c Only run preprocess, compile, and assemble steps
|
2021-01-06 23:42:24 +08:00
|
|
|
! HELP-NEXT: -D <macro>=<value> Define <macro> to <value> (or 1 if <value> omitted)
|
2020-10-27 20:26:47 +08:00
|
|
|
! HELP-NEXT: -E Only run the preprocessor
|
2021-02-05 05:11:22 +08:00
|
|
|
! HELP-NEXT: -falternative-parameter-statement
|
|
|
|
! HELP-NEXT: Enable the old style PARAMETER statement
|
|
|
|
! HELP-NEXT: -fbackslash Specify that backslash in string introduces an escape character
|
2020-10-06 00:42:00 +08:00
|
|
|
! HELP-NEXT: -fcolor-diagnostics Enable colors in diagnostics
|
2021-03-04 00:28:11 +08:00
|
|
|
! HELP-NEXT: -fdefault-double-8 Set the default double precision kind to an 8 byte wide type
|
|
|
|
! HELP-NEXT: -fdefault-integer-8 Set the default integer kind to an 8 byte wide type
|
|
|
|
! HELP-NEXT: -fdefault-real-8 Set the default real kind to an 8 byte wide type
|
2021-01-27 00:27:30 +08:00
|
|
|
! HELP-NEXT: -ffixed-form Process source files in fixed form
|
|
|
|
! HELP-NEXT: -ffixed-line-length=<value>
|
|
|
|
! HELP-NEXT: Use <value> as character line width in fixed mode
|
|
|
|
! HELP-NEXT: -ffree-form Process source files in free form
|
2021-02-05 05:11:22 +08:00
|
|
|
! HELP-NEXT: -fimplicit-none No implicit typing allowed unless overridden by IMPLICIT statements
|
|
|
|
! HELP-NEXT: -finput-charset=<value> Specify the default character set for source files
|
2021-03-24 00:24:57 +08:00
|
|
|
! HELP-NEXT: -fintrinsic-modules-path <dir>
|
|
|
|
! HELP-NEXT: Specify where to find the compiled intrinsic modules
|
2021-03-04 00:28:11 +08:00
|
|
|
! HELP-NEXT: -flarge-sizes Use INTEGER(KIND=8) for the result type in size-related intrinsics
|
2021-02-05 05:11:22 +08:00
|
|
|
! HELP-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
|
|
|
! HELP-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
|
|
|
! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
|
2021-02-10 17:24:45 +08:00
|
|
|
! HELP-NEXT: -fopenacc Enable OpenACC
|
|
|
|
! HELP-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code.
|
2021-02-05 05:11:22 +08:00
|
|
|
! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
|
2020-10-24 19:33:19 +08:00
|
|
|
! HELP-NEXT: -help Display available options
|
2021-01-19 18:01:38 +08:00
|
|
|
! HELP-NEXT: -I <dir> Add directory to the end of the list of include search paths
|
2021-02-05 00:13:04 +08:00
|
|
|
! HELP-NEXT: -module-dir <dir> Put MODULE files in <dir>
|
2021-04-07 19:42:37 +08:00
|
|
|
! HELP-NEXT: -nocpp Disable predefined and command line preprocessor macros
|
2020-10-24 19:33:19 +08:00
|
|
|
! HELP-NEXT: -o <file> Write output to <file>
|
2021-03-26 01:02:05 +08:00
|
|
|
! HELP-NEXT: -pedantic Warn on language extensions
|
2021-07-24 07:41:04 +08:00
|
|
|
! HELP-NEXT: -P Disable linemarker output in -E mode
|
2021-03-26 01:02:05 +08:00
|
|
|
! HELP-NEXT: -std=<value> Language standard to compile for
|
2021-01-06 23:42:24 +08:00
|
|
|
! HELP-NEXT: -U <macro> Undefine macro <macro>
|
2020-10-24 19:33:19 +08:00
|
|
|
! HELP-NEXT: --version Print version information
|
2021-04-06 00:41:46 +08:00
|
|
|
! HELP-NEXT: -W<warning> Enable the specified warning
|
2021-02-17 22:13:29 +08:00
|
|
|
! HELP-NEXT: -Xflang <arg> Pass <arg> to the flang compiler
|
2020-09-11 17:17:31 +08:00
|
|
|
|
2020-10-27 20:26:47 +08:00
|
|
|
!-------------------------------------------------------------
|
2021-04-09 18:32:31 +08:00
|
|
|
! EXPECTED OUTPUT FOR FLANG FRONTEND DRIVER (flang -fc1)
|
2020-10-27 20:26:47 +08:00
|
|
|
!-------------------------------------------------------------
|
2021-04-09 18:32:31 +08:00
|
|
|
! HELP-FC1:USAGE: flang
|
2020-10-06 00:42:00 +08:00
|
|
|
! HELP-FC1-EMPTY:
|
|
|
|
! HELP-FC1-NEXT:OPTIONS:
|
2021-04-07 19:42:37 +08:00
|
|
|
! HELP-FC1-NEXT: -cpp Enable predefined and command line preprocessor macros
|
2021-01-06 23:42:24 +08:00
|
|
|
! HELP-FC1-NEXT: -D <macro>=<value> Define <macro> to <value> (or 1 if <value> omitted)
|
2022-02-05 01:15:12 +08:00
|
|
|
! HELP-FC1-NEXT: -emit-llvm Use the LLVM representation for assembler and object files
|
2022-02-04 01:00:27 +08:00
|
|
|
! HELP-FC1-NEXT: -emit-mlir Build the parse tree, then lower it to MLIR
|
[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
|
|
|
! HELP-FC1-NEXT: -emit-obj Emit native object files
|
2021-01-06 23:42:24 +08:00
|
|
|
! HELP-FC1-NEXT: -E Only run the preprocessor
|
2021-02-05 05:11:22 +08:00
|
|
|
! HELP-FC1-NEXT: -falternative-parameter-statement
|
|
|
|
! HELP-FC1-NEXT: Enable the old style PARAMETER statement
|
|
|
|
! HELP-FC1-NEXT: -fbackslash Specify that backslash in string introduces an escape character
|
2021-06-15 23:30:23 +08:00
|
|
|
! HELP-FC1-NEXT: -fdebug-dump-all Dump symbols and the parse tree after the semantic checks
|
2021-03-30 18:35:42 +08:00
|
|
|
! HELP-FC1-NEXT: -fdebug-dump-parse-tree-no-sema
|
|
|
|
! HELP-FC1-NEXT: Dump the parse tree (skips the semantic checks)
|
2021-02-17 23:55:56 +08:00
|
|
|
! HELP-FC1-NEXT: -fdebug-dump-parse-tree Dump the parse tree
|
2021-02-24 01:59:17 +08:00
|
|
|
! HELP-FC1-NEXT: -fdebug-dump-parsing-log
|
|
|
|
! HELP-FC1-NEXT: Run instrumented parse and dump the parsing log
|
2021-02-17 23:55:56 +08:00
|
|
|
! HELP-FC1-NEXT: -fdebug-dump-provenance Dump provenance
|
|
|
|
! HELP-FC1-NEXT: -fdebug-dump-symbols Dump symbols after the semantic analysis
|
2021-02-18 02:53:05 +08:00
|
|
|
! HELP-FC1-NEXT: -fdebug-measure-parse-tree
|
|
|
|
! HELP-FC1-NEXT: Measure the parse tree
|
2021-03-11 20:35:45 +08:00
|
|
|
! HELP-FC1-NEXT: -fdebug-module-writer Enable debug messages while writing module files
|
2021-02-18 02:53:05 +08:00
|
|
|
! HELP-FC1-NEXT: -fdebug-pre-fir-tree Dump the pre-FIR tree
|
2021-03-30 18:35:42 +08:00
|
|
|
! HELP-FC1-NEXT: -fdebug-unparse-no-sema Unparse and stop (skips the semantic checks)
|
2021-02-04 19:14:57 +08:00
|
|
|
! HELP-FC1-NEXT: -fdebug-unparse-with-symbols
|
|
|
|
! HELP-FC1-NEXT: Unparse and stop.
|
|
|
|
! HELP-FC1-NEXT: -fdebug-unparse Unparse and stop.
|
2021-03-04 00:28:11 +08:00
|
|
|
! HELP-FC1-NEXT: -fdefault-double-8 Set the default double precision kind to an 8 byte wide type
|
|
|
|
! HELP-FC1-NEXT: -fdefault-integer-8 Set the default integer kind to an 8 byte wide type
|
|
|
|
! HELP-FC1-NEXT: -fdefault-real-8 Set the default real kind to an 8 byte wide type
|
2021-01-27 00:27:30 +08:00
|
|
|
! HELP-FC1-NEXT: -ffixed-form Process source files in fixed form
|
|
|
|
! HELP-FC1-NEXT: -ffixed-line-length=<value>
|
|
|
|
! HELP-FC1-NEXT: Use <value> as character line width in fixed mode
|
|
|
|
! HELP-FC1-NEXT: -ffree-form Process source files in free form
|
2021-04-14 18:43:14 +08:00
|
|
|
! HELP-FC1-NEXT: -fget-definition <value> <value> <value>
|
|
|
|
! HELP-FC1-NEXT: Get the symbol definition from <line> <start-column> <end-column>
|
2021-03-09 00:54:11 +08:00
|
|
|
! HELP-FC1-NEXT: -fget-symbols-sources Dump symbols and their source code locations
|
2021-02-05 05:11:22 +08:00
|
|
|
! HELP-FC1-NEXT: -fimplicit-none No implicit typing allowed unless overridden by IMPLICIT statements
|
|
|
|
! HELP-FC1-NEXT: -finput-charset=<value> Specify the default character set for source files
|
2021-03-24 00:24:57 +08:00
|
|
|
! HELP-FC1-NEXT: -fintrinsic-modules-path <dir>
|
|
|
|
! HELP-FC1-NEXT: Specify where to find the compiled intrinsic modules
|
2021-03-04 00:28:11 +08:00
|
|
|
! HELP-FC1-NEXT: -flarge-sizes Use INTEGER(KIND=8) for the result type in size-related intrinsics
|
2021-02-05 05:11:22 +08:00
|
|
|
! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
|
2021-06-04 22:25:58 +08:00
|
|
|
! HELP-FC1-NEXT: -fno-analyzed-objects-for-unparse
|
|
|
|
! HELP-FC1-NEXT: Do not use the analyzed objects when unparsing
|
[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
|
|
|
! HELP-FC1-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
|
2021-07-24 07:41:04 +08:00
|
|
|
! HELP-FC1-NEXT: -fno-reformat Dump the cooked character stream in -E mode
|
2021-02-10 17:24:45 +08:00
|
|
|
! HELP-FC1-NEXT: -fopenacc Enable OpenACC
|
|
|
|
! HELP-FC1-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code.
|
2021-02-05 05:11:22 +08:00
|
|
|
! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
|
2021-01-06 23:42:24 +08:00
|
|
|
! HELP-FC1-NEXT: -help Display available options
|
2021-06-07 22:40:26 +08:00
|
|
|
! HELP-FC1-NEXT: -init-only Only execute frontend initialization
|
2021-01-19 18:01:38 +08:00
|
|
|
! HELP-FC1-NEXT: -I <dir> Add directory to the end of the list of include search paths
|
2021-08-12 18:42:08 +08:00
|
|
|
! HELP-FC1-NEXT: -load <dsopath> Load the named plugin (dynamic shared object)
|
2021-02-05 00:13:04 +08:00
|
|
|
! HELP-FC1-NEXT: -module-dir <dir> Put MODULE files in <dir>
|
2021-06-04 20:58:03 +08:00
|
|
|
! HELP-FC1-NEXT: -module-suffix <suffix> Use <suffix> as the suffix for module files (the default value is `.mod`)
|
2021-04-07 19:42:37 +08:00
|
|
|
! HELP-FC1-NEXT: -nocpp Disable predefined and command line preprocessor macros
|
2021-01-06 23:42:24 +08:00
|
|
|
! HELP-FC1-NEXT: -o <file> Write output to <file>
|
2021-03-26 01:02:05 +08:00
|
|
|
! HELP-FC1-NEXT: -pedantic Warn on language extensions
|
2021-08-12 18:42:08 +08:00
|
|
|
! HELP-FC1-NEXT: -plugin <name> Use the named plugin action instead of the default action (use "help" to list available options)
|
2021-07-24 07:41:04 +08:00
|
|
|
! HELP-FC1-NEXT: -P Disable linemarker output in -E mode
|
2021-03-26 01:02:05 +08:00
|
|
|
! HELP-FC1-NEXT: -std=<value> Language standard to compile for
|
2021-02-17 22:13:29 +08:00
|
|
|
! HELP-FC1-NEXT: -test-io Run the InputOuputTest action. Use for development and testing only.
|
2021-01-06 23:42:24 +08:00
|
|
|
! HELP-FC1-NEXT: -U <macro> Undefine macro <macro>
|
|
|
|
! HELP-FC1-NEXT: --version Print version information
|
2021-04-06 00:41:46 +08:00
|
|
|
! HELP-FC1-NEXT: -W<warning> Enable the specified warning
|
2020-10-06 00:42:00 +08:00
|
|
|
|
2020-10-24 19:33:19 +08:00
|
|
|
!---------------
|
|
|
|
! EXPECTED ERROR
|
|
|
|
!---------------
|
|
|
|
! ERROR: error: unknown argument '-helps'; did you mean '-help'
|