Commit Graph

2988 Commits

Author SHA1 Message Date
Valentin Clement a48bee2294 [flang][fir][NFC] Move BoxType to TableGen type definition
This patch is a follow up of D96422 and move BoxType to TableGen.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D96476
2021-02-11 18:10:22 -05:00
Eric Schweitz f47d7c145b [flang][fir][NFC] Rename WhereOp to IfOp. 2021-02-11 11:33:37 -08:00
peter klausler 8880a63a15 [flang] Don't perform macro replacement unless *.F, *.F90, &c.
Avoid spurious and confusing macro replacements from things like
-DPIC on Fortran source files whose suffixes indicate that preprocessing
is not expected.

Add gfortran-like "-cpp" and "-nocpp" flags to f18 to force predefinition
of macros independent of the source file suffix.

Differential Revision: https://reviews.llvm.org/D96464
2021-02-11 11:25:41 -08:00
Eric Schweitz 4dc87d1010 [flang][fir] Update the kind mapping class.
The kind mapper provides a portable mechanism to map Fortran type KIND values
independent of the front-end to their corresponding MLIR and LLVM types.

Differential Revision: https://reviews.llvm.org/D96362
2021-02-11 11:11:52 -08:00
peter klausler 0bfa4ac6c6 [flang] Improve "Error reading module file" error message
Instead of using a message attachment with further details,
emit the details as part of a single message.

Differential Revision: https://reviews.llvm.org/D96465
2021-02-11 11:08:12 -08:00
Leandro Vaz 204360fd71 [flang] Fix typo in FlangConfig.cmake.in.
`find_package(Flang)` does not work as there is a missing `@` in the
FlangConfig.cmake.in file. This patch fixes the issue.

Reviewed By: thopre

Differential Revision: https://reviews.llvm.org/D96484
2021-02-11 18:09:47 +00:00
Sourabh Singh Tomar 6a7deff58e [flang] Remove `LINK_WITH_FIR` cmake switch
Most components required for this are already there.

Build and Testing clean.
ninja check-flang

Reviewed By: clementval, tskeith

Differential Revision: https://reviews.llvm.org/D96411
2021-02-11 22:52:13 +05:30
clementval 661f9e2a92 Revert "[flang][fir][NFC] Move BoxType to TableGen type definition"
This reverts commit d96bb48f78.
2021-02-11 11:36:35 -05:00
Valentin Clement d96bb48f78 [flang][fir][NFC] Move BoxType to TableGen type definition
This patch is a follow up of D96422 and move BoxType to TableGen.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D96476
2021-02-11 11:09:52 -05:00
Andrzej Warzynski 0feff71eab [flang][driver] Move standard macro predefs to a dedicated method (nfc)
This patch just addresses one of the outstanding TODOs. More
specifically, it moves all the outstanding standard macro predefinitions
from `SetDefaultFortranOpts` to `setDefaultPredefinitions`. This
dedicated method for standard macro predefs was introduced in:
  * https://reviews.llvm.org/D96032
2021-02-11 11:42:57 +00:00
Valentin Clement 5ad416ca78 [flang][fir] Fix Werror build failure after D96422 2021-02-10 21:44:16 -05:00
Valentin Clement 550f251e47 [flang][fir][NFC] Move ShapeShiftType to TableGen type definition
This patch is a follow up of D96422 and move the ShapeShiftType to
TableGen.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D96442
2021-02-10 20:32:28 -05:00
peter klausler 9895ba86a8 [flang] Cope with specific procedures with same name as generic
When accessing a specific procedure of a USE-associated generic
interface, we need to allow for the case in which that specific
procedure has the same name as the generic when testing for
its availability in the current scope.

Differential Revision: https://reviews.llvm.org/D96467
2021-02-10 17:30:22 -08:00
peter klausler 47b97d4bfb [flang] Manage per-specification-part state better
Some state in name resolution is stored in the DeclarationVisitor
instance and processed at the end of the specification part.
This state needs to accommodate nested specification parts, namely
the ones that can be nested in a subroutine or function interface
body.

Differential Revision: https://reviews.llvm.org/D96466
2021-02-10 17:23:53 -08:00
Valentin Clement edd365c709 [flang][fir][NFC] Move ShapeType to TableGen type definition
This is the first patch of a serie to move FIR types to TableGen format as suggested in D96172.
This patch is setting up the files for FIR types and move the ShapeType to TableGen.

