Commit Graph

3600 Commits

Author SHA1 Message Date
Shraiysh Vaishay 9fb52cb3f1 [MLIR][OpenMP] Added omp.atomic.read and omp.atomic.write
This patch supports the atomic construct (read and write) following
section 2.17.7 of OpenMP 5.0 standard. Also added tests and
verifier for the same.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D111992
2021-10-27 14:05:44 +05:30
River Riddle 4283168603 Fix AffineDemotion pass after the DialectConversion change in D111620 2021-10-27 04:13:18 +00:00
Valentin Clement 9daec09551
[fir] Avoid slice with substr in fir.array_load, fir.array_coor and fir.array_merge_store
Substring information on slice operation has been added in D112441.
The operations fir.array_load, fir.array_coor and fir.array_merge_store can take
a slice but not with a substring. This patch add this check in their verifier.

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

Reviewed By: schweitz

Differential Revision: https://reviews.llvm.org/D112568
2021-10-26 21:44:25 +02:00
Valentin Clement d43f779f82
[fir][NFC] Move RewritePatterns.td to CanonicalizationPatterns.td in Dialect
RewritePatterns.td/RewritePatterns.inc is used only by the
FIROps.cpp file. This patch move this file logically in the Dialect
folder together with FIRDialet, FIROps, FIRTypes ...
It also rename it to CanonicalizationPatterns.td.

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

Reviewed By: schweitz

Differential Revision: https://reviews.llvm.org/D112522
2021-10-26 21:12:54 +02:00
Valentin Clement 1189d97d12
[fir][NFC] Fix indentation for fir.alloca builders 2021-10-26 14:55:47 +02:00
Valentin Clement 7812f510d2
[fir] Add substring to fir.slice operation
This patch adds the substriing information to the fir.slice
operation. This will be used by character operations in later
upstreaming patches.

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

Reviewed By: jeanPerier

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2021-10-26 10:33:40 +02:00
Mike Rice d8699391a4 [OPENMP51]Initial parsing/sema for append_args clause for 'declare variant'
Adds initial parsing and sema for the 'append_args' clause.

Note that an AST clause is not created as it instead adds its values
to the OMPDeclareVariantAttr.

Differential Revision: https://reviews.llvm.org/D111854
2021-10-25 09:38:50 -07:00
Valentin Clement 608eb3d9c2
[fir][NFC] Format and make FIROps.td homogenous
This patch has couple of small changes to clean-up FIROps.td.
- Wrap lines that are longer than 80.
- All parser, verifier and printer that are single line are wrapped with double
  quotes.
- Couple of small typos.

Reviewed By: AlexisPerry

Differential Revision: https://reviews.llvm.org/D112436
2021-10-25 18:36:38 +02:00
Valentin Clement 84486cb222
[fir][NFC] Move MLIR includes to FIRDialect.td
The fir_Dialect definition was coming silently through FIRTypes.td.
Make the include of flang/Optimizer/Dialect/FIRDialect.td explicit in
FIROps.td and move MLIR includes to FIRDialect.td.

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

Reviewed By: AlexisPerry

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2021-10-25 18:33:46 +02:00
peter klausler fc3f92a8f4 [flang] Fix buildbot (new warnings on old code)
The clang-aarch64-full-2stage buildbot is complaining about a
warning with three instances in f18 code (none modified recently).
The warning is for using the | bitwise OR operator on bool operands.

In one instance, the bitwise operator was being used instead of the
logical || operator in order to avoid short-circuting.  The fix
requires using some temporary variables.  In the other two instances,
the bitwise operator seemed more idiomatic in context, but can be
replaced without harm with the logical operator.

Pushing without review as confidence is high and nobody wants
a buildbot to stay sad for long.
2021-10-22 17:52:32 -07:00
peter klausler b83242e20e [flang] Support legacy usage of 'A' edit descriptors for integer & real
The 'A' edit descriptor once served as a form of raw I/O of bytes
to/from variables that weren't of type CHARACTER (which itself
didn't exist until F'77).  This usage was especially common for
output of numeric variables that had been initialized with Hollerith.

Differential Revision: https://reviews.llvm.org/D112346
2021-10-22 16:02:33 -07:00
peter klausler 89a927c678 [flang] Fix NAMELIST input bug with multiple subscript triplets
NAMELIST input can contain array subscripts with triplet notation.
The calculation of the default effective stride for the constructed
array descriptor was simply incorrect after the first dimension.

Differential Revision: https://reviews.llvm.org/D112347
2021-10-22 15:59:28 -07:00
peter klausler f6aac0dd4d [flang] Fix DOT_PRODUCT for logical
A build-time check in a template class instantiation was applying
a test that's meaningful only for numeric types.

