FLANG
DirectivesCommon.h
1//===-- Lower/DirectivesCommon.h --------------------------------*- 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//===----------------------------------------------------------------------===//
16//===----------------------------------------------------------------------===//
17
18#ifndef FORTRAN_LOWER_DIRECTIVES_COMMON_H
19#define FORTRAN_LOWER_DIRECTIVES_COMMON_H
20
21#include "flang/Evaluate/tools.h"
22#include "flang/Lower/AbstractConverter.h"
23#include "flang/Lower/Bridge.h"
24#include "flang/Lower/ConvertVariable.h"
25#include "flang/Lower/OpenACC.h"
26#include "flang/Lower/OpenMP.h"
27#include "flang/Lower/PFTBuilder.h"
28#include "flang/Lower/StatementContext.h"
29#include "flang/Lower/Support/Utils.h"
30#include "flang/Optimizer/Builder/DirectivesCommon.h"
31#include "flang/Optimizer/Builder/HLFIRTools.h"
32#include "flang/Optimizer/Dialect/FIRType.h"
33#include "flang/Parser/parse-tree.h"
34#include "flang/Semantics/tools.h"
35#include "mlir/IR/Value.h"
36#include <list>
37#include <type_traits>
38
39namespace Fortran {
40namespace lower {
41
44template <typename... TerminatorOps>
46 fir::FirOpBuilder &builder,
47 std::list<Fortran::lower::pft::Evaluation> &evaluationList) {
48 mlir::Region *region = &builder.getRegion();
49 for (Fortran::lower::pft::Evaluation &eval : evaluationList) {
50 if (eval.block) {
51 if (eval.block->empty()) {
52 eval.block->erase();
53 eval.block = builder.createBlock(region);
54 } else {
55 [[maybe_unused]] mlir::Operation &terminatorOp = eval.block->back();
56 assert(mlir::isa<TerminatorOps...>(terminatorOp) &&
57 "expected terminator op");
58 }
59 }
60 if (!eval.isDirective() && eval.hasNestedEvaluations())
61 createEmptyRegionBlocks<TerminatorOps...>(builder,
62 eval.getNestedEvaluations());
63 }
64}
65
67getDataOperandBaseAddr(Fortran::lower::AbstractConverter &converter,
68 fir::FirOpBuilder &builder,
69 Fortran::lower::SymbolRef sym, mlir::Location loc,
70 bool unwrapFirBox = true) {
71 return fir::factory::getDataOperandBaseAddr(
72 builder, converter.getSymbolAddress(sym),
73 Fortran::semantics::IsOptional(sym), loc, unwrapFirBox);
74}
75
76namespace detail {
77template <typename T> //
78T &&AsRvalueRef(T &&t) {
79 return std::move(t);
80}
81template <typename T> //
82T AsRvalueRef(T &t) {
83 return t;
84}
85template <typename T> //
86T AsRvalueRef(const T &t) {
87 return t;
88}
89
90// Helper class for stripping enclosing parentheses and a conversion that
91// preserves type category. This is used for triplet elements, which are
92// always of type integer(kind=8). The lower/upper bounds are converted to
93// an "index" type, which is 64-bit, so the explicit conversion to kind=8
94// (if present) is not needed. When it's present, though, it causes generated
95// names to contain "int(..., kind=8)".
97 template <Fortran::common::TypeCategory Category>
98 static Fortran::semantics::MaybeExpr visit_with_category(
100 return Fortran::common::visit(
101 [](auto &&s) { return visit_with_category<Category>(s); }, expr.u);
102 }
103 template <Fortran::common::TypeCategory Category, typename T>
104 static Fortran::semantics::MaybeExpr visit_with_category(const T &x) {
106 if constexpr (Fortran::evaluate::IsSpecificIntrinsicType<Ty>) {
107 // GCC 7 workaround: Using Convert<Type<Category>, Category> in a
108 // parameter type of a SFINAE'd overload instantiates it and trips its
109 // static_assert. Use if constexpr instead of std::enable_if.
110 if constexpr (std::is_same_v<T,
112 return AsGenericExpr(AsRvalueRef(x.left()));
113 }
114 }
115 return std::nullopt;
116 }
117
118 template <Fortran::common::TypeCategory Category>
119 static Fortran::semantics::MaybeExpr
121 &expr) {
122 return Fortran::common::visit(
123 [](auto &&s) { return visit_with_category<Category>(s); }, expr.u);
124 }
125 static Fortran::semantics::MaybeExpr
127 return Fortran::common::visit([](auto &&s) { return visit(s); }, expr.u);
128 }
129 template <typename T> //
130 static Fortran::semantics::MaybeExpr visit(const T &) {
131 return std::nullopt;
132 }
133};
134
135static inline Fortran::semantics::SomeExpr
136peelOuterConvert(Fortran::semantics::SomeExpr &expr) {
137 if (auto peeled = PeelConvert::visit(expr))
138 return *peeled;
139 return expr;
140}
141} // namespace detail
142
145template <typename BoundsOp, typename BoundsType>
147genBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc,
150 const std::vector<Fortran::evaluate::Subscript> &subscripts,
151 std::stringstream &asFortran, fir::ExtendedValue &dataExv,
152 bool dataExvIsAssumedSize, fir::factory::AddrAndBoundsInfo &info,
153 bool treatIndexAsSection = false,
154 bool strideIncludeLowerExtent = false) {
155 int dimension = 0;
156 mlir::Type idxTy = builder.getIndexType();
157 mlir::Type boundTy = builder.getType<BoundsType>();
159
160 mlir::Value zero = builder.createIntegerConstant(loc, idxTy, 0);
161 mlir::Value one = builder.createIntegerConstant(loc, idxTy, 1);
162 const int dataExvRank = static_cast<int>(dataExv.rank());
163 mlir::Value cumulativeExtent = one;
164 for (const auto &subscript : subscripts) {
165 const auto *triplet{std::get_if<Fortran::evaluate::Triplet>(&subscript.u)};
166 if (triplet || treatIndexAsSection) {
167 if (dimension != 0)
168 asFortran << ',';
169 mlir::Value lbound, ubound, extent;
170 std::optional<std::int64_t> lval, uval;
171 mlir::Value baseLb =
172 fir::factory::readLowerBound(builder, loc, dataExv, dimension, one);
173 bool defaultLb = baseLb == one;
174 mlir::Value stride = one;
175 bool strideInBytes = false;
176
177 auto genSourceExtent = [&]() -> mlir::Value {
178 if (info.isPresent && mlir::isa<fir::BaseBoxType>(
179 fir::unwrapRefType(info.addr.getType()))) {
180 return builder
181 .genIfOp(loc, idxTy, info.isPresent, /*withElseRegion=*/true)
182 .genThen([&]() {
183 mlir::Value ext =
184 fir::factory::readExtent(builder, loc, dataExv, dimension);
185 fir::ResultOp::create(builder, loc, ext);
186 })
187 .genElse([&] {
188 mlir::Value zero = builder.createIntegerConstant(loc, idxTy, 0);
189 fir::ResultOp::create(builder, loc, zero);
190 })
191 .getResults()[0];
192 }
193 return fir::factory::readExtent(builder, loc, dataExv, dimension);
194 };
195
196 if (mlir::isa<fir::BaseBoxType>(
197 fir::unwrapRefType(info.addr.getType()))) {
198 if (info.isPresent) {
199 stride =
200 builder
201 .genIfOp(loc, idxTy, info.isPresent, /*withElseRegion=*/true)
202 .genThen([&]() {
203 mlir::Value box =
204 !fir::isBoxAddress(info.addr.getType())
205 ? info.addr
206 : fir::LoadOp::create(builder, loc, info.addr);
207 mlir::Value d =
208 builder.createIntegerConstant(loc, idxTy, dimension);
209 auto dimInfo = fir::BoxDimsOp::create(builder, loc, idxTy,
210 idxTy, idxTy, box, d);
211 fir::ResultOp::create(builder, loc,
212 dimInfo.getByteStride());
213 })
214 .genElse([&] {
215 mlir::Value zero =
216 builder.createIntegerConstant(loc, idxTy, 0);
217 fir::ResultOp::create(builder, loc, zero);
218 })
219 .getResults()[0];
220 } else {
221 mlir::Value box = !fir::isBoxAddress(info.addr.getType())
222 ? info.addr
223 : fir::LoadOp::create(builder, loc, info.addr);
224 mlir::Value d = builder.createIntegerConstant(loc, idxTy, dimension);
225 auto dimInfo =
226 fir::BoxDimsOp::create(builder, loc, idxTy, idxTy, idxTy, box, d);
227 stride = dimInfo.getByteStride();
228 }
229 strideInBytes = true;
230 }
231
232 Fortran::semantics::MaybeExpr lower;
233 if (triplet) {
234 lower = Fortran::evaluate::AsGenericExpr(triplet->lower());
235 } else {
236 // Case of IndirectSubscriptIntegerExpr
237 using IndirectSubscriptIntegerExpr =
238 Fortran::evaluate::IndirectSubscriptIntegerExpr;
239 using SubscriptInteger = Fortran::evaluate::SubscriptInteger;
241 std::get<IndirectSubscriptIntegerExpr>(subscript.u).value();
242 lower = Fortran::evaluate::AsGenericExpr(std::move(oneInt));
243 if (lower->Rank() > 0) {
244 mlir::emitError(
245 loc, "vector subscript cannot be used for an array section");
246 break;
247 }
248 }
249 if (lower) {
250 lval = Fortran::evaluate::ToInt64(*lower);
251 if (lval) {
252 if (defaultLb) {
253 lbound = builder.createIntegerConstant(loc, idxTy, *lval - 1);
254 } else {
255 mlir::Value lb = builder.createIntegerConstant(loc, idxTy, *lval);
256 lbound = mlir::arith::SubIOp::create(builder, loc, lb, baseLb);
257 }
258 asFortran << *lval;
259 } else {
260 mlir::Value lb =
261 fir::getBase(converter.genExprValue(loc, *lower, stmtCtx));
262 lb = builder.createConvert(loc, baseLb.getType(), lb);
263 lbound = mlir::arith::SubIOp::create(builder, loc, lb, baseLb);
264 asFortran << detail::peelOuterConvert(*lower).AsFortran();
265 }
266 } else {
267 // If the lower bound is not specified, then the section
268 // starts from offset 0 of the dimension.
269 // Note that the lowerbound in the BoundsOp is always 0-based.
270 lbound = zero;
271 }
272
273 if (!triplet) {
274 // If it is a scalar subscript, then the upper bound
275 // is equal to the lower bound, and the extent is one.
276 ubound = lbound;
277 extent = one;
278 } else {
279 asFortran << ':';
280 Fortran::semantics::MaybeExpr upper =
281 Fortran::evaluate::AsGenericExpr(triplet->upper());
282
283 if (upper) {
284 uval = Fortran::evaluate::ToInt64(*upper);
285 if (uval) {
286 if (defaultLb) {
287 ubound = builder.createIntegerConstant(loc, idxTy, *uval - 1);
288 } else {
289 mlir::Value ub = builder.createIntegerConstant(loc, idxTy, *uval);
290 ubound = mlir::arith::SubIOp::create(builder, loc, ub, baseLb);
291 }
292 asFortran << *uval;
293 } else {
294 mlir::Value ub =
295 fir::getBase(converter.genExprValue(loc, *upper, stmtCtx));
296 ub = builder.createConvert(loc, baseLb.getType(), ub);
297 ubound = mlir::arith::SubIOp::create(builder, loc, ub, baseLb);
298 asFortran << detail::peelOuterConvert(*upper).AsFortran();
299 }
300 }
301 if (lower && upper) {
302 if (lval && uval && *uval < *lval) {
303 mlir::emitError(loc, "zero sized array section");
304 break;
305 } else {
306 // Stride is mandatory in evaluate::Triplet. Make sure it's 1.
307 auto val = Fortran::evaluate::ToInt64(triplet->GetStride());
308 if (!val || *val != 1) {
309 mlir::emitError(loc, "stride cannot be specified on "
310 "an array section");
311 break;
312 }
313 }
314 }
315
316 extent = genSourceExtent();
317
318 if (dataExvIsAssumedSize && dimension + 1 == dataExvRank) {
319 extent = zero;
320 if (ubound && lbound) {
321 mlir::Value diff =
322 mlir::arith::SubIOp::create(builder, loc, ubound, lbound);
323 extent = mlir::arith::AddIOp::create(builder, loc, diff, one);
324 }
325 if (!ubound)
326 ubound = lbound;
327 }
328
329 if (!ubound) {
330 // ub = extent - 1
331 ubound = mlir::arith::SubIOp::create(builder, loc, extent, one);
332 }
333 }
334
335 // When the strideInBytes is true, it means the stride is from descriptor
336 // and this already includes the lower extents.
337 if (strideIncludeLowerExtent && !strideInBytes) {
338 stride = cumulativeExtent;
339 mlir::Value strideExtent = extent;
340 if (!triplet && dimension + 1 < dataExvRank)
341 strideExtent = genSourceExtent();
342 cumulativeExtent = builder.createOrFold<mlir::arith::MulIOp>(
343 loc, cumulativeExtent, strideExtent);
344 }
345
346 mlir::Value bound =
347 BoundsOp::create(builder, loc, boundTy, lbound, ubound, extent,
348 stride, strideInBytes, baseLb);
349 bounds.push_back(bound);
350 ++dimension;
351 }
352 }
353 return bounds;
354}
355
356namespace detail {
357template <typename Ref, typename Expr> //
358std::optional<Ref> getRef(Expr &&expr) {
359 if constexpr (std::is_same_v<llvm::remove_cvref_t<Expr>,
361 if (auto *ref = std::get_if<Ref>(&expr.u))
362 return *ref;
363 return std::nullopt;
364 } else {
365 auto maybeRef = Fortran::evaluate::ExtractDataRef(expr);
366 if (!maybeRef || !std::holds_alternative<Ref>(maybeRef->u))
367 return std::nullopt;
368 return std::get<Ref>(maybeRef->u);
369 }
370}
371} // namespace detail
372
373template <typename BoundsOp, typename BoundsType>
374fir::factory::AddrAndBoundsInfo gatherDataOperandAddrAndBounds(
375 Fortran::lower::AbstractConverter &converter, fir::FirOpBuilder &builder,
376 semantics::SemanticsContext &semaCtx,
377 Fortran::lower::StatementContext &stmtCtx,
378 Fortran::semantics::SymbolRef symbol,
379 const Fortran::semantics::MaybeExpr &maybeDesignator,
380 mlir::Location operandLocation, std::stringstream &asFortran,
381 llvm::SmallVector<mlir::Value> &bounds, bool treatIndexAsSection = false,
382 bool unwrapFirBox = true, bool genDefaultBounds = true,
383 bool strideIncludeLowerExtent = false,
384 bool loadAllocatableAndPointerComponent = true) {
385 using namespace Fortran;
386
387 fir::factory::AddrAndBoundsInfo info;
388
389 if (!maybeDesignator) {
390 info = getDataOperandBaseAddr(converter, builder, symbol, operandLocation,
391 unwrapFirBox);
392 asFortran << symbol->name().ToString();
393 return info;
394 }
395
396 semantics::SomeExpr designator = *maybeDesignator;
397
398 if ((designator.Rank() > 0 || treatIndexAsSection) &&
399 IsArrayElement(designator)) {
400 auto arrayRef = detail::getRef<evaluate::ArrayRef>(designator);
401 // This shouldn't fail after IsArrayElement(designator).
402 assert(arrayRef && "Expecting ArrayRef");
403
404 fir::ExtendedValue dataExv;
405 bool dataExvIsAssumedSize = false;
406
407 auto toMaybeExpr = [&](auto &&base) {
408 using BaseType = llvm::remove_cvref_t<decltype(base)>;
409 evaluate::ExpressionAnalyzer ea{semaCtx};
410
411 if constexpr (std::is_same_v<evaluate::NamedEntity, BaseType>) {
412 if (auto *ref = base.UnwrapSymbolRef())
413 return ea.Designate(evaluate::DataRef{*ref});
414 if (auto *ref = base.UnwrapComponent())
415 return ea.Designate(evaluate::DataRef{*ref});
416 llvm_unreachable("Unexpected NamedEntity");
417 } else {
418 static_assert(std::is_same_v<semantics::SymbolRef, BaseType>);
419 return ea.Designate(evaluate::DataRef{base});
420 }
421 };
422
423 auto arrayBase = toMaybeExpr(arrayRef->base());
424 assert(arrayBase);
425
426 if (auto comp = detail::getRef<evaluate::Component>(*arrayBase)) {
427 if (!loadAllocatableAndPointerComponent &&
428 semantics::IsAllocatableOrPointer(comp->symbol()))
429 dataExv = converter.genExprMutableBox(operandLocation, *arrayBase);
430 else
431 dataExv = converter.genExprAddr(operandLocation, *arrayBase, stmtCtx);
432 info.addr = fir::getBase(dataExv);
433 info.rawInput = info.addr;
434 asFortran << arrayBase->AsFortran();
435 } else {
436 const semantics::Symbol &sym = arrayRef->GetLastSymbol();
437 dataExvIsAssumedSize =
438 Fortran::semantics::IsAssumedSizeArray(sym.GetUltimate());
439 info = getDataOperandBaseAddr(converter, builder, sym, operandLocation,
440 unwrapFirBox);
441 dataExv = converter.getSymbolExtendedValue(sym);
442 asFortran << sym.name().ToString();
443 }
444
445 if (!arrayRef->subscript().empty()) {
446 asFortran << '(';
448 builder, operandLocation, converter, stmtCtx, arrayRef->subscript(),
449 asFortran, dataExv, dataExvIsAssumedSize, info, treatIndexAsSection,
450 strideIncludeLowerExtent);
451 }
452 asFortran << ')';
453 } else if (auto compRef = detail::getRef<evaluate::Component>(designator)) {
454 fir::ExtendedValue compExv;
455 if (!loadAllocatableAndPointerComponent &&
456 semantics::IsAllocatableOrPointer(compRef->symbol()))
457 compExv = converter.genExprMutableBox(operandLocation, designator);
458 else
459 compExv = converter.genExprAddr(operandLocation, designator, stmtCtx);
460 info.addr = fir::getBase(compExv);
461 info.rawInput = info.addr;
462 if (genDefaultBounds &&
463 mlir::isa<fir::SequenceType>(fir::unwrapRefType(info.addr.getType())))
465 builder, operandLocation, compExv,
466 /*isAssumedSize=*/false, strideIncludeLowerExtent);
467 asFortran << designator.AsFortran();
468
469 if (semantics::IsOptional(compRef->GetLastSymbol())) {
470 info.isPresent = fir::IsPresentOp::create(
471 builder, operandLocation, builder.getI1Type(), info.rawInput);
472 }
473
474 if (unwrapFirBox) {
475 if (auto loadOp =
476 mlir::dyn_cast_or_null<fir::LoadOp>(info.addr.getDefiningOp())) {
477 if (fir::isAllocatableType(loadOp.getType()) ||
478 fir::isPointerType(loadOp.getType())) {
479 info.boxType = info.addr.getType();
480 info.addr =
481 fir::BoxAddrOp::create(builder, operandLocation, info.addr);
482 }
483 info.rawInput = info.addr;
484 }
485 }
486
487 // If the component is an allocatable or pointer the result of
488 // genExprAddr will be the result of a fir.box_addr operation or
489 // a fir.box_addr has been inserted just before.
490 // Retrieve the box so we handle it like other descriptor.
491 if (auto boxAddrOp =
492 mlir::dyn_cast_or_null<fir::BoxAddrOp>(info.addr.getDefiningOp())) {
493 info.addr = boxAddrOp.getVal();
494 info.boxType = info.addr.getType();
495 info.rawInput = info.addr;
496 if (genDefaultBounds)
498 builder, operandLocation, compExv, info);
499 }
500 } else {
501 if (detail::getRef<evaluate::ArrayRef>(designator)) {
502 fir::ExtendedValue compExv =
503 converter.genExprAddr(operandLocation, designator, stmtCtx);
504 info.addr = fir::getBase(compExv);
505 info.rawInput = info.addr;
506 asFortran << designator.AsFortran();
507 } else if (auto symRef = detail::getRef<semantics::SymbolRef>(designator)) {
508 // Scalar or full array.
509 fir::ExtendedValue dataExv = converter.getSymbolExtendedValue(*symRef);
510 info = getDataOperandBaseAddr(converter, builder, *symRef,
511 operandLocation, unwrapFirBox);
512 if (genDefaultBounds && mlir::isa<fir::BaseBoxType>(
513 fir::unwrapRefType(info.addr.getType()))) {
514 info.boxType = fir::unwrapRefType(info.addr.getType());
516 builder, operandLocation, dataExv, info);
517 }
518 bool dataExvIsAssumedSize =
519 Fortran::semantics::IsAssumedSizeArray(symRef->get().GetUltimate());
520 if (genDefaultBounds && mlir::isa<fir::SequenceType>(
521 fir::unwrapRefType(info.addr.getType()))) {
523 builder, operandLocation, dataExv, dataExvIsAssumedSize,
524 strideIncludeLowerExtent);
525 }
526 if ((genDefaultBounds && fir::characterWithDynamicLen(
527 fir::unwrapRefType(info.addr.getType()))) ||
528 mlir::isa<fir::BoxCharType>(
529 fir::unwrapRefType(info.addr.getType()))) {
530 bounds = {fir::factory::genBoundsOpFromBoxChar<BoundsOp, BoundsType>(
531 builder, operandLocation, dataExv, info)};
532 }
533 asFortran << symRef->get().name().ToString();
534 } else { // Unsupported
535 llvm::report_fatal_error("Unsupported type of OpenACC operand");
536 }
537 }
538
539 return info;
540}
541
542} // namespace lower
543} // namespace Fortran
544
545#endif // FORTRAN_LOWER_DIRECTIVES_COMMON_H
Definition common.h:222
Definition type.h:61
Definition AbstractConverter.h:87
virtual fir::MutableBoxValue genExprMutableBox(mlir::Location loc, const SomeExpr &expr)=0
virtual mlir::Value getSymbolAddress(SymbolRef sym)=0
Get the mlir instance of a symbol.
virtual fir::ExtendedValue genExprValue(const SomeExpr &expr, StatementContext &context, mlir::Location *locPtr=nullptr)=0
Generate the computations of the expression to produce a value.
virtual fir::ExtendedValue genExprAddr(const SomeExpr &expr, StatementContext &context, mlir::Location *locPtr=nullptr, bool allowCoarray=false)=0
Definition StatementContext.h:46
Definition BoxValue.h:469
Definition FIRBuilder.h:66
mlir::Value createConvert(mlir::Location loc, mlir::Type toTy, mlir::Value val)
Lazy creation of fir.convert op.
Definition FIRBuilder.cpp:668
IfBuilder genIfOp(mlir::Location loc, mlir::TypeRange results, mlir::Value cdt, bool withElseRegion)
Definition FIRBuilder.h:589
mlir::Region & getRegion()
Get the current Region of the insertion point.
Definition FIRBuilder.h:120
mlir::Value createIntegerConstant(mlir::Location loc, mlir::Type integerType, std::int64_t i)
Definition FIRBuilder.cpp:150
Definition OpenACC.h:20
Definition ParserActions.h:24
llvm::SmallVector< mlir::Value > genBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc, Fortran::lower::AbstractConverter &converter, Fortran::lower::StatementContext &stmtCtx, const std::vector< Fortran::evaluate::Subscript > &subscripts, std::stringstream &asFortran, fir::ExtendedValue &dataExv, bool dataExvIsAssumedSize, fir::factory::AddrAndBoundsInfo &info, bool treatIndexAsSection=false, bool strideIncludeLowerExtent=false)
Definition DirectivesCommon.h:147
void createEmptyRegionBlocks(fir::FirOpBuilder &builder, std::list< Fortran::lower::pft::Evaluation > &evaluationList)
Definition DirectivesCommon.h:45
Definition bit-population-count.h:20
llvm::SmallVector< mlir::Value > genBaseBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc, fir::ExtendedValue dataExv, bool isAssumedSize, bool strideIncludeLowerExtent=false)
Definition DirectivesCommon.h:276
llvm::SmallVector< mlir::Value > genBoundsOpsFromBox(fir::FirOpBuilder &builder, mlir::Location loc, fir::ExtendedValue dataExv, AddrAndBoundsInfo &info)
Generate the bounds operation from the descriptor information.
Definition DirectivesCommon.h:209
mlir::Value readLowerBound(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &box, unsigned dim, mlir::Value defaultValue)
Definition FIRBuilder.cpp:1078
mlir::Value readExtent(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &box, unsigned dim)
Read or get the extent in dimension dim of the array described by box.
Definition FIRBuilder.cpp:1047
bool isBoxAddress(mlir::Type t)
Is t an address to fir.box or class type?
Definition FIRType.h:535
mlir::Value getBase(const ExtendedValue &exv)
Definition BoxValue.cpp:21
bool isPointerType(mlir::Type ty)
Definition FIRType.cpp:315
bool characterWithDynamicLen(mlir::Type t)
Returns true iff t is a fir.char type and has an unknown length.
Definition FIRType.h:263
bool isAllocatableType(mlir::Type ty)
Return true iff ty is the type of an ALLOCATABLE entity or value.
Definition FIRType.cpp:323
Definition expression.h:218
Definition variable.h:293
Definition type.h:408
Definition DirectivesCommon.h:96
Definition PFTBuilder.h:222
Definition DirectivesCommon.h:31