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#include "llvm/ADT/StringRef.h"
20
21namespace mlir {
22class Value;
23class ValueRange;
24class Location;
25} // namespace mlir
26
27namespace fir {
28class FirOpBuilder;
29} // namespace fir
30
31namespace Fortran {
32namespace parser {
33struct AllocateStmt;
34struct DeallocateStmt;
35} // namespace parser
36
37namespace semantics {
38class Symbol;
39class DerivedTypeSpec;
40} // namespace semantics
41
42namespace lower {
43struct SymbolBox;
44
45class StatementContext;
46
47bool isArraySectionWithoutVectorSubscript(const SomeExpr &expr);
48
50void genAllocateStmt(AbstractConverter &converter,
51 const parser::AllocateStmt &stmt, mlir::Location loc);
52
54void genDeallocateStmt(AbstractConverter &converter,
55 const parser::DeallocateStmt &stmt, mlir::Location loc);
56
57void genDeallocateBox(AbstractConverter &converter,
58 const fir::MutableBoxValue &box, mlir::Location loc,
59 const Fortran::semantics::Symbol *sym = nullptr,
60 mlir::Value declaredTypeDesc = {});
61
63void genDeallocateIfAllocated(AbstractConverter &converter,
64 const fir::MutableBoxValue &box,
65 mlir::Location loc,
66 const Fortran::semantics::Symbol *sym = nullptr);
67
72createMutableBox(AbstractConverter &converter, mlir::Location loc,
73 const pft::Variable &var, mlir::Value boxAddr,
74 mlir::ValueRange nonDeferredParams, bool alwaysUseBox,
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,
102
103} // namespace lower
104} // namespace Fortran
105
106#endif // FORTRAN_LOWER_ALLOCATABLE_H
Definition: symbol.h:712
Definition: FIRBuilder.h:55
Definition: BoxValue.h:360
fir::MutableBoxValue createMutableBox(AbstractConverter &converter, mlir::Location loc, const pft::Variable &var, mlir::Value boxAddr, mlir::ValueRange nonDeferredParams, bool alwaysUseBox, unsigned allocator=kDefaultAllocator)
Definition: Allocatable.cpp:1084
void associateMutableBox(AbstractConverter &converter, mlir::Location loc, const fir::MutableBoxValue &box, const SomeExpr &source, mlir::ValueRange lbounds, StatementContext &stmtCtx)
Definition: Allocatable.cpp:1110
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:1185
bool isWholePointer(const SomeExpr &expr)
Is expr a reference to an entity with the POINTER attribute?
Definition: Allocatable.cpp:1145
void genDeallocateStmt(AbstractConverter &converter, const parser::DeallocateStmt &stmt, mlir::Location loc)
Lower a deallocate statement to fir.
Definition: Allocatable.cpp:926
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:905
bool isWholeAllocatable(const SomeExpr &expr)
Is expr a reference to an entity with the ALLOCATABLE attribute?
Definition: Allocatable.cpp:1138
mlir::Value getAssumedCharAllocatableOrPointerLen(fir::FirOpBuilder &builder, mlir::Location loc, const Fortran::semantics::Symbol &sym, mlir::Value box)
Definition: Allocatable.cpp:1152
void genAllocateStmt(AbstractConverter &converter, const parser::AllocateStmt &stmt, mlir::Location loc)
Lower an allocate statement to fir.
Definition: Allocatable.cpp:805
Definition: bit-population-count.h:20
Definition: AbstractConverter.h:31
@ Value
Lower argument to a value. Mainly intended for scalar arguments.
Definition: AbstractConverter.h:27