As discussed with @schweitz, I'm taking over this task to help the FIR upstreaming effort.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D96422
2021-02-10 19:48:23 -05:00
Andrzej Warzynski cf471632b1 [flang][driver] Add missing dependency in unit tests (nfc)
The following patch revealed a missing dependency in the CMake script
for Flang driver unit tests:
  * https://reviews.llvm.org/D96032
The following buildbots are failing ("BUILD_SHARED_LIBS" is set to ON):
  * http://lab.llvm.org:8011/#/builders/134/builds/1840
  * http://lab.llvm.org:8011/#/builders/66/builds/1785
  * http://lab.llvm.org:8011/#/builders/33/builds/2436

This patch adds the missing dependency.

From what I can see, FortranSemantics and FortranParser are only
indirect dependencies of FlangFrontendTests and IIUC shouldn't be
required here. This is something that we should revisit at some point.
In this patch I focus on fixing the build.
2021-02-10 13:31:49 +00:00
Alex Zinenko 2996a8d675 [mlir] avoid exposing mutable DialectRegistry from MLIRContext
MLIRContext allows its users to access directly to the DialectRegistry it
contains. While sometimes useful for registering additional dialects on an
already existing context, this breaks the encapsulation by essentially giving
raw accesses to a part of the context's internal state. Remove this mutable
access and instead provide a method to append a given DialectRegistry to the
one already contained in the context. Also provide a shortcut mechanism to
construct a context from an already existing registry, which seems to be a
common use case in the wild. Keep read-only access to the registry contained in
the context in case it needs to be copied or used for constructing another
context.

With this change, DialectRegistry is no longer concerned with loading the
dialects and deciding whether to invoke delayed interface registration. Loading
is concentrated in the MLIRContext, and the functionality of the registry
better reflects its name.

