Commit graph

3389 commits

Author SHA1 Message Date
peter klausler 3fefebabe5 [flang] Fold EOSHIFT
Implement constant folding for the transformational intrinsic
function EOSHIFT.

Differential Revision: https://reviews.llvm.org/D108941
2021-08-30 16:27:35 -07:00
Chris Lattner faf1c22408 [Builder] Eliminate the StringRef/StringAttr forms of getSymbolRefAttr.
The StringAttr version doesn't need a context, so we can just use the
existing `SymbolRefAttr::get` form.  The StringRef version isn't preferred
so we want to encourage people to use StringAttr.

There is an additional form of getSymbolRefAttr that takes a (SymbolTrait
implementing) operation.  This should also be moved, but I'll do that as
a separate patch.

Differential Revision: https://reviews.llvm.org/D108922
2021-08-30 16:05:36 -07:00
peter klausler 0bbb2d0036 [flang] Fold CSHIFT
Implement folding of the transformational intrinsic function
CSHIFT for all types.

Differential Revision: https://reviews.llvm.org/D108931
2021-08-30 13:01:56 -07:00
Jean Perier 58e1a5e4c2 [flang][mlir] Fix FIR after D108899
After 41d4aa7de6, some builder.getStringAttr
calls in FIR were wrong.
2021-08-30 13:51:39 +02:00
Diana Picus 4fae60c4b0 [flang] Add runtime interface for GET_COMMAND_ARGUMENT
GET_COMMAND_ARGUMENT takes a lot of optional arguments: VALUE, LENGTH,
STATUS and ERRMSG. This patch breaks up the interface into 2 different
functions:

* One for getting the LENGTH of an argument.

* One for getting the VALUE and the ERRMSG of an argument. This returns
the STATUS, which can be easily ignored by lowering if it is missing in
the invocation.

Differential Revision: https://reviews.llvm.org/D108688
2021-08-30 07:31:13 +00:00
Diana Picus cc4d28691b [flang] Add runtime interface for COMMAND_ARGUMENT_COUNT
Differential Revision: https://reviews.llvm.org/D108687
2021-08-30 07:31:13 +00:00
Jean Perier 31fb52f874 [flang] Apply double precision KindCode in specific proc interface
The double precision KindCode was ignored when building the interface
of specific intrinsic procedures leading to bad semantics checks.

Differential Revision: https://reviews.llvm.org/D108828
2021-08-30 08:59:58 +02:00
Jean Perier 9016b2a1ca [flang] Take result length into account in ApplyElementwise folding
ApplyElementwise on character operation was always creating a result
ArrayConstructor with the length of the left operand. This is not
correct for concatenation and SetLength operations.

Compute and thread the length to the spot creating the ArrayConstructor
so that the length is correct for those character operations.

Differential Revision: https://reviews.llvm.org/D108711
2021-08-26 09:46:14 +02:00
Jean Perier b3e392c081 [flang] Implement Posix version of DATE_AND_TIME runtime
Use gettimeofday and localtime_r to implement DATE_AND_TIME intrinsic.
The Windows version fallbacks to the "no date and time information
available" defined by the standard (strings set to blanks and values to
-HUGE).

The implementation uses an ifdef between windows and the rest because
from my tests, the SFINAE approach leads to undeclared name bogus errors
with clang 8 that seems to ignore failure to instantiate is not an error
for the function names (i.e., it understands it should not instantiate
the version using gettimeofday if it is not there, but still yields an
error that it is not declared on the spot where it is called in the
uninstantiated version).

Differential Revision: https://reviews.llvm.org/D108622
2021-08-25 11:16:52 +02:00
peter klausler b232a88c6f [flang] runtime: fix WRITE after BACKSPACE on variable-length file
BACKSPACE leaves "recordLength" set, which is fine for a later READ,
but it causes a later WRITE to fail due to a misinterpretation of the
knowledge of the record length as indication of a fixed-length record
file (RECL=).  Fix.

