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
200 mlir::Value createAllOnesInteger(mlir::Location loc, mlir::Type integerType);
201
204 mlir::Value createMinusOneInteger(mlir::Location loc,
205 mlir::Type integerType) {
206 return createAllOnesInteger(loc, integerType);
207 }
208
210 mlir::Value createRealConstant(mlir::Location loc, mlir::Type realType,
211 llvm::APFloat::integerPart val);
212
214 mlir::Value createRealConstant(mlir::Location loc, mlir::Type realType,
215 const llvm::APFloat &val);
216
218 mlir::Value createRealZeroConstant(mlir::Location loc, mlir::Type realType) {
219 return createRealConstant(loc, realType, 0u);
220 }
221
223 mlir::Value createRealOneConstant(mlir::Location loc, mlir::Type realType) {
224 return createRealConstant(loc, realType, 1u);
225 }
226
229 mlir::Value allocateLocal(mlir::Location loc, mlir::Type ty,
230 llvm::StringRef uniqName, llvm::StringRef name,
231 bool pinned, llvm::ArrayRef<mlir::Value> shape,
233 bool asTarget = false);
234 mlir::Value allocateLocal(mlir::Location loc, mlir::Type ty,
235 llvm::StringRef uniqName, llvm::StringRef name,
238 bool asTarget = false);
239
242 mlir::ArrayAttr create2DI64ArrayAttr(
243 llvm::SmallVectorImpl<llvm::SmallVector<int64_t>> &intData);
244
248 mlir::Value createTemporaryAlloc(
249 mlir::Location loc, mlir::Type type, llvm::StringRef name,
250 mlir::ValueRange lenParams = {}, mlir::ValueRange shape = {},
251 llvm::ArrayRef<mlir::NamedAttribute> attrs = {},
252 std::optional<Fortran::common::CUDADataAttr> cudaAttr = std::nullopt);
253
257 mlir::Value createTemporary(
258 mlir::Location loc, mlir::Type type, llvm::StringRef name = {},
259 mlir::ValueRange shape = {}, mlir::ValueRange lenParams = {},
260 llvm::ArrayRef<mlir::NamedAttribute> attrs = {},
261 std::optional<Fortran::common::CUDADataAttr> cudaAttr = std::nullopt);
262
264 mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
265 mlir::ValueRange shape) {
266 return createTemporary(loc, type, llvm::StringRef{}, shape);
267 }
268
269 mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
271 return createTemporary(loc, type, llvm::StringRef{}, {}, {}, attrs);
272 }
273
274 mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
275 llvm::StringRef name,
276 llvm::ArrayRef<mlir::NamedAttribute> attrs) {
277 return createTemporary(loc, type, name, {}, {}, attrs);
278 }
279
281 mlir::Value
282 createHeapTemporary(mlir::Location loc, mlir::Type type,
283 llvm::StringRef name = {}, mlir::ValueRange shape = {},
284 mlir::ValueRange lenParams = {},
285 llvm::ArrayRef<mlir::NamedAttribute> attrs = {});
286
291 static mlir::Value genTempDeclareOp(fir::FirOpBuilder &builder,
292 mlir::Location loc, mlir::Value memref,
293 llvm::StringRef name, mlir::Value shape,
294 llvm::ArrayRef<mlir::Value> typeParams,
295 fir::FortranVariableFlagsAttr attrs);
296
313 std::pair<mlir::Value, bool> createAndDeclareTemp(
314 mlir::Location loc, mlir::Type baseType, mlir::Value shape,
315 llvm::ArrayRef<mlir::Value> extents,
316 llvm::ArrayRef<mlir::Value> typeParams,
317 const std::function<decltype(genTempDeclareOp)> &genDeclare,
318 mlir::Value polymorphicMold, bool useStack, llvm::StringRef tmpName);
320 std::pair<mlir::Value, bool>
321 createArrayTemp(mlir::Location loc, fir::SequenceType arrayType,
322 mlir::Value shape, llvm::ArrayRef<mlir::Value> extents,
324 const std::function<decltype(genTempDeclareOp)> &genDeclare,
325 mlir::Value polymorphicMold, bool useStack = false,
326 llvm::StringRef tmpName = ".tmp.array") {
327 return createAndDeclareTemp(loc, arrayType, shape, extents, typeParams,
328 genDeclare, polymorphicMold, useStack, tmpName);
329 }
330
334 mlir::Value genStackSave(mlir::Location loc);
335
338 void genStackRestore(mlir::Location loc, mlir::Value stackPointer);
339
341 fir::GlobalOp createGlobal(mlir::Location loc, mlir::Type type,
342 llvm::StringRef name,
343 fir::LinkageAttr linkage = {},
344 mlir::Attribute value = {}, bool isConst = false,
345 bool isTarget = false,
346 cuf::DataAttributeAttr dataAttr = {},
347 bool setDefaultAlignment = true);
348
349 fir::GlobalOp createGlobal(mlir::Location loc, mlir::Type type,
350 llvm::StringRef name, bool isConst, bool isTarget,
351 std::function<void(FirOpBuilder &)> bodyBuilder,
352 fir::LinkageAttr linkage = {},
353 cuf::DataAttributeAttr dataAttr = {},
354 bool setDefaultAlignment = true);
355
357 fir::GlobalOp createGlobalConstant(mlir::Location loc, mlir::Type type,
358 llvm::StringRef name,
359 fir::LinkageAttr linkage = {},
360 mlir::Attribute value = {}) {
361 return createGlobal(loc, type, name, linkage, value, /*isConst=*/true,
362 /*isTarget=*/false);
363 }
364
365 fir::GlobalOp
366 createGlobalConstant(mlir::Location loc, mlir::Type type,
367 llvm::StringRef name,
368 std::function<void(FirOpBuilder &)> bodyBuilder,
369 fir::LinkageAttr linkage = {}) {
370 return createGlobal(loc, type, name, /*isConst=*/true, /*isTarget=*/false,
371 bodyBuilder, linkage);
372 }
373
375 fir::StringLitOp createStringLitOp(mlir::Location loc,
376 llvm::StringRef string);
377
378 std::pair<fir::TypeInfoOp, mlir::OpBuilder::InsertPoint>
379 createTypeInfoOp(mlir::Location loc, fir::RecordType recordType,
380 fir::RecordType parentType);
381
382 //===--------------------------------------------------------------------===//
383 // Linkage helpers (inline). The default linkage is external.
384 //===--------------------------------------------------------------------===//
385
386 static fir::LinkageAttr createCommonLinkage(mlir::MLIRContext *context) {
387 return fir::LinkageAttr::get(context, fir::LinkageEnum::Common);
388 }
389 fir::LinkageAttr createCommonLinkage() {
390 return createCommonLinkage(getContext());
391 }
392
393 fir::LinkageAttr createExternalLinkage() {
394 return fir::LinkageAttr::get(getContext(), fir::LinkageEnum::External);
395 }
396
397 fir::LinkageAttr createInternalLinkage() {
398 return fir::LinkageAttr::get(getContext(), fir::LinkageEnum::Internal);
399 }
400
401 fir::LinkageAttr createLinkOnceLinkage() {
402 return fir::LinkageAttr::get(getContext(), fir::LinkageEnum::Linkonce);
403 }
404
405 fir::LinkageAttr createLinkOnceODRLinkage() {
406 return fir::LinkageAttr::get(getContext(), fir::LinkageEnum::LinkonceODR);
407 }
408
409 fir::LinkageAttr createWeakLinkage() {
410 return fir::LinkageAttr::get(getContext(), fir::LinkageEnum::Weak);
411 }
412
415 mlir::func::FuncOp getNamedFunction(llvm::StringRef name) {
417 }
418 static mlir::func::FuncOp
419 getNamedFunction(mlir::ModuleOp module, const mlir::SymbolTable *symbolTable,
420 llvm::StringRef name);
421
424 mlir::func::FuncOp getNamedFunction(mlir::SymbolRefAttr symbol) {
425 return getNamedFunction(getModule(), getMLIRSymbolTable(), symbol);
426 }
427 static mlir::func::FuncOp
428 getNamedFunction(mlir::ModuleOp module, const mlir::SymbolTable *symbolTable,
429 mlir::SymbolRefAttr symbol);
430
431 fir::GlobalOp getNamedGlobal(llvm::StringRef name) {
432 return getNamedGlobal(getModule(), getMLIRSymbolTable(), name);
433 }
434
435 static fir::GlobalOp getNamedGlobal(mlir::ModuleOp module,
436 const mlir::SymbolTable *symbolTable,
437 llvm::StringRef name);
438
440 mlir::Value createConvert(mlir::Location loc, mlir::Type toTy,
441 mlir::Value val);
442
445 mlir::Value createConvertWithVolatileCast(mlir::Location loc, mlir::Type toTy,
446 mlir::Value val);
447
449 mlir::Value createVolatileCast(mlir::Location loc, bool isVolatile,
450 mlir::Value value);
451
454 void createStoreWithConvert(mlir::Location loc, mlir::Value val,
455 mlir::Value addr);
456
459 mlir::Value loadIfRef(mlir::Location loc, mlir::Value val);
460
463 mlir::func::FuncOp createFunction(mlir::Location loc, llvm::StringRef name,
464 mlir::FunctionType ty) {
465 return createFunction(loc, getModule(), name, ty, getMLIRSymbolTable());
466 }
467
468 static mlir::func::FuncOp createFunction(mlir::Location loc,
469 mlir::ModuleOp module,
470 llvm::StringRef name,
471 mlir::FunctionType ty,
472 mlir::SymbolTable *);
473
478 mlir::func::FuncOp createRuntimeFunction(mlir::Location loc,
479 llvm::StringRef name,
480 mlir::FunctionType ty,
481 bool isIO = false);
482
484 mlir::Value convertToIndexType(mlir::Location loc, mlir::Value val) {
485 return createConvert(loc, getIndexType(), val);
486 }
487
489 mlir::Value genShape(mlir::Location loc, const fir::AbstractArrayBox &arr);
490 mlir::Value genShape(mlir::Location loc, llvm::ArrayRef<mlir::Value> shift,
492 mlir::Value genShape(mlir::Location loc, llvm::ArrayRef<mlir::Value> exts);
493 mlir::Value genShift(mlir::Location loc, llvm::ArrayRef<mlir::Value> shift);
494
497 mlir::Value createShape(mlir::Location loc, const fir::ExtendedValue &exv);
498
501 mlir::Value createSlice(mlir::Location loc, const fir::ExtendedValue &exv,
502 mlir::ValueRange triples, mlir::ValueRange path);
503
510 mlir::Value createBox(mlir::Location loc, const fir::ExtendedValue &exv,
511 bool isPolymorphic = false, bool isAssumedType = false,
512 unsigned corank = 0);
513
514 mlir::Value createBox(mlir::Location loc, mlir::Type boxType,
515 mlir::Value addr, mlir::Value shape, mlir::Value slice,
516 llvm::ArrayRef<mlir::Value> lengths, mlir::Value tdesc);
517
519 mlir::Value createBool(mlir::Location loc, bool b) {
520 return createIntegerConstant(loc, getIntegerType(1), b ? 1 : 0);
521 }
522
523 //===--------------------------------------------------------------------===//
524 // If-Then-Else generation helper
525 //===--------------------------------------------------------------------===//
526
531 class IfBuilder {
532 public:
533 IfBuilder(fir::IfOp ifOp, FirOpBuilder &builder)
534 : ifOp{ifOp}, builder{builder} {}
535 template <typename CC>
536 IfBuilder &genThen(CC func) {
537 builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
538 func();
539 return *this;
540 }
541 template <typename CC>
542 IfBuilder &genElse(CC func) {
543 assert(!ifOp.getElseRegion().empty() && "must have else region");
544 builder.setInsertionPointToStart(&ifOp.getElseRegion().front());
545 func();
546 return *this;
547 }
548 void end() { builder.setInsertionPointAfter(ifOp); }
549
551 mlir::Operation::result_range getResults() {
552 end();
553 return ifOp.getResults();
554 }
555
556 fir::IfOp &getIfOp() { return ifOp; };
557
558 private:
559 fir::IfOp ifOp;
560 FirOpBuilder &builder;
561 };
562
565 IfBuilder genIfOp(mlir::Location loc, mlir::TypeRange results,
566 mlir::Value cdt, bool withElseRegion) {
567 auto op = fir::IfOp::create(*this, loc, results, cdt, withElseRegion);
568 return IfBuilder(op, *this);
569 }
570
573 IfBuilder genIfThen(mlir::Location loc, mlir::Value cdt) {
574 auto op = fir::IfOp::create(*this, loc, mlir::TypeRange(), cdt, false);
575 return IfBuilder(op, *this);
576 }
577
580 IfBuilder genIfThenElse(mlir::Location loc, mlir::Value cdt) {
581 auto op = fir::IfOp::create(*this, loc, mlir::TypeRange(), cdt, true);
582 return IfBuilder(op, *this);
583 }
584
585 mlir::Value genNot(mlir::Location loc, mlir::Value boolean) {
586 return mlir::arith::CmpIOp::create(*this, loc,
587 mlir::arith::CmpIPredicate::eq, boolean,
588 createBool(loc, false));
589 }
590
592 mlir::Value genIsNotNullAddr(mlir::Location loc, mlir::Value addr);
593
595 mlir::Value genIsNullAddr(mlir::Location loc, mlir::Value addr);
596
599 mlir::Value genExtentFromTriplet(mlir::Location loc, mlir::Value lb,
600 mlir::Value ub, mlir::Value step,
601 mlir::Type type, bool fold = false);
602
605 mlir::Value genAbsentOp(mlir::Location loc, mlir::Type argTy);
606
610 void setFastMathFlags(mlir::arith::FastMathFlags flags) {
611 fastMathFlags = flags;
612 }
613
617
619 mlir::arith::FastMathFlags getFastMathFlags() const { return fastMathFlags; }
620
626 mlir::arith::FastMathFlags flags = getFastMathFlags();
627 if (flags == mlir::arith::FastMathFlags::none)
628 return {};
629
630 std::string fmfString{mlir::arith::stringifyFastMathFlags(flags)};
631 std::replace(fmfString.begin(), fmfString.end(), ',', '_');
632 return fmfString;
633 }
634
637 class FastMathFlagGuard {
638 public:
639 FastMathFlagGuard(FirOpBuilder &builder, mlir::arith::FastMathFlags flags)
640 : builder{builder}, savedFlags{builder.getFastMathFlags()} {
641 builder.setFastMathFlags(flags);
642 }
643 FastMathFlagGuard(const FastMathFlagGuard &) = delete;
644 FastMathFlagGuard &operator=(const FastMathFlagGuard &) = delete;
645 ~FastMathFlagGuard() { builder.setFastMathFlags(savedFlags); }
646
647 private:
648 FirOpBuilder &builder;
649 mlir::arith::FastMathFlags savedFlags;
650 };
651
655 void setIntegerOverflowFlags(mlir::arith::IntegerOverflowFlags flags) {
656 integerOverflowFlags = flags;
657 }
658
660 mlir::arith::IntegerOverflowFlags getIntegerOverflowFlags() const {
661 return integerOverflowFlags;
662 }
663
667 complexDivisionToRuntimeFlag = flag;
668 }
669
672 return complexDivisionToRuntimeFlag;
673 }
674
677 fpMaxminBehavior = mode;
678 }
679 Fortran::common::FPMaxminBehavior getFPMaxminBehavior() const {
680 return fpMaxminBehavior;
681 }
682
684 LLVM_DUMP_METHOD void dumpFunc();
685
687 void notifyOperationInserted(mlir::Operation *op,
688 mlir::OpBuilder::InsertPoint previous) override {
689 // We only care about newly created operations.
690 if (previous.isSet())
691 return;
692 setCommonAttributes(op);
693 }
694
696 mlir::DataLayout &getDataLayout();
697
700 template <typename OpTy>
701 mlir::Value createUnsigned(mlir::Location loc, mlir::Type resultType,
702 mlir::Value left, mlir::Value right) {
703 if (!resultType.isIntOrFloat())
704 return OpTy::create(*this, loc, resultType, left, right);
705 mlir::Type signlessType = mlir::IntegerType::get(
706 getContext(), resultType.getIntOrFloatBitWidth(),
707 mlir::IntegerType::SignednessSemantics::Signless);
708 mlir::Type opResType = resultType;
709 if (left.getType().isUnsignedInteger()) {
710 left = createConvert(loc, signlessType, left);
711 opResType = signlessType;
712 }
713 if (right.getType().isUnsignedInteger()) {
714 right = createConvert(loc, signlessType, right);
715 opResType = signlessType;
716 }
717 mlir::Value result = OpTy::create(*this, loc, opResType, left, right);
718 if (resultType.isUnsignedInteger())
719 result = createConvert(loc, resultType, result);
720 return result;
721 }
722
724 mlir::Value genPtrCompare(mlir::Location loc,
725 mlir::arith::CmpIPredicate predicate,
726 mlir::Value ptr1, mlir::Value ptr2) {
727 ptr1 = createConvert(loc, getIndexType(), ptr1);
728 ptr2 = createConvert(loc, getIndexType(), ptr2);
729 return mlir::arith::CmpIOp::create(*this, loc, predicate, ptr1, ptr2);
730 }
731
732private:
735 void setCommonAttributes(mlir::Operation *op) const;
736
737 KindMapping kindMap;
738
741 mlir::arith::FastMathFlags fastMathFlags{};
742
748 Fortran::common::FPMaxminBehavior fpMaxminBehavior{
749 Fortran::common::FPMaxminBehavior::Legacy};
750
753 mlir::arith::IntegerOverflowFlags integerOverflowFlags{};
754
757 bool complexDivisionToRuntimeFlag = true;
758
761 mlir::SymbolTable *symbolTable = nullptr;
762
766 std::unique_ptr<mlir::DataLayout> dataLayout = nullptr;
767};
768
769} // namespace fir
770
771namespace fir::factory {
772
774
775//===----------------------------------------------------------------------===//
776// ExtendedValue inquiry helpers
777//===----------------------------------------------------------------------===//
778
783mlir::Value readCharLen(fir::FirOpBuilder &builder, mlir::Location loc,
784 const fir::ExtendedValue &box);
785
787mlir::Value readExtent(fir::FirOpBuilder &builder, mlir::Location loc,
788 const fir::ExtendedValue &box, unsigned dim);
789
793mlir::Value readLowerBound(fir::FirOpBuilder &builder, mlir::Location loc,
794 const fir::ExtendedValue &box, unsigned dim,
795 mlir::Value defaultValue);
796
798llvm::SmallVector<mlir::Value> readExtents(fir::FirOpBuilder &builder,
799 mlir::Location loc,
800 const fir::BoxValue &box);
801
807fir::ExtendedValue readBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
808 const fir::BoxValue &box);
809
812llvm::SmallVector<mlir::Value>
813getNonDefaultLowerBounds(fir::FirOpBuilder &builder, mlir::Location loc,
814 const fir::ExtendedValue &exv);
815
816//===----------------------------------------------------------------------===//
817// String literal helper helpers
818//===----------------------------------------------------------------------===//
819
822fir::ExtendedValue createStringLiteral(fir::FirOpBuilder &, mlir::Location,
823 llvm::StringRef string);
824
827std::string uniqueCGIdent(llvm::StringRef prefix, llvm::StringRef name);
828
831llvm::SmallVector<mlir::Value> createExtents(fir::FirOpBuilder &builder,
832 mlir::Location loc,
833 fir::SequenceType seqTy);
834
835//===--------------------------------------------------------------------===//
836// Location helpers
837//===--------------------------------------------------------------------===//
838
840mlir::Value locationToFilename(fir::FirOpBuilder &, mlir::Location);
842mlir::Value locationToLineNo(fir::FirOpBuilder &, mlir::Location, mlir::Type);
843
844//===--------------------------------------------------------------------===//
845// ExtendedValue helpers
846//===--------------------------------------------------------------------===//
847
850fir::ExtendedValue componentToExtendedValue(fir::FirOpBuilder &builder,
851 mlir::Location loc,
852 mlir::Value component);
853
860fir::ExtendedValue arrayElementToExtendedValue(fir::FirOpBuilder &builder,
861 mlir::Location loc,
862 const fir::ExtendedValue &array,
863 mlir::Value element);
864
869fir::ExtendedValue arraySectionElementToExtendedValue(
870 fir::FirOpBuilder &builder, mlir::Location loc,
871 const fir::ExtendedValue &array, mlir::Value element, mlir::Value slice);
872
875void genScalarAssignment(fir::FirOpBuilder &builder, mlir::Location loc,
876 const fir::ExtendedValue &lhs,
877 const fir::ExtendedValue &rhs,
878 bool needFinalization = false,
879 bool isTemporaryLHS = false,
880 mlir::ArrayAttr accessGroups = {});
881
885void genRecordAssignment(fir::FirOpBuilder &builder, mlir::Location loc,
886 const fir::ExtendedValue &lhs,
887 const fir::ExtendedValue &rhs,
888 bool needFinalization = false,
889 bool isTemporaryLHS = false);
890
893mlir::Value createZeroValue(fir::FirOpBuilder &builder, mlir::Location loc,
894 mlir::Type type);
895
898mlir::Value createOneValue(fir::FirOpBuilder &builder, mlir::Location loc,
899 mlir::Type type);
900
903mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc,
904 mlir::Value lb, mlir::Value ub);
905mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc,
906 mlir::Value lb, mlir::Value ub, mlir::Value zero,
907 mlir::Value one);
908
910mlir::Value genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
911 mlir::Value value);
912mlir::Value genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
913 mlir::Value value, mlir::Value zero);
914
916mlir::Value genCPtrOrCFunptrAddr(fir::FirOpBuilder &builder, mlir::Location loc,
917 mlir::Value cPtr, mlir::Type ty);
918
920mlir::Value genCPtrOrCFunptrValue(fir::FirOpBuilder &builder,
921 mlir::Location loc, mlir::Value cPtr);
922
925fir::BoxValue createBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
926 const fir::ExtendedValue &exv,
927 unsigned corank = 0);
928
930mlir::Value createNullBoxProc(fir::FirOpBuilder &builder, mlir::Location loc,
931 mlir::Type boxType);
932
935mlir::Value createConvert(mlir::OpBuilder &, mlir::Location, mlir::Type,
936 mlir::Value);
937
939void setInternalLinkage(mlir::func::FuncOp);
940
941llvm::SmallVector<mlir::Value>
942elideExtentsAlreadyInType(mlir::Type type, mlir::ValueRange shape);
943
944llvm::SmallVector<mlir::Value>
945elideLengthsAlreadyInType(mlir::Type type, mlir::ValueRange lenParams);
946
948uint64_t getAllocaAddressSpace(const mlir::DataLayout *dataLayout);
949
956llvm::SmallVector<mlir::Value> deduceOptimalExtents(mlir::ValueRange extents1,
957 mlir::ValueRange extents2);
958
959uint64_t getGlobalAddressSpace(mlir::DataLayout *dataLayout);
960
961uint64_t getProgramAddressSpace(mlir::DataLayout *dataLayout);
962
973llvm::SmallVector<mlir::Value> updateRuntimeExtentsForEmptyArrays(
974 fir::FirOpBuilder &builder, mlir::Location loc, mlir::ValueRange extents);
975
979mlir::Value genLifetimeStart(mlir::OpBuilder &builder, mlir::Location loc,
980 fir::AllocaOp alloc, const mlir::DataLayout *dl);
981
984void genLifetimeEnd(mlir::OpBuilder &builder, mlir::Location loc,
985 mlir::Value mem);
986
992mlir::Value getDescriptorWithNewBaseAddress(fir::FirOpBuilder &builder,
993 mlir::Location loc, mlir::Value box,
994 mlir::Value newAddr);
995
997std::optional<mlir::Value>
998genIndexBasedDisjointnessCheck(mlir::Location loc, fir::FirOpBuilder &builder,
999 mlir::Value lhsRef, mlir::Value rhsRef);
1000
1002std::optional<mlir::Value>
1003genAddressBasedDisjointnessCheck(mlir::Location loc, fir::FirOpBuilder &builder,
1004 mlir::Value lhsRef, mlir::Value rhsRef);
1005
1006} // namespace fir::factory
1007
1008#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:531
mlir::Operation::result_range getResults()
End the IfOp and return the results if any.
Definition FIRBuilder.h:551
Definition FIRBuilder.h:66
IfBuilder genIfThenElse(mlir::Location loc, mlir::Value cdt)
Definition FIRBuilder.h:580
fir::StringLitOp createStringLitOp(mlir::Location loc, llvm::StringRef string)
Convert a StringRef string into a fir::StringLitOp.
Definition FIRBuilder.cpp:650
mlir::Value genExtentFromTriplet(mlir::Location loc, mlir::Value lb, mlir::Value ub, mlir::Value step, mlir::Type type, bool fold=false)
Definition FIRBuilder.cpp:889
void genStackRestore(mlir::Location loc, mlir::Value stackPointer)
Definition FIRBuilder.cpp:451
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:218
void setFPMaxminBehavior(Fortran::common::FPMaxminBehavior mode)
Setter/getter for fpMaxminBehavior.
Definition FIRBuilder.h:676
mlir::Value createSlice(mlir::Location loc, const fir::ExtendedValue &exv, mlir::ValueRange triples, mlir::ValueRange path)
Definition FIRBuilder.cpp:716
mlir::Value createConvert(mlir::Location loc, mlir::Type toTy, mlir::Value val)
Lazy creation of fir.convert op.
Definition FIRBuilder.cpp:630
IfBuilder genIfOp(mlir::Location loc, mlir::TypeRange results, mlir::Value cdt, bool withElseRegion)
Definition FIRBuilder.h:565
mlir::Value genIsNullAddr(mlir::Location loc, mlir::Value addr)
Generate code testing addr is a null address.
Definition FIRBuilder.cpp:874
mlir::func::FuncOp getNamedFunction(mlir::SymbolRefAttr symbol)
Definition FIRBuilder.h:424
mlir::Value createRealConstant(mlir::Location loc, mlir::Type realType, llvm::APFloat::integerPart val)
Create a real constant from an integer value.
Definition FIRBuilder.cpp:181
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:340
IfBuilder genIfThen(mlir::Location loc, mlir::Value cdt)
Definition FIRBuilder.h:573
mlir::Value genStackSave(mlir::Location loc)
Definition FIRBuilder.cpp:445
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:682
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:170
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:403
mlir::Value createMinusOneInteger(mlir::Location loc, mlir::Type integerType)
Definition FIRBuilder.h:204
mlir::Value createVolatileCast(mlir::Location loc, bool isVolatile, mlir::Value value)
Cast value to have isVolatile volatility.
Definition FIRBuilder.cpp:600
void setComplexDivisionToRuntimeFlag(bool flag)
Definition FIRBuilder.h:666
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:610
LLVM_DUMP_METHOD void dumpFunc()
Dump the current function. (debug)
Definition FIRBuilder.cpp:856
mlir::ArrayAttr create2DI64ArrayAttr(llvm::SmallVectorImpl< llvm::SmallVector< int64_t > > &intData)
Definition FIRBuilder.cpp:330
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:458
mlir::Value convertWithSemantics(mlir::Location loc, mlir::Type toTy, mlir::Value val, bool allowCharacterConversion=false, bool allowRebox=false)
Definition FIRBuilder.cpp:527
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:321
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:724
mlir::Value genIsNotNullAddr(mlir::Location loc, mlir::Value addr)
Generate code testing addr is not a null address.
Definition FIRBuilder.cpp:868
mlir::Value convertToIndexType(mlir::Location loc, mlir::Value val)
Cast the input value to IndexType.
Definition FIRBuilder.h:484
void createStoreWithConvert(mlir::Location loc, mlir::Value val, mlir::Value addr)
Definition FIRBuilder.cpp:635
void setIntegerOverflowFlags(mlir::arith::IntegerOverflowFlags flags)
Definition FIRBuilder.h:655
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:767
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:687
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:431
mlir::func::FuncOp getNamedFunction(llvm::StringRef name)
Definition FIRBuilder.h:415
std::string getFastMathFlagsString()
Definition FIRBuilder.h:625
mlir::Value createUnsigned(mlir::Location loc, mlir::Type resultType, mlir::Value left, mlir::Value right)
Definition FIRBuilder.h:701
bool getComplexDivisionToRuntimeFlag() const
Get current ComplexDivisionToRuntimeFlag value.
Definition FIRBuilder.h:671
mlir::Value createBool(mlir::Location loc, bool b)
Create constant i1 with value 1. if b is true or 0. otherwise.
Definition FIRBuilder.h:519
mlir::arith::IntegerOverflowFlags getIntegerOverflowFlags() const
Get current IntegerOverflowFlags value.
Definition FIRBuilder.h:660
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:364
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:357
mlir::Block * getAllocaBlock()
Definition FIRBuilder.cpp:316
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:644
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:388
mlir::Value createConvertWithVolatileCast(mlir::Location loc, mlir::Type toTy, mlir::Value val)
Definition FIRBuilder.cpp:610
mlir::Value createShape(mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:695
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:241
mlir::Value genAbsentOp(mlir::Location loc, mlir::Type argTy)
Definition FIRBuilder.cpp:908
mlir::arith::FastMathFlags getFastMathFlags() const
Get current FastMathFlags value.
Definition FIRBuilder.h:619
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:223
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:463
mlir::DataLayout & getDataLayout()
Construct a data layout on demand and return it.
Definition FIRBuilder.cpp:971
mlir::Value createTemporary(mlir::Location loc, mlir::Type type, mlir::ValueRange shape)
Create an unnamed and untracked temporary on the stack.
Definition FIRBuilder.h:264
mlir::Type getIntPtrType()
Definition FIRBuilder.h:174
Definition KindMapping.h:48
Definition BoxValue.h:361
Definition FIRType.h:106
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:1269
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:1618
mlir::Value createZeroValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type type)
Definition FIRBuilder.cpp:1566
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:1368
llvm::SmallVector< mlir::Value > deduceOptimalExtents(mlir::ValueRange extents1, mlir::ValueRange extents2)
Definition FIRBuilder.cpp:1776
fir::BoxValue createBoxValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &exv, unsigned corank=0)
Definition FIRBuilder.cpp:1710
mlir::Value getDescriptorWithNewBaseAddress(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value box, mlir::Value newAddr)
Definition FIRBuilder.cpp:1846
mlir::Value createOneValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type type)
Definition FIRBuilder.cpp:1585
mlir::Value readLowerBound(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &box, unsigned dim, mlir::Value defaultValue)
Definition FIRBuilder.cpp:1038
std::string uniqueCGIdent(llvm::StringRef prefix, llvm::StringRef name)
Definition FIRBuilder.cpp:1183
llvm::SmallVector< mlir::Value > updateRuntimeExtentsForEmptyArrays(fir::FirOpBuilder &builder, mlir::Location loc, mlir::ValueRange extents)
Definition FIRBuilder.cpp:1803
llvm::SmallVector< mlir::Value > getNonDefaultLowerBounds(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:1136
fir::ExtendedValue createStringLiteral(fir::FirOpBuilder &, mlir::Location, llvm::StringRef string)
Definition FIRBuilder.cpp:1221
mlir::Value locationToFilename(fir::FirOpBuilder &, mlir::Location)
Generate a string literal containing the file name and return its address.
Definition FIRBuilder.cpp:1203
mlir::Value locationToLineNo(fir::FirOpBuilder &, mlir::Location, mlir::Type)
Generate a constant of the given type with the location line number.
Definition FIRBuilder.cpp:1213
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:1868
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:1007
mlir::Value readCharLen(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &box)
Definition FIRBuilder.cpp:982
void genLifetimeEnd(mlir::OpBuilder &builder, mlir::Location loc, mlir::Value mem)
Definition FIRBuilder.cpp:1841
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:1921
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:1658
llvm::SmallVector< mlir::Value > readExtents(fir::FirOpBuilder &builder, mlir::Location loc, const fir::BoxValue &box)
Read extents from box.
Definition FIRBuilder.cpp:1068
mlir::Value genCPtrOrCFunptrValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value cPtr)
Get the C address value.
Definition FIRBuilder.cpp:1676
uint64_t getAllocaAddressSpace(const mlir::DataLayout *dataLayout)
Get the address space which should be used for allocas.
Definition FIRBuilder.cpp:1768
void setInternalLinkage(mlir::func::FuncOp)
Set internal linkage attribute on a function.
Definition FIRBuilder.cpp:1760
mlir::Value createNullBoxProc(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type boxType)
Generate Null BoxProc for procedure pointer null initialization.
Definition FIRBuilder.cpp:1749
fir::ExtendedValue arraySectionElementToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &array, mlir::Value element, mlir::Value slice)
Definition FIRBuilder.cpp:1353
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:1513
mlir::Value createConvert(mlir::OpBuilder &, mlir::Location, mlir::Type, mlir::Value)
Definition FIRBuilder.cpp:617
fir::ExtendedValue readBoxValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::BoxValue &box)
Definition FIRBuilder.cpp:1107
mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value lb, mlir::Value ub)
Definition FIRBuilder.cpp:1635
fir::ExtendedValue arrayElementToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &array, mlir::Value element)
Definition FIRBuilder.cpp:1323
llvm::SmallVector< mlir::Value > createExtents(fir::FirOpBuilder &builder, mlir::Location loc, fir::SequenceType seqTy)
Definition FIRBuilder.cpp:1243
mlir::Value genLifetimeStart(mlir::OpBuilder &builder, mlir::Location loc, fir::AllocaOp alloc, const mlir::DataLayout *dl)
Definition FIRBuilder.cpp:1829
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:281
bool isAssumedType(mlir::Type ty)
Definition FIRType.cpp:372
Definition AbstractConverter.h:32