Commit Graph

4243 Commits

Author SHA1 Message Date
Peter Klausler 435641bc3d [flang] Catch bad OPEN(STATUS=) cases
STATUS='NEW' and 'REPLACE' require FILE= to be present.
STATUS='SCRATCH' may not appear with FILE=.

These errors are caught at compilation time when constant character
strings are used in an OPEN statement, but the runtime needs
to enforce them as well to catch errors in OPEN statements
with character variables and expressions.

Differential Revision: https://reviews.llvm.org/D122509
2022-03-25 18:24:50 -07:00
Peter Klausler 5c116d50e4 [flang] Mark C_ASSOCIATED specific procedures as PURE
The interfaces to C_ASSOCIATED()'s specific procedures must be
PURE so that they are accepted for use in specification expressions.

Differential Revision: https://reviews.llvm.org/D122438
2022-03-25 15:04:26 -07:00
Peter Klausler 2ab9990c9e [flang] Add & use a better visit()
Adds flang/include/flang/Common/visit.h, which defines
a Fortran::common::visit() template function that is a drop-in
replacement for std::visit().  Modifies most use sites in
the front-end and runtime to use common::visit().

The C++ standard mandates that std::visit() have O(1) execution
time, which forces implementations to build dispatch tables.
This new common::visit() is O(log2 N) in the number of alternatives
in a variant<>, but that N tends to be small and so this change
produces a fairly significant improvement in compiler build
memory requirements, a 5-10% improvement in compiler build time,
and a small improvement in compiler execution time.

Building with -DFLANG_USE_STD_VISIT causes common::visit()
to be an alias for std::visit().

Calls to common::visit() with multiple variant arguments
are referred to std::visit(), pending further work.

Differential Revision: https://reviews.llvm.org/D122441
2022-03-25 13:15:20 -07:00
Peter Klausler 0363a164b6 [flang] Fix bogus error from assignment to CLASS(*)
Assignment semantics was coughing up bad errors and crashes for
intrinsic assignments to unlimited polymorphic entities while
looking for any (impossible) user defined ASSIGNMENT(=) generic
or intrinsic type conversion.

Differential Revision: https://reviews.llvm.org/D122440
2022-03-25 11:17:01 -07:00
Jean Perier 5bc9ee1b78 [flang][lowering] Handle zero extent case in LBOUND
Follow up of https://reviews.llvm.org/D121488. Ensure lower bounds
are `1` when the related dimension extent is zero. Note that lower
bounds from descriptors are now guaranteed to fulfill this property
after the runtime/codegen patches.

Also fixes explicit shape array extent lowering when instantiating
variables to deal with negative extent cases (issue found while testing
LBOUND edge case). This notably caused allocation crashes when dealing
with automatic arrays with reversed bounds or negative size
specification expression. The standard specifies that the extent of such
arrays is zero. This change has some ripple effect in the current lit
tests.

Add move two helpers as part of this change:
- Add a helper to tell if a fir::ExtendedValue describes an assumed size
  array (last dimension extent is unknown to the compiler, both at compile
  time and runtime).

- Move and share getIntIfConstant from Character.cpp so that it can be
  used elsewhere (NFC).

Differential Revision: https://reviews.llvm.org/D122467
2022-03-25 18:05:54 +01:00
Peter Klausler 174cabeda5 [flang] Fix cycle-catcher in procedure characterization
The "seenProcs" sets passed as arguments to the procedure and dummy
procedure characterization routines need to be passed by value so that
local updates to those sets do not become permanent.  They are
presently passed by reference and that has led to bogus errors about
recursively defined procedures in testing.

(It might be faster to pass the sets by reference and undo those local
updates in these functions, but that's error-prone, and the performance
difference is not expected to be detectable in practice.)

Differential Revision: https://reviews.llvm.org/D122439
2022-03-25 09:49:55 -07:00
Kiran Chandramohan 7babc8e6cd [Flang] Lower achar intrinsic
The intrinsic returns the character located at the position requested
in the ASCII sequence. The intrinsic is lowered to inline FIR code.

This is part of the upstreaming effort from the fir-dev branch in [1].
[1] https://github.com/flang-compiler/f18-llvm-project

Reviewed By: clementval

