[flang] Add Pre-FIR Tree structure to help lowering the parse-tree
authorJean Perier <jperier@nvidia.com>
Tue, 28 Jan 2020 12:58:30 +0000 (04:58 -0800)
committerJean Perier <jperier@nvidia.com>
Mon, 17 Feb 2020 10:38:49 +0000 (02:38 -0800)
commit336408679535454f8708899cc49cda9395dd725a
tree128687838397f4735ba2ac583a93e47a4b55611a
parentc52cd6355ca7f0cfcd259a4e5e6a544141619628
[flang] Add Pre-FIR Tree structure to help lowering the parse-tree

The Pre-FIR Tree structure is a transient data structure that
is meant to be built from the parse tree just before lowering to
FIR and that will be deleted just afterwards. It is not meant to perfrom
optimization analysis and transformations. It only provides temporary
information, such as label target information or parse tree parent nodes,
that is meant to be used to lower the parse tree structure into
FIR operations.
A PFTBuilder class builds the Pre-Fir Tree from the parse-tree.
A pretty printer is available to visualize this data structure.

- Lit tests are added to:
  1. that the PFT tree structure is as expected
  2. that the PFT captures all intented nodes

- Cmake changes: Prevent warnings inisde LLVM headers when compiling flang

The issue is that some LLVM headers  define functions where the usage of
the parameters depend on environment ifdef. See for instance Size in:
https://github.com/llvm/llvm-project/blob/5f940220bf9438e95ffa4a627ac1591be1e1ba6e/llvm/include/llvm/Support/Compiler.h#L574

Because flang is build with -Werror and -Wunused-parameter is default in
clang, this may breaks build in some environments (like with clang9 on macos).
A solution would be to add -Wno-unused-parameter to flang CmakLists.txt,
but it is wished to keep this warning on flang sources for quality purposes.
Fixing LLVM headers is not an easy task and `[[maybe_unused]]` is C++17 and
cannot be used yet in LLVM headers.
Hence, this fix simply silence warnings coming from LLVM headers by telling
CMake they are to be considered as if they were system headers.

- drone.io changes: remove llvm 6.0 from clang config in drone.io and link
flang with libstdc++ instead of libc++

llvm-dev resolved to llvm-6.0 in clang builds on drone.io. llvm 6.0 too old.
LLVM packages are linked with libstdc++ standard library whereas libc++ was
used for flang. This caused link time failure when building clang. Change
frone.io to build flang with libc++.

Note:
This commit does not reflect an actual work log, it is a feature based split of the
changes done in the FIR experimental branch. The related work log can be found in the
commits between:
864898cbe509d032abfe1172ec367dbd3dd92bc1
and
137c23da9c64cf90584cf81fd646053a69e91f63

Other changes come from https://github.com/flang-compiler/f18/pull/959 review.

Original-commit: flang-compiler/f18@edb0943bca4b81689f320bda341040bf255d6e2e
Reviewed-on: https://github.com/flang-compiler/f18/pull/959
16 files changed:
flang/.drone.star
flang/CMakeLists.txt
flang/include/flang/lower/PFTBuilder.h [new file with mode: 0644]
flang/include/flang/parser/dump-parse-tree.h
flang/lib/CMakeLists.txt
flang/lib/lower/CMakeLists.txt [new file with mode: 0644]
flang/lib/lower/PFTBuilder.cpp [new file with mode: 0644]
flang/test-lit/CMakeLists.txt
flang/test-lit/lit.cfg.py
flang/test-lit/lit.site.cfg.py.in
flang/test-lit/lower/pre-fir-tree01.f90 [new file with mode: 0644]
flang/test-lit/lower/pre-fir-tree02.f90 [new file with mode: 0644]
flang/test-lit/lower/pre-fir-tree03.f90 [new file with mode: 0644]
flang/test-lit/lower/pre-fir-tree04.f90 [new file with mode: 0644]
flang/tools/f18/CMakeLists.txt
flang/tools/f18/f18.cpp