FLANG
ConvertExprToHLFIR.h
1//===-- Lower/ConvertExprToHLFIR.h -- lowering of expressions ----*- C++-*-===//
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//===----------------------------------------------------------------------===//
15//===----------------------------------------------------------------------===//
16
17#ifndef FORTRAN_LOWER_CONVERTEXPRTOHLFIR_H
18#define FORTRAN_LOWER_CONVERTEXPRTOHLFIR_H
19
20#include "flang/Lower/StatementContext.h"
21#include "flang/Lower/Support/Utils.h"
22#include "flang/Optimizer/Builder/FIRBuilder.h"
23#include "flang/Optimizer/Builder/HLFIRTools.h"
24
25namespace mlir {
26class Location;
27} // namespace mlir
28
29namespace hlfir {
30class ElementalAddrOp;
31}
32
33namespace Fortran::lower {
34
36class SymMap;
37
38hlfir::EntityWithAttributes
39convertExprToHLFIR(mlir::Location loc, Fortran::lower::AbstractConverter &,
40 const Fortran::lower::SomeExpr &, Fortran::lower::SymMap &,
41 Fortran::lower::StatementContext &);
42
43inline fir::ExtendedValue translateToExtendedValue(
44 mlir::Location loc, fir::FirOpBuilder &builder, hlfir::Entity entity,
45 Fortran::lower::StatementContext &context, bool contiguityHint = false) {
46 auto [exv, exvCleanup] =
47 hlfir::translateToExtendedValue(loc, builder, entity, contiguityHint);
48 if (exvCleanup)
49 context.attachCleanup(*exvCleanup);
50 return exv;
51}
52
55fir::ExtendedValue convertExprToBox(mlir::Location loc,
56 Fortran::lower::AbstractConverter &,
57 const Fortran::lower::SomeExpr &,
58 Fortran::lower::SymMap &,
59 Fortran::lower::StatementContext &);
60fir::ExtendedValue convertToBox(mlir::Location loc,
61 Fortran::lower::AbstractConverter &,
62 hlfir::Entity entity,
63 Fortran::lower::StatementContext &,
64 mlir::Type fortranType, unsigned corank = 0);
65
91fir::ExtendedValue convertExprToAddress(mlir::Location loc,
92 Fortran::lower::AbstractConverter &,
93 const Fortran::lower::SomeExpr &,
94 Fortran::lower::SymMap &,
95 Fortran::lower::StatementContext &);
96fir::ExtendedValue convertToAddress(mlir::Location loc,
97 Fortran::lower::AbstractConverter &,
98 hlfir::Entity entity,
99 Fortran::lower::StatementContext &,
100 mlir::Type fortranType);
101
103fir::ExtendedValue convertExprToValue(mlir::Location loc,
104 Fortran::lower::AbstractConverter &,
105 const Fortran::lower::SomeExpr &,
106 Fortran::lower::SymMap &,
107 Fortran::lower::StatementContext &);
108fir::ExtendedValue convertToValue(mlir::Location loc,
109 Fortran::lower::AbstractConverter &,
110 hlfir::Entity entity,
111 Fortran::lower::StatementContext &);
112
114fir::FortranVariableOpInterface convertDataRefToHLFIRVariable(
115 mlir::Location loc, Fortran::lower::AbstractConverter &,
116 const Fortran::evaluate::DataRef &, Fortran::lower::SymMap &,
117 Fortran::lower::StatementContext &);
118
119fir::ExtendedValue convertDataRefToValue(mlir::Location loc,
120 Fortran::lower::AbstractConverter &,
121 const Fortran::evaluate::DataRef &,
122 Fortran::lower::SymMap &,
123 Fortran::lower::StatementContext &);
124
128fir::MutableBoxValue
129convertExprToMutableBox(mlir::Location loc, Fortran::lower::AbstractConverter &,
130 const Fortran::lower::SomeExpr &,
131 Fortran::lower::SymMap &);
141 mlir::Location loc, Fortran::lower::AbstractConverter &,
142 const Fortran::lower::SomeExpr &, Fortran::lower::SymMap &,
143 Fortran::lower::StatementContext &);
144
150 mlir::Location loc, Fortran::lower::AbstractConverter &converter,
151 const Fortran::lower::SomeExpr &expr, Fortran::lower::SymMap &symMap,
152 Fortran::lower::StatementContext &stmtCtx);
153
156hlfir::Entity genEnumerationOrdinalDesignator(mlir::Location loc,
157 fir::FirOpBuilder &builder,
158 hlfir::Entity enumVar);
159
161hlfir::EntityWithAttributes genEnumerationTemp(mlir::Location loc,
162 fir::FirOpBuilder &builder,
163 fir::RecordType recTy,
164 mlir::Value ordinal,
165 llvm::StringRef name);
166
167} // namespace Fortran::lower
168
169#endif // FORTRAN_LOWER_CONVERTEXPRTOHLFIR_H
Definition AbstractConverter.h:87
void attachCleanup(CleanupFunction cuf)
Append a cleanup function to the "list" of cleanup functions.
Definition StatementContext.h:69
Definition SymbolMap.h:181
Definition ParserActions.h:24
fir::FortranVariableOpInterface convertDataRefToHLFIRVariable(mlir::Location loc, Fortran::lower::AbstractConverter &, const Fortran::evaluate::DataRef &, Fortran::lower::SymMap &, Fortran::lower::StatementContext &)
Lower a DataRef to the HLFIR variable that designates it.
Definition ConvertExprToHLFIR.cpp:2723
hlfir::Entity genVectorSubscriptedDesignatorFirstElementAddress(mlir::Location loc, Fortran::lower::AbstractConverter &converter, const Fortran::lower::SomeExpr &expr, Fortran::lower::SymMap &symMap, Fortran::lower::StatementContext &stmtCtx)
Definition ConvertExprToHLFIR.cpp:2765
fir::MutableBoxValue convertExprToMutableBox(mlir::Location loc, Fortran::lower::AbstractConverter &, const Fortran::lower::SomeExpr &, Fortran::lower::SymMap &)
Definition ConvertExprToHLFIR.cpp:2739
fir::ExtendedValue convertExprToAddress(mlir::Location loc, Fortran::lower::AbstractConverter &, const Fortran::lower::SomeExpr &, Fortran::lower::SymMap &, Fortran::lower::StatementContext &)
Definition ConvertExprToHLFIR.cpp:2694
hlfir::Entity genEnumerationOrdinalDesignator(mlir::Location loc, fir::FirOpBuilder &builder, hlfir::Entity enumVar)
Definition ConvertExprToHLFIR.cpp:2619
hlfir::ElementalAddrOp convertVectorSubscriptedExprToElementalAddr(mlir::Location loc, Fortran::lower::AbstractConverter &, const Fortran::lower::SomeExpr &, Fortran::lower::SymMap &, Fortran::lower::StatementContext &)
Definition ConvertExprToHLFIR.cpp:2757
fir::ExtendedValue convertExprToValue(mlir::Location loc, Fortran::lower::AbstractConverter &, const Fortran::lower::SomeExpr &, Fortran::lower::SymMap &, Fortran::lower::StatementContext &)
Lower an evaluate::Expr to a fir::ExtendedValue value.
Definition ConvertExprToHLFIR.cpp:2714
fir::ExtendedValue convertExprToBox(mlir::Location loc, Fortran::lower::AbstractConverter &, const Fortran::lower::SomeExpr &, Fortran::lower::SymMap &, Fortran::lower::StatementContext &)
Definition ConvertExprToHLFIR.cpp:2669
hlfir::EntityWithAttributes genEnumerationTemp(mlir::Location loc, fir::FirOpBuilder &builder, fir::RecordType recTy, mlir::Value ordinal, llvm::StringRef name)
Create a scalar temporary of enumeration type recTy holding ordinal.
Definition ConvertExprToHLFIR.cpp:2644
Definition AbstractConverter.h:32