FLANG
FIRBuilder.h
1//===-- FirBuilder.h -- FIR operation builder -------------------*- 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// Builder routines for constructing the FIR dialect of MLIR. As FIR is a
10// dialect of MLIR, it makes extensive use of MLIR interfaces and MLIR's coding
11// style (https://mlir.llvm.org/getting_started/DeveloperGuide/) is used in this
12// module.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
17#define FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
18
19#include "flang/Optimizer/Dialect/FIRBoxUtils.h"
20#include "flang/Optimizer/Dialect/FIROps.h"
21#include "flang/Optimizer/Dialect/FIROpsSupport.h"
22#include "flang/Optimizer/Dialect/FIRType.h"
23#include "flang/Optimizer/Dialect/Support/FIRContext.h"
24#include "flang/Optimizer/Dialect/Support/KindMapping.h"
27#include "mlir/IR/Builders.h"
28#include "mlir/IR/BuiltinOps.h"
29#include "llvm/ADT/DenseMap.h"
30#include <optional>
31#include <utility>
32
33namespace mlir {
34class DataLayout;
35class SymbolTable;
36}
37
38namespace fir {
40class ExtendedValue;
41class MutableBoxValue;
42class BoxValue;
43
45constexpr unsigned defaultArrayGlobalAlignment = 64;
47inline mlir::Type getIntPtrType(mlir::OpBuilder &builder) {
48 // TODO: Delay the need of such type until codegen or find a way to use
49 // llvm::DataLayout::getPointerSizeInBits here.
50 return builder.getI64Type();
51}
52
53//===----------------------------------------------------------------------===//
54// FirOpBuilder
55//===----------------------------------------------------------------------===//
56
59class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
60public:
61 explicit FirOpBuilder(mlir::Operation *op, fir::KindMapping kindMap,
62 mlir::SymbolTable *symbolTable = nullptr)
63 : OpBuilder{op, /*listener=*/this}, kindMap{std::move(kindMap)},
64 symbolTable{symbolTable} {
65 auto fmi = mlir::dyn_cast<mlir::arith::ArithFastMathInterface>(*op);
66 if (fmi) {
67 // Set the builder with FastMathFlags attached to the operation.
68 setFastMathFlags(fmi.getFastMathFlagsAttr().getValue());
69 }
70 }
71 explicit FirOpBuilder(mlir::OpBuilder &builder, fir::KindMapping kindMap,
72 mlir::SymbolTable *symbolTable = nullptr)
73 : OpBuilder(builder), OpBuilder::Listener(), kindMap{std::move(kindMap)},
74 symbolTable{symbolTable} {
75 setListener(this);
76 }
77 explicit FirOpBuilder(mlir::OpBuilder &builder, mlir::ModuleOp mod)
78 : OpBuilder(builder), OpBuilder::Listener(),
79 kindMap{getKindMapping(mod)} {
80 setListener(this);
81 }
82 explicit FirOpBuilder(mlir::OpBuilder &builder, fir::KindMapping kindMap,
83 mlir::Operation *op)
84 : OpBuilder(builder), OpBuilder::Listener(), kindMap{std::move(kindMap)} {
85 setListener(this);
86 auto fmi = mlir::dyn_cast<mlir::arith::ArithFastMathInterface>(*op);
87 if (fmi) {
88 // Set the builder with FastMathFlags attached to the operation.
89 setFastMathFlags(fmi.getFastMathFlagsAttr().getValue());
90 }
91 }
92 FirOpBuilder(mlir::OpBuilder &builder, mlir::Operation *op)
93 : FirOpBuilder(builder, fir::getKindMapping(op), op) {}
94
95 // The listener self-reference has to be updated in case of copy-construction.
96 FirOpBuilder(const FirOpBuilder &other)
97 : OpBuilder(other), OpBuilder::Listener(), kindMap{other.kindMap},
98 fastMathFlags{other.fastMathFlags},
99 integerOverflowFlags{other.integerOverflowFlags},
100 symbolTable{other.symbolTable} {
101 setListener(this);
102 }
103
104 FirOpBuilder(FirOpBuilder &&other)
105 : OpBuilder(other), OpBuilder::Listener(),
106 kindMap{std::move(other.kindMap)}, fastMathFlags{other.fastMathFlags},
107 integerOverflowFlags{other.integerOverflowFlags},
108 symbolTable{other.symbolTable} {
109 setListener(this);
110 }
111
113 mlir::Region &getRegion() { return *getBlock()->getParent(); }
114
116 mlir::ModuleOp getModule() {
117 return getRegion().getParentOfType<mlir::ModuleOp>();
118 }
119
121 mlir::func::FuncOp getFunction() {
122 return getRegion().getParentOfType<mlir::func::FuncOp>();
123 }
124
126 const fir::KindMapping &getKindMap() { return kindMap; }
127
129 mlir::SymbolTable *getMLIRSymbolTable() { return symbolTable; }
130
132 [[maybe_unused]] mlir::IntegerType getDefaultIntegerType() {
133 return getIntegerType(
134 getKindMap().getIntegerBitsize(getKindMap().defaultIntegerKind()));
135 }
136
143 mlir::Value convertWithSemantics(mlir::Location loc, mlir::Type toTy,
144 mlir::Value val,
145 bool allowCharacterConversion = false,
146 bool allowRebox = false);
147
149 mlir::Block *getEntryBlock() { return &getFunction().front(); }
150
154 mlir::Block *getAllocaBlock();
155
157 mlir::Type getRefType(mlir::Type eleTy, bool isVolatile = false);
158
160 mlir::Type getVarLenSeqTy(mlir::Type eleTy, unsigned rank = 1);
161
163 mlir::Type getCharacterLengthType() { return getIndexType(); }
164
167 mlir::Type getIntPtrType() { return fir::getIntPtrType(*this); }
168
170 mlir::SymbolRefAttr getSymbolRefAttr(llvm::StringRef str) {
171 return mlir::SymbolRefAttr::get(getContext(), str);
172 }
173
175 mlir::Type getRealType(int kind);
176
177 fir::BoxProcType getBoxProcType(mlir::FunctionType funcTy) {
178 return fir::BoxProcType::get(getContext(), funcTy);
179 }
180
183 mlir::Value createNullConstant(mlir::Location loc, mlir::Type ptrType = {});
184
188 mlir::Value createIntegerConstant(mlir::Location loc, mlir::Type integerType,
189 std::int64_t i);
190
193 mlir::Value createAllOnesInteger(mlir::Location loc, mlir::Type integerType);
194
197 mlir::Value createMinusOneInteger(mlir::Location loc,
198 mlir::Type integerType) {
199 return createAllOnesInteger(loc, integerType);
200 }
201
203 mlir::Value createRealConstant(mlir::Location loc, mlir::Type realType,
204 llvm::APFloat::integerPart val);
205
207 mlir::Value createRealConstant(mlir::Location loc, mlir::Type realType,
208 const llvm::APFloat &val);
209
211 mlir::Value createRealZeroConstant(mlir::Location loc, mlir::Type realType) {
212 return createRealConstant(loc, realType, 0u);
213 }
214
216 mlir::Value createRealOneConstant(mlir::Location loc, mlir::Type realType) {
217 return createRealConstant(loc, realType, 1u);
218 }
219
222 mlir::Value allocateLocal(mlir::Location loc, mlir::Type ty,
223 llvm::StringRef uniqName, llvm::StringRef name,
224 bool pinned, llvm::ArrayRef<mlir::Value> shape,
226 bool asTarget = false);
227 mlir::Value allocateLocal(mlir::Location loc, mlir::Type ty,
228 llvm::StringRef uniqName, llvm::StringRef name,
231 bool asTarget = false);
232
235 mlir::ArrayAttr create2DI64ArrayAttr(
236 llvm::SmallVectorImpl<llvm::SmallVector<int64_t>> &intData);
237
241 mlir::Value createTemporaryAlloc(
242 mlir::Location loc, mlir::Type type, llvm::StringRef name,
243 mlir::ValueRange lenParams = {}, mlir::ValueRange shape = {},
244 llvm::ArrayRef<mlir::NamedAttribute> attrs = {},
245 std::optional<Fortran::common::CUDADataAttr> cudaAttr = std::nullopt);
246
250 mlir::Value createTemporary(
251 mlir::Location loc, mlir::Type type, llvm::StringRef name = {},
252 mlir::ValueRange shape = {}, mlir::ValueRange lenParams = {},
253 llvm::ArrayRef<mlir::NamedAttribute> attrs = {},
254 std::optional<Fortran::common::CUDADataAttr> cudaAttr = std::nullopt);
255
257 mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
258 mlir::ValueRange shape) {
259 return createTemporary(loc, type, llvm::StringRef{}, shape);
260 }
261
262 mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
264 return createTemporary(loc, type, llvm::StringRef{}, {}, {}, attrs);
265 }
266
267 mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
268 llvm::StringRef name,
269 llvm::ArrayRef<mlir::NamedAttribute> attrs) {
270 return createTemporary(loc, type, name, {}, {}, attrs);
271 }
272
274 mlir::Value
275 createHeapTemporary(mlir::Location loc, mlir::Type type,
276 llvm::StringRef name = {}, mlir::ValueRange shape = {},
277 mlir::ValueRange lenParams = {},
278 llvm::ArrayRef<mlir::NamedAttribute> attrs = {});
279
284 static mlir::Value genTempDeclareOp(fir::FirOpBuilder &builder,
285 mlir::Location loc, mlir::Value memref,
286 llvm::StringRef name, mlir::Value shape,
287 llvm::ArrayRef<mlir::Value> typeParams,
288 fir::FortranVariableFlagsAttr attrs);
289
306 std::pair<mlir::Value, bool> createAndDeclareTemp(
307 mlir::Location loc, mlir::Type baseType, mlir::Value shape,
308 llvm::ArrayRef<mlir::Value> extents,
309 llvm::ArrayRef<mlir::Value> typeParams,
310 const std::function<decltype(genTempDeclareOp)> &genDeclare,
311 mlir::Value polymorphicMold, bool useStack, llvm::StringRef tmpName);
313 std::pair<mlir::Value, bool>
314 createArrayTemp(mlir::Location loc, fir::SequenceType arrayType,
315 mlir::Value shape, llvm::ArrayRef<mlir::Value> extents,
317 const std::function<decltype(genTempDeclareOp)> &genDeclare,
318 mlir::Value polymorphicMold, bool useStack = false,
319 llvm::StringRef tmpName = ".tmp.array") {
320 return createAndDeclareTemp(loc, arrayType, shape, extents, typeParams,
321 genDeclare, polymorphicMold, useStack, tmpName);
322 }
323
327 mlir::Value genStackSave(mlir::Location loc);
328
331 void genStackRestore(mlir::Location loc, mlir::Value stackPointer);
332
334 fir::GlobalOp createGlobal(mlir::Location loc, mlir::Type type,
335 llvm::StringRef name,
336 mlir::StringAttr linkage = {},
337 mlir::Attribute value = {}, bool isConst = false,
338 bool isTarget = false,
339 cuf::DataAttributeAttr dataAttr = {},
340 bool setDefaultAlignment = true);
341
342 fir::GlobalOp createGlobal(mlir::Location loc, mlir::Type type,
343 llvm::StringRef name, bool isConst, bool isTarget,
344 std::function<void(FirOpBuilder &)> bodyBuilder,
345 mlir::StringAttr linkage = {},
346 cuf::DataAttributeAttr dataAttr = {},
347 bool setDefaultAlignment = true);
348
350 fir::GlobalOp createGlobalConstant(mlir::Location loc, mlir::Type type,
351 llvm::StringRef name,
352 mlir::StringAttr linkage = {},
353 mlir::Attribute value = {}) {
354 return createGlobal(loc, type, name, linkage, value, /*isConst=*/true,
355 /*isTarget=*/false);
356 }
357
358 fir::GlobalOp
359 createGlobalConstant(mlir::Location loc, mlir::Type type,
360 llvm::StringRef name,
361 std::function<void(FirOpBuilder &)> bodyBuilder,
362 mlir::StringAttr linkage = {}) {
363 return createGlobal(loc, type, name, /*isConst=*/true, /*isTarget=*/false,
364 bodyBuilder, linkage);
365 }
366
368 fir::StringLitOp createStringLitOp(mlir::Location loc,
369 llvm::StringRef string);
370
371 std::pair<fir::TypeInfoOp, mlir::OpBuilder::InsertPoint>
372 createTypeInfoOp(mlir::Location loc, fir::RecordType recordType,
373 fir::RecordType parentType);
374
375 //===--------------------------------------------------------------------===//
376 // Linkage helpers (inline). The default linkage is external.
377 //===--------------------------------------------------------------------===//
378
379 static mlir::StringAttr createCommonLinkage(mlir::MLIRContext *context) {
380 return mlir::StringAttr::get(context, "common");
381 }
382 mlir::StringAttr createCommonLinkage() {
383 return createCommonLinkage(getContext());
384 }
385
386 mlir::StringAttr createExternalLinkage() { return getStringAttr("external"); }
387
388 mlir::StringAttr createInternalLinkage() { return getStringAttr("internal"); }
389
390 mlir::StringAttr createLinkOnceLinkage() { return getStringAttr("linkonce"); }
391
392 mlir::StringAttr createLinkOnceODRLinkage() {
393 return getStringAttr("linkonce_odr");
394 }
395
396 mlir::StringAttr createWeakLinkage() { return getStringAttr("weak"); }
397
400 mlir::func::FuncOp getNamedFunction(llvm::StringRef name) {
402 }
403 static mlir::func::FuncOp
404 getNamedFunction(mlir::ModuleOp module, const mlir::SymbolTable *symbolTable,
405 llvm::StringRef name);
406
409 mlir::func::FuncOp getNamedFunction(mlir::SymbolRefAttr symbol) {
410 return getNamedFunction(getModule(), getMLIRSymbolTable(), symbol);
411 }
412 static mlir::func::FuncOp
413 getNamedFunction(mlir::ModuleOp module, const mlir::SymbolTable *symbolTable,
414 mlir::SymbolRefAttr symbol);
415
416 fir::GlobalOp getNamedGlobal(llvm::StringRef name) {
417 return getNamedGlobal(getModule(), getMLIRSymbolTable(), name);
418 }
419
420 static fir::GlobalOp getNamedGlobal(mlir::ModuleOp module,
421 const mlir::SymbolTable *symbolTable,
422 llvm::StringRef name);
423
425 mlir::Value createConvert(mlir::Location loc, mlir::Type toTy,
426 mlir::Value val);
427
430 mlir::Value createConvertWithVolatileCast(mlir::Location loc, mlir::Type toTy,
431 mlir::Value val);
432
434 mlir::Value createVolatileCast(mlir::Location loc, bool isVolatile,
435 mlir::Value value);
436
439 void createStoreWithConvert(mlir::Location loc, mlir::Value val,
440 mlir::Value addr);
441
444 mlir::Value loadIfRef(mlir::Location loc, mlir::Value val);
445
448 mlir::func::FuncOp createFunction(mlir::Location loc, llvm::StringRef name,
449 mlir::FunctionType ty) {
450 return createFunction(loc, getModule(), name, ty, getMLIRSymbolTable());
451 }
452
453 static mlir::func::FuncOp createFunction(mlir::Location loc,
454 mlir::ModuleOp module,
455 llvm::StringRef name,
456 mlir::FunctionType ty,
457 mlir::SymbolTable *);
458
463 mlir::func::FuncOp createRuntimeFunction(mlir::Location loc,
464 llvm::StringRef name,
465 mlir::FunctionType ty,
466 bool isIO = false);
467
469 mlir::Value convertToIndexType(mlir::Location loc, mlir::Value val) {
470 return createConvert(loc, getIndexType(), val);
471 }
472
474 mlir::Value genShape(mlir::Location loc, const fir::AbstractArrayBox &arr);
475 mlir::Value genShape(mlir::Location loc, llvm::ArrayRef<mlir::Value> shift,
477 mlir::Value genShape(mlir::Location loc, llvm::ArrayRef<mlir::Value> exts);
478 mlir::Value genShift(mlir::Location loc, llvm::ArrayRef<mlir::Value> shift);
479
482 mlir::Value createShape(mlir::Location loc, const fir::ExtendedValue &exv);
483
486 mlir::Value createSlice(mlir::Location loc, const fir::ExtendedValue &exv,
487 mlir::ValueRange triples, mlir::ValueRange path);
488
495 mlir::Value createBox(mlir::Location loc, const fir::ExtendedValue &exv,
496 bool isPolymorphic = false, bool isAssumedType = false);
497
498 mlir::Value createBox(mlir::Location loc, mlir::Type boxType,
499 mlir::Value addr, mlir::Value shape, mlir::Value slice,
500 llvm::ArrayRef<mlir::Value> lengths, mlir::Value tdesc);
501
503 mlir::Value createBool(mlir::Location loc, bool b) {
504 return createIntegerConstant(loc, getIntegerType(1), b ? 1 : 0);
505 }
506
507 //===--------------------------------------------------------------------===//
508 // If-Then-Else generation helper
509 //===--------------------------------------------------------------------===//
510
515 class IfBuilder {
516 public:
517 IfBuilder(fir::IfOp ifOp, FirOpBuilder &builder)
518 : ifOp{ifOp}, builder{builder} {}
519 template <typename CC>
520 IfBuilder &genThen(CC func) {
521 builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
522 func();
523 return *this;
524 }
525 template <typename CC>
526 IfBuilder &genElse(CC func) {
527 assert(!ifOp.getElseRegion().empty() && "must have else region");
528 builder.setInsertionPointToStart(&ifOp.getElseRegion().front());
529 func();
530 return *this;
531 }
532 void end() { builder.setInsertionPointAfter(ifOp); }
533
535 mlir::Operation::result_range getResults() {
536 end();
537 return ifOp.getResults();
538 }
539
540 fir::IfOp &getIfOp() { return ifOp; };
541
542 private:
543 fir::IfOp ifOp;
544 FirOpBuilder &builder;
545 };
546
549 IfBuilder genIfOp(mlir::Location loc, mlir::TypeRange results,
550 mlir::Value cdt, bool withElseRegion) {
551 auto op = fir::IfOp::create(*this, loc, results, cdt, withElseRegion);
552 return IfBuilder(op, *this);
553 }
554
557 IfBuilder genIfThen(mlir::Location loc, mlir::Value cdt) {
558 auto op = fir::IfOp::create(*this, loc, mlir::TypeRange(), cdt, false);
559 return IfBuilder(op, *this);
560 }
561
564 IfBuilder genIfThenElse(mlir::Location loc, mlir::Value cdt) {
565 auto op = fir::IfOp::create(*this, loc, mlir::TypeRange(), cdt, true);
566 return IfBuilder(op, *this);
567 }
568
569 mlir::Value genNot(mlir::Location loc, mlir::Value boolean) {
570 return mlir::arith::CmpIOp::create(*this, loc,
571 mlir::arith::CmpIPredicate::eq, boolean,
572 createBool(loc, false));
573 }
574
576 mlir::Value genIsNotNullAddr(mlir::Location loc, mlir::Value addr);
577
579 mlir::Value genIsNullAddr(mlir::Location loc, mlir::Value addr);
580
583 mlir::Value genExtentFromTriplet(mlir::Location loc, mlir::Value lb,
584 mlir::Value ub, mlir::Value step,
585 mlir::Type type, bool fold = false);
586
589 mlir::Value genAbsentOp(mlir::Location loc, mlir::Type argTy);
590
594 void setFastMathFlags(mlir::arith::FastMathFlags flags) {
595 fastMathFlags = flags;
596 }
597
601
603 mlir::arith::FastMathFlags getFastMathFlags() const { return fastMathFlags; }
604
610 mlir::arith::FastMathFlags flags = getFastMathFlags();
611 if (flags == mlir::arith::FastMathFlags::none)
612 return {};
613
614 std::string fmfString{mlir::arith::stringifyFastMathFlags(flags)};
615 std::replace(fmfString.begin(), fmfString.end(), ',', '_');
616 return fmfString;
617 }
618
622 void setIntegerOverflowFlags(mlir::arith::IntegerOverflowFlags flags) {
623 integerOverflowFlags = flags;
624 }
625
627 mlir::arith::IntegerOverflowFlags getIntegerOverflowFlags() const {
628 return integerOverflowFlags;
629 }
630
634 complexDivisionToRuntimeFlag = flag;
635 }
636
639 return complexDivisionToRuntimeFlag;
640 }
641
644 fpMaxminBehavior = mode;
645 }
646 Fortran::common::FPMaxminBehavior getFPMaxminBehavior() const {
647 return fpMaxminBehavior;
648 }
649
651 LLVM_DUMP_METHOD void dumpFunc();
652
654 void notifyOperationInserted(mlir::Operation *op,
655 mlir::OpBuilder::InsertPoint previous) override {
656 // We only care about newly created operations.
657 if (previous.isSet())
658 return;
659 setCommonAttributes(op);
660 }
661
663 mlir::DataLayout &getDataLayout();
664
667 template <typename OpTy>
668 mlir::Value createUnsigned(mlir::Location loc, mlir::Type resultType,
669 mlir::Value left, mlir::Value right) {
670 if (!resultType.isIntOrFloat())
671 return OpTy::create(*this, loc, resultType, left, right);
672 mlir::Type signlessType = mlir::IntegerType::get(
673 getContext(), resultType.getIntOrFloatBitWidth(),
674 mlir::IntegerType::SignednessSemantics::Signless);
675 mlir::Type opResType = resultType;
676 if (left.getType().isUnsignedInteger()) {
677 left = createConvert(loc, signlessType, left);
678 opResType = signlessType;
679 }
680 if (right.getType().isUnsignedInteger()) {
681 right = createConvert(loc, signlessType, right);
682 opResType = signlessType;
683 }
684 mlir::Value result = OpTy::create(*this, loc, opResType, left, right);
685 if (resultType.isUnsignedInteger())
686 result = createConvert(loc, resultType, result);
687 return result;
688 }
689
691 mlir::Value genPtrCompare(mlir::Location loc,
692 mlir::arith::CmpIPredicate predicate,
693 mlir::Value ptr1, mlir::Value ptr2) {
694 ptr1 = createConvert(loc, getIndexType(), ptr1);
695 ptr2 = createConvert(loc, getIndexType(), ptr2);
696 return mlir::arith::CmpIOp::create(*this, loc, predicate, ptr1, ptr2);
697 }
698
699private:
702 void setCommonAttributes(mlir::Operation *op) const;
703
704 KindMapping kindMap;
705
708 mlir::arith::FastMathFlags fastMathFlags{};
709
715 Fortran::common::FPMaxminBehavior fpMaxminBehavior{
716 Fortran::common::FPMaxminBehavior::Legacy};
717
720 mlir::arith::IntegerOverflowFlags integerOverflowFlags{};
721
724 bool complexDivisionToRuntimeFlag = true;
725
728 mlir::SymbolTable *symbolTable = nullptr;
729
733 std::unique_ptr<mlir::DataLayout> dataLayout = nullptr;
734};
735
736} // namespace fir
737
738namespace fir::factory {
739
741
742//===----------------------------------------------------------------------===//
743// ExtendedValue inquiry helpers
744//===----------------------------------------------------------------------===//
745
750mlir::Value readCharLen(fir::FirOpBuilder &builder, mlir::Location loc,
751 const fir::ExtendedValue &box);
752
754mlir::Value readExtent(fir::FirOpBuilder &builder, mlir::Location loc,
755 const fir::ExtendedValue &box, unsigned dim);
756
760mlir::Value readLowerBound(fir::FirOpBuilder &builder, mlir::Location loc,
761 const fir::ExtendedValue &box, unsigned dim,
762 mlir::Value defaultValue);
763
765llvm::SmallVector<mlir::Value> readExtents(fir::FirOpBuilder &builder,
766 mlir::Location loc,
767 const fir::BoxValue &box);
768
774fir::ExtendedValue readBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
775 const fir::BoxValue &box);
776
779llvm::SmallVector<mlir::Value>
780getNonDefaultLowerBounds(fir::FirOpBuilder &builder, mlir::Location loc,
781 const fir::ExtendedValue &exv);
782
786llvm::SmallVector<mlir::Value>
787getNonDeferredLenParams(const fir::ExtendedValue &exv);
788
789//===----------------------------------------------------------------------===//
790// String literal helper helpers
791//===----------------------------------------------------------------------===//
792
795fir::ExtendedValue createStringLiteral(fir::FirOpBuilder &, mlir::Location,
796 llvm::StringRef string);
797
800std::string uniqueCGIdent(llvm::StringRef prefix, llvm::StringRef name);
801
804llvm::SmallVector<mlir::Value> createExtents(fir::FirOpBuilder &builder,
805 mlir::Location loc,
806 fir::SequenceType seqTy);
807
808//===--------------------------------------------------------------------===//
809// Location helpers
810//===--------------------------------------------------------------------===//
811
813mlir::Value locationToFilename(fir::FirOpBuilder &, mlir::Location);
815mlir::Value locationToLineNo(fir::FirOpBuilder &, mlir::Location, mlir::Type);
816
817//===--------------------------------------------------------------------===//
818// ExtendedValue helpers
819//===--------------------------------------------------------------------===//
820
823fir::ExtendedValue componentToExtendedValue(fir::FirOpBuilder &builder,
824 mlir::Location loc,
825 mlir::Value component);
826
833fir::ExtendedValue arrayElementToExtendedValue(fir::FirOpBuilder &builder,
834 mlir::Location loc,
835 const fir::ExtendedValue &array,
836 mlir::Value element);
837
842fir::ExtendedValue arraySectionElementToExtendedValue(
843 fir::FirOpBuilder &builder, mlir::Location loc,
844 const fir::ExtendedValue &array, mlir::Value element, mlir::Value slice);
845
848void genScalarAssignment(fir::FirOpBuilder &builder, mlir::Location loc,
849 const fir::ExtendedValue &lhs,
850 const fir::ExtendedValue &rhs,
851 bool needFinalization = false,
852 bool isTemporaryLHS = false,
853 mlir::ArrayAttr accessGroups = {});
854
858void genRecordAssignment(fir::FirOpBuilder &builder, mlir::Location loc,
859 const fir::ExtendedValue &lhs,
860 const fir::ExtendedValue &rhs,
861 bool needFinalization = false,
862 bool isTemporaryLHS = false);
863
867mlir::TupleType getRaggedArrayHeaderType(fir::FirOpBuilder &builder);
868
873mlir::Value genLenOfCharacter(fir::FirOpBuilder &builder, mlir::Location loc,
874 fir::ArrayLoadOp arrLoad,
875 llvm::ArrayRef<mlir::Value> path,
876 llvm::ArrayRef<mlir::Value> substring);
877mlir::Value genLenOfCharacter(fir::FirOpBuilder &builder, mlir::Location loc,
878 fir::SequenceType seqTy, mlir::Value memref,
879 llvm::ArrayRef<mlir::Value> typeParams,
880 llvm::ArrayRef<mlir::Value> path,
881 llvm::ArrayRef<mlir::Value> substring);
882
885mlir::Value createZeroValue(fir::FirOpBuilder &builder, mlir::Location loc,
886 mlir::Type type);
887
890mlir::Value createOneValue(fir::FirOpBuilder &builder, mlir::Location loc,
891 mlir::Type type);
892
894std::optional<std::int64_t> getExtentFromTriplet(mlir::Value lb, mlir::Value ub,
895 mlir::Value stride);
896
899mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc,
900 mlir::Value lb, mlir::Value ub);
901mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc,
902 mlir::Value lb, mlir::Value ub, mlir::Value zero,
903 mlir::Value one);
904
906mlir::Value genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
907 mlir::Value value);
908mlir::Value genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
909 mlir::Value value, mlir::Value zero);
910
912mlir::Value genCPtrOrCFunptrAddr(fir::FirOpBuilder &builder, mlir::Location loc,
913 mlir::Value cPtr, mlir::Type ty);
914
916mlir::Value genCPtrOrCFunptrValue(fir::FirOpBuilder &builder,
917 mlir::Location loc, mlir::Value cPtr);
918
921fir::BoxValue createBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
922 const fir::ExtendedValue &exv);
923
925mlir::Value createNullBoxProc(fir::FirOpBuilder &builder, mlir::Location loc,
926 mlir::Type boxType);
927
930mlir::Value createConvert(mlir::OpBuilder &, mlir::Location, mlir::Type,
931 mlir::Value);
932
934void setInternalLinkage(mlir::func::FuncOp);
935
936llvm::SmallVector<mlir::Value>
937elideExtentsAlreadyInType(mlir::Type type, mlir::ValueRange shape);
938
939llvm::SmallVector<mlir::Value>
940elideLengthsAlreadyInType(mlir::Type type, mlir::ValueRange lenParams);
941
943uint64_t getAllocaAddressSpace(const mlir::DataLayout *dataLayout);
944
951llvm::SmallVector<mlir::Value> deduceOptimalExtents(mlir::ValueRange extents1,
952 mlir::ValueRange extents2);
953
954uint64_t getGlobalAddressSpace(mlir::DataLayout *dataLayout);
955
956uint64_t getProgramAddressSpace(mlir::DataLayout *dataLayout);
957
968llvm::SmallVector<mlir::Value> updateRuntimeExtentsForEmptyArrays(
969 fir::FirOpBuilder &builder, mlir::Location loc, mlir::ValueRange extents);
970
974mlir::Value genLifetimeStart(mlir::OpBuilder &builder, mlir::Location loc,
975 fir::AllocaOp alloc, const mlir::DataLayout *dl);
976
979void genLifetimeEnd(mlir::OpBuilder &builder, mlir::Location loc,
980 mlir::Value mem);
981
987mlir::Value getDescriptorWithNewBaseAddress(fir::FirOpBuilder &builder,
988 mlir::Location loc, mlir::Value box,
989 mlir::Value newAddr);
990
991} // namespace fir::factory
992
993#endif // FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
Definition MathOptionsBase.h:22
Definition BoxValue.h:125
Definition BoxValue.h:291
Definition BoxValue.h:478
Definition FIRBuilder.h:515
mlir::Operation::result_range getResults()
End the IfOp and return the results if any.
Definition FIRBuilder.h:535
Definition FIRBuilder.h:59
IfBuilder genIfThenElse(mlir::Location loc, mlir::Value cdt)
Definition FIRBuilder.h:564
fir::StringLitOp createStringLitOp(mlir::Location loc, llvm::StringRef string)
Convert a StringRef string into a fir::StringLitOp.
Definition FIRBuilder.cpp:640
mlir::Value genExtentFromTriplet(mlir::Location loc, mlir::Value lb, mlir::Value ub, mlir::Value step, mlir::Type type, bool fold=false)
Definition FIRBuilder.cpp:879
void genStackRestore(mlir::Location loc, mlir::Value stackPointer)
Definition FIRBuilder.cpp:441
mlir::SymbolRefAttr getSymbolRefAttr(llvm::StringRef str)
Wrap str to a SymbolRefAttr.
Definition FIRBuilder.h:170
mlir::Value createRealZeroConstant(mlir::Location loc, mlir::Type realType)
Create a real constant of type realType with a value zero.
Definition FIRBuilder.h:211
void setFPMaxminBehavior(Fortran::common::FPMaxminBehavior mode)
Setter/getter for fpMaxminBehavior.
Definition FIRBuilder.h:643
mlir::Value createSlice(mlir::Location loc, const fir::ExtendedValue &exv, mlir::ValueRange triples, mlir::ValueRange path)
Definition FIRBuilder.cpp:706
mlir::Value createConvert(mlir::Location loc, mlir::Type toTy, mlir::Value val)
Lazy creation of fir.convert op.
Definition FIRBuilder.cpp:620
IfBuilder genIfOp(mlir::Location loc, mlir::TypeRange results, mlir::Value cdt, bool withElseRegion)
Definition FIRBuilder.h:549
mlir::Value genIsNullAddr(mlir::Location loc, mlir::Value addr)
Generate code testing addr is a null address.
Definition FIRBuilder.cpp:864
mlir::func::FuncOp getNamedFunction(mlir::SymbolRefAttr symbol)
Definition FIRBuilder.h:409
mlir::Value createRealConstant(mlir::Location loc, mlir::Type realType, llvm::APFloat::integerPart val)
Create a real constant from an integer value.
Definition FIRBuilder.cpp:178
mlir::Type getCharacterLengthType()
Get character length type.
Definition FIRBuilder.h:163
mlir::Value createTemporaryAlloc(mlir::Location loc, mlir::Type type, llvm::StringRef name, mlir::ValueRange lenParams={}, mlir::ValueRange shape={}, llvm::ArrayRef< mlir::NamedAttribute > attrs={}, std::optional< Fortran::common::CUDADataAttr > cudaAttr=std::nullopt)
Definition FIRBuilder.cpp:330
IfBuilder genIfThen(mlir::Location loc, mlir::Value cdt)
Definition FIRBuilder.h:557
mlir::Value genStackSave(mlir::Location loc)
Definition FIRBuilder.cpp:435
mlir::Value genShape(mlir::Location loc, const fir::AbstractArrayBox &arr)
Construct one of the two forms of shape op from an array box.
Definition FIRBuilder.cpp:672
const fir::KindMapping & getKindMap()
Get a reference to the kind map.
Definition FIRBuilder.h:126
mlir::Type getRefType(mlir::Type eleTy, bool isVolatile=false)
Safely create a reference type to the type eleTy.
Definition FIRBuilder.cpp:109
mlir::Value createAllOnesInteger(mlir::Location loc, mlir::Type integerType)
Definition FIRBuilder.cpp:167
mlir::ModuleOp getModule()
Get the current Module.
Definition FIRBuilder.h:116
std::pair< mlir::Value, bool > createAndDeclareTemp(mlir::Location loc, mlir::Type baseType, mlir::Value shape, llvm::ArrayRef< mlir::Value > extents, llvm::ArrayRef< mlir::Value > typeParams, const std::function< decltype(genTempDeclareOp)> &genDeclare, mlir::Value polymorphicMold, bool useStack, llvm::StringRef tmpName)
Definition FIRBuilder.cpp:393
fir::GlobalOp createGlobalConstant(mlir::Location loc, mlir::Type type, llvm::StringRef name, mlir::StringAttr linkage={}, mlir::Attribute value={})
Create a global constant (read-only) value.
Definition FIRBuilder.h:350
mlir::Value createMinusOneInteger(mlir::Location loc, mlir::Type integerType)
Definition FIRBuilder.h:197
mlir::Value createVolatileCast(mlir::Location loc, bool isVolatile, mlir::Value value)
Cast value to have isVolatile volatility.
Definition FIRBuilder.cpp:590
void setComplexDivisionToRuntimeFlag(bool flag)
Definition FIRBuilder.h:633
mlir::IntegerType getDefaultIntegerType()
Get the default integer type.
Definition FIRBuilder.h:132
mlir::Value createNullConstant(mlir::Location loc, mlir::Type ptrType={})
Definition FIRBuilder.cpp:139
void setFastMathFlags(mlir::arith::FastMathFlags flags)
Definition FIRBuilder.h:594
LLVM_DUMP_METHOD void dumpFunc()
Dump the current function. (debug)
Definition FIRBuilder.cpp:846
mlir::ArrayAttr create2DI64ArrayAttr(llvm::SmallVectorImpl< llvm::SmallVector< int64_t > > &intData)
Definition FIRBuilder.cpp:320
mlir::Value convertWithSemantics(mlir::Location loc, mlir::Type toTy, mlir::Value val, bool allowCharacterConversion=false, bool allowRebox=false)
Definition FIRBuilder.cpp:517
mlir::SymbolTable * getMLIRSymbolTable()
Get func.func/fir.global symbol table attached to this builder if any.
Definition FIRBuilder.h:129
std::pair< mlir::Value, bool > createArrayTemp(mlir::Location loc, fir::SequenceType arrayType, mlir::Value shape, llvm::ArrayRef< mlir::Value > extents, llvm::ArrayRef< mlir::Value > typeParams, const std::function< decltype(genTempDeclareOp)> &genDeclare, mlir::Value polymorphicMold, bool useStack=false, llvm::StringRef tmpName=".tmp.array")
Create and declare an array temporary.
Definition FIRBuilder.h:314
mlir::Value genPtrCompare(mlir::Location loc, mlir::arith::CmpIPredicate predicate, mlir::Value ptr1, mlir::Value ptr2)
Compare two pointer-like values using the given predicate.
Definition FIRBuilder.h:691
mlir::Value genIsNotNullAddr(mlir::Location loc, mlir::Value addr)
Generate code testing addr is not a null address.
Definition FIRBuilder.cpp:858
mlir::Value convertToIndexType(mlir::Location loc, mlir::Value val)
Cast the input value to IndexType.
Definition FIRBuilder.h:469
void createStoreWithConvert(mlir::Location loc, mlir::Value val, mlir::Value addr)
Definition FIRBuilder.cpp:625
void setIntegerOverflowFlags(mlir::arith::IntegerOverflowFlags flags)
Definition FIRBuilder.h:622
mlir::func::FuncOp createRuntimeFunction(mlir::Location loc, llvm::StringRef name, mlir::FunctionType ty, bool isIO=false)
Definition FIRBuilder.cpp:53
mlir::Region & getRegion()
Get the current Region of the insertion point.
Definition FIRBuilder.h:113
void notifyOperationInserted(mlir::Operation *op, mlir::OpBuilder::InsertPoint previous) override
FirOpBuilder hook for creating new operation.
Definition FIRBuilder.h:654
static mlir::Value genTempDeclareOp(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value memref, llvm::StringRef name, mlir::Value shape, llvm::ArrayRef< mlir::Value > typeParams, fir::FortranVariableFlagsAttr attrs)
Definition FIRBuilder.cpp:421
mlir::func::FuncOp getNamedFunction(llvm::StringRef name)
Definition FIRBuilder.h:400
std::string getFastMathFlagsString()
Definition FIRBuilder.h:609
mlir::Value createUnsigned(mlir::Location loc, mlir::Type resultType, mlir::Value left, mlir::Value right)
Definition FIRBuilder.h:668
bool getComplexDivisionToRuntimeFlag() const
Get current ComplexDivisionToRuntimeFlag value.
Definition FIRBuilder.h:638
mlir::Value createBool(mlir::Location loc, bool b)
Create constant i1 with value 1. if b is true or 0. otherwise.
Definition FIRBuilder.h:503
mlir::arith::IntegerOverflowFlags getIntegerOverflowFlags() const
Get current IntegerOverflowFlags value.
Definition FIRBuilder.h:627
mlir::func::FuncOp getFunction()
Get the current Function.
Definition FIRBuilder.h:121
mlir::Value createTemporary(mlir::Location loc, mlir::Type type, llvm::StringRef name={}, mlir::ValueRange shape={}, mlir::ValueRange lenParams={}, llvm::ArrayRef< mlir::NamedAttribute > attrs={}, std::optional< Fortran::common::CUDADataAttr > cudaAttr=std::nullopt)
Definition FIRBuilder.cpp:354
mlir::Type getRealType(int kind)
Get the mlir float type that implements Fortran REAL(kind).
Definition FIRBuilder.cpp:119
mlir::Block * getAllocaBlock()
Get the block for adding Allocas.
Definition FIRBuilder.cpp:278
mlir::Type getVarLenSeqTy(mlir::Type eleTy, unsigned rank=1)
Create a sequence of eleTy with rank dimensions of unknown size.
Definition FIRBuilder.cpp:114
fir::GlobalOp createGlobal(mlir::Location loc, mlir::Type type, llvm::StringRef name, mlir::StringAttr linkage={}, mlir::Attribute value={}, bool isConst=false, bool isTarget=false, cuf::DataAttributeAttr dataAttr={}, bool setDefaultAlignment=true)
Create a global value.
Definition FIRBuilder.cpp:448
mlir::Value loadIfRef(mlir::Location loc, mlir::Value val)
Definition FIRBuilder.cpp:634
mlir::Value createHeapTemporary(mlir::Location loc, mlir::Type type, llvm::StringRef name={}, mlir::ValueRange shape={}, mlir::ValueRange lenParams={}, llvm::ArrayRef< mlir::NamedAttribute > attrs={})
Create a temporary on the heap.
Definition FIRBuilder.cpp:378
mlir::Value createConvertWithVolatileCast(mlir::Location loc, mlir::Type toTy, mlir::Value val)
Definition FIRBuilder.cpp:600
mlir::Value createShape(mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:685
mlir::Value allocateLocal(mlir::Location loc, mlir::Type ty, llvm::StringRef uniqName, llvm::StringRef name, bool pinned, llvm::ArrayRef< mlir::Value > shape, llvm::ArrayRef< mlir::Value > lenParams, bool asTarget=false)
Definition FIRBuilder.cpp:238
mlir::Value genAbsentOp(mlir::Location loc, mlir::Type argTy)
Definition FIRBuilder.cpp:898
mlir::arith::FastMathFlags getFastMathFlags() const
Get current FastMathFlags value.
Definition FIRBuilder.h:603
mlir::Value createIntegerConstant(mlir::Location loc, mlir::Type integerType, std::int64_t i)
Definition FIRBuilder.cpp:145
mlir::Value createBox(mlir::Location loc, const fir::ExtendedValue &exv, bool isPolymorphic=false, bool isAssumedType=false)
Definition FIRBuilder.cpp:757
mlir::Value createRealOneConstant(mlir::Location loc, mlir::Type realType)
Create a real constant of type realType with value one.
Definition FIRBuilder.h:216
mlir::Block * getEntryBlock()
Get the entry block of the current Function.
Definition FIRBuilder.h:149
mlir::func::FuncOp createFunction(mlir::Location loc, llvm::StringRef name, mlir::FunctionType ty)
Definition FIRBuilder.h:448
mlir::DataLayout & getDataLayout()
Construct a data layout on demand and return it.
Definition FIRBuilder.cpp:961
mlir::Value createTemporary(mlir::Location loc, mlir::Type type, mlir::ValueRange shape)
Create an unnamed and untracked temporary on the stack.
Definition FIRBuilder.h:257
mlir::Type getIntPtrType()
Definition FIRBuilder.h:167
Definition KindMapping.h:48
Definition BoxValue.h:360
Definition FIRType.h:103
Definition OpenACC.h:20
FPMaxminBehavior
Definition FPMaxminBehavior.h:29
Definition BoxValue.h:445
fir::ExtendedValue componentToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value component)
Definition FIRBuilder.cpp:1316
mlir::Value genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value value)
Generate max(value, 0) where value is a scalar integer.
Definition FIRBuilder.cpp:1761
mlir::Value createZeroValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type type)
Definition FIRBuilder.cpp:1681
void genScalarAssignment(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &lhs, const fir::ExtendedValue &rhs, bool needFinalization=false, bool isTemporaryLHS=false, mlir::ArrayAttr accessGroups={})
Definition FIRBuilder.cpp:1415
llvm::SmallVector< mlir::Value > deduceOptimalExtents(mlir::ValueRange extents1, mlir::ValueRange extents2)
Definition FIRBuilder.cpp:1918
mlir::Value getDescriptorWithNewBaseAddress(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value box, mlir::Value newAddr)
Definition FIRBuilder.cpp:1988
mlir::Value createOneValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type type)
Definition FIRBuilder.cpp:1700
mlir::Value readLowerBound(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &box, unsigned dim, mlir::Value defaultValue)
Definition FIRBuilder.cpp:1028
std::string uniqueCGIdent(llvm::StringRef prefix, llvm::StringRef name)
Definition FIRBuilder.cpp:1230
llvm::SmallVector< mlir::Value > updateRuntimeExtentsForEmptyArrays(fir::FirOpBuilder &builder, mlir::Location loc, mlir::ValueRange extents)
Definition FIRBuilder.cpp:1945
llvm::SmallVector< mlir::Value > getNonDefaultLowerBounds(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:1126
fir::ExtendedValue createStringLiteral(fir::FirOpBuilder &, mlir::Location, llvm::StringRef string)
Definition FIRBuilder.cpp:1268
mlir::TupleType getRaggedArrayHeaderType(fir::FirOpBuilder &builder)
Definition FIRBuilder.cpp:1614
mlir::Value locationToFilename(fir::FirOpBuilder &, mlir::Location)
Generate a string literal containing the file name and return its address.
Definition FIRBuilder.cpp:1250
mlir::Value locationToLineNo(fir::FirOpBuilder &, mlir::Location, mlir::Type)
Generate a constant of the given type with the location line number.
Definition FIRBuilder.cpp:1260
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:997
mlir::Value readCharLen(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &box)
Definition FIRBuilder.cpp:972
void genLifetimeEnd(mlir::OpBuilder &builder, mlir::Location loc, mlir::Value mem)
Definition FIRBuilder.cpp:1983
mlir::Value genCPtrOrCFunptrAddr(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value cPtr, mlir::Type ty)
Get the C address from a type(C_PTR/C_FUNPTR/C_DEVPTR) entity.
Definition FIRBuilder.cpp:1801
llvm::SmallVector< mlir::Value > readExtents(fir::FirOpBuilder &builder, mlir::Location loc, const fir::BoxValue &box)
Read extents from box.
Definition FIRBuilder.cpp:1058
std::optional< std::int64_t > getExtentFromTriplet(mlir::Value lb, mlir::Value ub, mlir::Value stride)
Get the integer constants of triplet and compute the extent.
Definition FIRBuilder.cpp:1721
mlir::Value genCPtrOrCFunptrValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value cPtr)
Get the C address value.
Definition FIRBuilder.cpp:1819
uint64_t getAllocaAddressSpace(const mlir::DataLayout *dataLayout)
Get the address space which should be used for allocas.
Definition FIRBuilder.cpp:1910
void setInternalLinkage(mlir::func::FuncOp)
Set internal linkage attribute on a function.
Definition FIRBuilder.cpp:1902
mlir::Value createNullBoxProc(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type boxType)
Generate Null BoxProc for procedure pointer null initialization.
Definition FIRBuilder.cpp:1891
fir::ExtendedValue arraySectionElementToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &array, mlir::Value element, mlir::Value slice)
Definition FIRBuilder.cpp:1400
mlir::Value genLenOfCharacter(fir::FirOpBuilder &builder, mlir::Location loc, fir::ArrayLoadOp arrLoad, llvm::ArrayRef< mlir::Value > path, llvm::ArrayRef< mlir::Value > substring)
Definition FIRBuilder.cpp:1623
fir::BoxValue createBoxValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:1853
void genRecordAssignment(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &lhs, const fir::ExtendedValue &rhs, bool needFinalization=false, bool isTemporaryLHS=false)
Definition FIRBuilder.cpp:1560
mlir::Value createConvert(mlir::OpBuilder &, mlir::Location, mlir::Type, mlir::Value)
Definition FIRBuilder.cpp:607
fir::ExtendedValue readBoxValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::BoxValue &box)
Definition FIRBuilder.cpp:1097
mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value lb, mlir::Value ub)
Definition FIRBuilder.cpp:1778
fir::ExtendedValue arrayElementToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &array, mlir::Value element)
Definition FIRBuilder.cpp:1370
llvm::SmallVector< mlir::Value > getNonDeferredLenParams(const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:1148
llvm::SmallVector< mlir::Value > createExtents(fir::FirOpBuilder &builder, mlir::Location loc, fir::SequenceType seqTy)
Definition FIRBuilder.cpp:1290
mlir::Value genLifetimeStart(mlir::OpBuilder &builder, mlir::Location loc, fir::AllocaOp alloc, const mlir::DataLayout *dl)
Definition FIRBuilder.cpp:1971
Definition AbstractConverter.h:37
KindMapping getKindMapping(mlir::ModuleOp mod)
Definition FIRContext.cpp:43
mlir::Type getIntPtrType(mlir::OpBuilder &builder)
Get the integer type with a pointer size.
Definition FIRBuilder.h:47
void genDimInfoFromBox(mlir::OpBuilder &builder, mlir::Location loc, mlir::Value box, llvm::SmallVectorImpl< mlir::Value > *lbounds, llvm::SmallVectorImpl< mlir::Value > *extents, llvm::SmallVectorImpl< mlir::Value > *strides)
Definition FIRBoxUtils.cpp:16
constexpr unsigned defaultArrayGlobalAlignment
Default alignment (in bytes) applied to array globals.
Definition FIRBuilder.h:45
bool isAssumedType(mlir::Type ty)
Definition FIRType.cpp:364
Definition AbstractConverter.h:32