Differential Revision: https://reviews.llvm.org/D108594
2021-08-24 09:34:52 -07:00
peter klausler 3265b93363 [flang] Extension: reduced scope for some implied DO loop indices
The index of an implied DO loop in a DATA statement or array
constructor is defined by Fortran 2018 to have scope over its
implied DO loop.  This definition is unfortunate, because it
requires the implied DO loop's bounds expressions to be in the
scope of the index variable.  Consequently, in code like

  integer, parameter :: j = 5
  real, save :: a(5) = [(j, j=1, j)]

the upper bound of the loop is a reference to the index variable,
not the parameter in the enclosing scope.

This patch limits the scope of the index variable to the "body"
of the implied DO loop as one would naturally expect, with a warning.
I would have preferred to make this a hard error, but most Fortran
compilers treat this case as f18 now does.  If the standard
were to be fixed, the warning could be made optional.

Differential Revision: https://reviews.llvm.org/D108595
2021-08-24 09:34:18 -07:00
Andrzej Warzynski 787c443a8d [flang] Refine output file generation
This patch cleans-up the file generation code in Flang's frontend
driver. It improves the layering between
`CompilerInstance::CreateDefaultOutputFile`,
`CompilerInstance::CreateOutputFile` and their various clients.

* Rename `CreateOutputFile` as `CreateOutputFileImpl` and make it
  private. This method is an implementation detail.
* Instead of passing an `std::error_code` out parameter into
  `CreateOutputFileImpl`, have it return Expected<>. This is a bit shorter
  and idiomatic LLVM.
* Make `CreateDefaultOutputFile` (which calls `CreateOutputFileImpl`)
  issue an error when file creation fails. The error code from
  `CreateOutputFileImpl` is used to generate a meaningful diagnostic
  message.
* Remove error reporting from `PrintPreprocessedAction::ExecuteAction`.
  This is only for cases when output file generation fails. This is
  handled in `CreateDefaultOutputFile` instead (see the previous point).
* Inline `AddOutputFile` into its only caller,
  `CreateDefaultOutputFile`.
* Switch from `lvm::buffer_ostream` to `llvm::buffer_unique_ostream>`
  for non-seekable output streams. This simplifies the logic in the driver
  and was introduced for this very reason in [1]
* Moke sure that the diagnostics from the prescanner when running `-E`
  (`PrintPreprocessedAction::ExecuteAction`) are printed before the actual
  output is generated.
* Update comments, add test.

NOTE: This patch relands [2]. As suggested by Michael Kruse in the
post-commit/post-revert review, I've added the following:
```
config.errc_messages = "@LLVM_LIT_ERRC_MESSAGES@"
```
in Flang's `lit.site.cfg.py.in`. This way, `%errc_ENOENT` in
output-paths.f90 gets the correct value on Windows as well as on Linux.

[1] https://reviews.llvm.org/D93260
[2] fd21d1e198

Reviewed By: ashermancinelli

Differential Revision: https://reviews.llvm.org/D108390
2021-08-21 15:18:48 +00:00
Ivan Zhechev 0d1a0f7e8d Make test_symbols.py compare files line-by-line
We currently feed full files to Python's unified_diff.
It's not quite what we want though -
line-by-line comparison makes more sense
(we want to be able to identify missing/unnecessary lines)
and is also easier to parse for humans.
This patch makes sure that we compare one line at a time.

This change pretties up the output formatting in the script.
Output before:

```
!DEF:/m/s/xINTENT(IN)(Implicit)ObjectEntityREAL(4)
!DEF:/m/s/yINTENT(INOUT)(Implicit)ObjectEntityREAL(4)
-!-D-E-F-:-f-o-o-b-a-r-
puresubroutines(x,y)bind(c)
!REF:/m/s/x
intent(in)::x
```
Proposed output after:

```
!DEF:/m/s/xINTENT(IN)(Implicit)ObjectEntityREAL(4)
!DEF:/m/s/yINTENT(INOUT)(Implicit)ObjectEntityREAL(4)
-!DEF:foobar
puresubroutines(x,y)bind(c)
!REF:/m/s/x
intent(in)::x
```

Reviewed By: Meinersbur, awarzynski

