FLANG
Allocatable.h
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 "flang/Runtime/allocator-registry-consts.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
45
46bool isArraySectionWithoutVectorSubscript(const SomeExpr &expr);
47
50 const parser::AllocateStmt &stmt, mlir::Location loc);
51
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
63 const fir::MutableBoxValue &box,
64 mlir::Location loc,
65 const Fortran::semantics::Symbol *sym = nullptr);
66
70fir::MutableBoxValue createMutableBox(AbstractConverter &converter,
71 mlir::Location loc,
72 const pft::Variable &var,
73 mlir::Value boxAddr,
74 mlir::ValueRange nonDeferredParams,
75 unsigned allocator = kDefaultAllocator);
76
81void associateMutableBox(AbstractConverter &converter, mlir::Location loc,
82 const fir::MutableBoxValue &box,
83 const SomeExpr &source, mlir::ValueRange lbounds,
84 StatementContext &stmtCtx);
85
87bool isWholeAllocatable(const SomeExpr &expr);
88
90bool isWholePointer(const SomeExpr &expr);
91
95 fir::FirOpBuilder &builder, mlir::Location loc,
96 const Fortran::semantics::Symbol &sym, mlir::Value box);
97
99mlir::Value
100getTypeDescAddr(AbstractConverter &converter, mlir::Location loc,
101 const Fortran::semantics::DerivedTypeSpec &typeSpec);
102
103} // namespace lower
104} // namespace Fortran
105
106#endif // FORTRAN_LOWER_ALLOCATABLE_H
Definition AbstractConverter.h:87
Definition StatementContext.h:46
Definition symbol.h:896
Definition FIRBuilder.h:59
Definition ParserActions.h:24
void associateMutableBox(AbstractConverter &converter, mlir::Location loc, const fir::MutableBoxValue &box, const SomeExpr &source, mlir::ValueRange lbounds, StatementContext &stmtCtx)
Definition Allocatable.cpp:1119
mlir::Value getTypeDescAddr(AbstractConverter &converter, mlir::Location loc, const Fortran::semantics::DerivedTypeSpec &typeSpec)
Retrieve the address of a type descriptor from its derived type spec.
Definition Allocatable.cpp:1181
bool isWholePointer(const SomeExpr &expr)
Is expr a reference to an entity with the POINTER attribute?
Definition Allocatable.cpp:1141
void genDeallocateStmt(AbstractConverter &converter, const parser::DeallocateStmt &stmt, mlir::Location loc)
Lower a deallocate statement to fir.
Definition Allocatable.cpp:1047
void genDeallocateIfAllocated(AbstractConverter &converter, const fir::MutableBoxValue &box, mlir::Location loc, const Fortran::semantics::Symbol *sym=nullptr)
Deallocate an allocatable if it is allocated at the end of its lifetime.
Definition Allocatable.cpp:1026
bool isWholeAllocatable(const SomeExpr &expr)
Is expr a reference to an entity with the ALLOCATABLE attribute?
Definition Allocatable.cpp:1134
mlir::Value getAssumedCharAllocatableOrPointerLen(fir::FirOpBuilder &builder, mlir::Location loc, const Fortran::semantics::Symbol &sym, mlir::Value box)
Definition Allocatable.cpp:1148
fir::MutableBoxValue createMutableBox(AbstractConverter &converter, mlir::Location loc, const pft::Variable &var, mlir::Value boxAddr, mlir::ValueRange nonDeferredParams, unsigned allocator=kDefaultAllocator)
Definition Allocatable.cpp:1094
void genAllocateStmt(AbstractConverter &converter, const parser::AllocateStmt &stmt, mlir::Location loc)
Lower an allocate statement to fir.
Definition Allocatable.cpp:904
Definition check-expression.h:19
Definition bit-population-count.h:20
Definition AbstractConverter.h:37
Definition AbstractConverter.h:32
Definition SymbolMap.h:52
Definition PFTBuilder.h:417
Definition parse-tree.h:2021
Definition parse-tree.h:2041