19 Commits

Author SHA1 Message Date
Jean Perier
6e3292fba5 [flang] Lower parentheses with hlfir.as_expr and hlfir.no_reassoc
Differential Revision: https://reviews.llvm.org/D139523
2022-12-07 14:45:55 +01:00
Kazu Hirata
9a41739565 [flang] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-03 12:14:21 -08:00
Jean Perier
655d994adc [flang] fix unused-but-set-parameter warning in ConvertExprToHLFIR.cpp
Some named value operands are not used yet (TODOs). Some compilers
complain about it. Remove names of unused parameters.

Differential Revision: https://reviews.llvm.org/D139207
2022-12-02 17:57:12 +01:00
Jean Perier
f24466cf62 [flang] Lower conversions to HLFIR
Differential Revision: https://reviews.llvm.org/D139196
2022-12-02 16:19:38 +01:00
Jean Perier
ffdb5f951c [flang] add missing unreachable in D139179
Fix bot failure https://lab.llvm.org/buildbot/#/builders/160/builds/13647
caused by https://reviews.llvm.org/D139179.

Even if the switch is fully covering, adding an unreachable after is
required to cover all path since the switch argument could be a broken
value that does not belong to the enum.
2022-12-02 05:46:22 -08:00
Jean Perier
12c8797fc4 [flang] Lower unary operation to HLFIR
Lower not, negate, and complex component to HLFIR.
Parentheses is the only remaining operation, but needs some
care/thinking to properly deal with character/derived variables.

Differential Revision: https://reviews.llvm.org/D139186
2022-12-02 14:22:41 +01:00
Jean Perier
fed3d272da [flang] Make SetLength TODO explicit in HLFIR
evaluate::SetLength is the last intrinsic binary operation
that needs to be lowered to HLFIR. It will require an hlfir.set_length
op or hlfir.as_expr to convert the result to an expression. Add a TODO
for now.

Differential Revision: https://reviews.llvm.org/D139183
2022-12-02 14:21:27 +01:00
Jean Perier
26ceeee757 [flang] Lower complex constructor to HLFIR
Differential Revision: https://reviews.llvm.org/D139180
2022-12-02 14:20:22 +01:00
Jean Perier
248fcb13be [flang] Lower logical operations to HLFIR
Differential Revision: https://reviews.llvm.org/D139179
2022-12-02 14:19:12 +01:00
Jean Perier
12530711fc [flang] Lower relational to HLFIR
Differential Revision: https://reviews.llvm.org/D139176
2022-12-02 14:18:10 +01:00
Jean Perier
991a90a00d [flang] Lower evaluate::Extremum
Update BinaryOp<T>::gen so that const T& is threaded and some
operation knowledge that is not encoded by the type T or the arguments
can be used. For Extremum, it is the order (Greater or Lesser) that is
required, but this will also be required for evaluate::Relational.

Differential Revision: https://reviews.llvm.org/D139124
2022-12-02 09:29:39 +01:00
Jean Perier
89af7de9de [flang] Lower power to HLFIR
Differential Revision: https://reviews.llvm.org/D139117
2022-12-01 17:49:36 +01:00
Jean Perier
440e9baa62 [flang] Lower add, mul, div, and sub to HLFIR
Only lower operations when the operands are scalar for now.

Differential Revision: https://reviews.llvm.org/D139108
2022-12-01 17:39:53 +01:00
Jean Perier
e78e4a1761 [flang] lower F77 calls in HLFIR
Use recently added hlfir.associate/hlfir.end_associate to deal
with the cases where the actual argument is an expression.

Differential Revision: https://reviews.llvm.org/D139009
2022-12-01 11:22:38 +01:00
Jean Perier
94b9fbabe8 [flang] Lower concatenation to hlfir.concat
Differential Revision: https://reviews.llvm.org/D138664
2022-11-25 09:36:58 +01:00
Jean Perier
07b8927394 [flang] Lower ArrayRef to hlfir.designate
Also add support for fir.boxchar in HLFIRTools so that character
designator with none constant lengths can be processed/converted to
fir::ExtendedValue.

Differential Revision: https://reviews.llvm.org/D138190
2022-11-18 10:09:12 +01:00
Jean Perier
fcfb620db5 [flang][NFC] rename hlfir::FortranEntity into EntityWithAttributes
This reflects the fact that Attributes will not always be visible when
looking at an HLFIR variable. The EntityWithAttributes class is used
to denote in the compiler code that the value at hand has visible
attributes. It is intended to be used in lowering so that the code
can query about operands attributes when generating code.

Differential Revision: https://reviews.llvm.org/D137792
2022-11-14 10:37:16 +01:00
Jean Perier
3952377f71 [flang] lower intrinsic constants to HLFIR
Use the utility to lower Constant<T> that was split from current lowering
in https://reviews.llvm.org/D136955.

The difference in HLFIR is the addition of a fir.declare on constant
outlined in memory so that all the information about them is available.

Lowering to HLFIR is enabled in Brideg::genExprValue to allow testing
of scalar constant lowering.

Differential Revision: https://reviews.llvm.org/D137084
2022-11-02 08:39:51 +01:00
Jean Perier
c14ef2d762 [flang] Add kernel to lower expressions to HLFIR
This patch adds the kernel to lower evaluate::Expr to HLFIR to a
hlfir::FortranEntity (a single mlir::Value that can be interpreted as
a Fortran variable or the value of a Fortram expression).

It implements lowering of simple name designators ("x") and starts
adding a translation layer in AbstractConverter::genExprBox and
AbstractConverter::genExprAddr so that the new expression lowering
can be used without any changes for now in the current statement and
construct lowering.

Differential Revision: https://reviews.llvm.org/D136453
2022-10-24 15:36:23 +02:00