13 Commits

Author SHA1 Message Date
Valentin Clement (バレンタイン クレメン)
3847620ba9
[flang][NFC] Move the rest of ops creation to new APIs (#152079) 2025-08-05 07:27:43 -07:00
Valentin Clement (バレンタイン クレメン)
951f40ac38
[flang][NFC] Update flang/unittests to the new create APIs (#152056)
While I was updating the creation of CUF operation in #152050, I noticed
some other places in flang that were not updated. This patch updates the
FIR operation creations in `flang/unittests`
2025-08-04 16:49:43 -07:00
Kazu Hirata
151fffccf1
[flang] Migrate away from ArrayRef(std::nullopt_t) (#149454)
ArrayRef(std::nullopt_t) has been deprecated.  This patch replaces
std::nullopt with mlir::TypeRange{} or mlir::ValueRange{} as
appropriate.
2025-07-18 08:05:12 -07:00
Kazu Hirata
2a7328daca
[flang] Migrate away from ArrayRef(std::nullopt_t) (#149337)
ArrayRef(std::nullopt_t) has been deprecated.  This patch replaces
std::nullopt with {}.

A subsequence patch will address those places where we need to replace
std::nullopt with mlir::TypeRange{} or mlir::ValueRange{}.
2025-07-17 15:23:55 -07:00
Matthias Springer
f023da12d1
[mlir][IR] Remove factory methods from FloatType (#123026)
This commit removes convenience methods from `FloatType` to make it
independent of concrete interface implementations.

See discussion here:
https://discourse.llvm.org/t/rethink-on-approach-to-low-precision-fp-types/82361

Note for LLVM integration: Replace `FloatType::getF32(` with
`Float32Type::get(` etc.
2025-01-16 08:56:09 +01:00
Matthias Springer
c870632ef6
[flang] Fix some memory leaks (#121050)
This commit fixes some but not all memory leaks in Flang. There are
still 91 tests that fail with ASAN.

- Use `mlir::OwningOpRef` instead of `std::unique_ptr`. The latter does
not free allocations of nested blocks.
- Pass `ModuleOp` as value instead of reference.
- Add few missing deallocations in test cases and other places.
2024-12-25 09:42:03 +01:00
Valentin Clement (バレンタイン クレメン)
45daa4fdc6
[flang][cuda] Move CUDA Fortran operations to a CUF dialect (#92317)
The number of operations dedicated to CUF grew and where all still in
FIR. In order to have a better organization, the CUF operations,
attributes and code is moved into their specific dialect and files. CUF
dialect is tightly coupled with HLFIR/FIR and their types.

The CUF attributes are bundled into their own library since some
HLFIR/FIR operations depend on them and the CUF dialect depends on the
FIR types. Without having the attributes into a separate library there
would be a dependency cycle.
2024-05-17 09:37:53 -07:00
Slava Zakharin
986f832cff
[flang] Added fir.dummy_scope operation to preserve dummy arguments association. (#90642)
The new operation is just an abstract attribute that is attached to
[hl]fir.declare operations of dummy arguments of a subroutine.
Dummy arguments of the same subroutine refer to the same
fir.dummy_scope, so they can be recognized as such during FIR AliasAnalysis.
Note that the fir.dummy_scope must be specific to the runtime
instantiation of a subroutine, so any MLIR inlining/cloning should duplicate and
unique it vs using the same fir.dummy_scope for different runtime instantiations.
This is why I made it an operation rather than an attribute.
The new operation uses a write effect on DebuggingResource, same as
[hl]fir.declare, to avoid optimizing it away.
2024-04-30 17:40:36 -07:00
Valentin Clement (バレンタイン クレメン)
7ff488708c
[flang][cuda][NFC] Rename CUDAAttribute to CUDADataAttribute (#81323)
The newly introduced `CUDAAttribute` is meant for CUDA attributes
associated with variable. In order to not clash with the future
attribute for function/subroutine, rename `CUDAAttribute` to
`CUDADataAttribute`.
2024-02-09 13:57:26 -08:00
Valentin Clement (バレンタイン クレメン)
abc4f74df7
[flang][cuda] Lower attribute for local variable (#81076)
This is a first simple patch to introduce a new FIR attribute to carry
the CUDA variable attribute information to hlfir.declare and fir.declare
operations. It currently lowers this information for local variables.

The texture attribute is omitted since it is rejected by semantic and
will not make its way to MLIR.

This new attribute is added as optional attribute to the hlfir.declare
and fir.declare operations.
2024-02-08 10:03:08 -08:00
Jean Perier
b22fa8659a [flang][NFC] add builder to simplify fir.shape creation
Differential Revision: https://reviews.llvm.org/D140031
2022-12-15 11:14:14 +01:00
Kazu Hirata
63b63c3dcd [flang/unittests] 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 19:08:01 -08:00
Jean Perier
a398981fb0 [flang] Add fir.declare operation
Add fir.declare operation whose purpose was described in https://reviews.llvm.org/D134285.
It uses the FortranVariableInterfaceOp for most of its logic (including the verifier).
The rational is that all these aspects/logic will be shared by hlfir.designate and
hlfir.associate.

Its codegen and lowering will be added in later patches.

Differential Revision: https://reviews.llvm.org/D136181
2022-10-19 11:06:58 +02:00