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/FIROps.h"
20#include "flang/Optimizer/Dialect/FIROpsSupport.h"
21#include "flang/Optimizer/Dialect/FIRType.h"
22#include "flang/Optimizer/Dialect/Support/FIRContext.h"
23#include "flang/Optimizer/Dialect/Support/KindMapping.h"
25#include "mlir/IR/Builders.h"
26#include "mlir/IR/BuiltinOps.h"
27#include "llvm/ADT/DenseMap.h"
28#include <optional>
29#include <utility>
30
31namespace mlir {
32class DataLayout;
33class SymbolTable;
34}
35
36namespace fir {
38class ExtendedValue;
39class MutableBoxValue;
40class BoxValue;
41
43inline mlir::Type getIntPtrType(mlir::OpBuilder &builder) {
44 // TODO: Delay the need of such type until codegen or find a way to use
45 // llvm::DataLayout::getPointerSizeInBits here.
46 return builder.getI64Type();
47}
48
49//===----------------------------------------------------------------------===//
50// FirOpBuilder
51//===----------------------------------------------------------------------===//
52
55class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
56public:
57 explicit FirOpBuilder(mlir::Operation *op, fir::KindMapping kindMap,
58 mlir::SymbolTable *symbolTable = nullptr)
59 : OpBuilder{op, /*listener=*/this}, kindMap{std::move(kindMap)},
60 symbolTable{symbolTable} {
61 auto fmi = mlir::dyn_cast<mlir::arith::ArithFastMathInterface>(*op);
62 if (fmi) {
63 // Set the builder with FastMathFlags attached to the operation.
64 setFastMathFlags(fmi.getFastMathFlagsAttr().getValue());
65 }
66 }
67 explicit FirOpBuilder(mlir::OpBuilder &builder, fir::KindMapping kindMap,
68 mlir::SymbolTable *symbolTable = nullptr)
69 : OpBuilder(builder), OpBuilder::Listener(), kindMap{std::move(kindMap)},
70 symbolTable{symbolTable} {
71 setListener(this);
72 }
73 explicit FirOpBuilder(mlir::OpBuilder &builder, mlir::ModuleOp mod)
74 : OpBuilder(builder), OpBuilder::Listener(),
75 kindMap{getKindMapping(mod)} {
76 setListener(this);
77 }
78 explicit FirOpBuilder(mlir::OpBuilder &builder, fir::KindMapping kindMap,
79 mlir::Operation *op)
80 : OpBuilder(builder), OpBuilder::Listener(), kindMap{std::move(kindMap)} {
81 setListener(this);
82 auto fmi = mlir::dyn_cast<mlir::arith::ArithFastMathInterface>(*op);
83 if (fmi) {
84 // Set the builder with FastMathFlags attached to the operation.
85 setFastMathFlags(fmi.getFastMathFlagsAttr().getValue());
86 }
87 }
88 FirOpBuilder(mlir::OpBuilder &builder, mlir::Operation *op)
89 : FirOpBuilder(builder, fir::getKindMapping(op), op) {}
90
91 // The listener self-reference has to be updated in case of copy-construction.
92 FirOpBuilder(const FirOpBuilder &other)
93 : OpBuilder(other), OpBuilder::Listener(), kindMap{other.kindMap},
94 fastMathFlags{other.fastMathFlags},
95 integerOverflowFlags{other.integerOverflowFlags},
96 symbolTable{other.symbolTable} {
97 setListener(this);
98 }
99
100 FirOpBuilder(FirOpBuilder &&other)
101 : OpBuilder(other), OpBuilder::Listener(),
102 kindMap{std::move(other.kindMap)}, fastMathFlags{other.fastMathFlags},
103 integerOverflowFlags{other.integerOverflowFlags},
104 symbolTable{other.symbolTable} {
105 setListener(this);
106 }
107
109 mlir::Region &getRegion() { return *getBlock()->getParent(); }
110
112 mlir::ModuleOp getModule() {
113 return getRegion().getParentOfType<mlir::ModuleOp>();
114 }
115
117 mlir::func::FuncOp getFunction() {
118 return getRegion().getParentOfType<mlir::func::FuncOp>();
119 }
120
122 const fir::KindMapping &getKindMap() { return kindMap; }
123
125 mlir::SymbolTable *getMLIRSymbolTable() { return symbolTable; }
126
128 [[maybe_unused]] mlir::IntegerType getDefaultIntegerType() {
129 return getIntegerType(
130 getKindMap().getIntegerBitsize(getKindMap().defaultIntegerKind()));
131 }
132
139 mlir::Value convertWithSemantics(mlir::Location loc, mlir::Type toTy,
140 mlir::Value val,
141 bool allowCharacterConversion = false,
142 bool allowRebox = false);
143
145 mlir::Block *getEntryBlock() { return &getFunction().front(); }
146
150 mlir::Block *getAllocaBlock();
151
153 mlir::Type getRefType(mlir::Type eleTy, bool isVolatile = false);
154
156 mlir::Type getVarLenSeqTy(mlir::Type eleTy, unsigned rank = 1);
157
159 mlir::Type getCharacterLengthType() { return getIndexType(); }
160
163 mlir::Type getIntPtrType() { return fir::getIntPtrType(*this); }
164
166 mlir::SymbolRefAttr getSymbolRefAttr(llvm::StringRef str) {
167 return mlir::SymbolRefAttr::get(getContext(), str);
168 }
169
171 mlir::Type getRealType(int kind);
172
173 fir::BoxProcType getBoxProcType(mlir::FunctionType funcTy) {
174 return fir::BoxProcType::get(getContext(), funcTy);
175 }
176
179 mlir::Value createNullConstant(mlir::Location loc, mlir::Type ptrType = {});
180
184 mlir::Value createIntegerConstant(mlir::Location loc, mlir::Type integerType,
185 std::int64_t i);
186
189 mlir::Value createAllOnesInteger(mlir::Location loc, mlir::Type integerType);
190
193 mlir::Value createMinusOneInteger(mlir::Location loc,
194 mlir::Type integerType) {
195 return createAllOnesInteger(loc, integerType);
196 }
197
199 mlir::Value createRealConstant(mlir::Location loc, mlir::Type realType,
200 llvm::APFloat::integerPart val);
201
203 mlir::Value createRealConstant(mlir::Location loc, mlir::Type realType,
204 const llvm::APFloat &val);
205
207 mlir::Value createRealZeroConstant(mlir::Location loc, mlir::Type realType) {
208 return createRealConstant(loc, realType, 0u);
209 }
210
212 mlir::Value createRealOneConstant(mlir::Location loc, mlir::Type realType) {
213 return createRealConstant(loc, realType, 1u);
214 }
215
218 mlir::Value allocateLocal(mlir::Location loc, mlir::Type ty,
219 llvm::StringRef uniqName, llvm::StringRef name,
220 bool pinned, llvm::ArrayRef<mlir::Value> shape,
222 bool asTarget = false);
223 mlir::Value allocateLocal(mlir::Location loc, mlir::Type ty,
224 llvm::StringRef uniqName, llvm::StringRef name,
227 bool asTarget = false);
228
231 mlir::ArrayAttr create2DI64ArrayAttr(
232 llvm::SmallVectorImpl<llvm::SmallVector<int64_t>> &intData);
233
237 mlir::Value createTemporaryAlloc(
238 mlir::Location loc, mlir::Type type, llvm::StringRef name,
239 mlir::ValueRange lenParams = {}, mlir::ValueRange shape = {},
240 llvm::ArrayRef<mlir::NamedAttribute> attrs = {},
241 std::optional<Fortran::common::CUDADataAttr> cudaAttr = std::nullopt);
242
246 mlir::Value createTemporary(
247 mlir::Location loc, mlir::Type type, llvm::StringRef name = {},
248 mlir::ValueRange shape = {}, mlir::ValueRange lenParams = {},
249 llvm::ArrayRef<mlir::NamedAttribute> attrs = {},
250 std::optional<Fortran::common::CUDADataAttr> cudaAttr = std::nullopt);
251
253 mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
254 mlir::ValueRange shape) {
255 return createTemporary(loc, type, llvm::StringRef{}, shape);
256 }
257
258 mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
260 return createTemporary(loc, type, llvm::StringRef{}, {}, {}, attrs);
261 }
262
263 mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
264 llvm::StringRef name,
265 llvm::ArrayRef<mlir::NamedAttribute> attrs) {
266 return createTemporary(loc, type, name, {}, {}, attrs);
267 }
268
270 mlir::Value
271 createHeapTemporary(mlir::Location loc, mlir::Type type,
272 llvm::StringRef name = {}, mlir::ValueRange shape = {},
273 mlir::ValueRange lenParams = {},
274 llvm::ArrayRef<mlir::NamedAttribute> attrs = {});
275
280 static mlir::Value genTempDeclareOp(fir::FirOpBuilder &builder,
281 mlir::Location loc, mlir::Value memref,
282 llvm::StringRef name, mlir::Value shape,
283 llvm::ArrayRef<mlir::Value> typeParams,
284 fir::FortranVariableFlagsAttr attrs);
285
302 std::pair<mlir::Value, bool> createAndDeclareTemp(
303 mlir::Location loc, mlir::Type baseType, mlir::Value shape,
304 llvm::ArrayRef<mlir::Value> extents,
305 llvm::ArrayRef<mlir::Value> typeParams,
306 const std::function<decltype(genTempDeclareOp)> &genDeclare,
307 mlir::Value polymorphicMold, bool useStack, llvm::StringRef tmpName);
309 std::pair<mlir::Value, bool>
310 createArrayTemp(mlir::Location loc, fir::SequenceType arrayType,
311 mlir::Value shape, llvm::ArrayRef<mlir::Value> extents,
313 const std::function<decltype(genTempDeclareOp)> &genDeclare,
314 mlir::Value polymorphicMold, bool useStack = false,
315 llvm::StringRef tmpName = ".tmp.array") {
316 return createAndDeclareTemp(loc, arrayType, shape, extents, typeParams,
317 genDeclare, polymorphicMold, useStack, tmpName);
318 }
319
323 mlir::Value genStackSave(mlir::Location loc);
324
327 void genStackRestore(mlir::Location loc, mlir::Value stackPointer);
328
330 fir::GlobalOp createGlobal(mlir::Location loc, mlir::Type type,
331 llvm::StringRef name,
332 mlir::StringAttr linkage = {},
333 mlir::Attribute value = {}, bool isConst = false,
334 bool isTarget = false,
335 cuf::DataAttributeAttr dataAttr = {});
336
337 fir::GlobalOp createGlobal(mlir::Location loc, mlir::Type type,
338 llvm::StringRef name, bool isConst, bool isTarget,
339 std::function<void(FirOpBuilder &)> bodyBuilder,
340 mlir::StringAttr linkage = {},
341 cuf::DataAttributeAttr dataAttr = {});
342
344 fir::GlobalOp createGlobalConstant(mlir::Location loc, mlir::Type type,
345 llvm::StringRef name,
346 mlir::StringAttr linkage = {},
347 mlir::Attribute value = {}) {
348 return createGlobal(loc, type, name, linkage, value, /*isConst=*/true,
349 /*isTarget=*/false);
350 }
351
352 fir::GlobalOp
353 createGlobalConstant(mlir::Location loc, mlir::Type type,
354 llvm::StringRef name,
355 std::function<void(FirOpBuilder &)> bodyBuilder,
356 mlir::StringAttr linkage = {}) {
357 return createGlobal(loc, type, name, /*isConst=*/true, /*isTarget=*/false,
358 bodyBuilder, linkage);
359 }
360
362 fir::StringLitOp createStringLitOp(mlir::Location loc,
363 llvm::StringRef string);
364
365 std::pair<fir::TypeInfoOp, mlir::OpBuilder::InsertPoint>
366 createTypeInfoOp(mlir::Location loc, fir::RecordType recordType,
367 fir::RecordType parentType);
368
369 //===--------------------------------------------------------------------===//
370 // Linkage helpers (inline). The default linkage is external.
371 //===--------------------------------------------------------------------===//
372
373 static mlir::StringAttr createCommonLinkage(mlir::MLIRContext *context) {
374 return mlir::StringAttr::get(context, "common");
375 }
376 mlir::StringAttr createCommonLinkage() {
377 return createCommonLinkage(getContext());
378 }
379
380 mlir::StringAttr createExternalLinkage() { return getStringAttr("external"); }
381
382 mlir::StringAttr createInternalLinkage() { return getStringAttr("internal"); }
383
384 mlir::StringAttr createLinkOnceLinkage() { return getStringAttr("linkonce"); }
385
386 mlir::StringAttr createLinkOnceODRLinkage() {
387 return getStringAttr("linkonce_odr");
388 }
389
390 mlir::StringAttr createWeakLinkage() { return getStringAttr("weak"); }
391
394 mlir::func::FuncOp getNamedFunction(llvm::StringRef name) {
396 }
397 static mlir::func::FuncOp
398 getNamedFunction(mlir::ModuleOp module, const mlir::SymbolTable *symbolTable,
399 llvm::StringRef name);
400
403 mlir::func::FuncOp getNamedFunction(mlir::SymbolRefAttr symbol) {
404 return getNamedFunction(getModule(), getMLIRSymbolTable(), symbol);
405 }
406 static mlir::func::FuncOp
407 getNamedFunction(mlir::ModuleOp module, const mlir::SymbolTable *symbolTable,
408 mlir::SymbolRefAttr symbol);
409
410 fir::GlobalOp getNamedGlobal(llvm::StringRef name) {
411 return getNamedGlobal(getModule(), getMLIRSymbolTable(), name);
412 }
413
414 static fir::GlobalOp getNamedGlobal(mlir::ModuleOp module,
415 const mlir::SymbolTable *symbolTable,
416 llvm::StringRef name);
417
419 mlir::Value createConvert(mlir::Location loc, mlir::Type toTy,
420 mlir::Value val);
421
424 mlir::Value createConvertWithVolatileCast(mlir::Location loc, mlir::Type toTy,
425 mlir::Value val);
426
428 mlir::Value createVolatileCast(mlir::Location loc, bool isVolatile,
429 mlir::Value value);
430
433 void createStoreWithConvert(mlir::Location loc, mlir::Value val,
434 mlir::Value addr);
435
438 mlir::Value loadIfRef(mlir::Location loc, mlir::Value val);
439
442 mlir::func::FuncOp createFunction(mlir::Location loc, llvm::StringRef name,
443 mlir::FunctionType ty) {
444 return createFunction(loc, getModule(), name, ty, getMLIRSymbolTable());
445 }
446
447 static mlir::func::FuncOp createFunction(mlir::Location loc,
448 mlir::ModuleOp module,
449 llvm::StringRef name,
450 mlir::FunctionType ty,
451 mlir::SymbolTable *);
452
457 mlir::func::FuncOp createRuntimeFunction(mlir::Location loc,
458 llvm::StringRef name,
459 mlir::FunctionType ty,
460 bool isIO = false);
461
463 mlir::Value convertToIndexType(mlir::Location loc, mlir::Value val) {
464 return createConvert(loc, getIndexType(), val);
465 }
466
468 mlir::Value genShape(mlir::Location loc, const fir::AbstractArrayBox &arr);
469 mlir::Value genShape(mlir::Location loc, llvm::ArrayRef<mlir::Value> shift,
471 mlir::Value genShape(mlir::Location loc, llvm::ArrayRef<mlir::Value> exts);
472 mlir::Value genShift(mlir::Location loc, llvm::ArrayRef<mlir::Value> shift);
473
476 mlir::Value createShape(mlir::Location loc, const fir::ExtendedValue &exv);
477
480 mlir::Value createSlice(mlir::Location loc, const fir::ExtendedValue &exv,
481 mlir::ValueRange triples, mlir::ValueRange path);
482
489 mlir::Value createBox(mlir::Location loc, const fir::ExtendedValue &exv,
490 bool isPolymorphic = false, bool isAssumedType = false);
491
492 mlir::Value createBox(mlir::Location loc, mlir::Type boxType,
493 mlir::Value addr, mlir::Value shape, mlir::Value slice,
494 llvm::ArrayRef<mlir::Value> lengths, mlir::Value tdesc);
495
497 mlir::Value createBool(mlir::Location loc, bool b) {
498 return createIntegerConstant(loc, getIntegerType(1), b ? 1 : 0);
499 }
500
501 //===--------------------------------------------------------------------===//
502 // If-Then-Else generation helper
503 //===--------------------------------------------------------------------===//
504
509 class IfBuilder {
510 public:
511 IfBuilder(fir::IfOp ifOp, FirOpBuilder &builder)
512 : ifOp{ifOp}, builder{builder} {}
513 template <typename CC>
514 IfBuilder &genThen(CC func) {
515 builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
516 func();
517 return *this;
518 }
519 template <typename CC>
520 IfBuilder &genElse(CC func) {
521 assert(!ifOp.getElseRegion().empty() && "must have else region");
522 builder.setInsertionPointToStart(&ifOp.getElseRegion().front());
523 func();
524 return *this;
525 }
526 void end() { builder.setInsertionPointAfter(ifOp); }
527
529 mlir::Operation::result_range getResults() {
530 end();
531 return ifOp.getResults();
532 }
533
534 fir::IfOp &getIfOp() { return ifOp; };
535
536 private:
537 fir::IfOp ifOp;
538 FirOpBuilder &builder;
539 };
540
543 IfBuilder genIfOp(mlir::Location loc, mlir::TypeRange results,
544 mlir::Value cdt, bool withElseRegion) {
545 auto op = fir::IfOp::create(*this, loc, results, cdt, withElseRegion);
546 return IfBuilder(op, *this);
547 }
548
551 IfBuilder genIfThen(mlir::Location loc, mlir::Value cdt) {
552 auto op = fir::IfOp::create(*this, loc, mlir::TypeRange(), cdt, false);
553 return IfBuilder(op, *this);
554 }
555
558 IfBuilder genIfThenElse(mlir::Location loc, mlir::Value cdt) {
559 auto op = fir::IfOp::create(*this, loc, mlir::TypeRange(), cdt, true);
560 return IfBuilder(op, *this);
561 }
562
563 mlir::Value genNot(mlir::Location loc, mlir::Value boolean) {
564 return mlir::arith::CmpIOp::create(*this, loc,
565 mlir::arith::CmpIPredicate::eq, boolean,
566 createBool(loc, false));
567 }
568
570 mlir::Value genIsNotNullAddr(mlir::Location loc, mlir::Value addr);
571
573 mlir::Value genIsNullAddr(mlir::Location loc, mlir::Value addr);
574
577 mlir::Value genExtentFromTriplet(mlir::Location loc, mlir::Value lb,
578 mlir::Value ub, mlir::Value step,
579 mlir::Type type);
580
583 mlir::Value genAbsentOp(mlir::Location loc, mlir::Type argTy);
584
588 void setFastMathFlags(mlir::arith::FastMathFlags flags) {
589 fastMathFlags = flags;
590 }
591
595
597 mlir::arith::FastMathFlags getFastMathFlags() const { return fastMathFlags; }
598
604 mlir::arith::FastMathFlags flags = getFastMathFlags();
605 if (flags == mlir::arith::FastMathFlags::none)
606 return {};
607
608 std::string fmfString{mlir::arith::stringifyFastMathFlags(flags)};
609 std::replace(fmfString.begin(), fmfString.end(), ',', '_');
610 return fmfString;
611 }
612
616 void setIntegerOverflowFlags(mlir::arith::IntegerOverflowFlags flags) {
617 integerOverflowFlags = flags;
618 }
619
621 mlir::arith::IntegerOverflowFlags getIntegerOverflowFlags() const {
622 return integerOverflowFlags;
623 }
624
628 complexDivisionToRuntimeFlag = flag;
629 }
630
633 return complexDivisionToRuntimeFlag;
634 }
635
637 LLVM_DUMP_METHOD void dumpFunc();
638
640 void notifyOperationInserted(mlir::Operation *op,
641 mlir::OpBuilder::InsertPoint previous) override {
642 // We only care about newly created operations.
643 if (previous.isSet())
644 return;
645 setCommonAttributes(op);
646 }
647
649 mlir::DataLayout &getDataLayout();
650
653 template <typename OpTy>
654 mlir::Value createUnsigned(mlir::Location loc, mlir::Type resultType,
655 mlir::Value left, mlir::Value right) {
656 if (!resultType.isIntOrFloat())
657 return OpTy::create(*this, loc, resultType, left, right);
658 mlir::Type signlessType = mlir::IntegerType::get(
659 getContext(), resultType.getIntOrFloatBitWidth(),
660 mlir::IntegerType::SignednessSemantics::Signless);
661 mlir::Type opResType = resultType;
662 if (left.getType().isUnsignedInteger()) {
663 left = createConvert(loc, signlessType, left);
664 opResType = signlessType;
665 }
666 if (right.getType().isUnsignedInteger()) {
667 right = createConvert(loc, signlessType, right);
668 opResType = signlessType;
669 }
670 mlir::Value result = OpTy::create(*this, loc, opResType, left, right);
671 if (resultType.isUnsignedInteger())
672 result = createConvert(loc, resultType, result);
673 return result;
674 }
675
677 mlir::Value genPtrCompare(mlir::Location loc,
678 mlir::arith::CmpIPredicate predicate,
679 mlir::Value ptr1, mlir::Value ptr2) {
680 ptr1 = createConvert(loc, getIndexType(), ptr1);
681 ptr2 = createConvert(loc, getIndexType(), ptr2);
682 return mlir::arith::CmpIOp::create(*this, loc, predicate, ptr1, ptr2);
683 }
684
685private:
688 void setCommonAttributes(mlir::Operation *op) const;
689
690 KindMapping kindMap;
691
694 mlir::arith::FastMathFlags fastMathFlags{};
695
698 mlir::arith::IntegerOverflowFlags integerOverflowFlags{};
699
702 bool complexDivisionToRuntimeFlag = true;
703
706 mlir::SymbolTable *symbolTable = nullptr;
707
711 std::unique_ptr<mlir::DataLayout> dataLayout = nullptr;
712};
713
714} // namespace fir
715
716namespace fir::factory {
717
718//===----------------------------------------------------------------------===//
719// ExtendedValue inquiry helpers
720//===----------------------------------------------------------------------===//
721
726mlir::Value readCharLen(fir::FirOpBuilder &builder, mlir::Location loc,
727 const fir::ExtendedValue &box);
728
730mlir::Value readExtent(fir::FirOpBuilder &builder, mlir::Location loc,
731 const fir::ExtendedValue &box, unsigned dim);
732
736mlir::Value readLowerBound(fir::FirOpBuilder &builder, mlir::Location loc,
737 const fir::ExtendedValue &box, unsigned dim,
738 mlir::Value defaultValue);
739
741llvm::SmallVector<mlir::Value> readExtents(fir::FirOpBuilder &builder,
742 mlir::Location loc,
743 const fir::BoxValue &box);
744
750fir::ExtendedValue readBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
751 const fir::BoxValue &box);
752
755llvm::SmallVector<mlir::Value>
756getNonDefaultLowerBounds(fir::FirOpBuilder &builder, mlir::Location loc,
757 const fir::ExtendedValue &exv);
758
762llvm::SmallVector<mlir::Value>
763getNonDeferredLenParams(const fir::ExtendedValue &exv);
764
765//===----------------------------------------------------------------------===//
766// String literal helper helpers
767//===----------------------------------------------------------------------===//
768
771fir::ExtendedValue createStringLiteral(fir::FirOpBuilder &, mlir::Location,
772 llvm::StringRef string);
773
776std::string uniqueCGIdent(llvm::StringRef prefix, llvm::StringRef name);
777
780llvm::SmallVector<mlir::Value> createExtents(fir::FirOpBuilder &builder,
781 mlir::Location loc,
782 fir::SequenceType seqTy);
783
784//===--------------------------------------------------------------------===//
785// Location helpers
786//===--------------------------------------------------------------------===//
787
789mlir::Value locationToFilename(fir::FirOpBuilder &, mlir::Location);
791mlir::Value locationToLineNo(fir::FirOpBuilder &, mlir::Location, mlir::Type);
792
793//===--------------------------------------------------------------------===//
794// ExtendedValue helpers
795//===--------------------------------------------------------------------===//
796
799fir::ExtendedValue componentToExtendedValue(fir::FirOpBuilder &builder,
800 mlir::Location loc,
801 mlir::Value component);
802
809fir::ExtendedValue arrayElementToExtendedValue(fir::FirOpBuilder &builder,
810 mlir::Location loc,
811 const fir::ExtendedValue &array,
812 mlir::Value element);
813
818fir::ExtendedValue arraySectionElementToExtendedValue(
819 fir::FirOpBuilder &builder, mlir::Location loc,
820 const fir::ExtendedValue &array, mlir::Value element, mlir::Value slice);
821
824void genScalarAssignment(fir::FirOpBuilder &builder, mlir::Location loc,
825 const fir::ExtendedValue &lhs,
826 const fir::ExtendedValue &rhs,
827 bool needFinalization = false,
828 bool isTemporaryLHS = false,
829 mlir::ArrayAttr accessGroups = {});
830
834void genRecordAssignment(fir::FirOpBuilder &builder, mlir::Location loc,
835 const fir::ExtendedValue &lhs,
836 const fir::ExtendedValue &rhs,
837 bool needFinalization = false,
838 bool isTemporaryLHS = false);
839
843mlir::TupleType getRaggedArrayHeaderType(fir::FirOpBuilder &builder);
844
849mlir::Value genLenOfCharacter(fir::FirOpBuilder &builder, mlir::Location loc,
850 fir::ArrayLoadOp arrLoad,
851 llvm::ArrayRef<mlir::Value> path,
852 llvm::ArrayRef<mlir::Value> substring);
853mlir::Value genLenOfCharacter(fir::FirOpBuilder &builder, mlir::Location loc,
854 fir::SequenceType seqTy, mlir::Value memref,
855 llvm::ArrayRef<mlir::Value> typeParams,
856 llvm::ArrayRef<mlir::Value> path,
857 llvm::ArrayRef<mlir::Value> substring);
858
861mlir::Value createZeroValue(fir::FirOpBuilder &builder, mlir::Location loc,
862 mlir::Type type);
863
866mlir::Value createOneValue(fir::FirOpBuilder &builder, mlir::Location loc,
867 mlir::Type type);
868
870std::optional<std::int64_t> getExtentFromTriplet(mlir::Value lb, mlir::Value ub,
871 mlir::Value stride);
872
875mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc,
876 mlir::Value lb, mlir::Value ub);
877mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc,
878 mlir::Value lb, mlir::Value ub, mlir::Value zero,
879 mlir::Value one);
880
882mlir::Value genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
883 mlir::Value value);
884mlir::Value genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
885 mlir::Value value, mlir::Value zero);
886
890mlir::Value genCPtrOrCFunptrAddr(fir::FirOpBuilder &builder, mlir::Location loc,
891 mlir::Value cPtr, mlir::Type ty);
892
895mlir::Value genCDevPtrAddr(fir::FirOpBuilder &builder, mlir::Location loc,
896 mlir::Value cDevPtr, mlir::Type ty);
897
899mlir::Value genCPtrOrCFunptrValue(fir::FirOpBuilder &builder,
900 mlir::Location loc, mlir::Value cPtr);
901
904fir::BoxValue createBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
905 const fir::ExtendedValue &exv);
906
908mlir::Value createNullBoxProc(fir::FirOpBuilder &builder, mlir::Location loc,
909 mlir::Type boxType);
910
913mlir::Value createConvert(mlir::OpBuilder &, mlir::Location, mlir::Type,
914 mlir::Value);
915
917void setInternalLinkage(mlir::func::FuncOp);
918
919llvm::SmallVector<mlir::Value>
920elideExtentsAlreadyInType(mlir::Type type, mlir::ValueRange shape);
921
922llvm::SmallVector<mlir::Value>
923elideLengthsAlreadyInType(mlir::Type type, mlir::ValueRange lenParams);
924
926uint64_t getAllocaAddressSpace(const mlir::DataLayout *dataLayout);
927
934llvm::SmallVector<mlir::Value> deduceOptimalExtents(mlir::ValueRange extents1,
935 mlir::ValueRange extents2);
936
937uint64_t getGlobalAddressSpace(mlir::DataLayout *dataLayout);
938
939uint64_t getProgramAddressSpace(mlir::DataLayout *dataLayout);
940
951llvm::SmallVector<mlir::Value> updateRuntimeExtentsForEmptyArrays(
952 fir::FirOpBuilder &builder, mlir::Location loc, mlir::ValueRange extents);
953
958void genDimInfoFromBox(fir::FirOpBuilder &builder, mlir::Location loc,
959 mlir::Value box,
960 llvm::SmallVectorImpl<mlir::Value> *lbounds,
961 llvm::SmallVectorImpl<mlir::Value> *extents,
962 llvm::SmallVectorImpl<mlir::Value> *strides);
963
967mlir::Value genLifetimeStart(mlir::OpBuilder &builder, mlir::Location loc,
968 fir::AllocaOp alloc, const mlir::DataLayout *dl);
969
972void genLifetimeEnd(mlir::OpBuilder &builder, mlir::Location loc,
973 mlir::Value mem);
974
980mlir::Value getDescriptorWithNewBaseAddress(fir::FirOpBuilder &builder,
981 mlir::Location loc, mlir::Value box,
982 mlir::Value newAddr);
983
984} // namespace fir::factory
985
986#endif // FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
Definition MathOptionsBase.h:22
Definition BoxValue.h:125
Definition BoxValue.h:291
Definition BoxValue.h:478
Definition FIRBuilder.h:509
mlir::Operation::result_range getResults()
End the IfOp and return the results if any.
Definition FIRBuilder.h:529
Definition FIRBuilder.h:55
IfBuilder genIfThenElse(mlir::Location loc, mlir::Value cdt)
Definition FIRBuilder.h:558
fir::StringLitOp createStringLitOp(mlir::Location loc, llvm::StringRef string)
Convert a StringRef string into a fir::StringLitOp.
Definition FIRBuilder.cpp:632
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={})
Create a global value.
Definition FIRBuilder.cpp:447
void genStackRestore(mlir::Location loc, mlir::Value stackPointer)
Definition FIRBuilder.cpp:440
mlir::SymbolRefAttr getSymbolRefAttr(llvm::StringRef str)
Wrap str to a SymbolRefAttr.
Definition FIRBuilder.h:166
mlir::Value createRealZeroConstant(mlir::Location loc, mlir::Type realType)
Create a real constant of type realType with a value zero.
Definition FIRBuilder.h:207
mlir::Value createSlice(mlir::Location loc, const fir::ExtendedValue &exv, mlir::ValueRange triples, mlir::ValueRange path)
Definition FIRBuilder.cpp:698
mlir::Value createConvert(mlir::Location loc, mlir::Type toTy, mlir::Value val)
Lazy creation of fir.convert op.
Definition FIRBuilder.cpp:612
IfBuilder genIfOp(mlir::Location loc, mlir::TypeRange results, mlir::Value cdt, bool withElseRegion)
Definition FIRBuilder.h:543
mlir::Value genIsNullAddr(mlir::Location loc, mlir::Value addr)
Generate code testing addr is a null address.
Definition FIRBuilder.cpp:856
mlir::func::FuncOp getNamedFunction(mlir::SymbolRefAttr symbol)
Definition FIRBuilder.h:403
mlir::Value createRealConstant(mlir::Location loc, mlir::Type realType, llvm::APFloat::integerPart val)
Create a real constant from an integer value.
Definition FIRBuilder.cpp:177
mlir::Type getCharacterLengthType()
Get character length type.
Definition FIRBuilder.h:159
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:329
IfBuilder genIfThen(mlir::Location loc, mlir::Value cdt)
Definition FIRBuilder.h:551
mlir::Value genStackSave(mlir::Location loc)
Definition FIRBuilder.cpp:434
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:664
const fir::KindMapping & getKindMap()
Get a reference to the kind map.
Definition FIRBuilder.h:122
mlir::Type getRefType(mlir::Type eleTy, bool isVolatile=false)
Safely create a reference type to the type eleTy.
Definition FIRBuilder.cpp:108
mlir::Value createAllOnesInteger(mlir::Location loc, mlir::Type integerType)
Definition FIRBuilder.cpp:166
mlir::ModuleOp getModule()
Get the current Module.
Definition FIRBuilder.h:112
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:392
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:344
mlir::Value createMinusOneInteger(mlir::Location loc, mlir::Type integerType)
Definition FIRBuilder.h:193
mlir::Value createVolatileCast(mlir::Location loc, bool isVolatile, mlir::Value value)
Cast value to have isVolatile volatility.
Definition FIRBuilder.cpp:582
void setComplexDivisionToRuntimeFlag(bool flag)
Definition FIRBuilder.h:627
mlir::IntegerType getDefaultIntegerType()
Get the default integer type.
Definition FIRBuilder.h:128
mlir::Value createNullConstant(mlir::Location loc, mlir::Type ptrType={})
Definition FIRBuilder.cpp:138
void setFastMathFlags(mlir::arith::FastMathFlags flags)
Definition FIRBuilder.h:588
LLVM_DUMP_METHOD void dumpFunc()
Dump the current function. (debug)
Definition FIRBuilder.cpp:838
mlir::ArrayAttr create2DI64ArrayAttr(llvm::SmallVectorImpl< llvm::SmallVector< int64_t > > &intData)
Definition FIRBuilder.cpp:319
mlir::Value convertWithSemantics(mlir::Location loc, mlir::Type toTy, mlir::Value val, bool allowCharacterConversion=false, bool allowRebox=false)
Definition FIRBuilder.cpp:509
mlir::SymbolTable * getMLIRSymbolTable()
Get func.func/fir.global symbol table attached to this builder if any.
Definition FIRBuilder.h:125
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:310
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:677
mlir::Value genIsNotNullAddr(mlir::Location loc, mlir::Value addr)
Generate code testing addr is not a null address.
Definition FIRBuilder.cpp:850
mlir::Value convertToIndexType(mlir::Location loc, mlir::Value val)
Cast the input value to IndexType.
Definition FIRBuilder.h:463
void createStoreWithConvert(mlir::Location loc, mlir::Value val, mlir::Value addr)
Definition FIRBuilder.cpp:617
void setIntegerOverflowFlags(mlir::arith::IntegerOverflowFlags flags)
Definition FIRBuilder.h:616
mlir::func::FuncOp createRuntimeFunction(mlir::Location loc, llvm::StringRef name, mlir::FunctionType ty, bool isIO=false)
Definition FIRBuilder.cpp:52
mlir::Region & getRegion()
Get the current Region of the insertion point.
Definition FIRBuilder.h:109
void notifyOperationInserted(mlir::Operation *op, mlir::OpBuilder::InsertPoint previous) override
FirOpBuilder hook for creating new operation.
Definition FIRBuilder.h:640
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:420
mlir::func::FuncOp getNamedFunction(llvm::StringRef name)
Definition FIRBuilder.h:394
mlir::Value genExtentFromTriplet(mlir::Location loc, mlir::Value lb, mlir::Value ub, mlir::Value step, mlir::Type type)
Definition FIRBuilder.cpp:862
std::string getFastMathFlagsString()
Definition FIRBuilder.h:603
mlir::Value createUnsigned(mlir::Location loc, mlir::Type resultType, mlir::Value left, mlir::Value right)
Definition FIRBuilder.h:654
bool getComplexDivisionToRuntimeFlag() const
Get current ComplexDivisionToRuntimeFlag value.
Definition FIRBuilder.h:632
mlir::Value createBool(mlir::Location loc, bool b)
Create constant i1 with value 1. if b is true or 0. otherwise.
Definition FIRBuilder.h:497
mlir::arith::IntegerOverflowFlags getIntegerOverflowFlags() const
Get current IntegerOverflowFlags value.
Definition FIRBuilder.h:621
mlir::func::FuncOp getFunction()
Get the current Function.
Definition FIRBuilder.h:117
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:353
mlir::Type getRealType(int kind)
Get the mlir float type that implements Fortran REAL(kind).
Definition FIRBuilder.cpp:118
mlir::Block * getAllocaBlock()
Get the block for adding Allocas.
Definition FIRBuilder.cpp:277
mlir::Type getVarLenSeqTy(mlir::Type eleTy, unsigned rank=1)
Create a sequence of eleTy with rank dimensions of unknown size.
Definition FIRBuilder.cpp:113
mlir::Value loadIfRef(mlir::Location loc, mlir::Value val)
Definition FIRBuilder.cpp:626
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:377
mlir::Value createConvertWithVolatileCast(mlir::Location loc, mlir::Type toTy, mlir::Value val)
Definition FIRBuilder.cpp:592
mlir::Value createShape(mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:677
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:237
mlir::Value genAbsentOp(mlir::Location loc, mlir::Type argTy)
Definition FIRBuilder.cpp:879
mlir::arith::FastMathFlags getFastMathFlags() const
Get current FastMathFlags value.
Definition FIRBuilder.h:597
mlir::Value createIntegerConstant(mlir::Location loc, mlir::Type integerType, std::int64_t i)
Definition FIRBuilder.cpp:144
mlir::Value createBox(mlir::Location loc, const fir::ExtendedValue &exv, bool isPolymorphic=false, bool isAssumedType=false)
Definition FIRBuilder.cpp:749
mlir::Value createRealOneConstant(mlir::Location loc, mlir::Type realType)
Create a real constant of type realType with value one.
Definition FIRBuilder.h:212
mlir::Block * getEntryBlock()
Get the entry block of the current Function.
Definition FIRBuilder.h:145
mlir::func::FuncOp createFunction(mlir::Location loc, llvm::StringRef name, mlir::FunctionType ty)
Definition FIRBuilder.h:442
mlir::DataLayout & getDataLayout()
Construct a data layout on demand and return it.
Definition FIRBuilder.cpp:942
mlir::Value createTemporary(mlir::Location loc, mlir::Type type, mlir::ValueRange shape)
Create an unnamed and untracked temporary on the stack.
Definition FIRBuilder.h:253
mlir::Type getIntPtrType()
Definition FIRBuilder.h:163
Definition KindMapping.h:48
Definition BoxValue.h:360
Definition FIRType.h:92
Definition OpenACC.h:20
Definition BoxValue.h:445
fir::ExtendedValue componentToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value component)
Definition FIRBuilder.cpp:1297
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:1735
mlir::Value createZeroValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type type)
Definition FIRBuilder.cpp:1655
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:1396
llvm::SmallVector< mlir::Value > deduceOptimalExtents(mlir::ValueRange extents1, mlir::ValueRange extents2)
Definition FIRBuilder.cpp:1903
mlir::Value getDescriptorWithNewBaseAddress(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value box, mlir::Value newAddr)
Definition FIRBuilder.cpp:1999
mlir::Value createOneValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type type)
Definition FIRBuilder.cpp:1674
mlir::Value readLowerBound(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &box, unsigned dim, mlir::Value defaultValue)
Definition FIRBuilder.cpp:1009
std::string uniqueCGIdent(llvm::StringRef prefix, llvm::StringRef name)
Definition FIRBuilder.cpp:1211
mlir::Value genCDevPtrAddr(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value cDevPtr, mlir::Type ty)
Definition FIRBuilder.cpp:1785
llvm::SmallVector< mlir::Value > updateRuntimeExtentsForEmptyArrays(fir::FirOpBuilder &builder, mlir::Location loc, mlir::ValueRange extents)
Definition FIRBuilder.cpp:1930
llvm::SmallVector< mlir::Value > getNonDefaultLowerBounds(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:1107
fir::ExtendedValue createStringLiteral(fir::FirOpBuilder &, mlir::Location, llvm::StringRef string)
Definition FIRBuilder.cpp:1249
mlir::TupleType getRaggedArrayHeaderType(fir::FirOpBuilder &builder)
Definition FIRBuilder.cpp:1588
mlir::Value locationToFilename(fir::FirOpBuilder &, mlir::Location)
Generate a string literal containing the file name and return its address.
Definition FIRBuilder.cpp:1231
mlir::Value locationToLineNo(fir::FirOpBuilder &, mlir::Location, mlir::Type)
Generate a constant of the given type with the location line number.
Definition FIRBuilder.cpp:1241
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:978
mlir::Value readCharLen(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &box)
Definition FIRBuilder.cpp:953
void genLifetimeEnd(mlir::OpBuilder &builder, mlir::Location loc, mlir::Value mem)
Definition FIRBuilder.cpp:1994
mlir::Value genCPtrOrCFunptrAddr(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value cPtr, mlir::Type ty)
Definition FIRBuilder.cpp:1775
llvm::SmallVector< mlir::Value > readExtents(fir::FirOpBuilder &builder, mlir::Location loc, const fir::BoxValue &box)
Read extents from box.
Definition FIRBuilder.cpp:1039
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:1695
mlir::Value genCPtrOrCFunptrValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value cPtr)
Get the C address value.
Definition FIRBuilder.cpp:1804
uint64_t getAllocaAddressSpace(const mlir::DataLayout *dataLayout)
Get the address space which should be used for allocas.
Definition FIRBuilder.cpp:1895
void setInternalLinkage(mlir::func::FuncOp)
Set internal linkage attribute on a function.
Definition FIRBuilder.cpp:1887
mlir::Value createNullBoxProc(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type boxType)
Generate Null BoxProc for procedure pointer null initialization.
Definition FIRBuilder.cpp:1876
fir::ExtendedValue arraySectionElementToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &array, mlir::Value element, mlir::Value slice)
Definition FIRBuilder.cpp:1381
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:1597
fir::BoxValue createBoxValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:1838
void genDimInfoFromBox(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value box, llvm::SmallVectorImpl< mlir::Value > *lbounds, llvm::SmallVectorImpl< mlir::Value > *extents, llvm::SmallVectorImpl< mlir::Value > *strides)
Definition FIRBuilder.cpp:1956
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:1541
mlir::Value createConvert(mlir::OpBuilder &, mlir::Location, mlir::Type, mlir::Value)
Definition FIRBuilder.cpp:599
fir::ExtendedValue readBoxValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::BoxValue &box)
Definition FIRBuilder.cpp:1078
mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value lb, mlir::Value ub)
Definition FIRBuilder.cpp:1752
fir::ExtendedValue arrayElementToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &array, mlir::Value element)
Definition FIRBuilder.cpp:1351
llvm::SmallVector< mlir::Value > getNonDeferredLenParams(const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:1129
llvm::SmallVector< mlir::Value > createExtents(fir::FirOpBuilder &builder, mlir::Location loc, fir::SequenceType seqTy)
Definition FIRBuilder.cpp:1271
mlir::Value genLifetimeStart(mlir::OpBuilder &builder, mlir::Location loc, fir::AllocaOp alloc, const mlir::DataLayout *dl)
Definition FIRBuilder.cpp:1982
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:43
bool isAssumedType(mlir::Type ty)
Definition FIRType.cpp:364
Definition AbstractConverter.h:32