Commit Graph

4917 Commits

Author SHA1 Message Date
Dominik Adamski cc8c746f8d [NFC][Flang] Add simd collapse test case
Flang supports lowering collapse clause to MLIR for worksharing loops
and simd loops. Simd collapse clause is represented in MLIR code as a
simd-loop having a list of indices, bounds and steps where the size of the list
is equal to the collapse value.

Support for simd collapse clause was added by several patches:
https://reviews.llvm.org/D118065 -> basic support for simd-loop in MLIR.
                                    Loop collapsing is done in the same way as
                                    for worksharing loops:
                                    https://reviews.llvm.org/D105706
https://reviews.llvm.org/D125282 -> support for lowering simd clause from
                                    Fortran into MLIR
https://reviews.llvm.org/D125302 -> lowering collapse clause from Fortran to
                                    MLIR. Lowering collapse clause is done
                                    before simd-specific function is called.
https://reviews.llvm.org/D128338 -> modified the MLIR representation of
                                    collapse clause. Removed collapse keyword
                                    in OpenMP MLIR dialect. Use loop list to
                                    represent collapse clause. This loop list
                                    is created by changes from patch:
                                    https://reviews.llvm.org/D125302 and it is
                                    passed to function responsible for lowering
                                    of simd directive which was implemented in
                                    patch: https://reviews.llvm.org/D125282

Reviewed By: kiranchandramohan

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

