[clang] 3a1513c - [flang][driver] Add forced form flags and -ffixed-line-length
Author: Faris Rehman Date: 2021-02-04T12:24:15Z New Revision: 3a1513c142f4a1ddb97d882a12c89f90cb2529ac URL: https://github.com/llvm/llvm-project/commit/3a1513c142f4a1ddb97d882a12c89f90cb2529ac DIFF: https://github.com/llvm/llvm-project/commit/3a1513c142f4a1ddb97d882a12c89f90cb2529ac.diff LOG: [flang][driver] Add forced form flags and -ffixed-line-length Add support for the following layout options: * -ffree-form * -ffixed-form - -ffixed-line-length=n (alias -ffixed-line-length-n) Additionally remove options `-fno-free-form` and `-fno-fixed-form` as they were initially added to forward to gfortran but gfortran does not support these flags. This patch adds the flag FlangOnlyOption to the existing options `-ffixed-form`, `-ffree-form` and `-ffree-line-length-` in Options.td. As of commit 6a75496836ea14bcfd2f4b59d35a1cad4ac58cee, these flags are not currently forwarded to gfortran anyway. The default fixed line length in FrontendOptions is 72, based off the current default in Fortran::parser::Options. The line length cannot be set to a negative integer, or a positive integer less than 7 excluding 0, consistent with the behaviour of gfortran. This patch does not add `-ffree-line-length-n` as Fortran::parser::Options does not have a variable for free form columns. Whilst the `fixedFormColumns` variable is used in f18 for `-ffree-line-length-n`, f18 only allows `-ffree-line-length-none`/`-ffree-line-length-0` and not a user-specified value. `fixedFormcolumns` cannot be used in the new driver as it is ignored in the frontend when dealing with free form files. Summary of changes: - Remove -fno-fixed-form and -fno-free-form from Options.td - Make -ffixed-form, -ffree-form and -ffree-line-length-n FlangOnlyOption in Options.td - Create AddFortranDialectOptions method in Flang.cpp - Create FortranForm enum in FrontendOptions.h - Add fortranForm_ and fixedFormColumns_ to Fortran::frontend::FrontendOptions - Update fixed-form-test.f so that it guarantees that it fails when forced as a free form file to better facilitate testing. Differential Revision: https://reviews.llvm.org/D95460 Added: flang/test/Flang-Driver/Inputs/fixed-line-length-test.f flang/test/Flang-Driver/fixed-free-flag.f90 flang/test/Flang-Driver/fixed-line-length.f90 Modified: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Flang.cpp clang/lib/Driver/ToolChains/Flang.h flang/include/flang/Frontend/FrontendOptions.h flang/lib/Frontend/CompilerInstance.cpp flang/lib/Frontend/CompilerInvocation.cpp flang/test/Flang-Driver/Inputs/fixed-form-test.f flang/test/Flang-Driver/driver-help-hidden.f90 flang/test/Flang-Driver/driver-help.f90 Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index b7eac8e67573..920b6c0adf89 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4129,7 +4129,6 @@ def fblas_matmul_limit_EQ : Joined<["-"], "fblas-matmul-limit=">, Group, Group; def ffpe_trap_EQ : Joined<["-"], "ffpe-trap=">, Group; def ffree_line_length_VALUE : Joined<["-"], "ffree-line-length-">, Group; def finit_character_EQ : Joined<["-"], "finit-character=">, Group; @@ -4163,8 +4162,6 @@ defm dump_fortran_original : BooleanFFlag<"dump-fortran-original">, Group, Group; defm external_blas : BooleanFFlag<"external-blas">, Group; defm f2c : BooleanFFlag<"f2c">, Group; -defm fixed_form : BooleanFFlag<"fixed-form">, Group; -defm free_form : BooleanFFlag<"free-form">, Group; defm frontend_optimize : BooleanFFlag<"frontend-optimize">, Group; defm implicit_none : BooleanFFlag<"implicit-none">, Group; defm init_local_zero : BooleanFFlag<"init-local-zero">, Group; @@ -4207,6 +4204,20 @@ def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, Flags<[CC1Optio def test_io : Flag<["-"], "test-io">, Flags<[HelpHidden, FlangOption, FC1Option, FlangOnlyOption]>, Group, HelpText<"Run the InputOuputTest action. Use for development and testing only.">; +let Flags = [FC1Option, FlangOption, FlangOnlyOption] in { + +def ffixed_form : Flag<["-"], "ffixed-form">, Group, + HelpText<"Process source files in fixed form">; +def ffree_form : Flag<["-"], "ffree-form">, Group, + HelpText<"Process source files in free form">; +def ffixed_line_length_EQ : Joined<["-"], "ffixed-line-length=">, Group, + HelpText<"Use as character line width in fixed mode">, + DocBrief<[{Set column after which characters are ignored in typical fixed-form lines in the source +file}]>; +def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, Group, Alias; + +} + //===--===// // CC1 Options //===--===// diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/
[clang] 6d48a1a - [flang][driver] Add support for -fopenmp and -fopenacc
Author: Faris Rehman Date: 2021-02-10T09:59:35Z New Revision: 6d48a1a53fabae8715091a9aca128cc4a5d9b0a6 URL: https://github.com/llvm/llvm-project/commit/6d48a1a53fabae8715091a9aca128cc4a5d9b0a6 DIFF: https://github.com/llvm/llvm-project/commit/6d48a1a53fabae8715091a9aca128cc4a5d9b0a6.diff LOG: [flang][driver] Add support for -fopenmp and -fopenacc Add support for the following options: * -fopenmp * -fopenacc Update OpenMP and OpenACC semantics tests to use the new driver if it is built, otherwise use f18. OpenMP tests that include `use omp_lib` or run `test_symbols.sh` have not been updated as they require options `-intrinsic-module-directory` and `-funparse-with-symbols` which are currently not implemented in the new driver. Similarly OpenACC tests that run `test_symbols.sh` have not been updated. This patch also moves semanticsContext to CompilerInvocation and creates it in CompilerInvocation#setSemanticsOpts so that the semantics context can use Fortran::parser::Options#features. Summary of changes: - Move semanticsContext to CompilerInvocation.h - Update OpenMP and OpenACC semantics tests that do not rely on `-intrinsic-module-directory` and `-funparse-with-symbols` to use %flang Differential Revision: https://reviews.llvm.org/D96032 Added: Modified: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Flang.cpp flang/include/flang/Frontend/CompilerInstance.h flang/include/flang/Frontend/CompilerInvocation.h flang/include/flang/Frontend/FrontendOptions.h flang/lib/Frontend/CompilerInstance.cpp flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp flang/test/Flang-Driver/driver-help-hidden.f90 flang/test/Flang-Driver/driver-help.f90 flang/test/Semantics/OpenACC/acc-atomic-validity.f90 flang/test/Semantics/OpenACC/acc-branch.f90 flang/test/Semantics/OpenACC/acc-cache-validity.f90 flang/test/Semantics/OpenACC/acc-canonicalization-validity.f90 flang/test/Semantics/OpenACC/acc-data.f90 flang/test/Semantics/OpenACC/acc-declare-validity.f90 flang/test/Semantics/OpenACC/acc-host-data.f90 flang/test/Semantics/OpenACC/acc-init-validity.f90 flang/test/Semantics/OpenACC/acc-kernels-loop.f90 flang/test/Semantics/OpenACC/acc-kernels.f90 flang/test/Semantics/OpenACC/acc-loop.f90 flang/test/Semantics/OpenACC/acc-parallel-loop-validity.f90 flang/test/Semantics/OpenACC/acc-parallel.f90 flang/test/Semantics/OpenACC/acc-resolve01.f90 flang/test/Semantics/OpenACC/acc-resolve02.f90 flang/test/Semantics/OpenACC/acc-routine-validity.f90 flang/test/Semantics/OpenACC/acc-serial-loop.f90 flang/test/Semantics/OpenACC/acc-serial.f90 flang/test/Semantics/OpenACC/acc-set-validity.f90 flang/test/Semantics/OpenACC/acc-shutdown-validity.f90 flang/test/Semantics/OpenACC/acc-update-validity.f90 flang/test/Semantics/OpenACC/acc-wait-validity.f90 flang/test/Semantics/omp-atomic.f90 flang/test/Semantics/omp-combined-constructs.f90 flang/test/Semantics/omp-copyin01.f90 flang/test/Semantics/omp-copyin02.f90 flang/test/Semantics/omp-copyin03.f90 flang/test/Semantics/omp-copyin04.f90 flang/test/Semantics/omp-copyin05.f90 flang/test/Semantics/omp-declarative-directive.f90 flang/test/Semantics/omp-default.f90 flang/test/Semantics/omp-default02.f90 flang/test/Semantics/omp-depend01.f90 flang/test/Semantics/omp-depend02.f90 flang/test/Semantics/omp-depend03.f90 flang/test/Semantics/omp-device-constructs.f90 flang/test/Semantics/omp-do-collapse-positivecases.f90 flang/test/Semantics/omp-do-collapse.f90 flang/test/Semantics/omp-do-cycle.f90 flang/test/Semantics/omp-do-ordered-positivecases.f90 flang/test/Semantics/omp-do-ordered.f90 flang/test/Semantics/omp-do-schedule01.f90 flang/test/Semantics/omp-do-schedule02.f90 flang/test/Semantics/omp-do01.f90 flang/test/Semantics/omp-do02.f90 flang/test/Semantics/omp-do03.f90 flang/test/Semantics/omp-do04.f90 flang/test/Semantics/omp-do05.f90 flang/test/Semantics/omp-do06.f90 flang/test/Semantics/omp-do07.f90 flang/test/Semantics/omp-do08.f90 flang/test/Semantics/omp-do09.f90 flang/test/Semantics/omp-do10.f90 flang/test/Semantics/omp-flush01.f90 flang/test/Semantics/omp-invalid-branch.f90 flang/test/Semantics/omp-loop-association.f90 flang/test/Semantics/omp-loop-simd01.f90 flang/test/Semantics/omp-nested01.f90 flang/test/Semantics/omp-no-dowhile-in-parallel.f90 flang/test/Semantics/omp-parallel-private01.f90 flang/test/Semantics/omp-parallel-private02.f90 flang/test/Semantics/omp-parallel-private03.f90 flang/test/Semantics/omp-parallel-private04.f90 flang/test/Semantics/omp-parallel-shared01.f90 flang/test/Semantics/omp-parallel-shared02.f90 flang/test/Semantics/omp-parallel-shared03.f90 flang/test/Semantics/omp-parallel-shared04.f90 flang
[clang] 10826ea - [flang][driver] Add extension options and -finput-charset
Author: Faris Rehman Date: 2021-02-16T11:27:06Z New Revision: 10826ea7b1c12c2afe421448996f98ed66869020 URL: https://github.com/llvm/llvm-project/commit/10826ea7b1c12c2afe421448996f98ed66869020 DIFF: https://github.com/llvm/llvm-project/commit/10826ea7b1c12c2afe421448996f98ed66869020.diff LOG: [flang][driver] Add extension options and -finput-charset Add the following options: * -fimplicit-none and -fno-implicit-none * -fbackslash and -fno-backslash * -flogical-abbreviations and -fno-logical-abbreviations * -fxor-operator and -fno-xor-operator * -falternative-parameter-statement * -finput-charset= Summary of changes: - Enable extensions in CompilerInvocation#ParseFrontendArgs - Add encoding_ to Fortran::frontend::FrontendOptions - Add encoding to Fortran::parser::Options Differential Revision: https://reviews.llvm.org/D96407 Added: flang/test/Flang-Driver/escaped-backslash.f90 flang/test/Flang-Driver/frontend-forwarding.f90 flang/test/Flang-Driver/implicit-none.f90 Modified: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Flang.cpp flang/include/flang/Frontend/FrontendOptions.h flang/include/flang/Parser/parsing.h flang/lib/Frontend/CompilerInstance.cpp flang/lib/Frontend/CompilerInvocation.cpp flang/test/Flang-Driver/driver-help-hidden.f90 flang/test/Flang-Driver/driver-help.f90 flang/test/Semantics/oldparam02.f90 flang/test/Semantics/resolve64.f90 Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 04a23c59e264..b3e17e1bfe27 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1714,7 +1714,8 @@ def fexperimental_strict_floating_point : Flag<["-"], "fexperimental-strict-floa Group, Flags<[CC1Option]>, HelpText<"Enables experimental strict floating point in LLVM.">, MarshallingInfoFlag>; -def finput_charset_EQ : Joined<["-"], "finput-charset=">, Group; +def finput_charset_EQ : Joined<["-"], "finput-charset=">, Flags<[FlangOption, FC1Option]>, Group, + HelpText<"Specify the default character set for source files">; def fexec_charset_EQ : Joined<["-"], "fexec-charset=">, Group; def finstrument_functions : Flag<["-"], "finstrument-functions">, Group, Flags<[CC1Option]>, HelpText<"Generate calls to instrument function entry and exit">, @@ -4170,7 +4171,6 @@ defm aggressive_function_elimination : BooleanFFlag<"aggressive-function-elimina defm align_commons : BooleanFFlag<"align-commons">, Group; defm all_intrinsics : BooleanFFlag<"all-intrinsics">, Group; defm automatic : BooleanFFlag<"automatic">, Group; -defm backslash : BooleanFFlag<"backslash">, Group; defm backtrace : BooleanFFlag<"backtrace">, Group; defm bounds_check : BooleanFFlag<"bounds-check">, Group; defm check_array_temporaries : BooleanFFlag<"check-array-temporaries">, Group; @@ -4187,7 +4187,6 @@ defm dump_parse_tree : BooleanFFlag<"dump-parse-tree">, Group; defm external_blas : BooleanFFlag<"external-blas">, Group; defm f2c : BooleanFFlag<"f2c">, Group; defm frontend_optimize : BooleanFFlag<"frontend-optimize">, Group; -defm implicit_none : BooleanFFlag<"implicit-none">, Group; defm init_local_zero : BooleanFFlag<"init-local-zero">, Group; defm integer_4_integer_8 : BooleanFFlag<"integer-4-integer-8">, Group; defm intrinsic_modules_path : BooleanFFlag<"intrinsic-modules-path">, Group; @@ -4241,6 +4240,22 @@ file}]>; def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, Group, Alias; def fopenacc : Flag<["-"], "fopenacc">, Group, HelpText<"Enable OpenACC">; +def fbackslash : Flag<["-"], "fbackslash">, Group, + HelpText<"Specify that backslash in string introduces an escape character">, + DocBrief<[{Change the interpretation of backslashes in string literals from +a single backslash character to "C-style" escape characters.}]>; +def fno_backslash : Flag<["-"], "fno-backslash">, Group; +def fxor_operator : Flag<["-"], "fxor-operator">, Group, + HelpText<"Enable .XOR. as a synonym of .NEQV.">; +def fno_xor_operator : Flag<["-"], "fno-xor-operator">, Group; +def flogical_abbreviations : Flag<["-"], "flogical-abbreviations">, Group, + HelpText<"Enable logical abbreviations">; +def fno_logical_abbreviations : Flag<["-"], "fno-logical-abbreviations">, Group; +def fimplicit_none : Flag<["-"], "fimplicit-none">, Group, + HelpText<"No implicit typing allowed unless overridden by IMPLICIT statements">; +def fno_implicit_none : Flag<["-"], "fno-implicit-none">, Group; +def falternative_parameter_statement : Flag<["-"], "falternative-parameter-statement">, Group, + HelpText<"Enable the old style PARAMETER statement">; } diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index c96b33ba1696..98d37eb7e692 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/Too
[clang] 4bd08da - [flang][driver] Add debug dump options
Author: Faris Rehman Date: 2021-02-18T11:33:24Z New Revision: 4bd08dab5ff99d094513f4adf4bf16bbce8f5a1f URL: https://github.com/llvm/llvm-project/commit/4bd08dab5ff99d094513f4adf4bf16bbce8f5a1f DIFF: https://github.com/llvm/llvm-project/commit/4bd08dab5ff99d094513f4adf4bf16bbce8f5a1f.diff LOG: [flang][driver] Add debug dump options Add the following options: * -fdebug-dump-symbols * -fdebug-dump-parse-tree * -fdebug-dump-provenance Summary of changes: - Add 3 new frontend actions: DebugDumpSymbolsAction, DebugDumpParseTreeAction and DebugDumpProvenanceAction - Add a unique pointer to the Semantics instance created in PrescanAndSemaAction - Move fatal semantic error reporting to its own method, FrontendActions#reportFatalSemanticErrors - Port most tests using `-fdebug-dump-symbols` and `-fdebug-dump-parse-tree` to the new driver if built, otherwise default to f18 Differential Revision: https://reviews.llvm.org/D96716 Added: flang/test/Flang-Driver/debug-provenance.f90 Modified: clang/include/clang/Driver/Options.td flang/include/flang/Frontend/FrontendActions.h flang/include/flang/Frontend/FrontendOptions.h flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp flang/test/Flang-Driver/driver-help.f90 flang/test/Semantics/data05.f90 flang/test/Semantics/data08.f90 flang/test/Semantics/data09.f90 flang/test/Semantics/offsets01.f90 flang/test/Semantics/offsets02.f90 flang/test/Semantics/offsets03.f90 flang/test/Semantics/resolve100.f90 flang/test/Semantics/rewrite01.f90 Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 7312c1988efe..635af48cc051 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4269,6 +4269,12 @@ def fdebug_unparse : Flag<["-"], "fdebug-unparse">, Group, HelpText<"Unparse and stop.">; def fdebug_unparse_with_symbols : Flag<["-"], "fdebug-unparse-with-symbols">, Group, HelpText<"Unparse and stop.">; +def fdebug_dump_symbols : Flag<["-"], "fdebug-dump-symbols">, Group, + HelpText<"Dump symbols after the semantic analysis">; +def fdebug_dump_parse_tree : Flag<["-"], "fdebug-dump-parse-tree">, Group, + HelpText<"Dump the parse tree">; +def fdebug_dump_provenance : Flag<["-"], "fdebug-dump-provenance">, Group, + HelpText<"Dump provenance">; } diff --git a/flang/include/flang/Frontend/FrontendActions.h b/flang/include/flang/Frontend/FrontendActions.h index 4c29d0d5a641..ebcb695cca72 100644 --- a/flang/include/flang/Frontend/FrontendActions.h +++ b/flang/include/flang/Frontend/FrontendActions.h @@ -10,6 +10,8 @@ #define LLVM_FLANG_FRONTEND_FRONTENDACTIONS_H #include "flang/Frontend/FrontendAction.h" +#include "flang/Semantics/semantics.h" +#include namespace Fortran::frontend { @@ -37,12 +39,26 @@ class PrintPreprocessedAction : public PrescanAction { void ExecuteAction() override; }; +class DebugDumpProvenanceAction : public PrescanAction { + void ExecuteAction() override; +}; + //===--===// // PrescanAndSema Actions //===--===// class PrescanAndSemaAction : public FrontendAction { + std::unique_ptr semantics_; + void ExecuteAction() override = 0; bool BeginSourceFileAction(CompilerInstance &ci) override; + +public: + Fortran::semantics::Semantics &semantics() { return *semantics_; } + const Fortran::semantics::Semantics &semantics() const { return *semantics_; } + + void setSemantics(std::unique_ptr semantics) { +semantics_ = std::move(semantics); + } }; class DebugUnparseWithSymbolsAction : public PrescanAndSemaAction { @@ -53,6 +69,14 @@ class DebugUnparseAction : public PrescanAndSemaAction { void ExecuteAction() override; }; +class DebugDumpSymbolsAction : public PrescanAndSemaAction { + void ExecuteAction() override; +}; + +class DebugDumpParseTreeAction : public PrescanAndSemaAction { + void ExecuteAction() override; +}; + class ParseSyntaxOnlyAction : public PrescanAndSemaAction { void ExecuteAction() override; }; diff --git a/flang/include/flang/Frontend/FrontendOptions.h b/flang/include/flang/Frontend/FrontendOptions.h index bcf59289d01d..a26e1e3d84c7 100644 --- a/flang/include/flang/Frontend/FrontendOptions.h +++ b/flang/include/flang/Frontend/FrontendOptions.h @@ -41,6 +41,15 @@ enum ActionKind { /// Fortran source file DebugUnparseWithSymbols, + /// Parse, run semantics and then output symbols from semantics + DebugDumpSymbols, + + /// Parse, run semantics and then output the parse tree + DebugDumpParseTree, + + /// Dump provenance + DebugDumpProvenance + /// TODO: RunPreprocessor, EmitLLVM, EmitLLVMOnly,
[clang] 529f718 - [flang][driver] Add debug measure-parse-tree and pre-fir-tree options
Author: Faris Rehman Date: 2021-02-19T11:27:54Z New Revision: 529f71811b0475995f2d9cf766f18d897eec574c URL: https://github.com/llvm/llvm-project/commit/529f71811b0475995f2d9cf766f18d897eec574c DIFF: https://github.com/llvm/llvm-project/commit/529f71811b0475995f2d9cf766f18d897eec574c.diff LOG: [flang][driver] Add debug measure-parse-tree and pre-fir-tree options Add the following options: * -fdebug-measure-parse-tree * -fdebug-pre-fir-tree Summary of changes: - Add 2 new frontend actions: DebugMeasureParseTreeAction and DebugPreFIRTreeAction - Add MeasurementVisitor to FrontendActions.h - Make reportFatalSemanticErrors return true if there are any fatal errors - Port most of the `-fdebug-pre-fir-tree` tests to use the new driver if built, otherwise use f18. Differential Revision: https://reviews.llvm.org/D96884 Added: flang/test/Flang-Driver/debug-measure-parse-tree.f90 Modified: clang/include/clang/Driver/Options.td flang/include/flang/Frontend/FrontendActions.h flang/include/flang/Frontend/FrontendOptions.h flang/lib/Frontend/CMakeLists.txt flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp flang/test/Flang-Driver/driver-help.f90 flang/test/Lower/pre-fir-tree01.f90 flang/test/Lower/pre-fir-tree02.f90 flang/test/Lower/pre-fir-tree03.f90 flang/test/Lower/pre-fir-tree05.f90 Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 17eb0ade2493..ade330bd7ba4 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4288,6 +4288,10 @@ def fdebug_dump_parse_tree : Flag<["-"], "fdebug-dump-parse-tree">, Group; def fdebug_dump_provenance : Flag<["-"], "fdebug-dump-provenance">, Group, HelpText<"Dump provenance">; +def fdebug_measure_parse_tree : Flag<["-"], "fdebug-measure-parse-tree">, Group, + HelpText<"Measure the parse tree">; +def fdebug_pre_fir_tree : Flag<["-"], "fdebug-pre-fir-tree">, Group, + HelpText<"Dump the pre-FIR tree">; } diff --git a/flang/include/flang/Frontend/FrontendActions.h b/flang/include/flang/Frontend/FrontendActions.h index ebcb695cca72..f6dfdd2dc09b 100644 --- a/flang/include/flang/Frontend/FrontendActions.h +++ b/flang/include/flang/Frontend/FrontendActions.h @@ -15,6 +15,17 @@ namespace Fortran::frontend { +// TODO: This is a copy from f18.cpp. It doesn't really belong here and should +// be moved to a more suitable place in future. +struct MeasurementVisitor { + template bool Pre(const A &) { return true; } + template void Post(const A &) { +++objects; +bytes += sizeof(A); + } + size_t objects{0}, bytes{0}; +}; + //===--===// // Custom Consumer Actions //===--===// @@ -43,6 +54,10 @@ class DebugDumpProvenanceAction : public PrescanAction { void ExecuteAction() override; }; +class DebugMeasureParseTreeAction : public PrescanAction { + void ExecuteAction() override; +}; + //===--===// // PrescanAndSema Actions //===--===// @@ -77,6 +92,10 @@ class DebugDumpParseTreeAction : public PrescanAndSemaAction { void ExecuteAction() override; }; +class DebugPreFIRTreeAction : public PrescanAndSemaAction { + void ExecuteAction() override; +}; + class ParseSyntaxOnlyAction : public PrescanAndSemaAction { void ExecuteAction() override; }; diff --git a/flang/include/flang/Frontend/FrontendOptions.h b/flang/include/flang/Frontend/FrontendOptions.h index a26e1e3d84c7..98a717dfa6ec 100644 --- a/flang/include/flang/Frontend/FrontendOptions.h +++ b/flang/include/flang/Frontend/FrontendOptions.h @@ -48,7 +48,14 @@ enum ActionKind { DebugDumpParseTree, /// Dump provenance - DebugDumpProvenance + DebugDumpProvenance, + + /// Parse then output the number of objects in the parse tree and the overall + /// size + DebugMeasureParseTree, + + /// Parse, run semantics and then output the pre-FIR tree + DebugPreFIRTree /// TODO: RunPreprocessor, EmitLLVM, EmitLLVMOnly, /// EmitCodeGenOnly, EmitAssembly, (...) diff --git a/flang/lib/Frontend/CMakeLists.txt b/flang/lib/Frontend/CMakeLists.txt index 53c2518d2912..abaa77f6af54 100644 --- a/flang/lib/Frontend/CMakeLists.txt +++ b/flang/lib/Frontend/CMakeLists.txt @@ -16,6 +16,7 @@ add_flang_library(flangFrontend FortranSemantics FortranEvaluate FortranCommon + FortranLower clangBasic clangDriver diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index ecc0fda4546b..822bf26f3577 100644 --- a/flang/lib/Frontend/Compil