Differential Revision: https://reviews.llvm.org/D122480

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-03-25 14:23:32 +00:00
Jean Perier 6daa206b5d [flang][NFC] fix comment typo in SetLowerBound description 2022-03-25 01:32:57 -07:00
Jean Perier d3bc3a0400 [flang][codegen] ensure descriptor lower bounds are LBOUND compliant
Follow-up of https://reviews.llvm.org/D121488 to ensure all descriptors
created inline complies with LBOUND requirement that the lower bound is
`1` when the related dimension extent is zero.

Both fir.xrebox and fir.xembox codegen is updated to enforce this
constraint.

Also upstream the "normalized lower bound" attribute that was added in fir-dev
since embox codegen was upstreamed, it is conflicting with this patch
otherwise.

Differential Revision: https://reviews.llvm.org/D122419
2022-03-25 09:02:57 +01:00
Jean Perier 7f1adbaba9 [flang] Fix LBOUND rewrite on descriptor components
GetLowerBoundHelper rewrite in https://reviews.llvm.org/D121488 was
incorrect with POINTER/ALLOCATABLE components. The rewrite created a
descriptor inquiry to the component symbol only instead of the whole
named entity. The base information was lost, and not retrievable.
LBOUND(a(10)%p) became LBOUND(p).

Fix this regression, and also update DescriptorInquiry unparsing to
carry the kind information. DescriptorInquiries are KIND 8 expressions,
while LBOUND/SIZE/RANK, %LEN are default kind expressions.
This caused `print *,lbound(x,kind=8)` to unparse as `print*,lbound(x)` which is not
semantically the same (this unparsing issue was not an issue for
lowering, but I noticed it while writing my regression test).

Differential Revision: https://reviews.llvm.org/D122406
2022-03-25 09:00:56 +01:00
Valentin Clement 50354558a7
[flang] Lower mvbits intrinsic
This patch adds the lowering for the `mvbits`
intrinsic.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122412

Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2022-03-25 08:01:27 +01:00
Peter Steinfeld df209b8038 [flang] Make not yet implemented messages more consistent
To make it easier to find things that are not yet implemented, I'm changing the
messages that appear in the compiler's output to all have the string "not yet
implemented:".

These changes apply to files in the front end.  I have another set of changes
to files in the lowering code.