Differential Revision: https://reviews.llvm.org/D112345
2021-10-22 15:56:20 -07:00
peter klausler fbb020fb48 [flang] Extension: allow tabs in output format strings
A CHARACTER variable used as an output format may contain
unquoted tab characters, which are treated as if they had
been quoted.  This is an extension supported by all other
Fortran compilers to which I have access.

Differential Revision: https://reviews.llvm.org/D112350
2021-10-22 15:53:29 -07:00
peter klausler ce71f8e017 [flang] Fix crash on empty formatted external READs
ExternalFileUnit::BeginReadingRecord() must be called at least once
during an external formatted READ statement before FinishReadingRecord().
In the case of a formatted external READ with no data items, the call
to finish processing of the format (which might have lingering control
items that need doing) was taking place before the call to BeginReadingRecord
from ExternalIoStatementState::EndIoStatement.  Add a call to
BeginReadingRecord on this path.

Differential Revision: https://reviews.llvm.org/D112351
2021-10-22 15:48:45 -07:00
Peter Klausler a5a493e192 [flang] Speed common runtime cases of DOT_PRODUCT & MATMUL
Look for contiguous numeric argument arrays at runtime and
use specialized code for them.

Differential Revision: https://reviews.llvm.org/D112239
2021-10-22 14:36:13 -07:00
peter klausler 14b90d1fe0 [flang] Fix generic resolution case
Don't try to convert INTEGER argument expressions to the kind of
the dummy argument when performing generic resolution; specific
procedures may be distinguished only by their kinds.

Differential Revision: https://reviews.llvm.org/D112240
2021-10-22 13:38:47 -07:00
peter klausler b8452dba28 [flang] Support NAMELIST input of short arrays
NAMELIST array input does not need to fully define an array.
If another input item begins after at least one element,
it ends input into the array and the remaining items are
not modified.

The tricky part of supporting this feature is that it's not
always easy to determine whether the next non-blank thing in
the input is a value or the next item's name, esp. in the case
of logical data where T and F can be names.  E.g.,

  &group logicalArray = t f f t
      = 1 /

should read three elements into "logicalArray" and then read
an integer or real variable named "t".

So the I/O runtime has to do some look-ahead to determine whether
the next thing in the input is a name followed by '=', '(', or '%'.
Since the '=' may be on a later record, possibly with intervening
NAMELIST comments, the runtime has to support a general form of
saving and restoring its current position.  The infrastructure
in the I/O runtime already has to support repositioning for
list-directed repetition, even on non-positionable input sources
like terminals and sockets; this patch adds an internal RAII API
to make it easier to save a position and then do arbitrary
look-ahead.

Differential Revision: https://reviews.llvm.org/D112245
2021-10-22 13:38:11 -07:00
peter klausler c4ba1108dd [flang] Extension to distinguish specific procedures
Allocatable dummy arguments can be used to distinguish
two specific procedures in a generic interface when
it is the case that exactly one of them is polymorphic
or exactly one of them is unlimited polymorphic.  The
standard requires that an actual argument corresponding
to an (unlimited) polymorphic allocatable dummy argument
must also be an (unlimited) polymorphic allocatable, so an
actual argument that's acceptable to one procedure must
necessarily be a bad match for the other.

Differential Revision: https://reviews.llvm.org/D112237
2021-10-22 12:38:21 -07:00
peter klausler f2360e1156 [flang] Enforce rest of semantic constraint C919
A reference to an allocatable or pointer component must be applied
to a scalar base object.  (This is the second part of constraint C919;
the first part is already checked.)

Differential Revision: https://reviews.llvm.org/D112241
2021-10-22 11:35:58 -07:00
peter klausler b03628d986 [flang] Emit unformatted headers & footers even with RECL=
The runtime library was emitting unformatted record headers and
footers when an external unit had no fixed RECL=.  This is wrong
for sequential files, which should have headers & footers even
with RECL.  Change to omit headers & footers from unformatted
I/O only for direct access files.

Differential Revision: https://reviews.llvm.org/D112243
2021-10-22 11:07:01 -07:00
peter klausler d5074c7166 [flang] Fix bogus folding error for ISHFT(x, negative)
Negative shift counts are of course valid for ISHFT when
shifting to the right.  This patch decouples the folding of
ISHFT from that of SHIFTA/L/R and adds tests.

Differential Revision: https://reviews.llvm.org/D112244
2021-10-22 10:38:27 -07:00
Andrzej Warzynski 3085e67851 [Flang][docs] Remove an out-dated section on the new driver
This section of the documentation should've been deleted in:
https://reviews.llvm.org/D105811

I am submitting this without a review as it's an obvious omission.
2021-10-22 14:44:24 +00:00
Valentin Clement a2e7af7516
[fir] Add utility function to FIRBuilder and MutableBox
This patch is extracted from D111337 to make is smaller.
It introduce utility functions to the FIRBuilder and add the MutableBox
files.

- genShape
- readCharLen
- getExtents

