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
20namespace mlir {
21class Value;
22class ValueRange;
23class Location;
24} // namespace mlir
25
26namespace fir {
27class FirOpBuilder;
28} // namespace fir
29
30namespace Fortran {
31namespace parser {
32struct AllocateStmt;
33struct DeallocateStmt;
34} // namespace parser
35
36namespace semantics {
37class Symbol;
38class DerivedTypeSpec;
39} // namespace semantics
40
41namespace lower {
42struct SymbolBox;
43
44class StatementContext;
45
46bool isArraySectionWithoutVectorSubscript(const SomeExpr &expr);
47
48/// Lower an allocate statement to fir.
49void genAllocateStmt(AbstractConverter &converter,
50 const parser::AllocateStmt &stmt, mlir::Location loc);
51
52/// Lower a deallocate statement to fir.
53void genDeallocateStmt(AbstractConverter &converter,
54 const parser::DeallocateStmt &stmt, mlir::Location loc);
55
56void 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.
62void 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.
70fir::MutableBoxValue
71createMutableBox(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.
79void 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?
85bool isWholeAllocatable(const SomeExpr &expr);
86
87/// Is \p expr a reference to an entity with the POINTER attribute?
88bool 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.
92mlir::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.
97mlir::Value
98getTypeDescAddr(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.

source code of flang/include/flang/Lower/Allocatable.h