Differential Revision: https://reviews.llvm.org/D107954
2021-08-20 18:28:35 +01:00
Andrzej Warzynski 316be03ff5 Revert "[flang] Refine output file generation"
This reverts commit fd21d1e198.

The test added in this patch [1] is failing on Windows and causing the
Windows BuildBot [2] to fail. I don't see any obvious way to fix this,
so reverting in order to investigate.

[1] llvm-project/flang/test/Driver/output-paths.f90
[2] https://lab.llvm.org/buildbot/#/builders/172/builds/2077
2021-08-20 09:16:11 +00:00
Andrzej Warzynski fd21d1e198 [flang] Refine output file generation
This patch refactors the file generation API in Flang's frontend driver.
It improves the layering between `CreateDefaultOutputFile`,
`CreateOutputFile` (`CompilerInstance` methods) and their various
clients.

List of changes:
* Rename `CreateOutputFile` as `CreateOutputFileImpl` and make it
private. This method is an implementation detail.
* Instead of passing an `std::error_code` out parameter into
`CreateOutputFileImpl`, have it return Expected<>. This is a bit shorter
and more idiomatic LLVM.
* Make `CreateDefaultOutputFile` (which calls `CreateOutputFileImpl`)
issue an error when file creation fails. The error code from
`CreateOutputFileImpl` is used to generate a meaningful diagnostic
message.
* Remove error reporting from `PrintPreprocessedAction::ExecuteAction`.
This is only for cases when output file generation fails. This is
handled in `CreateDefaultOutputFile` instead (see the previous point).
* Inline `AddOutputFile` into its only caller,
`CreateDefaultOutputFile`.
* Switch from `lvm::buffer_ostream` to `llvm::buffer_unique_ostream>`
for non-seekable output streams. This simplifies the logic in the driver
and was introduced for this very reason in [1]
* Moke sure that the diagnostics from the prescanner when running `-E`
(`PrintPreprocessedAction::ExecuteAction`) are printed before the actual
output is generated.
* Update comments, add test.

[1] https://reviews.llvm.org/D93260

Differential Revision: https://reviews.llvm.org/D108390
2021-08-20 06:46:44 +00:00
Andrzej Warzynski dcc6b7b1d5 [OptTable] Refine how printHelp treats empty help texts
Currently, `printHelp` behaves differently for options that:
  * do not define `HelpText` (such options _are not printed_), and
  * define its `HelpText` as `HelpText<"">` (such options _are printed_).
In practice, both approaches lead to no help text and `printHelp` should
treat them consistently. This patch addresses that by making
`printHelpt` check the length of the help text to be printed.

All affected tests have been updated accordingly. The option definitions
for llvm-cvtres have been updated with a short description or "Not
  implemented" for options that are ignored by the tool.

Differential Revision: https://reviews.llvm.org/D107557
2021-08-19 09:30:15 +00:00
Stuart Ellis 520e5db26a [flang][driver] Add print function name Plugin example
Replacing Hello World example Plugin with one that counts and prints the names of
functions and subroutines.
This involves changing the `PluginParseTreeAction` Plugin base class to
inherit from `PrescanAndSemaAction` class to get access to the Parse Tree
so that the Plugin can walk it.
Additionally, there are tests of this new Plugin to check it prints the correct
things in different circumstances.

Depends on: D106137

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D107089
2021-08-19 08:25:34 +00:00
Diana Picus 3330b2532f [flang] Add POSIX implementation for SYSTEM_CLOCK
This is very similar to CPU_TIME, except that we return nanoseconds
rather than seconds. This means we're potentially dealing with rather
large numbers, so we'll have to wrap around to avoid overflows.

Differential Revision: https://reviews.llvm.org/D105970
2021-08-19 07:39:37 +00:00
Diana Picus 0104cc85b1 [flang] Add default implementation for SYSTEM_CLOCK
Add an implementation for the runtime functions related to SYSTEM_CLOCK.
As with CPU_TIME, this is based on std::clock(), which should be
available everywhere, but it is highly recommended to add
platform-specific implementations for systems where std::clock() behaves
poorly (e.g. POSIX).

