Warning: This file is not a C or C++ file. It does not have highlighting.
1 | //===-- Allocatable.h -- Allocatable statements lowering ------------------===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/ |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #ifndef FORTRAN_LOWER_ALLOCATABLE_H |
14 | #define FORTRAN_LOWER_ALLOCATABLE_H |
15 | |
16 | #include "flang/Lower/AbstractConverter.h" |
17 | #include "flang/Optimizer/Builder/MutableBox.h" |
18 | #include "llvm/ADT/StringRef.h" |
19 | |
20 | namespace mlir { |
21 | class Value; |
22 | class ValueRange; |
23 | class Location; |
24 | } // namespace mlir |
25 | |
26 | namespace fir { |
27 | class FirOpBuilder; |
28 | } // namespace fir |
29 | |
30 | namespace Fortran { |
31 | namespace parser { |
32 | struct AllocateStmt; |
33 | struct DeallocateStmt; |
34 | } // namespace parser |
35 | |
36 | namespace semantics { |
37 | class Symbol; |
38 | class DerivedTypeSpec; |
39 | } // namespace semantics |
40 | |
41 | namespace lower { |
42 | struct SymbolBox; |
43 | |
44 | class StatementContext; |
45 | |
46 | bool isArraySectionWithoutVectorSubscript(const SomeExpr &expr); |
47 | |
48 | /// Lower an allocate statement to fir. |
49 | void genAllocateStmt(AbstractConverter &converter, |
50 | const parser::AllocateStmt &stmt, mlir::Location loc); |
51 | |
52 | /// Lower a deallocate statement to fir. |
53 | void genDeallocateStmt(AbstractConverter &converter, |
54 | const parser::DeallocateStmt &stmt, mlir::Location loc); |
55 | |
56 | void genDeallocateBox(AbstractConverter &converter, |
57 | const fir::MutableBoxValue &box, mlir::Location loc, |
58 | const Fortran::semantics::Symbol *sym = nullptr, |
59 | mlir::Value declaredTypeDesc = {}); |
60 | |
61 | /// Deallocate an allocatable if it is allocated at the end of its lifetime. |
62 | void genDeallocateIfAllocated(AbstractConverter &converter, |
63 | const fir::MutableBoxValue &box, |
64 | mlir::Location loc, |
65 | const Fortran::semantics::Symbol *sym = nullptr); |
66 | |
67 | /// Create a MutableBoxValue for an allocatable or pointer entity. |
68 | /// If the variables is a local variable that is not a dummy, it will be |
69 | /// initialized to unallocated/diassociated status. |
70 | fir::MutableBoxValue |
71 | createMutableBox(AbstractConverter &converter, mlir::Location loc, |
72 | const pft::Variable &var, mlir::Value boxAddr, |
73 | mlir::ValueRange nonDeferredParams, bool alwaysUseBox); |
74 | |
75 | /// Assign a boxed value to a boxed variable, \p box (known as a |
76 | /// MutableBoxValue). Expression \p source will be lowered to build the |
77 | /// assignment. If \p lbounds is not empty, it is used to define the result's |
78 | /// lower bounds. Otherwise, the lower bounds from \p source will be used. |
79 | void associateMutableBox(AbstractConverter &converter, mlir::Location loc, |
80 | const fir::MutableBoxValue &box, |
81 | const SomeExpr &source, mlir::ValueRange lbounds, |
82 | StatementContext &stmtCtx); |
83 | |
84 | /// Is \p expr a reference to an entity with the ALLOCATABLE attribute? |
85 | bool isWholeAllocatable(const SomeExpr &expr); |
86 | |
87 | /// Is \p expr a reference to an entity with the POINTER attribute? |
88 | bool isWholePointer(const SomeExpr &expr); |
89 | |
90 | /// Read the length from \p box for an assumed length character allocatable or |
91 | /// pointer dummy argument given by \p sym. |
92 | mlir::Value getAssumedCharAllocatableOrPointerLen( |
93 | fir::FirOpBuilder &builder, mlir::Location loc, |
94 | const Fortran::semantics::Symbol &sym, mlir::Value box); |
95 | |
96 | /// Retrieve the address of a type descriptor from its derived type spec. |
97 | mlir::Value |
98 | getTypeDescAddr(AbstractConverter &converter, mlir::Location loc, |
99 | const Fortran::semantics::DerivedTypeSpec &typeSpec); |
100 | |
101 | } // namespace lower |
102 | } // namespace Fortran |
103 | |
104 | #endif // FORTRAN_LOWER_ALLOCATABLE_H |
105 |
Warning: This file is not a C or C++ file. It does not have highlighting.