Signed-off-by: Dominik Adamski <dominik.adamski@amd.com>
2022-08-17 07:42:22 -05:00
Mats Petersson 726786083f [flang]Avoid asking for operands when there are none
Fix one encountered (issue #57072) and two potential scenarios where the
code would ask for an operand that isn't there.

Add test for the encountered case.

Reviewed By: vzakhari

Differential Revision: https://reviews.llvm.org/D131671
2022-08-17 12:31:42 +01:00
Rainer Orth bcb2740f41 [flang] Add Solaris/x86 support to Optimizer/CodeGen/Target.cpp
When testing LLVM 15.0.0 rc1 on Solaris, I found that 50+ flang tests
`FAIL`ed with

  error:
/vol/llvm/src/llvm-project/local/flang/lib/Optimizer/CodeGen/Target.cpp:310:
not yet implemented: target not implemented

This patch fixes that for Solaris/x86, where the fix is trivial (just
handling it like the other x86 OSes).

Tested on `amd64-pc-solaris2.11`; only a single failure remains now.

Differential Revision: https://reviews.llvm.org/D131054
2022-08-17 11:54:38 +02:00
David Blaikie fe7450b34d Revert "flang: Fix flang build with -Wctad-maybe-unsupported"
-Wctad-maybe-unsupported is now disabled for flang so these explicit
deduction guides are not required.

This reverts commit 248591aabe.
2022-08-16 17:43:40 +00:00
David Blaikie e2333b5550 Revert "Some more from-the-hip ctad-maybe-unsupported fixes for flang"
-Wctad-maybe-unsupported is now disabled for flang so these explicit
deduction guides are not required.

This reverts commit ec3956b6e6.
2022-08-16 17:43:08 +00:00
David Blaikie 357e99aff0 Disable -Wctad-maybe-unsupported in flang since it already uses the feature a lot 2022-08-16 17:42:45 +00:00
David Blaikie ec3956b6e6 Some more from-the-hip ctad-maybe-unsupported fixes for flang 2022-08-16 16:03:49 +00:00
David Blaikie 248591aabe flang: Fix flang build with -Wctad-maybe-unsupported
Shooting from the hip since I don't have a flang build locally, but
hopefully this works.
2022-08-16 01:08:17 +00:00
Valentin Clement 26d3655a15
[flang][docs] Add lowering design doc for polymorphic entities
This document aims to give insights at the representation of polymorphic
entities in FIR and how polymorphic related constructs and features are lowered
to FIR.

Reviewed By: klausler, razvanlupusoru

Differential Revision: https://reviews.llvm.org/D131515
2022-08-15 18:13:15 +02:00
Slava Zakharin 56eda98f0c [flang] Handle mixed types in DOT_PRODUCT simplification.
Fortran runtime supports mixed types by casting the loaded values
to the result type, so DOT_PRODUCT simplification has to do the same.

Differential Revision: https://reviews.llvm.org/D131726
2022-08-15 09:03:38 -07:00
Valentin Clement e114ecc5fe
[flang][openacc][NFC] Add test with allocatable and pointer arrays
This patch adds tests for the handling of array sections for
arrays with the ALLOCATABLE or POINTER attribute.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D131885
2022-08-15 16:45:08 +02:00
Diana Picus 467abac204 [flang] Install runtime libs with the toolchain
Make sure that FortranDecimal, FortranRuntime and Fortran_main are
installed/packaged even when LLVM_INSTALL_TOOLCHAIN_ONLY is enabled.
They are used by flang to link executables, so they should be provided
even with minimal installs.

Differential Revision: https://reviews.llvm.org/D131670
2022-08-15 07:43:47 +00:00
Kazu Hirata a8c294d6aa [flang] Remove redundant string initialization (NFC)
Identified with readability-redundant-string-init.
2022-08-14 12:52:01 -07:00
Valentin Clement 83fa975679
[flang][openacc] Handle array section and derived-type components operands
This patch lowers correctly operands with array section
and derived-type component.

Depends on D131764

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D131765
2022-08-13 20:40:31 +02:00
Jeff Niu 58a47508f0 (Reland) [mlir] Switch segment size attributes to DenseI32ArrayAttr
This reland includes changes to the Python bindings.

Switch variadic operand and result segment size attributes to use the
dense i32 array. Dense integer arrays were introduced primarily to
represent index lists. They are a better fit for segment sizes than
dense elements attrs.

Depends on D131801

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D131803
2022-08-12 19:44:52 -04:00
Valentin Clement 8fc00247ce
[flang] Pass SemanticsContext to the LoweringBridge
The SemanticsContext is needed to analyze expression later in the
lowering for directive languages. This patch allows to keep a reference of
the SemanticsContext in the LoweringBridge.

Building block for D131765

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D131764
2022-08-12 21:23:05 +02:00
Nimish Mishra 435feefbdd [flang][OpenMP] Lowering support for default clause
This patch adds lowering support for default clause.

1. During symbol resolution in semantics, should the enclosing context
   have a default data sharing clause defined and a `parser::Name` is not
   attached to an explicit data sharing clause, the
   `semantics::Symbol::Flag::OmpPrivate` flag (in case of
   default(private)) and `semantics::Symbol::Flag::OmpFirstprivate` flag
   (in case of default(firstprivate)) is added to the symbol.

2. During lowering, all symbols having either
   `semantics::Symbol::Flag::OmpPrivate` or
   `semantics::Symbol::Flag::OmpFirstprivate` flag are collected and
   privatised appropriately.

Co-authored-by: Peixin Qiao <qiaopeixin@huawei.com>

Reviewed by: peixin

Differential Revision: https://reviews.llvm.org/D123930
2022-08-12 16:46:26 +05:30
Nimish Mishra 30b779d515 Revert "[flang][OpenMP] Lowering support for default clause"
This reverts commit 6a305c9b49.
2022-08-12 16:45:38 +05:30
Nimish Mishra 6a305c9b49 [flang][OpenMP] Lowering support for default clause
This patch adds lowering support for default clause.

1. During symbol resolution in semantics, should the enclosing context have
a default data sharing clause defined and a `parser::Name` is not attached
to an explicit data sharing clause, the
`semantics::Symbol::Flag::OmpPrivate` flag (in case of default(private))
and `semantics::Symbol::Flag::OmpFirstprivate` flag (in case of
default(firstprivate)) is added to the symbol.

2. During lowering, all symbols having either
`semantics::Symbol::Flag::OmpPrivate` or
`semantics::Symbol::Flag::OmpFirstprivate` flag are collected and
privatised appropriately.

Co-authored-by: Peixin Qiao <qiaopeixin@huawei.com>

Reviewed by: peixin

Differential Revision: https://reviews.llvm.org/D123930
2022-08-12 22:08:14 +05:30
Alex Zinenko e8e718fa4b Revert "[mlir] Switch segment size attributes to DenseI32ArrayAttr"
This reverts commit 30171e76f0.

Breaks Python tests in MLIR, missing C API and Python changes.
2022-08-12 10:22:47 +02:00
Jeff Niu 30171e76f0 [mlir] Switch segment size attributes to DenseI32ArrayAttr
Switch variadic operand and result segment size attributes to use the
dense i32 array. Dense integer arrays were introduced primarily to
represent index lists. They are a better fit for segment sizes than
dense elements attrs.

Depends on D131738

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D131702
2022-08-11 20:56:45 -04:00
Valentin Clement bdbf89b906
[flang][openacc] Propagate correct location information from directive
Location information was not correctly propagated when creating OpenACC
operations. This patch propagate the correct location information from
the parse tree nodes to OpenACC MLIR operations.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D131659
2022-08-11 20:35:48 +02:00
Jeff Niu 4e0a2bd627 [fir] Fix build 2022-08-11 01:10:33 -04:00
Slava Zakharin 1d5e7a498f [flang] Support DOT_PRODUCT in late inlining.
This change inlines DOT_PRODUCT calls for real and integer types.

Differential Revision: https://reviews.llvm.org/D131538
2022-08-10 16:30:35 -07:00
Naje George 7678db6ef4 [flang] Add semantics test for event_query subroutine
Reviewed By: ktras

Differential Revision: https://reviews.llvm.org/D131211
2022-08-10 13:45:34 -07:00
Jeff Niu 5c5af910fe [mlir][LLVMIR] "Modernize" Insert/ExtractValueOp
This patch "modernizes" the LLVM `insertvalue` and `extractvalue`
operations to use DenseI64ArrayAttr, since they only require an array of
indices and previously there was confusion about whether to use i32 or
i64 arrays, and to use assembly format.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D131537
2022-08-10 12:51:11 -04:00
Slava Zakharin 80dcc907a8 [NFC] Restructured SimplifyIntrinsicsPass::getOrCreateFunction.
I would like to add DOT_PRODUCT support in this pass, so this restructuring
is the first step to allow some code reuse inside getOrCreateFunction().

Differential Revision: https://reviews.llvm.org/D131530
2022-08-10 09:40:57 -07:00
Nikita Popov 8d6f61b6ad Revert "[Flang] Use find_program() to find clang-tblgen"
This reverts commit 3bba12a81e.

While this fixes doc generation in standalone flang builds, it
breaks them for combined builds of clang and flang.
2022-08-10 11:39:31 +02:00
Dominik Adamski 98ed6e1069 [Flang][OpenMP] Fix conversion of nested loops for SIMD directive
Flang was not able to convert simd directive which contains nested
Fortran loops. The nested Fortran loops inside SIMD directive
are modelled as FIR loops and they need to be translated into LLVM
MLIR dialect.

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

Reviewed by: peixin

Signed-off-by: Dominik Adamski <dominik.adamski@amd.com>
2022-08-10 03:54:30 -05:00
Nikita Popov 3bba12a81e [Flang] Use find_program() to find clang-tblgen
Use find_program() to find the clang-tblgen executable. The current
code ends up using docs/clang-tblgen for me...

This is the same way that mlir-tblgen is obtained in:
2724143551/flang/CMakeLists.txt (L95-L96).

Differential Revision: https://reviews.llvm.org/D131475
2022-08-10 10:26:36 +02:00
Jeff Niu 65923012b3 [flang] Revert changes (NFC) 2022-08-09 16:10:21 -04:00
Jeff Niu 0af643f3ce [mlir][LLVMIR] (NFC) Add convenience builders for ConstantOp
And clean up some of the user code
2022-08-09 15:34:36 -04:00
Dylan Fleming 9893b26dfa [Flang][OpenMP] Add support for integer multiplication reduction in worksharing-loop
Adds support for reduction of multiplcation
by extending OpenMP.cpp::genOpenMPReduction()
and altering the identity constant emitted in
OpenMP.cpp::createReductionDelc()

This patch builds D130077 and as such,
only supports reductions for interger types in
worksharping loops.

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D130767
2022-08-09 19:22:18 +00:00
Peter Klausler 46c49e66d8 [flang] Extend characterization & checking for procedure bindings
Procedure bindings with explicit interfaces don't work when the
interface is shadowed by a generic interface of the same name,
and can produce spurious semantic error messages.  Extend the
characterization and checking code for such things, and the utility
functionns on which they depend, to dig through generics when they
occlude interface-defining subprograms.  This is done on demand in
checking code, not once during name resolution, because the
procedures in question may also be forward-referenced.

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

diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index e79f8ab6503e..0b03bf06eb73 100644
--- a/flang/include/flang/Semantics/symbol.h
2022-08-09 12:01:45 -07:00
Peter Klausler 79d9918df6 [flang] Fix build warning from newer compilers
Remove a lambda capture of "[this]" in two cases where it
is no longer required.  Will be pushed without waiting for
review if CI is successful in order to resolve a sad build bot.

Differential Revision: https://reviews.llvm.org/D131506
2022-08-09 10:09:20 -07:00
V Donaldson cc71e69459 [flang] Intrinsic RANDOM_SEED calls with dynamically absent/present arguments 2022-08-09 09:08:55 -07:00
Peter Klausler f329cf97f2 [flang] Change names of specific procedures of generic interfaces in intrinsic modules
Intrinsic procedures in intrinsic modules that have (or better, *are*) generic interfaces
must not have specific procedures with the same name according to the Fortran
standard (17.11.1); i.e., a user program is allowed to define a procedure
of the same name as one of these generic interfaces, even when the generic is
in scope.

Differential Revision: https://reviews.llvm.org/D131108
2022-08-09 08:51:59 -07:00
Peter Klausler bad5205595 [flang][runtime] Support internal I/O to CHARACTER(KIND/=1)
Allow internal I/O to support non-default kinds of CHARACTER.

The I/O runtime design anticipated this standard feature, but
this patch is somewhat larger than I thought it would be because
many code sites had to have assumptions about units (characters
vs. bytes) brought into harmony, and some encoding utilities
had to be pulled out of IoStatementState and templatized into
their own new header file so that they are available to formatted
output code without having to "thread" an IoStatementState reference
through many call chains.

Differential Revision: https://reviews.llvm.org/D131107
2022-08-09 08:46:21 -07:00
Peter Klausler 525ff9bd20 [flang] Don't check procedure pointer interface function result specification expressions
When a procedure pointer references a function as its interface, don't
apply semantic checks to the specification expressions that appear in
the declaration of the function's result -- this can lead to bogus
error messages as those specification expressions are being examined
out of their proper context.

Differential Revision: https://reviews.llvm.org/D131106
2022-08-09 08:45:32 -07:00
Peter Klausler 5e8094bae5 [flang] Don't inherit ELEMENTAL attribute from intrinsics for TBP bindings
Type-bound procedure bindings that specify intrinsic procedures as their
interfaces should not acquire the ELEMENTAL attribute from the purposes
of compatibility checking between inherited bindings and their overrides
in extended derived types.

Differential Revision: https://reviews.llvm.org/D131104
2022-08-09 08:09:32 -07:00
Peter Klausler 37a0022aaa [flang] Don't lose homonymous specific when copying generic
Defined generic procedure interfaces are allowed to shadow non-generic
procedures of the same name in the same scope (whether or not
that non-generic procedure is a specific procedure of the generic).
When making a copy of a generic interface symbol so that it can
be locally modified or be merged with another generic, don't forget
about the homonymous non-generic procedure that it might shadow.

Differential Revision: https://reviews.llvm.org/D131103
2022-08-09 07:44:52 -07:00
Peter Klausler e1ee20d574 [flang] Ignore inaccessible components when extending types or constructing structures
Inaccessible components -- those declared PRIVATE in another module -- should
be allowed to be redeclared in extended types, and should be ignored if
they appear as keywords in structure constructors.

Differential Revision: https://reviews.llvm.org/D131102
2022-08-09 07:44:02 -07:00
Valentin Clement 4dece4007c
[flang] Pass the pipeline config to the pass
The newly added AlgebraicSimplification pass is triggering the
greedy pattern rewriter. Since we define a specific config in the
flang pipeline, this patch adds the ability to pass the config
to the pass directly.

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D131474
2022-08-09 16:05:34 +02:00
Peter Klausler 9d084982a3 [flang] Clarify CheckReductionDIM()
This utility routine in constant folding should return false when
a DIM= actual argument to a reduction intrinsic function has a
value that prevents folding, and true when folding can proceed.
The implementation was returning true in cases where a DIM=
argument was present but not constant.

Clarify the code and add commentary: a true result means that
there is no DIM= actual argument present, or that a DIM= argument
exists, is constant, and has a value that is in range.

Differential Revision: https://reviews.llvm.org/D131101
2022-08-09 05:51:45 -07:00
Peter Klausler b8641bfc4c [flang] Don't compute pointer component procedure characteristics when not needed
When a procedure pointer component has an interface that is a forward
reference to a procedure, syntax errors can be emitted if there is
a structure constructor that tries to initialize that component,
since its characteristics are not yet known; however, when the
initializer is a bare NULL(with no mold), those characteristics
don't matter.  Make the characterization of the procedure pointer
component take place only when needed.

Differential Revision: https://reviews.llvm.org/D131100
2022-08-08 15:59:12 -07:00
Michael Kruse 8c0979c8f7 [flang][test] Don't require .exe suffix.
The suffix is only added then the path the (lld-)link.exe is fully
resolved. Otherwise it may stay "link" or "lld-link".

On non-Windows platforms, lld-link also exists as a symbolic link to
lld, such that the full the path to lld-link might also be resolved
without .exe suffix in this case.

Note that CLANG_DEFAULT_LINKER could be set to other linkers such as
mold, in which case the test may still fail. This also applies to the
non-Windows tests that require "ld" in the linker name.

Fixes issue #56955
2022-08-08 16:55:30 -05:00
Slava Zakharin be8bacfd93 [flang] Replace more pgmath with libm.
With this change all supported pgmath functions for non-complex
data types are replaced with either libm calls or MLIR operations,
except for MOD and some flavors of POW, which are going to be addressed
by other commits.

At the current stage a few math intrinsics are lowered into libm calls
always. When appropriate MLIR operation are available, the table can be
updated to generate them.
2022-08-08 10:53:08 -07:00
Tarun Prabhu c1f65df19c [flang] Add an explicit condition for the BITS=0 case in the MASKL and MASKR intrinsics.
This fixes issue #56706.

Differential Revision: https://reviews.llvm.org/D130590
2022-08-08 10:33:49 -06:00
Jeff Niu 00f7096d31 [mlir][math] Rename math.abs -> math.absf
To make room for introducing `math.absi`.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D131325
2022-08-08 11:04:58 -04:00
Dylan Fleming 5784199dd1 [NFC][Flang][OpenMP] Refactor OpenMP.cpp::genOpenMPReduction
This patch serves two main purposes:
Firstly, to split some of the logic into a seperate method
to try and improve readability

On top of this, it aims to make creating the reductions more generic.
That way, subsequent patches adding reductions shouldn't need
to add a significant amount of extra logic checks, such as checking
for specific operators.

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D131161
2022-08-08 14:27:32 +00:00