The documentation for std::clock() doesn't specify a maximum value and
in fact wrap around behaviour is non-conforming.  Therefore, this
implementation of SYSTEM_CLOCK is not guaranteed to wrap around either,
and after std::clock reaches its maximum value we will likely just
return failure rather than wrap around. If this happens often on your
system, please add a new platform-specific implementation.

We define COUNT_MAX as either the maximum value that can be stored in
a std::clock_t or in a 64-bit integer (whichever is smaller), and
COUNT_RATE as CLOCKS_PER_SEC. For POSIX systems, the value of
CLOCKS_PER_SEC is hardcoded to 10^6 and irrelevant for the values
returned by std::clock.

Differential Revision: https://reviews.llvm.org/D105969
2021-08-18 07:39:13 +00:00
PeixinQiao 3883e266f4 [flang][OpenMP] Add semantic check for target nesting
This patch implements the following check for TARGET construct:
```
OpenMP Version 5.0 Target construct restriction: If a target update,
target data, target enter data, or target exit data construct is
encountered during execution of a target region, the behavior is
unspecified.
```

Also add one test case for the check.

Reviewed By: kiranchandramohan, clementval

Differential Revision: https://reviews.llvm.org/D106165
2021-08-18 09:40:52 +08:00
Peter Steinfeld b8ecdcdd81 [flang] Fix the vector version of EOSHIFT with a BOUNDARY argument
When the vector version of EOSHIFT was called, the BOUNDARY argument was being
ignored.  I fixed that and added a test that would not pass without this fix.

Differential Revision: https://reviews.llvm.org/D108249
2021-08-17 15:20:15 -07:00
peter klausler 4c15a9700b [flang] Add missing call to BeginReadingRecord()
NAMELIST input needs to start with a call to BeginReadingRecord().
Internal unit input doesn't care (so unit tests were passing), but
external unit input does need the call and will assert without it.

Differential Revision: https://reviews.llvm.org/D108051
2021-08-17 11:10:25 -07:00
peter klausler dfea011a37 [flang] Fix regression from recent runtime input fix
A recent runtime I/O change[1] was meant to improve the handling of
input from external files missing a terminal newline on their last
records; the change was "triggered" by the wrong circumstances and
causing reads that should have pulled more data into the buffer to be
treated as EOFs.  So fix that, and also don't retain input data
in the buffer once an input record has been finished unless it's
known that list-directed or NAMELIST input of a repeated input item
may need to backspace a non-positionable external unit to return
to the beginning of the repeated item.

[1] 6578893a0453384346f149479f8574dfff977ace

Differential Revision: https://reviews.llvm.org/D108164
2021-08-17 10:12:56 -07:00
Andrzej Warzynski 4f21e6aedd [flang][nfc] Tweak the FrontendAction class
This patch refactors the `FrontendAction` class. It merely moves code
around so that re-using it is easier. No new functionality is
introduced.

1. Three new member methods are introduced: `RunPrescan`, `RunParse`,
`RunSemanticChecks`.
2. The following free functions are re-implemented as member methods:
  * `reportFatalSemanticErrors`
  * `reportFatalScanningErrors`
  * `reportFatalParsingErrors`
  * `reportFatalErrors`
`reportFatalSemanticErrors` is updated to resemble the other error
reporting functions and to make the API more consistent.
3. The `BeginSourceFileAction` methods are simplified and the unused
input argument is deleted.

Differential Revision: https://reviews.llvm.org/D108130
2021-08-17 07:36:44 +00:00
Andrzej Warzynski 265a9961d1 [flang][nfc] Move Semantics from FrontendAction to CompilerInstance
`CompilerInstance` is a more appropriate place for a key component of
the frontend like `Semantics`.

This change opens a path for us to introduce new frontend actions that
will also run semantics, but for which inheriting from
`PrescanAndSemaAction` wouldn't make much sense. For example, for
code-gen actions we plan to introduce a dedicate hierarchy of action
classes.

