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
58mlir::Block *getAllocaBlock(mlir::Region &region);
59
60//===----------------------------------------------------------------------===//
61// FirOpBuilder
62//===----------------------------------------------------------------------===//
63
66class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
67public:
68 explicit FirOpBuilder(mlir::Operation *op, fir::KindMapping kindMap,
69 mlir::SymbolTable *symbolTable = nullptr)
70 : OpBuilder{op, /*listener=*/this}, kindMap{std::move(kindMap)},
71 symbolTable{symbolTable} {
72 auto fmi = mlir::dyn_cast<mlir::arith::ArithFastMathInterface>(*op);
73 if (fmi) {
74 // Set the builder with FastMathFlags attached to the operation.
75 setFastMathFlags(fmi.getFastMathFlagsAttr().getValue());
76 }
77 }
78 explicit FirOpBuilder(mlir::OpBuilder &builder, fir::KindMapping kindMap,
79 mlir::SymbolTable *symbolTable = nullptr)
80 : OpBuilder(builder), OpBuilder::Listener(), kindMap{std::move(kindMap)},
81 symbolTable{symbolTable} {
82 setListener(this);
83 }
84 explicit FirOpBuilder(mlir::OpBuilder &builder, mlir::ModuleOp mod)
85 : OpBuilder(builder), OpBuilder::Listener(),
86 kindMap{getKindMapping(mod)} {
87 setListener(this);
88 }
89 explicit FirOpBuilder(mlir::OpBuilder &builder, fir::KindMapping kindMap,
90 mlir::Operation *op)
91 : OpBuilder(builder), OpBuilder::Listener(), kindMap{std::move(kindMap)} {
92 setListener(this);
93 auto fmi = mlir::dyn_cast<mlir::arith::ArithFastMathInterface>(*op);
94 if (fmi) {
95 // Set the builder with FastMathFlags attached to the operation.
96 setFastMathFlags(fmi.getFastMathFlagsAttr().getValue());
97 }
98 }
99 FirOpBuilder(mlir::OpBuilder &builder, mlir::Operation *op)
100 : FirOpBuilder(builder, fir::getKindMapping(op), op) {}
101
102 // The listener self-reference has to be updated in case of copy-construction.
103 FirOpBuilder(const FirOpBuilder &other)
104 : OpBuilder(other), OpBuilder::Listener(), kindMap{other.kindMap},
105 fastMathFlags{other.fastMathFlags},
106 integerOverflowFlags{other.integerOverflowFlags},
107 symbolTable{other.symbolTable} {
108 setListener(this);
109 }
110
111 FirOpBuilder(FirOpBuilder &&other)
112 : OpBuilder(other), OpBuilder::Listener(),
113 kindMap{std::move(other.kindMap)}, fastMathFlags{other.fastMathFlags},
114 integerOverflowFlags{other.integerOverflowFlags},
115 symbolTable{other.symbolTable} {
116 setListener(this);
117 }
118
120 mlir::Region &getRegion() { return *getBlock()->getParent(); }
121
123 mlir::ModuleOp getModule() {
124 return getRegion().getParentOfType<mlir::ModuleOp>();
125 }
126
128 mlir::func::FuncOp getFunction() {
129 return getRegion().getParentOfType<mlir::func::FuncOp>();
130 }
131
133 const fir::KindMapping &getKindMap() { return kindMap; }
134
136 mlir::SymbolTable *getMLIRSymbolTable() { return symbolTable; }
137
139 [[maybe_unused]] mlir::IntegerType getDefaultIntegerType() {
140 return getIntegerType(
141 getKindMap().getIntegerBitsize(getKindMap().defaultIntegerKind()));
142 }
143
150 mlir::Value convertWithSemantics(mlir::Location loc, mlir::Type toTy,
151 mlir::Value val,
152 bool allowCharacterConversion = false,
153 bool allowRebox = false);
154
156 mlir::Block *getEntryBlock() { return &getFunction().front(); }
157
161 mlir::Block *getAllocaBlock();
162
164 mlir::Type getRefType(mlir::Type eleTy, bool isVolatile = false);
165
167 mlir::Type getVarLenSeqTy(mlir::Type eleTy, unsigned rank = 1);
168
170 mlir::Type getCharacterLengthType() { return getIndexType(); }
171
174 mlir::Type getIntPtrType() { return fir::getIntPtrType(*this); }
175
177 mlir::SymbolRefAttr getSymbolRefAttr(llvm::StringRef str) {
178 return mlir::SymbolRefAttr::get(getContext(), str);
179 }
180
182 mlir::Type getRealType(int kind);
183
184 fir::BoxProcType getBoxProcType(mlir::FunctionType funcTy) {
185 return fir::BoxProcType::get(getContext(), funcTy);
186 }
187
190 mlir::Value createNullConstant(mlir::Location loc, mlir::Type ptrType = {});
191
195 mlir::Value createIntegerConstant(mlir::Location loc, mlir::Type integerType,
196 std::int64_t i);
197
202 mlir::Value createIntegerConstant(mlir::Location loc, mlir::Type integerType,
203 const llvm::APInt &value);
204
207 mlir::Value createAllOnesInteger(mlir::Location loc, mlir::Type integerType);
208
211 mlir::Value createMinusOneInteger(mlir::Location loc,
212 mlir::Type integerType) {
213 return createAllOnesInteger(loc, integerType);
214 }
215
217 mlir::Value createRealConstant(mlir::Location loc, mlir::Type realType,
218 llvm::APFloat::integerPart val);
219
221 mlir::Value createRealConstant(mlir::Location loc, mlir::Type realType,
222 const llvm::APFloat &val);
223
225 mlir::Value createRealZeroConstant(mlir::Location loc, mlir::Type realType) {
226 return createRealConstant(loc, realType, 0u);
227 }
228
230 mlir::Value createRealOneConstant(mlir::Location loc, mlir::Type realType) {
231 return createRealConstant(loc, realType, 1u);
232 }
233
236 mlir::Value allocateLocal(mlir::Location loc, mlir::Type ty,
237 llvm::StringRef uniqName, llvm::StringRef name,
238 bool pinned, llvm::ArrayRef<mlir::Value> shape,
240 bool asTarget = false);
241 mlir::Value allocateLocal(mlir::Location loc, mlir::Type ty,
242 llvm::StringRef uniqName, llvm::StringRef name,
245 bool asTarget = false);
246
249 mlir::ArrayAttr create2DI64ArrayAttr(
251
255 mlir::Value createTemporaryAlloc(
256 mlir::Location loc, mlir::Type type, llvm::StringRef name,
257 mlir::ValueRange lenParams = {}, mlir::ValueRange shape = {},
258 llvm::ArrayRef<mlir::NamedAttribute> attrs = {},
259 std::optional<Fortran::common::CUDADataAttr> cudaAttr = std::nullopt);
260
264 mlir::Value createTemporary(
265 mlir::Location loc, mlir::Type type, llvm::StringRef name = {},
266 mlir::ValueRange shape = {}, mlir::ValueRange lenParams = {},
267 llvm::ArrayRef<mlir::NamedAttribute> attrs = {},
268 std::optional<Fortran::common::CUDADataAttr> cudaAttr = std::nullopt);
269
271 mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
272 mlir::ValueRange shape) {
273 return createTemporary(loc, type, llvm::StringRef{}, shape);
274 }
275
276 mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
278 return createTemporary(loc, type, llvm::StringRef{}, {}, {}, attrs);
279 }
280
281 mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
282 llvm::StringRef name,
283 llvm::ArrayRef<mlir::NamedAttribute> attrs) {
284 return createTemporary(loc, type, name, {}, {}, attrs);
285 }
286
288 mlir::Value
289 createHeapTemporary(mlir::Location loc, mlir::Type type,
290 llvm::StringRef name = {}, mlir::ValueRange shape = {},
291 mlir::ValueRange lenParams = {},
292 llvm::ArrayRef<mlir::NamedAttribute> attrs = {});
293
298 static mlir::Value genTempDeclareOp(fir::FirOpBuilder &builder,
299 mlir::Location loc, mlir::Value memref,
300 llvm::StringRef name, mlir::Value shape,
301 llvm::ArrayRef<mlir::Value> typeParams,
302 fir::FortranVariableFlagsAttr attrs);
303
320 std::pair<mlir::Value, bool> createAndDeclareTemp(
321 mlir::Location loc, mlir::Type baseType, mlir::Value shape,
322 llvm::ArrayRef<mlir::Value> extents,
323 llvm::ArrayRef<mlir::Value> typeParams,
324 const std::function<decltype(genTempDeclareOp)> &genDeclare,
325 mlir::Value polymorphicMold, bool useStack, llvm::StringRef tmpName);
327 std::pair<mlir::Value, bool>
328 createArrayTemp(mlir::Location loc, fir::SequenceType arrayType,
329 mlir::Value shape, llvm::ArrayRef<mlir::Value> extents,
331 const std::function<decltype(genTempDeclareOp)> &genDeclare,
332 mlir::Value polymorphicMold, bool useStack = false,
333 llvm::StringRef tmpName = ".tmp.array") {
334 return createAndDeclareTemp(loc, arrayType, shape, extents, typeParams,
335 genDeclare, polymorphicMold, useStack, tmpName);
336 }
337
341 mlir::Value genStackSave(mlir::Location loc);
342
345 void genStackRestore(mlir::Location loc, mlir::Value stackPointer);
346
348 fir::GlobalOp createGlobal(mlir::Location loc, mlir::Type type,
349 llvm::StringRef name,
350 fir::LinkageAttr linkage = {},
351 mlir::Attribute value = {}, bool isConst = false,
352 bool isTarget = false,
353 cuf::DataAttributeAttr dataAttr = {},
354 bool setDefaultAlignment = true);
355
356 fir::GlobalOp createGlobal(mlir::Location loc, mlir::Type type,
357 llvm::StringRef name, bool isConst, bool isTarget,
358 std::function<void(FirOpBuilder &)> bodyBuilder,
359 fir::LinkageAttr linkage = {},
360 cuf::DataAttributeAttr dataAttr = {},
361 bool setDefaultAlignment = true);
362
364 fir::GlobalOp createGlobalConstant(mlir::Location loc, mlir::Type type,
365 llvm::StringRef name,
366 fir::LinkageAttr linkage = {},
367 mlir::Attribute value = {}) {
368 return createGlobal(loc, type, name, linkage, value, /*isConst=*/true,
369 /*isTarget=*/false);
370 }
371
372 fir::GlobalOp
373 createGlobalConstant(mlir::Location loc, mlir::Type type,
374 llvm::StringRef name,
375 std::function<void(FirOpBuilder &)> bodyBuilder,
376 fir::LinkageAttr linkage = {}) {
377 return createGlobal(loc, type, name, /*isConst=*/true, /*isTarget=*/false,
378 bodyBuilder, linkage);
379 }
380
382 fir::StringLitOp createStringLitOp(mlir::Location loc,
383 llvm::StringRef string);
384
385 std::pair<fir::TypeInfoOp, mlir::OpBuilder::InsertPoint>
386 createTypeInfoOp(mlir::Location loc, fir::RecordType recordType,
387 fir::RecordType parentType);
388
389 //===--------------------------------------------------------------------===//
390 // Linkage helpers (inline). The default linkage is external.
391 //===--------------------------------------------------------------------===//
392
393 static fir::LinkageAttr createCommonLinkage(mlir::MLIRContext *context) {
394 return fir::LinkageAttr::get(context, fir::LinkageEnum::Common);
395 }
396 fir::LinkageAttr createCommonLinkage() {
397 return createCommonLinkage(getContext());
398 }
399
400 fir::LinkageAttr createExternalLinkage() {
401 return fir::LinkageAttr::get(getContext(), fir::LinkageEnum::External);
402 }
403
404 fir::LinkageAttr createInternalLinkage() {
405 return fir::LinkageAttr::get(getContext(), fir::LinkageEnum::Internal);
406 }
407
408 fir::LinkageAttr createLinkOnceLinkage() {
409 return fir::LinkageAttr::get(getContext(), fir::LinkageEnum::Linkonce);
410 }
411
412 fir::LinkageAttr createLinkOnceODRLinkage() {
413 return fir::LinkageAttr::get(getContext(), fir::LinkageEnum::LinkonceODR);
414 }
415
416 fir::LinkageAttr createWeakLinkage() {
417 return fir::LinkageAttr::get(getContext(), fir::LinkageEnum::Weak);
418 }
419
422 mlir::func::FuncOp getNamedFunction(llvm::StringRef name) {
424 }
425 static mlir::func::FuncOp
426 getNamedFunction(mlir::ModuleOp module, const mlir::SymbolTable *symbolTable,
427 llvm::StringRef name);
428
431 mlir::func::FuncOp getNamedFunction(mlir::SymbolRefAttr symbol) {
432 return getNamedFunction(getModule(), getMLIRSymbolTable(), symbol);
433 }
434 static mlir::func::FuncOp
435 getNamedFunction(mlir::ModuleOp module, const mlir::SymbolTable *symbolTable,
436 mlir::SymbolRefAttr symbol);
437
438 fir::GlobalOp getNamedGlobal(llvm::StringRef name) {
439 return getNamedGlobal(getModule(), getMLIRSymbolTable(), name);
440 }
441
442 static fir::GlobalOp getNamedGlobal(mlir::ModuleOp module,
443 const mlir::SymbolTable *symbolTable,
444 llvm::StringRef name);
445
447 mlir::Value createConvert(mlir::Location loc, mlir::Type toTy,
448 mlir::Value val);
449
452 mlir::Value createConvertWithVolatileCast(mlir::Location loc, mlir::Type toTy,
453 mlir::Value val);
454
456 mlir::Value createVolatileCast(mlir::Location loc, bool isVolatile,
457 mlir::Value value);
458
461 void createStoreWithConvert(mlir::Location loc, mlir::Value val,
462 mlir::Value addr);
463
466 mlir::Value loadIfRef(mlir::Location loc, mlir::Value val);
467
470 mlir::func::FuncOp createFunction(mlir::Location loc, llvm::StringRef name,
471 mlir::FunctionType ty) {
472 return createFunction(loc, getModule(), name, ty, getMLIRSymbolTable());
473 }
474
475 static mlir::func::FuncOp createFunction(mlir::Location loc,
476 mlir::ModuleOp module,
477 llvm::StringRef name,
478 mlir::FunctionType ty,
479 mlir::SymbolTable *);
480
485 mlir::func::FuncOp createRuntimeFunction(mlir::Location loc,
486 llvm::StringRef name,
487 mlir::FunctionType ty,
488 bool isIO = false);
489
491 mlir::Value convertToIndexType(mlir::Location loc, mlir::Value val) {
492 return createConvert(loc, getIndexType(), val);
493 }
494
496 mlir::Value genShape(mlir::Location loc, const fir::AbstractArrayBox &arr);
497 mlir::Value genShape(mlir::Location loc, llvm::ArrayRef<mlir::Value> shift,
499 mlir::Value genShape(mlir::Location loc, llvm::ArrayRef<mlir::Value> exts);
500 mlir::Value genShift(mlir::Location loc, llvm::ArrayRef<mlir::Value> shift);
501
504 mlir::Value createShape(mlir::Location loc, const fir::ExtendedValue &exv);
505
508 mlir::Value createSlice(mlir::Location loc, const fir::ExtendedValue &exv,
509 mlir::ValueRange triples, mlir::ValueRange path);
510
517 mlir::Value createBox(mlir::Location loc, const fir::ExtendedValue &exv,
518 bool isPolymorphic = false, bool isAssumedType = false,
519 unsigned corank = 0);
520
521 mlir::Value createBox(mlir::Location loc, mlir::Type boxType,
522 mlir::Value addr, mlir::Value shape, mlir::Value slice,
523 llvm::ArrayRef<mlir::Value> lengths, mlir::Value tdesc);
524
526 mlir::Value createBool(mlir::Location loc, bool b) {
527 return createIntegerConstant(loc, getIntegerType(1), b ? 1 : 0);
528 }
529
530 //===--------------------------------------------------------------------===//
531 // If-Then-Else generation helper
532 //===--------------------------------------------------------------------===//
533
538 class IfBuilder {
539 public:
540 IfBuilder(fir::IfOp ifOp, FirOpBuilder &builder)
541 : ifOp{ifOp}, builder{builder} {}
542 template <typename CC>
543 IfBuilder &genThen(CC func) {
544 builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
545 func();
546 return *this;
547 }
548 template <typename CC>
549 IfBuilder &genElse(CC func) {
550 assert(!ifOp.getElseRegion().empty() && "must have else region");
551 builder.setInsertionPointToStart(&ifOp.getElseRegion().front());
552 func();
553 return *this;
554 }
555 void end() { builder.setInsertionPointAfter(ifOp); }
556
558 mlir::Operation::result_range getResults() {
559 end();
560 return ifOp.getResults();
561 }
562
563 fir::IfOp &getIfOp() { return ifOp; };
564
565 private:
566 fir::IfOp ifOp;
567 FirOpBuilder &builder;
568 };
569
572 IfBuilder genIfOp(mlir::Location loc, mlir::TypeRange results,
573 mlir::Value cdt, bool withElseRegion) {
574 auto op = fir::IfOp::create(*this, loc, results, cdt, withElseRegion);
575 return IfBuilder(op, *this);
576 }
577
580 IfBuilder genIfThen(mlir::Location loc, mlir::Value cdt) {
581 auto op = fir::IfOp::create(*this, loc, mlir::TypeRange(), cdt, false);
582 return IfBuilder(op, *this);
583 }
584
587 IfBuilder genIfThenElse(mlir::Location loc, mlir::Value cdt) {
588 auto op = fir::IfOp::create(*this, loc, mlir::TypeRange(), cdt, true);
589 return IfBuilder(op, *this);
590 }
591
592 mlir::Value genNot(mlir::Location loc, mlir::Value boolean) {
593 return mlir::arith::CmpIOp::create(*this, loc,
594 mlir::arith::CmpIPredicate::eq, boolean,
595 createBool(loc, false));
596 }
597
599 mlir::Value genIsNotNullAddr(mlir::Location loc, mlir::Value addr);
600
602 mlir::Value genIsNullAddr(mlir::Location loc, mlir::Value addr);
603
606 mlir::Value genExtentFromTriplet(mlir::Location loc, mlir::Value lb,
607 mlir::Value ub, mlir::Value step,
608 mlir::Type type, bool fold = false);
609
612 mlir::Value genAbsentOp(mlir::Location loc, mlir::Type argTy);
613
617 void setFastMathFlags(mlir::arith::FastMathFlags flags) {
618 fastMathFlags = flags;
619 }
620
624
626 mlir::arith::FastMathFlags getFastMathFlags() const { return fastMathFlags; }
627
633 mlir::arith::FastMathFlags flags = getFastMathFlags();
634 if (flags == mlir::arith::FastMathFlags::none)
635 return {};
636
637 std::string fmfString{mlir::arith::stringifyFastMathFlags(flags)};
638 std::replace(fmfString.begin(), fmfString.end(), ',', '_');
639 return fmfString;
640 }
641
644 class FastMathFlagGuard {
645 public:
646 FastMathFlagGuard(FirOpBuilder &builder, mlir::arith::FastMathFlags flags)
647 : builder{builder}, savedFlags{builder.getFastMathFlags()} {
648 builder.setFastMathFlags(flags);
649 }
650 FastMathFlagGuard(const FastMathFlagGuard &) = delete;
651 FastMathFlagGuard &operator=(const FastMathFlagGuard &) = delete;
652 ~FastMathFlagGuard() { builder.setFastMathFlags(savedFlags); }
653
654 private:
655 FirOpBuilder &builder;
656 mlir::arith::FastMathFlags savedFlags;
657 };
658
662 void setIntegerOverflowFlags(mlir::arith::IntegerOverflowFlags flags) {
663 integerOverflowFlags = flags;
664 }
665
667 mlir::arith::IntegerOverflowFlags getIntegerOverflowFlags() const {
668 return integerOverflowFlags;
669 }
670
674 complexDivisionToRuntimeFlag = flag;
675 }
676
679 return complexDivisionToRuntimeFlag;
680 }
681
684 fpMaxminBehavior = mode;
685 }
686 Fortran::common::FPMaxminBehavior getFPMaxminBehavior() const {
687 return fpMaxminBehavior;
688 }
689
691 LLVM_DUMP_METHOD void dumpFunc();
692
694 void notifyOperationInserted(mlir::Operation *op,
695 mlir::OpBuilder::InsertPoint previous) override {
696 // We only care about newly created operations.
697 if (previous.isSet())
698 return;
699 setCommonAttributes(op);
700 }
701
703 mlir::DataLayout &getDataLayout();
704
707 template <typename OpTy>
708 mlir::Value createUnsigned(mlir::Location loc, mlir::Type resultType,
709 mlir::Value left, mlir::Value right) {
710 if (!resultType.isIntOrFloat())
711 return OpTy::create(*this, loc, resultType, left, right);
712 mlir::Type signlessType = mlir::IntegerType::get(
713 getContext(), resultType.getIntOrFloatBitWidth(),
714 mlir::IntegerType::SignednessSemantics::Signless);
715 mlir::Type opResType = resultType;
716 if (left.getType().isUnsignedInteger()) {
717 left = createConvert(loc, signlessType, left);
718 opResType = signlessType;
719 }
720 if (right.getType().isUnsignedInteger()) {
721 right = createConvert(loc, signlessType, right);
722 opResType = signlessType;
723 }
724 mlir::Value result = OpTy::create(*this, loc, opResType, left, right);
725 if (resultType.isUnsignedInteger())
726 result = createConvert(loc, resultType, result);
727 return result;
728 }
729
731 mlir::Value genPtrCompare(mlir::Location loc,
732 mlir::arith::CmpIPredicate predicate,
733 mlir::Value ptr1, mlir::Value ptr2) {
734 ptr1 = createConvert(loc, getIndexType(), ptr1);
735 ptr2 = createConvert(loc, getIndexType(), ptr2);
736 return mlir::arith::CmpIOp::create(*this, loc, predicate, ptr1, ptr2);
737 }
738
739private:
742 void setCommonAttributes(mlir::Operation *op) const;
743
744 KindMapping kindMap;
745
748 mlir::arith::FastMathFlags fastMathFlags{};
749
755 Fortran::common::FPMaxminBehavior fpMaxminBehavior{
756 Fortran::common::FPMaxminBehavior::Legacy};
757
760 mlir::arith::IntegerOverflowFlags integerOverflowFlags{};
761
764 bool complexDivisionToRuntimeFlag = true;
765
768 mlir::SymbolTable *symbolTable = nullptr;
769
773 std::unique_ptr<mlir::DataLayout> dataLayout = nullptr;
774};
775
776} // namespace fir
777
778namespace fir::factory {
779
781
782//===----------------------------------------------------------------------===//
783// ExtendedValue inquiry helpers
784//===----------------------------------------------------------------------===//
785
790mlir::Value readCharLen(fir::FirOpBuilder &builder, mlir::Location loc,
791 const fir::ExtendedValue &box);
792
794mlir::Value readExtent(fir::FirOpBuilder &builder, mlir::Location loc,
795 const fir::ExtendedValue &box, unsigned dim);
796
800mlir::Value readLowerBound(fir::FirOpBuilder &builder, mlir::Location loc,
801 const fir::ExtendedValue &box, unsigned dim,
802 mlir::Value defaultValue);
803
805llvm::SmallVector<mlir::Value> readExtents(fir::FirOpBuilder &builder,
806 mlir::Location loc,
807 const fir::BoxValue &box);
808
814fir::ExtendedValue readBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
815 const fir::BoxValue &box);
816
819llvm::SmallVector<mlir::Value>
820getNonDefaultLowerBounds(fir::FirOpBuilder &builder, mlir::Location loc,
821 const fir::ExtendedValue &exv);
822
823//===----------------------------------------------------------------------===//
824// String literal helper helpers
825//===----------------------------------------------------------------------===//
826
829fir::ExtendedValue createStringLiteral(fir::FirOpBuilder &, mlir::Location,
830 llvm::StringRef string);
831
834std::string uniqueCGIdent(llvm::StringRef prefix, llvm::StringRef name);
835
838llvm::SmallVector<mlir::Value> createExtents(fir::FirOpBuilder &builder,
839 mlir::Location loc,
840 fir::SequenceType seqTy);
841
842//===--------------------------------------------------------------------===//
843// Location helpers
844//===--------------------------------------------------------------------===//
845
847mlir::Value locationToFilename(fir::FirOpBuilder &, mlir::Location);
849mlir::Value locationToLineNo(fir::FirOpBuilder &, mlir::Location, mlir::Type);
850
851//===--------------------------------------------------------------------===//
852// ExtendedValue helpers
853//===--------------------------------------------------------------------===//
854
857fir::ExtendedValue componentToExtendedValue(fir::FirOpBuilder &builder,
858 mlir::Location loc,
859 mlir::Value component);
860
867fir::ExtendedValue arrayElementToExtendedValue(fir::FirOpBuilder &builder,
868 mlir::Location loc,
869 const fir::ExtendedValue &array,
870 mlir::Value element);
871
876fir::ExtendedValue arraySectionElementToExtendedValue(
877 fir::FirOpBuilder &builder, mlir::Location loc,
878 const fir::ExtendedValue &array, mlir::Value element, mlir::Value slice);
879
882void genScalarAssignment(fir::FirOpBuilder &builder, mlir::Location loc,
883 const fir::ExtendedValue &lhs,
884 const fir::ExtendedValue &rhs,
885 bool needFinalization = false,
886 bool isTemporaryLHS = false,
887 mlir::ArrayAttr accessGroups = {});
888
892void genRecordAssignment(fir::FirOpBuilder &builder, mlir::Location loc,
893 const fir::ExtendedValue &lhs,
894 const fir::ExtendedValue &rhs,
895 bool needFinalization = false,
896 bool isTemporaryLHS = false);
897
900mlir::Value createZeroValue(fir::FirOpBuilder &builder, mlir::Location loc,
901 mlir::Type type);
902
905mlir::Value createOneValue(fir::FirOpBuilder &builder, mlir::Location loc,
906 mlir::Type type);
907
910mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc,
911 mlir::Value lb, mlir::Value ub);
912mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc,
913 mlir::Value lb, mlir::Value ub, mlir::Value zero,
914 mlir::Value one);
915
917mlir::Value genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
918 mlir::Value value);
919mlir::Value genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
920 mlir::Value value, mlir::Value zero);
921
923mlir::Value genCPtrOrCFunptrAddr(fir::FirOpBuilder &builder, mlir::Location loc,
924 mlir::Value cPtr, mlir::Type ty);
925
927mlir::Value genCPtrOrCFunptrValue(fir::FirOpBuilder &builder,
928 mlir::Location loc, mlir::Value cPtr);
929
932fir::BoxValue createBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
933 const fir::ExtendedValue &exv,
934 unsigned corank = 0);
935
937mlir::Value createNullBoxProc(fir::FirOpBuilder &builder, mlir::Location loc,
938 mlir::Type boxType);
939
942mlir::Value createConvert(mlir::OpBuilder &, mlir::Location, mlir::Type,
943 mlir::Value);
944
946void setInternalLinkage(mlir::func::FuncOp);
947
948llvm::SmallVector<mlir::Value>
949elideExtentsAlreadyInType(mlir::Type type, mlir::ValueRange shape);
950
951llvm::SmallVector<mlir::Value>
952elideLengthsAlreadyInType(mlir::Type type, mlir::ValueRange lenParams);
953
955uint64_t getAllocaAddressSpace(const mlir::DataLayout *dataLayout);
956
963llvm::SmallVector<mlir::Value> deduceOptimalExtents(mlir::ValueRange extents1,
964 mlir::ValueRange extents2);
965
966uint64_t getGlobalAddressSpace(mlir::DataLayout *dataLayout);
967
968uint64_t getProgramAddressSpace(mlir::DataLayout *dataLayout);
969
980llvm::SmallVector<mlir::Value> updateRuntimeExtentsForEmptyArrays(
981 fir::FirOpBuilder &builder, mlir::Location loc, mlir::ValueRange extents);
982
986mlir::Value genLifetimeStart(mlir::OpBuilder &builder, mlir::Location loc,
987 fir::AllocaOp alloc, const mlir::DataLayout *dl);
988
991void genLifetimeEnd(mlir::OpBuilder &builder, mlir::Location loc,
992 mlir::Value mem);
993
999mlir::Value getDescriptorWithNewBaseAddress(fir::FirOpBuilder &builder,
1000 mlir::Location loc, mlir::Value box,
1001 mlir::Value newAddr);
1002
1004std::optional<mlir::Value>
1005genIndexBasedDisjointnessCheck(mlir::Location loc, fir::FirOpBuilder &builder,
1006 mlir::Value lhsRef, mlir::Value rhsRef);
1007
1009std::optional<mlir::Value>
1010genAddressBasedDisjointnessCheck(mlir::Location loc, fir::FirOpBuilder &builder,
1011 mlir::Value lhsRef, mlir::Value rhsRef);
1012
1013} // namespace fir::factory
1014
1015#endif // FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
Definition MathOptionsBase.h:22
Definition BoxValue.h:124
Definition BoxValue.h:292
Definition BoxValue.h:469
Definition FIRBuilder.h:538
mlir::Operation::result_range getResults()
End the IfOp and return the results if any.
Definition FIRBuilder.h:558
Definition FIRBuilder.h:66
IfBuilder genIfThenElse(mlir::Location loc, mlir::Value cdt)
Definition FIRBuilder.h:587
fir::StringLitOp createStringLitOp(mlir::Location loc, llvm::StringRef string)
Convert a StringRef string into a fir::StringLitOp.
Definition FIRBuilder.cpp:674
mlir::Value genExtentFromTriplet(mlir::Location loc, mlir::Value lb, mlir::Value ub, mlir::Value step, mlir::Type type, bool fold=false)
Definition FIRBuilder.cpp:913
void genStackRestore(mlir::Location loc, mlir::Value stackPointer)
Definition FIRBuilder.cpp:475
mlir::SymbolRefAttr getSymbolRefAttr(llvm::StringRef str)
Wrap str to a SymbolRefAttr.
Definition FIRBuilder.h:177
mlir::Value createRealZeroConstant(mlir::Location loc, mlir::Type realType)
Create a real constant of type realType with a value zero.
Definition FIRBuilder.h:225
void setFPMaxminBehavior(Fortran::common::FPMaxminBehavior mode)
Setter/getter for fpMaxminBehavior.
Definition FIRBuilder.h:683
mlir::Value createSlice(mlir::Location loc, const fir::ExtendedValue &exv, mlir::ValueRange triples, mlir::ValueRange path)
Definition FIRBuilder.cpp:740
mlir::Value createConvert(mlir::Location loc, mlir::Type toTy, mlir::Value val)
Lazy creation of fir.convert op.
Definition FIRBuilder.cpp:654
IfBuilder genIfOp(mlir::Location loc, mlir::TypeRange results, mlir::Value cdt, bool withElseRegion)
Definition FIRBuilder.h:572
mlir::Value genIsNullAddr(mlir::Location loc, mlir::Value addr)
Generate code testing addr is a null address.
Definition FIRBuilder.cpp:898
mlir::func::FuncOp getNamedFunction(mlir::SymbolRefAttr symbol)
Definition FIRBuilder.h:431
mlir::Value createRealConstant(mlir::Location loc, mlir::Type realType, llvm::APFloat::integerPart val)
Create a real constant from an integer value.
Definition FIRBuilder.cpp:199
mlir::Type getCharacterLengthType()
Get character length type.
Definition FIRBuilder.h:170
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:364
IfBuilder genIfThen(mlir::Location loc, mlir::Value cdt)
Definition FIRBuilder.h:580
mlir::Value genStackSave(mlir::Location loc)
Definition FIRBuilder.cpp:469
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:706
const fir::KindMapping & getKindMap()
Get a reference to the kind map.
Definition FIRBuilder.h:133
mlir::Type getRefType(mlir::Type eleTy, bool isVolatile=false)
Safely create a reference type to the type eleTy.
Definition FIRBuilder.cpp:112
mlir::Value createAllOnesInteger(mlir::Location loc, mlir::Type integerType)
Definition FIRBuilder.cpp:188
mlir::ModuleOp getModule()
Get the current Module.
Definition FIRBuilder.h:123
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:427
mlir::Value createMinusOneInteger(mlir::Location loc, mlir::Type integerType)
Definition FIRBuilder.h:211
mlir::Value createVolatileCast(mlir::Location loc, bool isVolatile, mlir::Value value)
Cast value to have isVolatile volatility.
Definition FIRBuilder.cpp:624
void setComplexDivisionToRuntimeFlag(bool flag)
Definition FIRBuilder.h:673
mlir::IntegerType getDefaultIntegerType()
Get the default integer type.
Definition FIRBuilder.h:139
mlir::Value createNullConstant(mlir::Location loc, mlir::Type ptrType={})
Definition FIRBuilder.cpp:142
void setFastMathFlags(mlir::arith::FastMathFlags flags)
Definition FIRBuilder.h:617
LLVM_DUMP_METHOD void dumpFunc()
Dump the current function. (debug)
Definition FIRBuilder.cpp:880
mlir::ArrayAttr create2DI64ArrayAttr(llvm::SmallVectorImpl< llvm::SmallVector< int64_t > > &intData)
Definition FIRBuilder.cpp:354
fir::GlobalOp createGlobal(mlir::Location loc, mlir::Type type, llvm::StringRef name, fir::LinkageAttr linkage={}, mlir::Attribute value={}, bool isConst=false, bool isTarget=false, cuf::DataAttributeAttr dataAttr={}, bool setDefaultAlignment=true)
Create a global value.
Definition FIRBuilder.cpp:482
mlir::Value convertWithSemantics(mlir::Location loc, mlir::Type toTy, mlir::Value val, bool allowCharacterConversion=false, bool allowRebox=false)
Definition FIRBuilder.cpp:551
mlir::SymbolTable * getMLIRSymbolTable()
Get func.func/fir.global symbol table attached to this builder if any.
Definition FIRBuilder.h:136
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:328
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:731
mlir::Value genIsNotNullAddr(mlir::Location loc, mlir::Value addr)
Generate code testing addr is not a null address.
Definition FIRBuilder.cpp:892
mlir::Value convertToIndexType(mlir::Location loc, mlir::Value val)
Cast the input value to IndexType.
Definition FIRBuilder.h:491
void createStoreWithConvert(mlir::Location loc, mlir::Value val, mlir::Value addr)
Definition FIRBuilder.cpp:659
void setIntegerOverflowFlags(mlir::arith::IntegerOverflowFlags flags)
Definition FIRBuilder.h:662
mlir::func::FuncOp createRuntimeFunction(mlir::Location loc, llvm::StringRef name, mlir::FunctionType ty, bool isIO=false)
Definition FIRBuilder.cpp:56
mlir::Value createBox(mlir::Location loc, const fir::ExtendedValue &exv, bool isPolymorphic=false, bool isAssumedType=false, unsigned corank=0)
Definition FIRBuilder.cpp:791
mlir::Region & getRegion()
Get the current Region of the insertion point.
Definition FIRBuilder.h:120
void notifyOperationInserted(mlir::Operation *op, mlir::OpBuilder::InsertPoint previous) override
FirOpBuilder hook for creating new operation.
Definition FIRBuilder.h:694
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:455
mlir::func::FuncOp getNamedFunction(llvm::StringRef name)
Definition FIRBuilder.h:422
std::string getFastMathFlagsString()
Definition FIRBuilder.h:632
mlir::Value createUnsigned(mlir::Location loc, mlir::Type resultType, mlir::Value left, mlir::Value right)
Definition FIRBuilder.h:708
bool getComplexDivisionToRuntimeFlag() const
Get current ComplexDivisionToRuntimeFlag value.
Definition FIRBuilder.h:678
mlir::Value createBool(mlir::Location loc, bool b)
Create constant i1 with value 1. if b is true or 0. otherwise.
Definition FIRBuilder.h:526
mlir::arith::IntegerOverflowFlags getIntegerOverflowFlags() const
Get current IntegerOverflowFlags value.
Definition FIRBuilder.h:667
mlir::func::FuncOp getFunction()
Get the current Function.
Definition FIRBuilder.h:128
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:388
mlir::Type getRealType(int kind)
Get the mlir float type that implements Fortran REAL(kind).
Definition FIRBuilder.cpp:122
fir::GlobalOp createGlobalConstant(mlir::Location loc, mlir::Type type, llvm::StringRef name, fir::LinkageAttr linkage={}, mlir::Attribute value={})
Create a global constant (read-only) value.
Definition FIRBuilder.h:364
mlir::Block * getAllocaBlock()
Definition FIRBuilder.cpp:340
mlir::Type getVarLenSeqTy(mlir::Type eleTy, unsigned rank=1)
Create a sequence of eleTy with rank dimensions of unknown size.
Definition FIRBuilder.cpp:117
mlir::Value loadIfRef(mlir::Location loc, mlir::Value val)
Definition FIRBuilder.cpp:668
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:412
mlir::Value createConvertWithVolatileCast(mlir::Location loc, mlir::Type toTy, mlir::Value val)
Definition FIRBuilder.cpp:634
mlir::Value createShape(mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:719
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:259
mlir::Value genAbsentOp(mlir::Location loc, mlir::Type argTy)
Definition FIRBuilder.cpp:932
mlir::arith::FastMathFlags getFastMathFlags() const
Get current FastMathFlags value.
Definition FIRBuilder.h:626
mlir::Value createIntegerConstant(mlir::Location loc, mlir::Type integerType, std::int64_t i)
Definition FIRBuilder.cpp:148
mlir::Value createRealOneConstant(mlir::Location loc, mlir::Type realType)
Create a real constant of type realType with value one.
Definition FIRBuilder.h:230
mlir::Block * getEntryBlock()
Get the entry block of the current Function.
Definition FIRBuilder.h:156
mlir::func::FuncOp createFunction(mlir::Location loc, llvm::StringRef name, mlir::FunctionType ty)
Definition FIRBuilder.h:470
mlir::DataLayout & getDataLayout()
Construct a data layout on demand and return it.
Definition FIRBuilder.cpp:995
mlir::Value createTemporary(mlir::Location loc, mlir::Type type, mlir::ValueRange shape)
Create an unnamed and untracked temporary on the stack.
Definition FIRBuilder.h:271
mlir::Type getIntPtrType()
Definition FIRBuilder.h:174
Definition KindMapping.h:48
Definition BoxValue.h:361
Definition FIRType.h:106
Definition OpenACC.h:22
Definition OpenACC.h:20
FPMaxminBehavior
Definition FPMaxminBehavior.h:29
Definition BoxValue.h:446
fir::ExtendedValue componentToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value component)
Definition FIRBuilder.cpp:1293
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:1593
mlir::Value createZeroValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type type)
Definition FIRBuilder.cpp:1541
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:1392
llvm::SmallVector< mlir::Value > deduceOptimalExtents(mlir::ValueRange extents1, mlir::ValueRange extents2)
Definition FIRBuilder.cpp:1751
fir::BoxValue createBoxValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &exv, unsigned corank=0)
Definition FIRBuilder.cpp:1685
mlir::Value getDescriptorWithNewBaseAddress(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value box, mlir::Value newAddr)
Definition FIRBuilder.cpp:1821
mlir::Value createOneValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type type)
Definition FIRBuilder.cpp:1560
mlir::Value readLowerBound(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &box, unsigned dim, mlir::Value defaultValue)
Definition FIRBuilder.cpp:1062
std::string uniqueCGIdent(llvm::StringRef prefix, llvm::StringRef name)
Definition FIRBuilder.cpp:1207
llvm::SmallVector< mlir::Value > updateRuntimeExtentsForEmptyArrays(fir::FirOpBuilder &builder, mlir::Location loc, mlir::ValueRange extents)
Definition FIRBuilder.cpp:1778
llvm::SmallVector< mlir::Value > getNonDefaultLowerBounds(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:1160
fir::ExtendedValue createStringLiteral(fir::FirOpBuilder &, mlir::Location, llvm::StringRef string)
Definition FIRBuilder.cpp:1245
mlir::Value locationToFilename(fir::FirOpBuilder &, mlir::Location)
Generate a string literal containing the file name and return its address.
Definition FIRBuilder.cpp:1227
mlir::Value locationToLineNo(fir::FirOpBuilder &, mlir::Location, mlir::Type)
Generate a constant of the given type with the location line number.
Definition FIRBuilder.cpp:1237
std::optional< mlir::Value > genIndexBasedDisjointnessCheck(mlir::Location loc, fir::FirOpBuilder &builder, mlir::Value lhsRef, mlir::Value rhsRef)
Generate a index-based disjointness check.
Definition FIRBuilder.cpp:1843
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:1031
mlir::Value readCharLen(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &box)
Definition FIRBuilder.cpp:1006
void genLifetimeEnd(mlir::OpBuilder &builder, mlir::Location loc, mlir::Value mem)
Definition FIRBuilder.cpp:1816
std::optional< mlir::Value > genAddressBasedDisjointnessCheck(mlir::Location loc, fir::FirOpBuilder &builder, mlir::Value lhsRef, mlir::Value rhsRef)
Generate a address-based disjointness check.
Definition FIRBuilder.cpp:1896
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:1633
llvm::SmallVector< mlir::Value > readExtents(fir::FirOpBuilder &builder, mlir::Location loc, const fir::BoxValue &box)
Read extents from box.
Definition FIRBuilder.cpp:1092
mlir::Value genCPtrOrCFunptrValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value cPtr)
Get the C address value.
Definition FIRBuilder.cpp:1651
uint64_t getAllocaAddressSpace(const mlir::DataLayout *dataLayout)
Get the address space which should be used for allocas.
Definition FIRBuilder.cpp:1743
void setInternalLinkage(mlir::func::FuncOp)
Set internal linkage attribute on a function.
Definition FIRBuilder.cpp:1735
mlir::Value createNullBoxProc(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type boxType)
Generate Null BoxProc for procedure pointer null initialization.
Definition FIRBuilder.cpp:1724
fir::ExtendedValue arraySectionElementToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &array, mlir::Value element, mlir::Value slice)
Definition FIRBuilder.cpp:1377
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:1457
mlir::Value createConvert(mlir::OpBuilder &, mlir::Location, mlir::Type, mlir::Value)
Definition FIRBuilder.cpp:641
fir::ExtendedValue readBoxValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::BoxValue &box)
Definition FIRBuilder.cpp:1131
mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value lb, mlir::Value ub)
Definition FIRBuilder.cpp:1610
fir::ExtendedValue arrayElementToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &array, mlir::Value element)
Definition FIRBuilder.cpp:1347
llvm::SmallVector< mlir::Value > createExtents(fir::FirOpBuilder &builder, mlir::Location loc, fir::SequenceType seqTy)
Definition FIRBuilder.cpp:1267
mlir::Value genLifetimeStart(mlir::OpBuilder &builder, mlir::Location loc, fir::AllocaOp alloc, const mlir::DataLayout *dl)
Definition FIRBuilder.cpp:1804
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
mlir::Block * getAllocaBlock(mlir::Region &region)
Get the block for adding Allocas.
Definition FIRBuilder.cpp:299
bool isAssumedType(mlir::Type ty)
Definition FIRType.cpp:373
Definition AbstractConverter.h:32