Depends On D96137

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D96331
2021-02-10 12:07:34 +01:00
Faris Rehman 6d48a1a53f [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
2021-02-10 09:59:35 +00:00
Eric Schweitz e090182fe1 [flang][fir] Updates to internal name uniquer.
https://github.com/flang-compiler/f18-llvm-project/pull/474

Differential Revision: https://reviews.llvm.org/D96361
2021-02-09 14:43:33 -08:00
Eric Schweitz 399c3d5b29 [flang][fir] Add shape, shape_shift, and slice types.
Adding the FIR types used to describe the Fortran semantics of indexing
FIR arrays.

https://github.com/flang-compiler/f18-llvm-project/pull/267

Differential Revision: https://reviews.llvm.org/D96172
2021-02-09 08:55:47 -08:00
Eric Schweitz 2cd0a113df [flang][fir] Add OpaqueAttr.
Add the opaque attribute class used in flang.

https://github.com/flang-compiler/f18-llvm-project/pull/402

Differential Revision: https://reviews.llvm.org/D96293
2021-02-08 16:02:22 -08:00
Eric Schweitz e892109c3e [flang][NFC] Add comment. 2021-02-08 13:49:16 -08:00
Eric Schweitz bdf3ad582e [flang][NFC] Update comments. 2021-02-08 12:11:49 -08:00
Eric Schweitz 7e20a41348 [flang][fir] Update FIR's character type.
Upstream the changes made to the !fir.char type.

https://github.com/flang-compiler/f18-llvm-project/pull/269
https://github.com/flang-compiler/f18-llvm-project/pull/557

Author: Eric Schweitz, Jean Perier

Differention Revision: https://reviews.llvm.org/D96183
2021-02-08 08:20:04 -08:00
Tres Popp c2c83e97c3 Revert "Revert "Reorder MLIRContext location in BuiltinAttributes.h""
This reverts commit 511dd4f438 along with
a couple fixes.

Original message:
Now the context is the first, rather than the last input.

This better matches the rest of the infrastructure and makes
it easier to move these types to being declaratively specified.

Phabricator: https://reviews.llvm.org/D96111
2021-02-08 10:39:58 +01:00
Tres Popp 511dd4f438 Revert "Reorder MLIRContext location in BuiltinAttributes.h"
This reverts commit 7827753f98.
2021-02-08 09:32:42 +01:00
Tres Popp 7827753f98 Reorder MLIRContext location in BuiltinAttributes.h
Now the context is the first, rather than the last input.

This better matches the rest of the infrastructure and makes
it easier to move these types to being declaratively specified.

Differential Revision: https://reviews.llvm.org/D96111
2021-02-08 09:28:09 +01:00
Eric Schweitz f6342806db [flang][fir] Add FIR's vector type.
This patch adds support for `!fir.vector`, a rank one, constant length
data type.

https://github.com/flang-compiler/f18-llvm-project/pull/413

Differential Revision: https://reviews.llvm.org/D96162
2021-02-05 12:44:19 -08:00
Eric Schweitz a1a1d338e9 [flang][NFC] Make KindTy consistent and consistently used.
Differential Revision: https://reviews.llvm.org/D96154
2021-02-05 10:54:58 -08:00
Eric Schweitz ea35745610 [flang][NFC] Update comments.
Differential Revision: https://reviews.llvm.org/D96152
2021-02-05 10:54:58 -08:00
Sourabh Singh Tomar bca0619a1b [flang] Adapt mlir based error status handling in `tco` tool
Earlier scheme was using negative integers for communicating error status,
switch to canonical MLIR style.

f18 commit authored by @schweitz:
c1af08d6e7

Reviewed By: mehdi_amini, clementval, svedanayagam

Differential Revision: https://reviews.llvm.org/D96068
2021-02-05 11:07:10 +05:30
Eric Schweitz 807a8daf1b fix -Werror build issue. 2021-02-04 16:58:33 -08:00
Eric Schweitz 9673a00995 [flang] Remove dims type and gendims op.
These are no longer part of FIR.
https://github.com/flang-compiler/f18-llvm-project/pull/267

Differential Revision: https://reviews.llvm.org/D96077
2021-02-04 14:37:07 -08:00
Mehdi Chinoune bdb40dd14e [flang][msvc] Reapply "Explicitly reference "this" inside closure"
Reapply {D88052}

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D96066
2021-02-04 16:33:51 -06:00
Eric Schweitz ae7e84285f [flang][NFC] Rename IntType to IntegerType.
https://github.com/flang-compiler/f18-llvm-project/pull/413

Differential Revision: https://reviews.llvm.org/D96072
2021-02-04 12:48:03 -08:00
Andrzej Warzynski ba000628bd [flang][driver] Fix reading from stdin when using `-test-io`
This patch adds logic in the InputOutputTestAction frontend action for
reading input from stdin. Without this patch the following fails:
```
    flang-new -fc1 -test-io -
```

The implementation of `InputOutputTestAction` is cleaned-up and a test
for reading from stdin is added.

Note that there's a difference between `-test-io` and e.g. `-E` in terms
of file I/O. The frontend action for the former handles all file I/O on
it's own. Conversely, the action corresponding to -E relies on the
prescanner API to handle this.

Currently we can't test reading from stdin for `flang-new -`. In this
case `libclangDriver` assumes `-x -c`. This in turn leads to `flang-new
-cc1`, which is not supported.
2021-02-04 16:51:59 +00:00
Arnamoy Bhattacharyya 985a42fdf8 [flang][driver] Add support for `-J/-module-dir`
Add support for option -J/-module-dir in the new Flang driver.  This
will allow for including module files in other directories, as the
default search path is currently the working folder. This also provides
an option of storing the output module in the specified folder.

Differential Revision: https://reviews.llvm.org/D95448
2021-02-04 16:31:40 +00:00
Andrzej Warzynski d06e94031b [flang][driver] Add PrescanAction frontend action (nfc)
This new action encapsulates all actions that require the prescanner to
be run before proceeding with other processing. By adding this new
action, we are better equipped to control which actions _do_ run the
prescanner and which _do not_.

The following actions that require the prescanner are refactored to
inherit from `PrescanAction`:
  * `PrintPreprocessedAction`
  * `ParseSyntaxOnlyAction` .

New virtual method is introduced to facilitate all this:
  * `BeginSourceFileAction`
Like in Clang, this method is run inside `BeginSourceFile`. In other
words, it is invoked before `ExecuteAction` for the corresponding
frontend action is run. This method allows us to:
  * carry out any processing that is always required by the action (e.g.
    run the prescanner)
  * fine tune the settings/options on a file-by-file basis (e.g. to
    decide between fixed-form and free-form based on file extension)

This patch implements non-functional-changes.

Reviewed By: FarisRehman

Differential Revision: https://reviews.llvm.org/D95464
2021-02-04 14:23:33 +00:00
Faris Rehman 3a1513c142 [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 6a75496836, 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
2021-02-04 12:24:15 +00:00
Peter Steinfeld 2018dafce5 [flang] Fix calls to LBOUND() intrinsic for arrays with lower bounds not 1
Constant folding for calls to LBOUND() was not working when the lower bound of
a constant array was not 1.

I fixed this and re-enabled the test in Evaluate/folding16.f90 that previously
was silently failing.  I slightly changed the test to parenthesize the first
argument to exercise all of the new code.

Differential Revision: https://reviews.llvm.org/D95894
2021-02-03 10:53:32 -08:00
Sourabh Singh Tomar f2879559ac [flang] Enable FIR types and Dialect round trip tests
Reviewed By: schweitz, mehdi_amini

Differential Revision: https://reviews.llvm.org/D95958
2021-02-03 23:46:55 +05:30
Sourabh Singh Tomar 4463e39d91 [flang][NFCI] Relpace `LoopOp` Op with `DoLoopOp` Op in FIR Dialect
Part of upstreaming effort,
PR: https://github.com/flang-compiler/f18-llvm-project/pull/296

Reviewed By: schweitz

Differential Revision: https://reviews.llvm.org/D95950
2021-02-03 22:57:49 +05:30
peter klausler 34eb0adaa9 [flang] Add -fsyntax-only to f18; retain -fparse-only synonym
Now that semantics is working, the standard -fsyntax-only option of
GNU and Clang should be used as the name of the option that causes
f18 to just run the front-end.  Support both options in f18, silently
accepting the old option as a synonym for the new one (as
preferred by the code owner), and replace all instances of the
old -fparse-only option with -fsyntax-only throughout the source base.

Differential Revision: https://reviews.llvm.org/D95887
2021-02-03 09:01:39 -08:00
Praveen 5bc6e75386 [Flang][OpenMP] Add semantic checks for invalid branches into or out of OpenMP constructs
OpenMP 4.5 - Check invalid branches into OpenMP strucutred blocks.
             Check invalid branches leaving OpenMP structured blocks.

Test cases : omp-do-cycle.f90, omp-invalid-branch.f90

Resolve related test cases marked as XFAIL

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D92735
2021-02-03 16:09:34 +05:30
peter klausler efc5926c20 [flang] Add TypeAndShape::MeasureElementSizeInBytes()
Split up MeasureSizeInBytes() so that array element sizes can be
calculated accurately; use the new API in some places where
DynamicType::MeasureSizeInBytes() was being used but the new
API performs better due to TypeAndShape having precise CHARACTER
length information.

Differential Revision: https://reviews.llvm.org/D95897
2021-02-02 15:15:20 -08:00
Eric Schweitz e2bd29a0d6 [flang][NFC] Update the CG rewrite pass.
Add description and dependencies.

Differential Revision: https://reviews.llvm.org/D95888
2021-02-02 11:56:21 -08:00
Eric Schweitz d395007216 [flang][NFC] Update #include.
Differential Revision: https://reviews.llvm.org/D95882
2021-02-02 11:52:55 -08:00
peter klausler aa39ddd0a3 [flang] Implement IEEE_SUPPORT_xxx inquiry functions
Implement IEEE_SUPPORT_DATATYPE() and other inquiry intrinisic
functions from the intrinsic module IEEE_ARITHMETIC, folding all of
their results to .TRUE.

Differential Revision: https://reviews.llvm.org/D95830
2021-02-02 11:38:19 -08:00
peter klausler dc6fadf708 [flang] Detect UBOUND() error on assumed-size array
UBOUND() is not allowed on the last dimension of an
assumed-size array dummy argument.

Differential Revision: https://reviews.llvm.org/D95831
2021-02-02 11:37:44 -08:00
Eric Schweitz af43440bd2 [flang][NFC] Update #include and comment.
Differential Revision: https://reviews.llvm.org/D95828
2021-02-02 08:49:04 -08:00