I've also added a doxyment for `CompilerInstance` to add a bit of
context for this change (and also make future refactoring more informed).
As `CompilerInstance` in Flang has been inspired by its counterpart in
Clang, this comment is roughly a verbatim copy of the comment in Clang
(with some adjustments from me). Credits to Daniel Dunbar for the great
design and the original comment.

Differential Revision: https://reviews.llvm.org/D108035
2021-08-15 09:33:07 +00:00
Kiran Chandramohan 6c3ae442ac [Flang] Fix for CI failure, Remove default case
Remove default case when all the enum values are covered in switch
statements.
2021-08-13 18:06:33 +01:00
Peixin Qiao 42f5110701 [flang][OpenMP] Add semantic check for teams nesting
This patch implements the following check for TEAMS construct:
```
OpenMP Version 5.0 Teams construct restriction: A teams region can
only be strictly nested within the implicit parallel region or a target
region. If a teams construct is nested within a target construct, that
target construct must contain no statements, declarations or directives
outside of the teams construct.
```

Also add one test case for the check.

Reviewed By: kiranchandramohan, clementval

Differential Revision: https://reviews.llvm.org/D106335
2021-08-13 10:42:47 -04:00
Peixin Qiao 70894c8dd1 [flang][OpenMP] Add semantic checks for cancellation nesting
This patch implements the following semantic checks for cancellation constructs:
```
OpenMP Version 5.0 Section 2.18.1: CANCEL construct restriction:
If construct-type-clause is taskgroup, the cancel construct must be
closely nested inside a task or a taskloop construct and the cancel
region must be closely nested inside a taskgroup region. If
construct-type-clause is sections, the cancel construct must be closely
nested inside a sections or section construct. Otherwise, the cancel
construct must be closely nested inside an OpenMP construct that matches
the type specified in construct-type-clause of the cancel construct.

OpenMP Version 5.0 Section 2.18.2: CANCELLATION POINT restriction:
A cancellation point construct for which construct-type-clause is
taskgroup must be closely nested inside a task or taskloop construct,
and the cancellation point region must be closely nested inside a
taskgroup region. A cancellation point construct for which
construct-type-clause is sections must be closely nested inside a
sections or section construct. A cancellation point construct for which
construct-type-clause is neither sections nor taskgroup must be closely
nested inside an OpenMP construct that matches the type specified in
construct-type-clause.
```

Also add test cases for the check.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D106538
2021-08-13 10:11:39 -04:00
Andrzej Warzynski 5437f2e9a9 [flang][nfc] Remove flang-new-driver from LIT
After merging https://reviews.llvm.org/D105811, `flang-new-driver` is no
longer required.

Differential Revision: https://reviews.llvm.org/D107990
2021-08-13 08:17:40 +00:00
peter klausler a05bae6163 [flang] Correct off-by-one error in SET_EXPONENT
SET_EXPONENT is returning values that are too large by a factor
of two.

Differential Revision: https://reviews.llvm.org/D107986
2021-08-12 12:50:16 -07:00
Andrzej Warzynski 8150c1bd8e [flang] Disable Plugins in out-of-tree builds
https://reviews.llvm.org/D106137 added support for plugins in Flang. The
CMake configuration for plugins requires some LLVM variables that are
not available in out-of-tree builds (e.g. `LLVM_SHLIB_OUTPUT_INTDIR`).
This has caused the out-of-tree BuildBot worker to start failing:
  * https://lab.llvm.org/buildbot/#/builders/175

This patch effectively disables plugins in out-of-tree builds and fixes
the configuration error. In order to support plugins in out-of-tree
builds, we would have to find a way to access the missing CMake
variables from LLVM. This could be implemented at a later time.

Differential Revision: https://reviews.llvm.org/D107973
2021-08-12 19:29:28 +00:00
Ivan Zhechev 35249cb7b1 [Flang] Fix error messages on Windows.
Flang uses positional arguments for `messages::say()`, such as "%1$s" which is only supported in MS Compilers with the `_*printf_p` form of the function. This uses a conditional macro to convert the existing `vsnprintf` used to the one needed in MS-World.

