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 unsigned corank = 0);
498
499 mlir::Value createBox(mlir::Location loc, mlir::Type boxType,
500 mlir::Value addr, mlir::Value shape, mlir::Value slice,
501 llvm::ArrayRef<mlir::Value> lengths, mlir::Value tdesc);
502
504 mlir::Value createBool(mlir::Location loc, bool b) {
505 return createIntegerConstant(loc, getIntegerType(1), b ? 1 : 0);
506 }
507
508 //===--------------------------------------------------------------------===//
509 // If-Then-Else generation helper
510 //===--------------------------------------------------------------------===//
511
516 class IfBuilder {
517 public:
518 IfBuilder(fir::IfOp ifOp, FirOpBuilder &builder)
519 : ifOp{ifOp}, builder{builder} {}
520 template <typename CC>
521 IfBuilder &genThen(CC func) {
522 builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
523 func();
524 return *this;
525 }
526 template <typename CC>
527 IfBuilder &genElse(CC func) {
528 assert(!ifOp.getElseRegion().empty() && "must have else region");
529 builder.setInsertionPointToStart(&ifOp.getElseRegion().front());
530 func();
531 return *this;
532 }
533 void end() { builder.setInsertionPointAfter(ifOp); }
534
536 mlir::Operation::result_range getResults() {
537 end();
538 return ifOp.getResults();
539 }
540
541 fir::IfOp &getIfOp() { return ifOp; };
542
543 private:
544 fir::IfOp ifOp;
545 FirOpBuilder &builder;
546 };
547
550 IfBuilder genIfOp(mlir::Location loc, mlir::TypeRange results,
551 mlir::Value cdt, bool withElseRegion) {
552 auto op = fir::IfOp::create(*this, loc, results, cdt, withElseRegion);
553 return IfBuilder(op, *this);
554 }
555
558 IfBuilder genIfThen(mlir::Location loc, mlir::Value cdt) {
559 auto op = fir::IfOp::create(*this, loc, mlir::TypeRange(), cdt, false);
560 return IfBuilder(op, *this);
561 }
562
565 IfBuilder genIfThenElse(mlir::Location loc, mlir::Value cdt) {
566 auto op = fir::IfOp::create(*this, loc, mlir::TypeRange(), cdt, true);
567 return IfBuilder(op, *this);
568 }
569
570 mlir::Value genNot(mlir::Location loc, mlir::Value boolean) {
571 return mlir::arith::CmpIOp::create(*this, loc,
572 mlir::arith::CmpIPredicate::eq, boolean,
573 createBool(loc, false));
574 }
575
577 mlir::Value genIsNotNullAddr(mlir::Location loc, mlir::Value addr);
578
580 mlir::Value genIsNullAddr(mlir::Location loc, mlir::Value addr);
581
584 mlir::Value genExtentFromTriplet(mlir::Location loc, mlir::Value lb,
585 mlir::Value ub, mlir::Value step,
586 mlir::Type type, bool fold = false);
587
590 mlir::Value genAbsentOp(mlir::Location loc, mlir::Type argTy);
591
595 void setFastMathFlags(mlir::arith::FastMathFlags flags) {
596 fastMathFlags = flags;
597 }
598
602
604 mlir::arith::FastMathFlags getFastMathFlags() const { return fastMathFlags; }
605
611 mlir::arith::FastMathFlags flags = getFastMathFlags();
612 if (flags == mlir::arith::FastMathFlags::none)
613 return {};
614
615 std::string fmfString{mlir::arith::stringifyFastMathFlags(flags)};
616 std::replace(fmfString.begin(), fmfString.end(), ',', '_');
617 return fmfString;
618 }
619
623 void setIntegerOverflowFlags(mlir::arith::IntegerOverflowFlags flags) {
624 integerOverflowFlags = flags;
625 }
626
628 mlir::arith::IntegerOverflowFlags getIntegerOverflowFlags() const {
629 return integerOverflowFlags;
630 }
631
635 complexDivisionToRuntimeFlag = flag;
636 }
637
640 return complexDivisionToRuntimeFlag;
641 }
642
645 fpMaxminBehavior = mode;
646 }
647 Fortran::common::FPMaxminBehavior getFPMaxminBehavior() const {
648 return fpMaxminBehavior;
649 }
650
652 LLVM_DUMP_METHOD void dumpFunc();
653
655 void notifyOperationInserted(mlir::Operation *op,
656 mlir::OpBuilder::InsertPoint previous) override {
657 // We only care about newly created operations.
658 if (previous.isSet())
659 return;
660 setCommonAttributes(op);
661 }
662
664 mlir::DataLayout &getDataLayout();
665
668 template <typename OpTy>
669 mlir::Value createUnsigned(mlir::Location loc, mlir::Type resultType,
670 mlir::Value left, mlir::Value right) {
671 if (!resultType.isIntOrFloat())
672 return OpTy::create(*this, loc, resultType, left, right);
673 mlir::Type signlessType = mlir::IntegerType::get(
674 getContext(), resultType.getIntOrFloatBitWidth(),
675 mlir::IntegerType::SignednessSemantics::Signless);
676 mlir::Type opResType = resultType;
677 if (left.getType().isUnsignedInteger()) {
678 left = createConvert(loc, signlessType, left);
679 opResType = signlessType;
680 }
681 if (right.getType().isUnsignedInteger()) {
682 right = createConvert(loc, signlessType, right);
683 opResType = signlessType;
684 }
685 mlir::Value result = OpTy::create(*this, loc, opResType, left, right);
686 if (resultType.isUnsignedInteger())
687 result = createConvert(loc, resultType, result);
688 return result;
689 }
690
692 mlir::Value genPtrCompare(mlir::Location loc,
693 mlir::arith::CmpIPredicate predicate,
694 mlir::Value ptr1, mlir::Value ptr2) {
695 ptr1 = createConvert(loc, getIndexType(), ptr1);
696 ptr2 = createConvert(loc, getIndexType(), ptr2);
697 return mlir::arith::CmpIOp::create(*this, loc, predicate, ptr1, ptr2);
698 }
699
700private:
703 void setCommonAttributes(mlir::Operation *op) const;
704
705 KindMapping kindMap;
706
709 mlir::arith::FastMathFlags fastMathFlags{};
710
716 Fortran::common::FPMaxminBehavior fpMaxminBehavior{
717 Fortran::common::FPMaxminBehavior::Legacy};
718
721 mlir::arith::IntegerOverflowFlags integerOverflowFlags{};
722
725 bool complexDivisionToRuntimeFlag = true;
726
729 mlir::SymbolTable *symbolTable = nullptr;
730
734 std::unique_ptr<mlir::DataLayout> dataLayout = nullptr;
735};
736
737} // namespace fir
738
739namespace fir::factory {
740
742
743//===----------------------------------------------------------------------===//
744// ExtendedValue inquiry helpers
745//===----------------------------------------------------------------------===//
746
751mlir::Value readCharLen(fir::FirOpBuilder &builder, mlir::Location loc,
752 const fir::ExtendedValue &box);
753
755mlir::Value readExtent(fir::FirOpBuilder &builder, mlir::Location loc,
756 const fir::ExtendedValue &box, unsigned dim);
757
761mlir::Value readLowerBound(fir::FirOpBuilder &builder, mlir::Location loc,
762 const fir::ExtendedValue &box, unsigned dim,
763 mlir::Value defaultValue);
764
766llvm::SmallVector<mlir::Value> readExtents(fir::FirOpBuilder &builder,
767 mlir::Location loc,
768 const fir::BoxValue &box);
769
775fir::ExtendedValue readBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
776 const fir::BoxValue &box);
777
780llvm::SmallVector<mlir::Value>
781getNonDefaultLowerBounds(fir::FirOpBuilder &builder, mlir::Location loc,
782 const fir::ExtendedValue &exv);
783
787llvm::SmallVector<mlir::Value>
788getNonDeferredLenParams(const fir::ExtendedValue &exv);
789
790//===----------------------------------------------------------------------===//
791// String literal helper helpers
792//===----------------------------------------------------------------------===//
793
796fir::ExtendedValue createStringLiteral(fir::FirOpBuilder &, mlir::Location,
797 llvm::StringRef string);
798
801std::string uniqueCGIdent(llvm::StringRef prefix, llvm::StringRef name);
802
805llvm::SmallVector<mlir::Value> createExtents(fir::FirOpBuilder &builder,
806 mlir::Location loc,
807 fir::SequenceType seqTy);
808
809//===--------------------------------------------------------------------===//
810// Location helpers
811//===--------------------------------------------------------------------===//
812
814mlir::Value locationToFilename(fir::FirOpBuilder &, mlir::Location);
816mlir::Value locationToLineNo(fir::FirOpBuilder &, mlir::Location, mlir::Type);
817
818//===--------------------------------------------------------------------===//
819// ExtendedValue helpers
820//===--------------------------------------------------------------------===//
821
824fir::ExtendedValue componentToExtendedValue(fir::FirOpBuilder &builder,
825 mlir::Location loc,
826 mlir::Value component);
827
834fir::ExtendedValue arrayElementToExtendedValue(fir::FirOpBuilder &builder,
835 mlir::Location loc,
836 const fir::ExtendedValue &array,
837 mlir::Value element);
838
843fir::ExtendedValue arraySectionElementToExtendedValue(
844 fir::FirOpBuilder &builder, mlir::Location loc,
845 const fir::ExtendedValue &array, mlir::Value element, mlir::Value slice);
846
849void genScalarAssignment(fir::FirOpBuilder &builder, mlir::Location loc,
850 const fir::ExtendedValue &lhs,
851 const fir::ExtendedValue &rhs,
852 bool needFinalization = false,
853 bool isTemporaryLHS = false,
854 mlir::ArrayAttr accessGroups = {});
855
859void genRecordAssignment(fir::FirOpBuilder &builder, mlir::Location loc,
860 const fir::ExtendedValue &lhs,
861 const fir::ExtendedValue &rhs,
862 bool needFinalization = false,
863 bool isTemporaryLHS = false);
864
868mlir::TupleType getRaggedArrayHeaderType(fir::FirOpBuilder &builder);
869
874mlir::Value genLenOfCharacter(fir::FirOpBuilder &builder, mlir::Location loc,
875 fir::ArrayLoadOp arrLoad,
876 llvm::ArrayRef<mlir::Value> path,
877 llvm::ArrayRef<mlir::Value> substring);
878mlir::Value genLenOfCharacter(fir::FirOpBuilder &builder, mlir::Location loc,
879 fir::SequenceType seqTy, mlir::Value memref,
880 llvm::ArrayRef<mlir::Value> typeParams,
881 llvm::ArrayRef<mlir::Value> path,
882 llvm::ArrayRef<mlir::Value> substring);
883
886mlir::Value createZeroValue(fir::FirOpBuilder &builder, mlir::Location loc,
887 mlir::Type type);
888
891mlir::Value createOneValue(fir::FirOpBuilder &builder, mlir::Location loc,
892 mlir::Type type);
893
895std::optional<std::int64_t> getExtentFromTriplet(mlir::Value lb, mlir::Value ub,
896 mlir::Value stride);
897
900mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc,
901 mlir::Value lb, mlir::Value ub);
902mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc,
903 mlir::Value lb, mlir::Value ub, mlir::Value zero,
904 mlir::Value one);
905
907mlir::Value genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
908 mlir::Value value);
909mlir::Value genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
910 mlir::Value value, mlir::Value zero);
911
913mlir::Value genCPtrOrCFunptrAddr(fir::FirOpBuilder &builder, mlir::Location loc,
914 mlir::Value cPtr, mlir::Type ty);
915
917mlir::Value genCPtrOrCFunptrValue(fir::FirOpBuilder &builder,
918 mlir::Location loc, mlir::Value cPtr);
919
922fir::BoxValue createBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
923 const fir::ExtendedValue &exv,
924 unsigned corank = 0);
925
927mlir::Value createNullBoxProc(fir::FirOpBuilder &builder, mlir::Location loc,
928 mlir::Type boxType);
929
932mlir::Value createConvert(mlir::OpBuilder &, mlir::Location, mlir::Type,
933 mlir::Value);
934
936void setInternalLinkage(mlir::func::FuncOp);
937
938llvm::SmallVector<mlir::Value>
939elideExtentsAlreadyInType(mlir::Type type, mlir::ValueRange shape);
940
941llvm::SmallVector<mlir::Value>
942elideLengthsAlreadyInType(mlir::Type type, mlir::ValueRange lenParams);
943
945uint64_t getAllocaAddressSpace(const mlir::DataLayout *dataLayout);
946
953llvm::SmallVector<mlir::Value> deduceOptimalExtents(mlir::ValueRange extents1,
954 mlir::ValueRange extents2);
955
956uint64_t getGlobalAddressSpace(mlir::DataLayout *dataLayout);
957
958uint64_t getProgramAddressSpace(mlir::DataLayout *dataLayout);
959
970llvm::SmallVector<mlir::Value> updateRuntimeExtentsForEmptyArrays(
971 fir::FirOpBuilder &builder, mlir::Location loc, mlir::ValueRange extents);
972
976mlir::Value genLifetimeStart(mlir::OpBuilder &builder, mlir::Location loc,
977 fir::AllocaOp alloc, const mlir::DataLayout *dl);
978
981void genLifetimeEnd(mlir::OpBuilder &builder, mlir::Location loc,
982 mlir::Value mem);
983
989mlir::Value getDescriptorWithNewBaseAddress(fir::FirOpBuilder &builder,
990 mlir::Location loc, mlir::Value box,
991 mlir::Value newAddr);
992
994std::optional<mlir::Value>
995genIndexBasedDisjointnessCheck(mlir::Location loc, fir::FirOpBuilder &builder,
996 mlir::Value lhsRef, mlir::Value rhsRef);
997
999std::optional<mlir::Value>
1000genAddressBasedDisjointnessCheck(mlir::Location loc, fir::FirOpBuilder &builder,
1001 mlir::Value lhsRef, mlir::Value rhsRef);
1002
1003} // namespace fir::factory
1004
1005#endif // FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
Definition MathOptionsBase.h:22
Definition BoxValue.h:125
Definition BoxValue.h:293
Definition BoxValue.h:480
Definition FIRBuilder.h:516
mlir::Operation::result_range getResults()
End the IfOp and return the results if any.
Definition FIRBuilder.h:536
Definition FIRBuilder.h:59
IfBuilder genIfThenElse(mlir::Location loc, mlir::Value cdt)
Definition FIRBuilder.h:565
fir::StringLitOp createStringLitOp(mlir::Location loc, llvm::StringRef string)
Convert a StringRef string into a fir::StringLitOp.
Definition FIRBuilder.cpp:643
mlir::Value genExtentFromTriplet(mlir::Location loc, mlir::Value lb, mlir::Value ub, mlir::Value step, mlir::Type type, bool fold=false)
Definition FIRBuilder.cpp:882
void genStackRestore(mlir::Location loc, mlir::Value stackPointer)
Definition FIRBuilder.cpp:444
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:644
mlir::Value createSlice(mlir::Location loc, const fir::ExtendedValue &exv, mlir::ValueRange triples, mlir::ValueRange path)
Definition FIRBuilder.cpp:709
mlir::Value createConvert(mlir::Location loc, mlir::Type toTy, mlir::Value val)
Lazy creation of fir.convert op.
Definition FIRBuilder.cpp:623
IfBuilder genIfOp(mlir::Location loc, mlir::TypeRange results, mlir::Value cdt, bool withElseRegion)
Definition FIRBuilder.h:550
mlir::Value genIsNullAddr(mlir::Location loc, mlir::Value addr)
Generate code testing addr is a null address.
Definition FIRBuilder.cpp:867
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:181
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:333
IfBuilder genIfThen(mlir::Location loc, mlir::Value cdt)
Definition FIRBuilder.h:558
mlir::Value genStackSave(mlir::Location loc)
Definition FIRBuilder.cpp:438
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:675
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:112
mlir::Value createAllOnesInteger(mlir::Location loc, mlir::Type integerType)
Definition FIRBuilder.cpp:170
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:396
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:593
void setComplexDivisionToRuntimeFlag(bool flag)
Definition FIRBuilder.h:634
mlir::IntegerType getDefaultIntegerType()
Get the default integer type.
Definition FIRBuilder.h:132
mlir::Value createNullConstant(mlir::Location loc, mlir::Type ptrType={})
Definition FIRBuilder.cpp:142
void setFastMathFlags(mlir::arith::FastMathFlags flags)
Definition FIRBuilder.h:595
LLVM_DUMP_METHOD void dumpFunc()
Dump the current function. (debug)
Definition FIRBuilder.cpp:849
mlir::ArrayAttr create2DI64ArrayAttr(llvm::SmallVectorImpl< llvm::SmallVector< int64_t > > &intData)
Definition FIRBuilder.cpp:323
mlir::Value convertWithSemantics(mlir::Location loc, mlir::Type toTy, mlir::Value val, bool allowCharacterConversion=false, bool allowRebox=false)
Definition FIRBuilder.cpp:520
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:692
mlir::Value genIsNotNullAddr(mlir::Location loc, mlir::Value addr)
Generate code testing addr is not a null address.
Definition FIRBuilder.cpp:861
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:628
void setIntegerOverflowFlags(mlir::arith::IntegerOverflowFlags flags)
Definition FIRBuilder.h:623
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:760
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:655
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:424
mlir::func::FuncOp getNamedFunction(llvm::StringRef name)
Definition FIRBuilder.h:400
std::string getFastMathFlagsString()
Definition FIRBuilder.h:610
mlir::Value createUnsigned(mlir::Location loc, mlir::Type resultType, mlir::Value left, mlir::Value right)
Definition FIRBuilder.h:669
bool getComplexDivisionToRuntimeFlag() const
Get current ComplexDivisionToRuntimeFlag value.
Definition FIRBuilder.h:639
mlir::Value createBool(mlir::Location loc, bool b)
Create constant i1 with value 1. if b is true or 0. otherwise.
Definition FIRBuilder.h:504
mlir::arith::IntegerOverflowFlags getIntegerOverflowFlags() const
Get current IntegerOverflowFlags value.
Definition FIRBuilder.h:628
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:357
mlir::Type getRealType(int kind)
Get the mlir float type that implements Fortran REAL(kind).
Definition FIRBuilder.cpp:122
mlir::Block * getAllocaBlock()
Get the block for adding Allocas.
Definition FIRBuilder.cpp:281
mlir::Type getVarLenSeqTy(mlir::Type eleTy, unsigned rank=1)
Create a sequence of eleTy with rank dimensions of unknown size.
Definition FIRBuilder.cpp:117
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:451
mlir::Value loadIfRef(mlir::Location loc, mlir::Value val)
Definition FIRBuilder.cpp:637
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:381
mlir::Value createConvertWithVolatileCast(mlir::Location loc, mlir::Type toTy, mlir::Value val)
Definition FIRBuilder.cpp:603
mlir::Value createShape(mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:688
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:901
mlir::arith::FastMathFlags getFastMathFlags() const
Get current FastMathFlags value.
Definition FIRBuilder.h:604
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: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:964
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:362
Definition FIRType.h:106
Definition OpenACC.h:20
FPMaxminBehavior
Definition FPMaxminBehavior.h:29
Definition BoxValue.h:447
fir::ExtendedValue componentToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value component)
Definition FIRBuilder.cpp:1319
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:1764
mlir::Value createZeroValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type type)
Definition FIRBuilder.cpp:1684
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:1418
llvm::SmallVector< mlir::Value > deduceOptimalExtents(mlir::ValueRange extents1, mlir::ValueRange extents2)
Definition FIRBuilder.cpp:1922
fir::BoxValue createBoxValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &exv, unsigned corank=0)
Definition FIRBuilder.cpp:1856
mlir::Value getDescriptorWithNewBaseAddress(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value box, mlir::Value newAddr)
Definition FIRBuilder.cpp:1992
mlir::Value createOneValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type type)
Definition FIRBuilder.cpp:1703
mlir::Value readLowerBound(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &box, unsigned dim, mlir::Value defaultValue)
Definition FIRBuilder.cpp:1031
std::string uniqueCGIdent(llvm::StringRef prefix, llvm::StringRef name)
Definition FIRBuilder.cpp:1233
llvm::SmallVector< mlir::Value > updateRuntimeExtentsForEmptyArrays(fir::FirOpBuilder &builder, mlir::Location loc, mlir::ValueRange extents)
Definition FIRBuilder.cpp:1949
llvm::SmallVector< mlir::Value > getNonDefaultLowerBounds(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:1129
fir::ExtendedValue createStringLiteral(fir::FirOpBuilder &, mlir::Location, llvm::StringRef string)
Definition FIRBuilder.cpp:1271
mlir::TupleType getRaggedArrayHeaderType(fir::FirOpBuilder &builder)
Definition FIRBuilder.cpp:1617
mlir::Value locationToFilename(fir::FirOpBuilder &, mlir::Location)
Generate a string literal containing the file name and return its address.
Definition FIRBuilder.cpp:1253
mlir::Value locationToLineNo(fir::FirOpBuilder &, mlir::Location, mlir::Type)
Generate a constant of the given type with the location line number.
Definition FIRBuilder.cpp:1263
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:2014
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:1000
mlir::Value readCharLen(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &box)
Definition FIRBuilder.cpp:975
void genLifetimeEnd(mlir::OpBuilder &builder, mlir::Location loc, mlir::Value mem)
Definition FIRBuilder.cpp:1987
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:2067
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:1804
llvm::SmallVector< mlir::Value > readExtents(fir::FirOpBuilder &builder, mlir::Location loc, const fir::BoxValue &box)
Read extents from box.
Definition FIRBuilder.cpp:1061
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:1724
mlir::Value genCPtrOrCFunptrValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value cPtr)
Get the C address value.
Definition FIRBuilder.cpp:1822
uint64_t getAllocaAddressSpace(const mlir::DataLayout *dataLayout)
Get the address space which should be used for allocas.
Definition FIRBuilder.cpp:1914
void setInternalLinkage(mlir::func::FuncOp)
Set internal linkage attribute on a function.
Definition FIRBuilder.cpp:1906
mlir::Value createNullBoxProc(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type boxType)
Generate Null BoxProc for procedure pointer null initialization.
Definition FIRBuilder.cpp:1895
fir::ExtendedValue arraySectionElementToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &array, mlir::Value element, mlir::Value slice)
Definition FIRBuilder.cpp:1403
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:1626
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:1563
mlir::Value createConvert(mlir::OpBuilder &, mlir::Location, mlir::Type, mlir::Value)
Definition FIRBuilder.cpp:610
fir::ExtendedValue readBoxValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::BoxValue &box)
Definition FIRBuilder.cpp:1100
mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value lb, mlir::Value ub)
Definition FIRBuilder.cpp:1781
fir::ExtendedValue arrayElementToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &array, mlir::Value element)
Definition FIRBuilder.cpp:1373
llvm::SmallVector< mlir::Value > getNonDeferredLenParams(const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:1151
llvm::SmallVector< mlir::Value > createExtents(fir::FirOpBuilder &builder, mlir::Location loc, fir::SequenceType seqTy)
Definition FIRBuilder.cpp:1293
mlir::Value genLifetimeStart(mlir::OpBuilder &builder, mlir::Location loc, fir::AllocaOp alloc, const mlir::DataLayout *dl)
Definition FIRBuilder.cpp:1975
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:372
Definition AbstractConverter.h:32