@@ -15,17 +15,13 @@ local:
1515```
1616
1717There are two main drivers in Flang:
18- * the compiler driver, ` flang-new `
19- * the frontend driver, ` flang-new -fc1 `
20-
21- > ** _ NOTE:_ ** The diagrams in this document refer to ` flang ` as opposed to
22- > ` flang-new ` . Eventually, ` flang-new ` will be renamed as ` flang ` and the
23- > diagrams reflect the final design that we are still working towards.
18+ * the compiler driver, ` flang `
19+ * the frontend driver, ` flang -fc1 `
2420
2521The ** compiler driver** will allow you to control all compilation phases (e.g.
2622preprocessing, semantic checks, code-generation, code-optimisation, lowering
2723and linking). For frontend specific tasks, the compiler driver creates a
28- Fortran compilation job and delegates it to ` flang-new -fc1 ` , the frontend
24+ Fortran compilation job and delegates it to ` flang -fc1 ` , the frontend
2925driver. For linking, it creates a linker job and calls an external linker (e.g.
3026LLVM's [ ` lld ` ] ( https://lld.llvm.org/ ) ). It can also call other tools such as
3127external assemblers (e.g. [ ` as ` ] ( https://www.gnu.org/software/binutils/ ) ). In
@@ -47,7 +43,7 @@ frontend. It uses MLIR and LLVM for code-generation and can be viewed as a
4743driver for Flang, LLVM and MLIR libraries. Contrary to the compiler driver, it
4844is not capable of calling any external tools (including linkers). It is aware
4945of all the frontend internals that are "hidden" from the compiler driver. It
50- accepts many frontend-specific options not available in ` flang-new ` and as such
46+ accepts many frontend-specific options not available in ` flang ` and as such
5147it provides a finer control over the frontend. Note that this tool is mostly
5248intended for Flang developers. In particular, there are no guarantees about the
5349stability of its interface and compiler developers can use it to experiment
@@ -62,30 +58,30 @@ frontend specific flag from the _compiler_ directly to the _frontend_ driver,
6258e.g.:
6359
6460``` bash
65- flang-new -Xflang -fdebug-dump-parse-tree input.f95
61+ flang -Xflang -fdebug-dump-parse-tree input.f95
6662```
6763
68- In the invocation above, ` -fdebug-dump-parse-tree ` is forwarded to `flang-new
64+ In the invocation above, ` -fdebug-dump-parse-tree ` is forwarded to `flang
6965-fc1` . Without the forwarding flag, ` -Xflang`, you would see the following
7066warning:
7167
7268``` bash
73- flang-new : warning: argument unused during compilation:
69+ flang: warning: argument unused during compilation:
7470```
7571
76- As ` -fdebug-dump-parse-tree ` is only supported by ` flang-new -fc1 ` , ` flang-new `
72+ As ` -fdebug-dump-parse-tree ` is only supported by ` flang -fc1 ` , ` flang `
7773will ignore it when used without ` Xflang ` .
7874
7975## Why Do We Need Two Drivers?
80- As hinted above, ` flang-new ` and ` flang-new -fc1 ` are two separate tools. The
81- fact that these tools are accessed through one binary, ` flang-new ` , is just an
76+ As hinted above, ` flang ` and ` flang -fc1 ` are two separate tools. The
77+ fact that these tools are accessed through one binary, ` flang ` , is just an
8278implementation detail. Each tool has a separate list of options, albeit defined
8379in the same file: ` clang/include/clang/Driver/Options.td ` .
8480
8581The separation helps us split various tasks and allows us to implement more
86- specialised tools. In particular, ` flang-new ` is not aware of various
82+ specialised tools. In particular, ` flang ` is not aware of various
8783compilation phases within the frontend (e.g. scanning, parsing or semantic
88- checks). It does not have to be. Conversely, the frontend driver, `flang-new
84+ checks). It does not have to be. Conversely, the frontend driver, `flang
8985-fc1`, needs not to be concerned with linkers or other external tools like
9086assemblers. Nor does it need to know where to look for various systems
9187libraries, which is usually OS and platform specific.
@@ -104,7 +100,7 @@ GCC](https://en.wikibooks.org/wiki/GNU_C_Compiler_Internals/GNU_C_Compiler_Archi
104100In fact, Flang needs to adhere to this model in order to be able to re-use
105101Clang's driver library. If you are more familiar with the [ architecture of
106102GFortran] ( https://gcc.gnu.org/onlinedocs/gcc-4.7.4/gfortran/About-GNU-Fortran.html )
107- than Clang, then ` flang-new ` corresponds to ` gfortran ` and ` flang-new -fc1 ` to
103+ than Clang, then ` flang ` corresponds to ` gfortran ` and ` flang -fc1 ` to
108104` f951 ` .
109105
110106## Compiler Driver
@@ -135,15 +131,15 @@ output from one action is the input for the subsequent one. You can use the
135131` -ccc-print-phases ` flag to see the sequence of actions that the driver will
136132create for your compiler invocation:
137133``` bash
138- flang-new -ccc-print-phases -E file.f
134+ flang -ccc-print-phases -E file.f
139135+- 0: input, " file.f" , f95-cpp-input
1401361: preprocessor, {0}, f95
141137```
142138As you can see, for ` -E ` the driver creates only two jobs and stops immediately
143139after preprocessing. The first job simply prepares the input. For ` -c ` , the
144140pipeline of the created jobs is more complex:
145141``` bash
146- flang-new -ccc-print-phases -c file.f
142+ flang -ccc-print-phases -c file.f
147143 +- 0: input, " file.f" , f95-cpp-input
148144 +- 1: preprocessor, {0}, f95
149145 +- 2: compiler, {1}, ir
@@ -158,7 +154,7 @@ command to call the frontend driver is generated (more specifically, an
158154instance of ` clang::driver::Command ` ). Every command is bound to an instance of
159155` clang::driver::Tool ` . For Flang we introduced a specialisation of this class:
160156` clang::driver::Flang ` . This class implements the logic to either translate or
161- forward compiler options to the frontend driver, ` flang-new -fc1 ` .
157+ forward compiler options to the frontend driver, ` flang -fc1 ` .
162158
163159You can read more on the design of ` clangDriver ` in Clang's [ Driver Design &
164160Internals] ( https://clang.llvm.org/docs/DriverInternals.html ) .
@@ -232,12 +228,12 @@ driver, `clang -cc1` and consists of the following classes:
232228This list is not exhaustive and only covers the main classes that implement the
233229driver. The main entry point for the frontend driver, ` fc1_main ` , is
234230implemented in ` flang/tools/flang-driver/driver.cpp ` . It can be accessed by
235- invoking the compiler driver, ` flang-new ` , with the ` -fc1 ` flag.
231+ invoking the compiler driver, ` flang ` , with the ` -fc1 ` flag.
236232
237233The frontend driver will only run one action at a time. If you specify multiple
238234action flags, only the last one will be taken into account. The default action
239235is ` ParseSyntaxOnlyAction ` , which corresponds to ` -fsyntax-only ` . In other
240- words, ` flang-new -fc1 <input-file> ` is equivalent to `flang-new -fc1 -fsyntax-only
236+ words, ` flang -fc1 <input-file> ` is equivalent to `flang -fc1 -fsyntax-only
241237<input-file >`.
242238
243239## Adding new Compiler Options
@@ -262,8 +258,8 @@ similar semantics to your new option and start by copying that.
262258For every new option, you will also have to define the visibility of the new
263259option. This is controlled through the ` Visibility ` field. You can use the
264260following Flang specific visibility flags to control this:
265- * ` FlangOption ` - this option will be available in the ` flang-new ` compiler driver,
266- * ` FC1Option ` - this option will be available in the ` flang-new -fc1 ` frontend driver,
261+ * ` FlangOption ` - this option will be available in the ` flang ` compiler driver,
262+ * ` FC1Option ` - this option will be available in the ` flang -fc1 ` frontend driver,
267263
268264Options that are supported by clang should explicitly specify ` ClangOption ` in
269265` Visibility ` , and options that are only supported in Flang should not specify
@@ -290,10 +286,10 @@ The parsing will depend on the semantics encoded in the TableGen definition.
290286
291287When adding a compiler driver option (i.e. an option that contains
292288` FlangOption ` among in it's ` Visibility ` ) that you also intend to be understood
293- by the frontend, make sure that it is either forwarded to ` flang-new -fc1 ` or
289+ by the frontend, make sure that it is either forwarded to ` flang -fc1 ` or
294290translated into some other option that is accepted by the frontend driver. In
295291the case of options that contain both ` FlangOption ` and ` FC1Option ` among its
296- flags, we usually just forward from ` flang-new ` to ` flang-new -fc1 ` . This is
292+ flags, we usually just forward from ` flang ` to ` flang -fc1 ` . This is
297293then tested in ` flang/test/Driver/frontend-forward.F90 ` .
298294
299295What follows is usually very dependant on the meaning of the corresponding
@@ -339,11 +335,11 @@ just added using your new frontend option.
339335
340336## CMake Support
341337As of [ #7246 ] ( https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7246 )
342- (and soon to be released CMake 3.24.0 ), `cmake` can detect `flang- new ` as a
338+ (and soon to be released CMake 3.24.0 ), `cmake` can detect `flang` as a
343339supported Fortran compiler. You can configure your CMake projects to use
344- `flang- new ` as follows:
340+ `flang` as follows:
345341```bash
346- cmake -DCMAKE_Fortran_COMPILER=<path/to/flang- new > <src/dir>
342+ cmake -DCMAKE_Fortran_COMPILER=<path/to/flang> <src/dir>
347343```
348344You should see the following in the output:
349345```
@@ -353,14 +349,14 @@ where `<version>` corresponds to the LLVM Flang version.
353349
354350## Testing
355351In LIT, we define two variables that you can use to invoke Flang's drivers:
356- * ` %flang ` is expanded as ` flang-new ` (i.e. the compiler driver)
357- * ` %flang_fc1 ` is expanded as ` flang-new -fc1 ` (i.e. the frontend driver)
352+ * ` %flang ` is expanded as ` flang ` (i.e. the compiler driver)
353+ * ` %flang_fc1 ` is expanded as ` flang -fc1 ` (i.e. the frontend driver)
358354
359355For most regression tests for the frontend, you will want to use ` %flang_fc1 ` .
360356In some cases, the observable behaviour will be identical regardless of whether
361357` %flang ` or ` %flang_fc1 ` is used. However, when you are using ` %flang ` instead
362358of ` %flang_fc1 ` , the compiler driver will add extra flags to the frontend
363- driver invocation (i.e. ` flang-new -fc1 -<extra-flags> ` ). In some cases that might
359+ driver invocation (i.e. ` flang -fc1 -<extra-flags> ` ). In some cases that might
364360be exactly what you want to test. In fact, you can check these additional
365361flags by using the ` -### ` compiler driver command line option.
366362
@@ -380,7 +376,7 @@ plugins. The process for using plugins includes:
380376* [ Creating a plugin] ( #creating-a-plugin )
381377* [ Loading and running a plugin] ( #loading-and-running-a-plugin )
382378
383- Flang plugins are limited to ` flang-new -fc1 ` and are currently only available /
379+ Flang plugins are limited to ` flang -fc1 ` and are currently only available /
384380been tested on Linux.
385381
386382### Creating a Plugin
@@ -465,14 +461,14 @@ static FrontendPluginRegistry::Add<PrintFunctionNamesAction> X(
465461
466462### Loading and Running a Plugin
467463In order to use plugins, there are 2 command line options made available to the
468- frontend driver, ` flang-new -fc1 ` :
464+ frontend driver, ` flang -fc1 ` :
469465* [ ` -load <dsopath> ` ] ( #the--load-dsopath-option ) for loading the dynamic shared
470466 object of the plugin
471467* [ ` -plugin <name> ` ] ( #the--plugin-name-option ) for calling the registered plugin
472468
473469Invocation of the example plugin is done through:
474470``` bash
475- flang-new -fc1 -load flangPrintFunctionNames.so -plugin print-fns file.f90
471+ flang -fc1 -load flangPrintFunctionNames.so -plugin print-fns file.f90
476472```
477473
478474Both these options are parsed in ` flang/lib/Frontend/CompilerInvocation.cpp ` and
@@ -493,7 +489,7 @@ reports an error diagnostic and returns `nullptr`.
493489
494490### Enabling In-Tree Plugins
495491For in-tree plugins, there is the CMake flag ` FLANG_PLUGIN_SUPPORT ` , enabled by
496- default, that controls the exporting of executable symbols from ` flang-new ` ,
492+ default, that controls the exporting of executable symbols from ` flang ` ,
497493which plugins need access to. Additionally, there is the CMake flag
498494` LLVM_BUILD_EXAMPLES ` , turned off by default, that is used to control if the
499495example programs are built. This includes plugins that are in the
@@ -526,7 +522,7 @@ invocations `invokeFIROptEarlyEPCallbacks`, `invokeFIRInlinerCallback`, and
526522`invokeFIROptLastEPCallbacks` for Flang drivers to be able to insert additonal
527523passes at different points of the default pass pipeline. An example use of these
528524extension point callbacks is shown in `registerDefaultInlinerPass` to invoke the
529- default inliner pass in `flang- new `.
525+ default inliner pass in `flang`.
530526
531527## LLVM Pass Plugins
532528
@@ -539,15 +535,15 @@ documentation for
539535[`llvm::PassBuilder`](https:// llvm.org/doxygen/classllvm_1_1PassBuilder.html)
540536for details.
541537
542- The framework to enable pass plugins in `flang- new ` uses the exact same
538+ The framework to enable pass plugins in `flang` uses the exact same
543539machinery as that used by `clang` and thus has the same capabilities and
544540limitations.
545541
546542In order to use a pass plugin, the pass (es) must be compiled into a dynamic
547543shared object which is then loaded using the ` -fpass-plugin ` option.
548544
549545```
550- flang-new -fpass-plugin=/path/to/plugin.so <file.f90>
546+ flang -fpass-plugin=/path/to/plugin.so <file.f90>
551547```
552548
553549This option is available in both the compiler driver and the frontend driver.
@@ -559,7 +555,7 @@ Pass extensions are similar to plugins, except that they can also be linked
559555statically. Setting ` -DLLVM_${NAME}_LINK_INTO_TOOLS ` to ` ON ` in the cmake
560556command turns the project into a statically linked extension. An example would
561557be Polly, e.g., using ` -DLLVM_POLLY_LINK_INTO_TOOLS=ON ` would link Polly passes
562- into ` flang-new ` as built-in middle-end passes.
558+ into ` flang ` as built-in middle-end passes.
563559
564560See the
565561[ ` WritingAnLLVMNewPMPass ` ] ( https://llvm.org/docs/WritingAnLLVMNewPMPass.html#id9 )
0 commit comments