7 tests in D107575 rely on this change.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D107654
2021-08-12 18:35:54 +01:00
Kiran Chandramohan 4573c31f89 [Flang] Fix build failure on MacOS
std::clock_t can be an unsigned value on some platforms like MacOS and
therefore needs a cast when initializing an std::clock_t value with -1.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D107972
2021-08-12 18:14:46 +01:00
peter klausler 467525bd07 [flang] Fix crash in runtime-type-info.cpp
Recent work in runtime assignments failed an assertion in fir-dev
while running tests (flang/test/Semantics/defined-ops.f90).  This
test didn't fail in llvm-project/main because only the "new" Arm
driver is used now, and that only builds runtime derived type information
tables when some debug dumping options are enabled.

So add a reproducing test case to another test that is run with
-fdebug-dump-symbols, and fix the crash by emitting special procedure
binding information only for type-bound generic ASSIGNMENT(=) bindings
that are relevant to the runtime support library for use in intrinsic
assignment of derived types.

Differential Revision: https://reviews.llvm.org/D107918
2021-08-12 09:32:08 -07:00
Stuart Ellis f52fc591fa [flang][driver] Add support for Frontend Plugins
Introducing a plugin API and a simple HelloWorld Plugin example.
This patch adds the `-load` and `-plugin` flags to frontend driver and
the code around using custom frontend actions from within a plugin
shared library object.

It also adds to the Driver-help test to check the help option with the
updated driver flags.

Additionally, the patch creates a plugin-example test to check the
HelloWorld plugin example runs correctly. As part of this, a new CMake
flag (`FLANG_BUILD_EXAMPLES`) is added to allow the example to be built
and for the test to run.

This Plugin API has only been tested on Linux.

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D106137
2021-08-12 11:42:16 +01:00
peter klausler 39c38c2152 [flang] Fix list-directed plural repeated null values at end of record
A repeated null value at the end of an input record with a count > 1
would incorrectly advance to the next record when resumed.  Fix.

Improve some poor naming and code flow noticed while debugging, so
next time will be easier.

Extend a unit test to check this case.

Differential Revision: https://reviews.llvm.org/D107917
2021-08-11 13:14:07 -07:00
peter klausler 101b3fed5e [flang] Fix two typos in API names
Differential Revision: https://reviews.llvm.org/D107916
2021-08-11 12:43:37 -07:00
Peter Steinfeld 3ad9826dcd [flang] Fix the extent calculation when upper bounds are less than lower bounds
When the upper bound is less than the lower bound, the extent is zero.  This is
specified in section 8.5.8.2, paragraph 3.

Note that similar problems exist in the lowering code.  This change only fixes
the problem for the front end.

I also added a test.

Differential Revision: https://reviews.llvm.org/D107832
2021-08-10 10:34:22 -07:00
Jean Perier f2f6190960 [flang] Always create HostAssocDetails for host object symbols with UseDetails
https://reviews.llvm.org/D105464 did not correctly cover the case
where the symbol from the host procedure is use associated. Outside
of the mis-parsed ArrayRef case, flang was also creating a symbol with
HostAssociated details inside the internal procedure (pointing to the
use associated symbol in the host). That is what lowering expects.
This patch ensures the same logic is applied in the mis-parsed array-ref name
resolution (and the pointer target name resolution).

Differential Revision: https://reviews.llvm.org/D107759
2021-08-10 12:38:19 +02:00
peter klausler 511ac6f8b4 [flang] Silence new build warning
Some build environments complain about unused data members in some
C++ translations of Fortran derived types; those members don't really
need to be present, so remove them.

Fix pushed w/o review to get build bots running again.
2021-08-09 11:57:45 -07:00
Andrzej Warzynski 41f4d47484 [flang] Make flang translate -M{fixed|free} into -f{fixed|free}-form
We are only adding this in `flang` - the bash wrapper script for the
driver. We don't have any specific plans to support `-M{fixed|free}` in
`flang-new` (i.e. the actual driver).

That feature was requested by one of our users.