Reviewed By: kiranchandramohan

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2021-10-22 10:00:34 +02:00
Valentin Clement 0bf230d422
[fir] Remove unused function in CharacterTest 2021-10-22 00:25:59 +02:00
Valentin Clement 2ba572a82a
[fir] Remove createConcatenate test temporarily
This test is makeing one buildbot fail for unknown reason. Remove
it until we can investifate further.
2021-10-21 22:40:19 +02:00
Valentin Clement 13c31539f7
[fir] Add Character helper
This patch is extracted from D111337. It introduce the
CharacterExprHelper that helps dealing with character in FIR.

Reviewed By: schweitz, awarzynski

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2021-10-21 18:45:32 +02:00
Valentin Clement 7bbd7e9c1d
Revert "[fir] Add Character helper"
This reverts commit e4ce92245c.

Buildbots not happy with the tests.
2021-10-21 11:36:10 +02:00
Valentin Clement e4ce92245c
[fir] Add Character helper
This patch is extracted from D111337. It introduce the
CharacterExprHelper that helps dealing with character in FIR.

Reviewed By: schweitz, awarzynski

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2021-10-21 09:48:37 +02:00
Valentin Clement 676d091c63
Revert "[fir] Add Character helper"
This reverts commit 02d7089c23.
2021-10-20 22:43:13 +02:00
Valentin Clement 02d7089c23
[fir] Add Character helper
This patch is extracted from D111337. It introduce the
CharacterExprHelper that helps dealing with character in FIR.

Reviewed By: schweitz, awarzynski

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2021-10-20 21:35:02 +02:00
Josh Mottley e9fe8ef4b0 [flang] flang-omp-report replace std::map with llvm::DenseMap
This patch replaces the uses of std::map with llvm::DenseMap in the
flang-omp-report plugin. It also removed the 'constructClauseCount' map
due to no longer being needed after the plugin was stripped down.
This is a one of several patches focusing on switching containers from STL to LLVM's ADT library.

Reviewed By: kiranchandramohan, clementval

Differential Revision: https://reviews.llvm.org/D111977
2021-10-20 07:57:04 +00:00
Josh Mottley 660c511e5b [Flang][flang-omp-report] Switch from std::string to StringRef (where possible)
This patch makes the following changes to flang-omp-report:
 - Update 'normalize_clause_name' parameter to use llvm::StringRef instead of
   std::sting.
 - Change usages of std::tolower to llvm::toLower from
   "ADT/StringExtras.h".
This is a one of several patches focusing on switching containers from STL to LLVM's ADT library.

Reviewed By: Leporacanthicus, clementval

Differential Revision: https://reviews.llvm.org/D111980
2021-10-20 07:55:44 +00:00
Valentin Clement c983aeddcf
[fir] Add character utility functions in FIRBuilder
Extract part of D111337 in order to mke it smaller
and easier to review. This patch add some utility
functions to the FIRBuilder.

Add the following utility functions:
- getCharacterLengthType
- createStringLiteral
- locationToFilename
- characterWithDynamicLen
- sequenceWithNonConstantShape
- hasDynamicSize

These bring up the BoxValue implementation together with it.

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

Reviewed By: AlexisPerry

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2021-10-19 22:34:21 +02:00
Valentin Clement 45503fc044
[fir] Add FIRBuilder utility functions
Extract some code from the big ptach D111337. This patch
contains some utility functions from the FIRBuidler.

List of utility functions added:
- getRegion
- getModule
- getKindMap
- getRefType
- getVarLenSeqTy
- getRealType
- createNullConstant
- createRealConstant
- createRealZeroConstant
- createGlobal
- createGlobalConstant
- createStringLitOp
- getNamedFunction
- getNamedGlobal
- createFunction
- addNamedFunction
- createBool

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

Reviewed By: kiranchandramohan

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2021-10-19 14:19:45 +02:00
peter klausler 2f80b73e0c [flang] Fold BTEST
Implements constant folding for BTEST intrinsic function.

Differential Revision: https://reviews.llvm.org/D111849
2021-10-18 13:46:46 -07:00
Valentin Clement f17f694a0f
[fir] Add IfBuilder and utility functions
In order to reduct the size of D111337. The IfBuilder and the two
utility functions genIsNotNull and genIsNull have been extracted in
a separate patch with dedicated unittests.

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

Reviewed By: Leporacanthicus

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2021-10-17 20:55:41 +02:00
PeixinQiao dd8c8d4b7c This patch supports the following checks for THREADPRIVATE Directive:
```
[5.1] 2.21.2 THREADPRIVATE Directive
A variable that appears in a threadprivate directive must be declared in
the scope of a module or have the SAVE attribute, either explicitly or
implicitly.
A variable that appears in a threadprivate directive must not be an
element of a common block or appear in an EQUIVALENCE statement.
```