Differential Revision: https://reviews.llvm.org/D122355
2022-03-24 15:19:40 -07:00
Valentin Clement a80bf18565
[flang][NFC] Remove unused variable 2022-03-24 20:43:11 +01:00
Valentin Clement 44b0ea44f2
[flang[OpenACC] Lower wait directive
This patch adds lowering for the `!$acc wait` directive
from the PFT to OpenACC dialect.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122399
2022-03-24 17:15:27 +01:00
Valentin Clement 5ee88e0ba5
[flang[OpenACC] Lower data directive
This patch adds lowering for the `!$acc data`
from the PFT to OpenACC dialect.

This patch is part of the upstreaming effort from fir-dev branch.

Depends on D122384

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122398
2022-03-24 15:30:31 +01:00
Valentin Clement c6a9ce2b6b
[flang][OpenACC] Lower update directive
This patch adds lowering for the `!$acc update`
from the PFT to OpenACC dialect.

This patch is part of the upstreaming effort from fir-dev branch.

Depends on D122387

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122396
2022-03-24 15:19:05 +01:00
Valentin Clement 39157b98fd
[flang][OpenACC] Lower init/shutdown directive
This patch adds lowering for the `!$acc init` and `!$acc shutdown`
from the PFT to OpenACC dialect.

This patch is part of the upstreaming effort from fir-dev branch.

Depends on D122384

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122387
2022-03-24 15:18:09 +01:00
Valentin Clement 67defe5067
[flang][OpenACC] Lower exit data directive
This patch adds lowering for the `!$acc exit data` directive
from the PFT to OpenACC dialect.

This patch is part of the upstreaming effort from fir-dev branch.

Depends on D122384

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122386
2022-03-24 15:15:56 +01:00
Valentin Clement 12d22cea73
[flang][OpenACC] Lower enter data directive
This patch adds lowering for the `!$acc enter data` directive
from the PFT to OpenACC dialect.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122384
2022-03-24 15:01:05 +01:00
Valentin Clement 30b4421a74
[flang][NFC] Add lowering test for array expression
This patches adds lowering tests for some array
expressions use cases.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122380

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-03-24 14:59:33 +01:00
Peixin-Qiao 6ce82eae1f [NFC][flang] Remove unused code in lowerExplicitLowerBounds
There is no need to lower the implicit lower bounds for assumed-shape
array in lowerExplicitLowerBounds. Remove the unused code.

Reviewed By: Jean Perier

Differential Revision: https://reviews.llvm.org/D122280
2022-03-24 16:50:38 +08:00
Jean Perier ca46521a4d [flang] UBOUND() edge case: empty dimension
Similarly to LBOUND in https://reviews.llvm.org/D121488, UBOUND must
return zero for an empty dimension, no matter the specification
expression.

Add a GetUBOUND method to be used in expression rewrite that prevents
folding UBOUND to a bound specification expression if the extent is
not a compile time constant.

Fold the case where the extents is known to be zero (and also deal with
this case in LBOUND since we can and should to comply with constant
expression requirements).

Differential Revision: https://reviews.llvm.org/D122242
2022-03-24 09:07:15 +01:00
Nimish Mishra 88d5289fc6 [flang][OpenMP] Added lowering support for sections construct
This patch adds lowering support (from PFT to FIR) for sections construct

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D122302
2022-03-24 13:29:38 +05:30
Shraiysh Vaishay cd28353e3f [flang] Single construct translation from PFT to FIR
This patch adds translation for single construct along with nowait
clause from PFT to FIR.

Allocate clause is added as a TODO as handleAllocateClause is added in
D122302.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D122324
2022-03-24 12:00:44 +05:30
Kiran Chandramohan cf198e927d [Flang][NFC] Rearrange intrinsic generator functions
This patch rearranges the generator functions for various intrinsics.
The rearrangement will help to identify any missing functionality.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122334
2022-03-24 02:03:12 +00:00
Valentin Clement d3ebefb154
[flang][NFC] Add forall lowering test
Add test for forall lowering use case.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122356

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-03-24 00:09:57 +01:00
Valentin Clement b914efc529
[flang][NFC] Add more lowering tests
This patch adds more lowering tests from the PFT to FIR.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122354

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-03-24 00:09:06 +01:00
Valentin Clement 00cc73044d
[flang][NFC] Add lowering tests for interfaces
This patch adds lowering tests for Fortran
interfaces.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122326

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-03-23 23:02:44 +01:00
Valentin Clement e847374e19
[flang][NFC] Add derived type lowering tests
Add more use cases of lowering of derived types.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122329

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Peter Steinfeld <psteinfeld@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2022-03-23 23:00:02 +01:00
Roger Ferrer Ibanez d2663fcc39 [flang][Evaluate] Fold DBLE
We can reuse the folding of REAL.

Differential Revision: https://reviews.llvm.org/D122214
2022-03-23 17:27:05 +00:00
Valentin Clement b38e78cc44
[flang][NFC] Add module lowering tests
This patch adds test for the lowering of Fortran modules.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122317

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-03-23 17:51:09 +01:00
Valentin Clement 850de56b06
[flang][NFC] Add nested where lowering test
this patch adds lowering tests for
netsed where statements

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122323

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-03-23 17:04:18 +01:00
Valentin Clement e539faced8
[flang][NFC] Add global lowering tests
This patch adds some lowering tests for globals.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122322

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-03-23 17:02:15 +01:00
Valentin Clement 3ea6727e33
[flang][NFC] Add IO related lowering tests
This patch adds lowering tests for IO related use cases.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122321

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-03-23 16:54:03 +01:00
Valentin Clement dd3e54213c
[flang][NFC] Add namelist lowering test
This patch adds a lowering test for the namelist.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122318

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Peter Steinfeld <psteinfeld@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2022-03-23 16:52:44 +01:00
Kiran Chandramohan 7a9891c598 [Flang] Lower sin, cos intrinsics
The intrinsic computes the sin, cosine values. By default they are lowered
to runtime calls to the pgmath library, for llvm lowering they are
lowered to llvm intrinsics. The generic and llvm lowering does not
lower floating point types with kind greater than 8, the llvm lowering
does not support the complex types.

This is part of the upstreaming effort from the fir-dev branch in [1].
[1] https://github.com/flang-compiler/f18-llvm-project

Reviewed By: clementval

Differential Revision: https://reviews.llvm.org/D122320

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-03-23 15:20:51 +00:00
Kiran Chandramohan 3d94851735 [Flang] Lower atan, sinh, cosh intrinsics
The intrinsic computes the tan and hyperbolic sin, cosine values. By
default they are lowered to runtime calls to the math library. Not all
types are supported currently. The generic and llvm lowering does not
lower floating point types with kind greater than 8, the llvm lowering
does not support the complex types.

Note: tanh is not present in fir-dev hence ignoring for now. We can add
support after upstreaming is complete. sin and cos will come in separate
patches since they have llvm intrinsic lowering.

This is part of the upstreaming effort from the fir-dev branch in [1].
[1] https://github.com/flang-compiler/f18-llvm-project

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122264

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: William Moses <gh@wsmoses.com>
2022-03-23 14:46:41 +00:00
Valentin Clement c1e7296354
[flang][NFC] Add character lowering tests
This patch some lowering tests for characters related operations.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122310

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2022-03-23 15:28:29 +01:00
Valentin Clement e28e1b4b6d
[flang][NFC] Add call lowering tests
This patch adds various lowering test
for calls.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122306

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Mats Petersson <mats.petersson@arm.com>
2022-03-23 15:27:17 +01:00
Valentin Clement ac4c0d6431
[flang][NFC] Add misc lowering tests
This patch adds some lowering tests.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122308

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-03-23 15:24:40 +01:00
Valentin Clement dfb31a28ff
[flang] Add lowering C interoperability test
This patch adds a lowering test for the C
interoperability.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122307

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-03-23 15:23:34 +01:00
Danny Mösch a749e3295d Replace links to archived mailing lists by links to Discourse forums 2022-03-23 10:10:20 -04:00
Valentin Clement 2985d1c267
[flang][NFC] Fix lowering tests indent
Remove 2 spaces indent that was introduced by mistake
when upstreaming these files.
2022-03-23 09:24:18 +01:00
Shraiysh Vaishay 51433662e2 [flang] Flush and master constructs
This patch adds tests for flush and master constructs

This is part of the upstreaming effort from the fir-dev branch in [1].
[1] https://github.com/flang-compiler/f18-llvm-project

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D122250

Co-authored By: Sourabh Singh Tomar <SourabhSingh.Tomar@amd.com>
2022-03-23 10:04:46 +05:30
Shraiysh Vaishay b244bba582 [mlir][OpenMP] Added assembly format for omp.wsloop and remove parseClauses
This patch
 - adds assembly format for `omp.wsloop` operation
 - removes the `parseClauses` clauses as it is not required anymore

This is expected to be the final patch in a series of patches for replacing
parsers for clauses with `oilist`.

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D121367
2022-03-23 10:02:02 +05:30
Valentin Clement d8beb2c33d
[flang][NFC] Add forall lowering tests
This patch adds some lowering tests for the `forall` construct.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122253

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-03-22 21:34:59 +01:00
Valentin Clement 3de6b1ce0d
[flang][NFC] Add pointer dummy arguments tests
This patch adds test for calls with POINTER dummy arguments on the caller side.

It also fixes some formatting error that was introduced when upstreaming
the other pointer tests.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122238

Co-authored-by: Jean Perier <jperier@nvidia.com>
2022-03-22 20:57:15 +01:00
Peter Klausler bafbae238a [flang] Initial UTF-8 support in runtime I/O
Implements UTF-8 encoding and decoding for external units
with OPEN(ENCODING='UTF-8').  This encoding applies to default
CHARACTER values that are not 7-bit ASCII as well as to
the wide CHARACTER kinds 2 and 4.  Basic testing is in place
via direct calls to the runtime I/O APIs, but serious checkout
awaits lowering support of the wide CHARACTER kinds.

Differential Revision: https://reviews.llvm.org/D122038
2022-03-22 11:48:14 -07:00
Peter Klausler 54d19ba208 [flang] Fix crash: ENTRY with generic interface of the same name
Name resolution was crashing while processing the ENTRY statement
due to a lack of special-case code necessary to handle the indirection
needed when the generic has the same name as the ENTRY.

Differential Revision: https://reviews.llvm.org/D122050
2022-03-22 11:10:30 -07:00
Valentin Clement 74f992929e
[flang][NFC] Remove unused variable
Fix for buildbot failure shown after fe252f8ed6
2022-03-22 16:13:03 +01:00