Differential Revision: https://reviews.llvm.org/D107081
2021-08-09 18:06:09 +01:00
peter klausler 65f5290432 [flang] Implement runtime Assign()
Define an API for, and implement, runtime support for arbitrary
assignment of one descriptor's data to another, with full support for
(re)allocation of allocatables with finalization when necessary,
user-defined derived type assignment TBP calls, and intrinsic (default)
componentwise assignment of derived type instances with allocation of
automatic components.  Also clean up API and implementation of
finalization/destruction using knowledge gained while studying
edge cases for assignment in the 2018 standard.

The look-up procedure for special procedure bindings in derived
types has been optimized from O(N) to O(1) since it will probably
matter more.  This required some analysis in runtime derived type
description table construction in semantics and some changes to the
table schemata.

Executable Fortran tests have been developed; they'll be added
to the test base once they can be lowered and run by f18.

Differential Revision: https://reviews.llvm.org/D107678
2021-08-09 09:31:32 -07:00
Ivan Zhechev eabae4cf57 [Flang] Ported test_symbols to Python
Due to unavailability of Flang testing on Windows, the shell scripts
are being ported to Python. The following changes are being made in
this patch: removed test_symbols.sh and common.sh, and ported them
to Python. Changes to the tests themselves so that they use the
python scripts instead of the shell script.

Reviewed By: Meinersbur, awarzynski, kiranchandramohan

Differential Revision: https://reviews.llvm.org/D107041
2021-08-09 16:20:06 +01:00
Asher Mancinelli dfce2909ee [flang] Lift -Werror checks into local functions
Lift checks for -Werror into local functions.

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D101261
2021-08-06 12:43:19 -06:00
Andrzej Warzynski 3709822d26 [flang][docs] Document the flang wrapper script
Differential Revision: https://reviews.llvm.org/D107543
2021-08-06 12:45:32 +00:00
Andrzej Warzynski 7b73ca3043 [flang][driver] Delete f18 (i.e. the old Flang driver)
This patch removes `f18`, a.k.a. the old driver. It is being replaced
with the new driver, `flang-new`, which has reached feature parity with
`f18` a while ago. This was discussed in [1] and also in [2].

With this change, `FLANG_BUILD_NEW_DRIVER` is no longer needed and is
also deleted. This means that we are making the dependency on Clang permanent
(i.e. it cannot be disabled with a CMake flag).

LIT set-up is updated accordingly. All references to `f18` or `f18.cpp`
are either updated or removed.

The `F18_FC` variable from the `flang` bash script is replaced with
`FLANG_FC`. The former is still supported for backwards compatibility.

[1] https://lists.llvm.org/pipermail/flang-dev/2021-June/000742.html
[2] https://reviews.llvm.org/D103177

Differential Revision: https://reviews.llvm.org/D105811
2021-08-05 12:57:15 +00:00
Andrzej Warzynski 55a9615599 [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-08-05 10:20:47 +00:00
peter klausler 4876520eef [flang] runtime: For Fw.d formatting, don't oscillate forever
The algorithm for Fw.d output will drive binary to decimal conversion for
an initial fixed number of digits, then adjust that number based on the
result's exposent.  For value close to a power of ten, this adjustment
process wouldn't terminate; e.g., formatting 9.999 as F10.2 would start
with 1e2, boost the digits to 2, get 9.99e1, decrease the digits, and loop.
Solve by refusing to boost the digits a second time.

Differential Revision: https://reviews.llvm.org/D107490
2021-08-04 12:19:23 -07:00
peter klausler 617be2756f [flang] Support DFLOAT legacy extension intrinsic function
Like the similar legacy extension FLOAT(), DFLOAT() represents a
conversion from default integer to DOUBLE PRECISION.  Rewrite
into a conversion operation.

Differential Revision: https://reviews.llvm.org/D107489
2021-08-04 12:18:41 -07:00
Matthias Springer b44eb5a149 [flang] Add missing FileSystem.h
This file was previously included transitively via `mlir/Transforms/Passes.h`, but the include has been removed from that file.

Differential Revision: https://reviews.llvm.org/D107455
2021-08-04 22:22:26 +09:00