This patch supports the following checks for DECLARE TARGET Directive:
```
[5.1] 2.14.7 Declare Target Directive
A variable that is part of another variable (as an array, structure
element or type parameter inquiry) cannot appear in a declare
target directive.
A variable that appears in a declare target directive must be declared
in the scope of a module or have the SAVE attribute, either explicitly
or implicitly.
A variable that appears in a declare target directive must not be an
element of a common block or appear in an EQUIVALENCE statement.
```

As Fortran 2018 standard [8.5.16] states, a variable, common block, or
procedure pointer declared in the scoping unit of a main program,
module, or submodule implicitly has the SAVE attribute, which may be
confirmed by explicit specification.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D109864
2021-10-17 22:08:02 +08:00
peter klausler 0fcda9ae57 [flang] Admit NULL() in generic procedure resolution cases
Semantics is rejecting valid programs with NULL() actual arguments
to generic interfaces, including user-defined operators.  Subclause
16.9.144(para 6) makes clear that NULL() can be a valid actual
argument to a generic interface so long as it does not produce
ambiguity.  This patch handles those cases, revises existing
tests, and adjust an error message about NULL() operands to
appear less like a blanket prohibition.

Differential Revision: https://reviews.llvm.org/D111850
2021-10-14 16:02:17 -07:00
peter klausler 6965a776ee [flang] Fold LGE/LGT/LLE/LLT intrinsic functions
Fold the legacy intrinsic functions LGE, LGT, LLE, & LLT
by rewriting them into character relational expressions and
then folding those.  Also fix folding of comparisons of
character values of distinct lengths: the shorter value must
be padded with blanks.  (This fix exposed some bad test cases,
which are also fixed.)

Differential Revision: https://reviews.llvm.org/D111843
2021-10-14 15:24:03 -07:00
peter klausler 1062f989af [flang] Expunge bogus semantic check for ELEMENTAL without dummies
Semantics refuses valid ELEMENTAL subprograms without dummy arguments,
but there's no such constraint in the standard; indeed, subclause
15.8.2 discusses the meaning of calls to ELEMENTAL functions with
arguments.  Remove the check and its test.

Differential Revision: https://reviews.llvm.org/D111832
2021-10-14 14:33:30 -07:00
Mogball cb3aa49ec0 [MLIR][arith] fix references to std.constant in comments
Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D111820
2021-10-14 20:38:47 +00:00
Josh Mottley 0b48b015b5 [Flang] flang-omp-report replace std::vector's with llvm::SmallVector
This patch replaces all uses of std::vector with llvm::SmallVector in the flang-omp-report plugin.
This is a one of several patches focusing on switching containers from STL to LLVM's ADT library.

Reviewed By: Leporacanthicus

Differential Revision: https://reviews.llvm.org/D111709
2021-10-14 11:05:24 +01:00
Valentin Clement 0fbd3aad75
[fir] Remove unused variable in FIRBuilder.h
Remove unsused variable that break Werror on some buildbots
2021-10-14 07:11:41 +02:00
Eric Schweitz bde89ac7f1
[fir] Add the DoLoopHelper
Add the DoLoopHelper. Some helpers functions
to create fir.do_loop operations.

This code was part of D111337 and was extracted in order to
make the patch easier to review.

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

Reviewed By: kiranchandramohan

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

Co-authored-by: Valentin Clement <clementval@gmail.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2021-10-13 21:48:45 +02:00
Mike Rice fb4c451001 [OPENMP51]Initial parsing/sema for adjust_args clause for 'declare variant'
Adds initial parsing and sema for the 'adjust_args' clause.

Note that an AST clause is not created as it instead adds its expressions
to the OMPDeclareVariantAttr.

Differential Revision: https://reviews.llvm.org/D99905
2021-10-13 09:34:09 -07:00
Valentin Clement b2169992aa
[fir][NFC] Add disclaimer to affine promotion/demotion passes
AffinePromotion and AffineDemotion passes where upstreamed
in their current status from fir-dev. In order to make sure everybody
is on the same page, this patch add some comments to state that.

Reviewed By: schweitz

Differential Revision: https://reviews.llvm.org/D111629
2021-10-13 17:47:14 +02:00
Diana Picus fc2ba5e53d [flang] Implement GET_ENVIRONMENT_VARIABLE(LENGTH)
Search for the environment variable in the envp string passed to
ProgramStart. This doesn't work if the main program isn't Fortran.

Differential Revision: https://reviews.llvm.org/D111394
2021-10-13 08:42:03 +00:00
Valentin Clement 665970d421
[fir][NFC] Remove unused variable 2021-10-13 10:40:38 +02:00
Valentin Clement 80bdf9c180
Revert "[fir] Update clang-tidy for the Optimizer directory"
This reverts commit edec659f48.
2021-10-13 09:29:54 +02:00