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"
26#include "mlir/IR/Builders.h"
27#include "mlir/IR/BuiltinOps.h"
28#include "llvm/ADT/DenseMap.h"
29#include <optional>
30#include <utility>
31
32namespace mlir {
33class DataLayout;
34class SymbolTable;
35}
36
37namespace fir {
39class ExtendedValue;
40class MutableBoxValue;
41class BoxValue;
42
44inline mlir::Type getIntPtrType(mlir::OpBuilder &builder) {
45 // TODO: Delay the need of such type until codegen or find a way to use
46 // llvm::DataLayout::getPointerSizeInBits here.
47 return builder.getI64Type();
48}
49
50//===----------------------------------------------------------------------===//
51// FirOpBuilder
52//===----------------------------------------------------------------------===//
53
56class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
57public:
58 explicit FirOpBuilder(mlir::Operation *op, fir::KindMapping kindMap,
59 mlir::SymbolTable *symbolTable = nullptr)
60 : OpBuilder{op, /*listener=*/this}, kindMap{std::move(kindMap)},
61 symbolTable{symbolTable} {
62 auto fmi = mlir::dyn_cast<mlir::arith::ArithFastMathInterface>(*op);
63 if (fmi) {
64 // Set the builder with FastMathFlags attached to the operation.
65 setFastMathFlags(fmi.getFastMathFlagsAttr().getValue());
66 }
67 }
68 explicit FirOpBuilder(mlir::OpBuilder &builder, fir::KindMapping kindMap,
69 mlir::SymbolTable *symbolTable = nullptr)
70 : OpBuilder(builder), OpBuilder::Listener(), kindMap{std::move(kindMap)},
71 symbolTable{symbolTable} {
72 setListener(this);
73 }
74 explicit FirOpBuilder(mlir::OpBuilder &builder, mlir::ModuleOp mod)
75 : OpBuilder(builder), OpBuilder::Listener(),
76 kindMap{getKindMapping(mod)} {
77 setListener(this);
78 }
79 explicit FirOpBuilder(mlir::OpBuilder &builder, fir::KindMapping kindMap,
80 mlir::Operation *op)
81 : OpBuilder(builder), OpBuilder::Listener(), kindMap{std::move(kindMap)} {
82 setListener(this);
83 auto fmi = mlir::dyn_cast<mlir::arith::ArithFastMathInterface>(*op);
84 if (fmi) {
85 // Set the builder with FastMathFlags attached to the operation.
86 setFastMathFlags(fmi.getFastMathFlagsAttr().getValue());
87 }
88 }
89 FirOpBuilder(mlir::OpBuilder &builder, mlir::Operation *op)
90 : FirOpBuilder(builder, fir::getKindMapping(op), op) {}
91
92 // The listener self-reference has to be updated in case of copy-construction.
93 FirOpBuilder(const FirOpBuilder &other)
94 : OpBuilder(other), OpBuilder::Listener(), kindMap{other.kindMap},
95 fastMathFlags{other.fastMathFlags},
96 integerOverflowFlags{other.integerOverflowFlags},
97 symbolTable{other.symbolTable} {
98 setListener(this);
99 }
100
101 FirOpBuilder(FirOpBuilder &&other)
102 : OpBuilder(other), OpBuilder::Listener(),
103 kindMap{std::move(other.kindMap)}, fastMathFlags{other.fastMathFlags},
104 integerOverflowFlags{other.integerOverflowFlags},
105 symbolTable{other.symbolTable} {
106 setListener(this);
107 }
108
110 mlir::Region &getRegion() { return *getBlock()->getParent(); }
111
113 mlir::ModuleOp getModule() {
114 return getRegion().getParentOfType<mlir::ModuleOp>();
115 }
116
118 mlir::func::FuncOp getFunction() {
119 return getRegion().getParentOfType<mlir::func::FuncOp>();
120 }
121
123 const fir::KindMapping &getKindMap() { return kindMap; }
124
126 mlir::SymbolTable *getMLIRSymbolTable() { return symbolTable; }
127
129 [[maybe_unused]] mlir::IntegerType getDefaultIntegerType() {
130 return getIntegerType(
131 getKindMap().getIntegerBitsize(getKindMap().defaultIntegerKind()));
132 }
133
140 mlir::Value convertWithSemantics(mlir::Location loc, mlir::Type toTy,
141 mlir::Value val,
142 bool allowCharacterConversion = false,
143 bool allowRebox = false);
144
146 mlir::Block *getEntryBlock() { return &getFunction().front(); }
147
151 mlir::Block *getAllocaBlock();
152
154 mlir::Type getRefType(mlir::Type eleTy, bool isVolatile = false);
155
157 mlir::Type getVarLenSeqTy(mlir::Type eleTy, unsigned rank = 1);
158
160 mlir::Type getCharacterLengthType() { return getIndexType(); }
161
164 mlir::Type getIntPtrType() { return fir::getIntPtrType(*this); }
165
167 mlir::SymbolRefAttr getSymbolRefAttr(llvm::StringRef str) {
168 return mlir::SymbolRefAttr::get(getContext(), str);
169 }
170
172 mlir::Type getRealType(int kind);
173
174 fir::BoxProcType getBoxProcType(mlir::FunctionType funcTy) {
175 return fir::BoxProcType::get(getContext(), funcTy);
176 }
177
180 mlir::Value createNullConstant(mlir::Location loc, mlir::Type ptrType = {});
181
185 mlir::Value createIntegerConstant(mlir::Location loc, mlir::Type integerType,
186 std::int64_t i);
187
190 mlir::Value createAllOnesInteger(mlir::Location loc, mlir::Type integerType);
191
194 mlir::Value createMinusOneInteger(mlir::Location loc,
195 mlir::Type integerType) {
196 return createAllOnesInteger(loc, integerType);
197 }
198
200 mlir::Value createRealConstant(mlir::Location loc, mlir::Type realType,
201 llvm::APFloat::integerPart val);
202
204 mlir::Value createRealConstant(mlir::Location loc, mlir::Type realType,
205 const llvm::APFloat &val);
206
208 mlir::Value createRealZeroConstant(mlir::Location loc, mlir::Type realType) {
209 return createRealConstant(loc, realType, 0u);
210 }
211
213 mlir::Value createRealOneConstant(mlir::Location loc, mlir::Type realType) {
214 return createRealConstant(loc, realType, 1u);
215 }
216
219 mlir::Value allocateLocal(mlir::Location loc, mlir::Type ty,
220 llvm::StringRef uniqName, llvm::StringRef name,
221 bool pinned, llvm::ArrayRef<mlir::Value> shape,
223 bool asTarget = false);
224 mlir::Value allocateLocal(mlir::Location loc, mlir::Type ty,
225 llvm::StringRef uniqName, llvm::StringRef name,
228 bool asTarget = false);
229
232 mlir::ArrayAttr create2DI64ArrayAttr(
233 llvm::SmallVectorImpl<llvm::SmallVector<int64_t>> &intData);
234
238 mlir::Value createTemporaryAlloc(
239 mlir::Location loc, mlir::Type type, llvm::StringRef name,
240 mlir::ValueRange lenParams = {}, mlir::ValueRange shape = {},
241 llvm::ArrayRef<mlir::NamedAttribute> attrs = {},
242 std::optional<Fortran::common::CUDADataAttr> cudaAttr = std::nullopt);
243
247 mlir::Value createTemporary(
248 mlir::Location loc, mlir::Type type, llvm::StringRef name = {},
249 mlir::ValueRange shape = {}, mlir::ValueRange lenParams = {},
250 llvm::ArrayRef<mlir::NamedAttribute> attrs = {},
251 std::optional<Fortran::common::CUDADataAttr> cudaAttr = std::nullopt);
252
254 mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
255 mlir::ValueRange shape) {
256 return createTemporary(loc, type, llvm::StringRef{}, shape);
257 }
258
259 mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
261 return createTemporary(loc, type, llvm::StringRef{}, {}, {}, attrs);
262 }
263
264 mlir::Value createTemporary(mlir::Location loc, mlir::Type type,
265 llvm::StringRef name,
266 llvm::ArrayRef<mlir::NamedAttribute> attrs) {
267 return createTemporary(loc, type, name, {}, {}, attrs);
268 }
269
271 mlir::Value
272 createHeapTemporary(mlir::Location loc, mlir::Type type,
273 llvm::StringRef name = {}, mlir::ValueRange shape = {},
274 mlir::ValueRange lenParams = {},
275 llvm::ArrayRef<mlir::NamedAttribute> attrs = {});
276
281 static mlir::Value genTempDeclareOp(fir::FirOpBuilder &builder,
282 mlir::Location loc, mlir::Value memref,
283 llvm::StringRef name, mlir::Value shape,
284 llvm::ArrayRef<mlir::Value> typeParams,
285 fir::FortranVariableFlagsAttr attrs);
286
303 std::pair<mlir::Value, bool> createAndDeclareTemp(
304 mlir::Location loc, mlir::Type baseType, mlir::Value shape,
305 llvm::ArrayRef<mlir::Value> extents,
306 llvm::ArrayRef<mlir::Value> typeParams,
307 const std::function<decltype(genTempDeclareOp)> &genDeclare,
308 mlir::Value polymorphicMold, bool useStack, llvm::StringRef tmpName);
310 std::pair<mlir::Value, bool>
311 createArrayTemp(mlir::Location loc, fir::SequenceType arrayType,
312 mlir::Value shape, llvm::ArrayRef<mlir::Value> extents,
314 const std::function<decltype(genTempDeclareOp)> &genDeclare,
315 mlir::Value polymorphicMold, bool useStack = false,
316 llvm::StringRef tmpName = ".tmp.array") {
317 return createAndDeclareTemp(loc, arrayType, shape, extents, typeParams,
318 genDeclare, polymorphicMold, useStack, tmpName);
319 }
320
324 mlir::Value genStackSave(mlir::Location loc);
325
328 void genStackRestore(mlir::Location loc, mlir::Value stackPointer);
329
331 fir::GlobalOp createGlobal(mlir::Location loc, mlir::Type type,
332 llvm::StringRef name,
333 mlir::StringAttr linkage = {},
334 mlir::Attribute value = {}, bool isConst = false,
335 bool isTarget = false,
336 cuf::DataAttributeAttr dataAttr = {});
337
338 fir::GlobalOp createGlobal(mlir::Location loc, mlir::Type type,
339 llvm::StringRef name, bool isConst, bool isTarget,
340 std::function<void(FirOpBuilder &)> bodyBuilder,
341 mlir::StringAttr linkage = {},
342 cuf::DataAttributeAttr dataAttr = {});
343
345 fir::GlobalOp createGlobalConstant(mlir::Location loc, mlir::Type type,
346 llvm::StringRef name,
347 mlir::StringAttr linkage = {},
348 mlir::Attribute value = {}) {
349 return createGlobal(loc, type, name, linkage, value, /*isConst=*/true,
350 /*isTarget=*/false);
351 }
352
353 fir::GlobalOp
354 createGlobalConstant(mlir::Location loc, mlir::Type type,
355 llvm::StringRef name,
356 std::function<void(FirOpBuilder &)> bodyBuilder,
357 mlir::StringAttr linkage = {}) {
358 return createGlobal(loc, type, name, /*isConst=*/true, /*isTarget=*/false,
359 bodyBuilder, linkage);
360 }
361
363 fir::StringLitOp createStringLitOp(mlir::Location loc,
364 llvm::StringRef string);
365
366 std::pair<fir::TypeInfoOp, mlir::OpBuilder::InsertPoint>
367 createTypeInfoOp(mlir::Location loc, fir::RecordType recordType,
368 fir::RecordType parentType);
369
370 //===--------------------------------------------------------------------===//
371 // Linkage helpers (inline). The default linkage is external.
372 //===--------------------------------------------------------------------===//
373
374 static mlir::StringAttr createCommonLinkage(mlir::MLIRContext *context) {
375 return mlir::StringAttr::get(context, "common");
376 }
377 mlir::StringAttr createCommonLinkage() {
378 return createCommonLinkage(getContext());
379 }
380
381 mlir::StringAttr createExternalLinkage() { return getStringAttr("external"); }
382
383 mlir::StringAttr createInternalLinkage() { return getStringAttr("internal"); }
384
385 mlir::StringAttr createLinkOnceLinkage() { return getStringAttr("linkonce"); }
386
387 mlir::StringAttr createLinkOnceODRLinkage() {
388 return getStringAttr("linkonce_odr");
389 }
390
391 mlir::StringAttr createWeakLinkage() { return getStringAttr("weak"); }
392
395 mlir::func::FuncOp getNamedFunction(llvm::StringRef name) {
397 }
398 static mlir::func::FuncOp
399 getNamedFunction(mlir::ModuleOp module, const mlir::SymbolTable *symbolTable,
400 llvm::StringRef name);
401
404 mlir::func::FuncOp getNamedFunction(mlir::SymbolRefAttr symbol) {
405 return getNamedFunction(getModule(), getMLIRSymbolTable(), symbol);
406 }
407 static mlir::func::FuncOp
408 getNamedFunction(mlir::ModuleOp module, const mlir::SymbolTable *symbolTable,
409 mlir::SymbolRefAttr symbol);
410
411 fir::GlobalOp getNamedGlobal(llvm::StringRef name) {
412 return getNamedGlobal(getModule(), getMLIRSymbolTable(), name);
413 }
414
415 static fir::GlobalOp getNamedGlobal(mlir::ModuleOp module,
416 const mlir::SymbolTable *symbolTable,
417 llvm::StringRef name);
418
420 mlir::Value createConvert(mlir::Location loc, mlir::Type toTy,
421 mlir::Value val);
422
425 mlir::Value createConvertWithVolatileCast(mlir::Location loc, mlir::Type toTy,
426 mlir::Value val);
427
429 mlir::Value createVolatileCast(mlir::Location loc, bool isVolatile,
430 mlir::Value value);
431
434 void createStoreWithConvert(mlir::Location loc, mlir::Value val,
435 mlir::Value addr);
436
439 mlir::Value loadIfRef(mlir::Location loc, mlir::Value val);
440
443 mlir::func::FuncOp createFunction(mlir::Location loc, llvm::StringRef name,
444 mlir::FunctionType ty) {
445 return createFunction(loc, getModule(), name, ty, getMLIRSymbolTable());
446 }
447
448 static mlir::func::FuncOp createFunction(mlir::Location loc,
449 mlir::ModuleOp module,
450 llvm::StringRef name,
451 mlir::FunctionType ty,
452 mlir::SymbolTable *);
453
458 mlir::func::FuncOp createRuntimeFunction(mlir::Location loc,
459 llvm::StringRef name,
460 mlir::FunctionType ty,
461 bool isIO = false);
462
464 mlir::Value convertToIndexType(mlir::Location loc, mlir::Value val) {
465 return createConvert(loc, getIndexType(), val);
466 }
467
469 mlir::Value genShape(mlir::Location loc, const fir::AbstractArrayBox &arr);
470 mlir::Value genShape(mlir::Location loc, llvm::ArrayRef<mlir::Value> shift,
472 mlir::Value genShape(mlir::Location loc, llvm::ArrayRef<mlir::Value> exts);
473 mlir::Value genShift(mlir::Location loc, llvm::ArrayRef<mlir::Value> shift);
474
477 mlir::Value createShape(mlir::Location loc, const fir::ExtendedValue &exv);
478
481 mlir::Value createSlice(mlir::Location loc, const fir::ExtendedValue &exv,
482 mlir::ValueRange triples, mlir::ValueRange path);
483
490 mlir::Value createBox(mlir::Location loc, const fir::ExtendedValue &exv,
491 bool isPolymorphic = false, bool isAssumedType = false);
492
493 mlir::Value createBox(mlir::Location loc, mlir::Type boxType,
494 mlir::Value addr, mlir::Value shape, mlir::Value slice,
495 llvm::ArrayRef<mlir::Value> lengths, mlir::Value tdesc);
496
498 mlir::Value createBool(mlir::Location loc, bool b) {
499 return createIntegerConstant(loc, getIntegerType(1), b ? 1 : 0);
500 }
501
502 //===--------------------------------------------------------------------===//
503 // If-Then-Else generation helper
504 //===--------------------------------------------------------------------===//
505
510 class IfBuilder {
511 public:
512 IfBuilder(fir::IfOp ifOp, FirOpBuilder &builder)
513 : ifOp{ifOp}, builder{builder} {}
514 template <typename CC>
515 IfBuilder &genThen(CC func) {
516 builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
517 func();
518 return *this;
519 }
520 template <typename CC>
521 IfBuilder &genElse(CC func) {
522 assert(!ifOp.getElseRegion().empty() && "must have else region");
523 builder.setInsertionPointToStart(&ifOp.getElseRegion().front());
524 func();
525 return *this;
526 }
527 void end() { builder.setInsertionPointAfter(ifOp); }
528
530 mlir::Operation::result_range getResults() {
531 end();
532 return ifOp.getResults();
533 }
534
535 fir::IfOp &getIfOp() { return ifOp; };
536
537 private:
538 fir::IfOp ifOp;
539 FirOpBuilder &builder;
540 };
541
544 IfBuilder genIfOp(mlir::Location loc, mlir::TypeRange results,
545 mlir::Value cdt, bool withElseRegion) {
546 auto op = fir::IfOp::create(*this, loc, results, cdt, withElseRegion);
547 return IfBuilder(op, *this);
548 }
549
552 IfBuilder genIfThen(mlir::Location loc, mlir::Value cdt) {
553 auto op = fir::IfOp::create(*this, loc, mlir::TypeRange(), cdt, false);
554 return IfBuilder(op, *this);
555 }
556
559 IfBuilder genIfThenElse(mlir::Location loc, mlir::Value cdt) {
560 auto op = fir::IfOp::create(*this, loc, mlir::TypeRange(), cdt, true);
561 return IfBuilder(op, *this);
562 }
563
564 mlir::Value genNot(mlir::Location loc, mlir::Value boolean) {
565 return mlir::arith::CmpIOp::create(*this, loc,
566 mlir::arith::CmpIPredicate::eq, boolean,
567 createBool(loc, false));
568 }
569
571 mlir::Value genIsNotNullAddr(mlir::Location loc, mlir::Value addr);
572
574 mlir::Value genIsNullAddr(mlir::Location loc, mlir::Value addr);
575
578 mlir::Value genExtentFromTriplet(mlir::Location loc, mlir::Value lb,
579 mlir::Value ub, mlir::Value step,
580 mlir::Type type, bool fold = false);
581
584 mlir::Value genAbsentOp(mlir::Location loc, mlir::Type argTy);
585
589 void setFastMathFlags(mlir::arith::FastMathFlags flags) {
590 fastMathFlags = flags;
591 }
592
596
598 mlir::arith::FastMathFlags getFastMathFlags() const { return fastMathFlags; }
599
605 mlir::arith::FastMathFlags flags = getFastMathFlags();
606 if (flags == mlir::arith::FastMathFlags::none)
607 return {};
608
609 std::string fmfString{mlir::arith::stringifyFastMathFlags(flags)};
610 std::replace(fmfString.begin(), fmfString.end(), ',', '_');
611 return fmfString;
612 }
613
617 void setIntegerOverflowFlags(mlir::arith::IntegerOverflowFlags flags) {
618 integerOverflowFlags = flags;
619 }
620
622 mlir::arith::IntegerOverflowFlags getIntegerOverflowFlags() const {
623 return integerOverflowFlags;
624 }
625
629 complexDivisionToRuntimeFlag = flag;
630 }
631
634 return complexDivisionToRuntimeFlag;
635 }
636
639 fpMaxminBehavior = mode;
640 }
641 Fortran::common::FPMaxminBehavior getFPMaxminBehavior() const {
642 return fpMaxminBehavior;
643 }
644
646 LLVM_DUMP_METHOD void dumpFunc();
647
649 void notifyOperationInserted(mlir::Operation *op,
650 mlir::OpBuilder::InsertPoint previous) override {
651 // We only care about newly created operations.
652 if (previous.isSet())
653 return;
654 setCommonAttributes(op);
655 }
656
658 mlir::DataLayout &getDataLayout();
659
662 template <typename OpTy>
663 mlir::Value createUnsigned(mlir::Location loc, mlir::Type resultType,
664 mlir::Value left, mlir::Value right) {
665 if (!resultType.isIntOrFloat())
666 return OpTy::create(*this, loc, resultType, left, right);
667 mlir::Type signlessType = mlir::IntegerType::get(
668 getContext(), resultType.getIntOrFloatBitWidth(),
669 mlir::IntegerType::SignednessSemantics::Signless);
670 mlir::Type opResType = resultType;
671 if (left.getType().isUnsignedInteger()) {
672 left = createConvert(loc, signlessType, left);
673 opResType = signlessType;
674 }
675 if (right.getType().isUnsignedInteger()) {
676 right = createConvert(loc, signlessType, right);
677 opResType = signlessType;
678 }
679 mlir::Value result = OpTy::create(*this, loc, opResType, left, right);
680 if (resultType.isUnsignedInteger())
681 result = createConvert(loc, resultType, result);
682 return result;
683 }
684
686 mlir::Value genPtrCompare(mlir::Location loc,
687 mlir::arith::CmpIPredicate predicate,
688 mlir::Value ptr1, mlir::Value ptr2) {
689 ptr1 = createConvert(loc, getIndexType(), ptr1);
690 ptr2 = createConvert(loc, getIndexType(), ptr2);
691 return mlir::arith::CmpIOp::create(*this, loc, predicate, ptr1, ptr2);
692 }
693
694private:
697 void setCommonAttributes(mlir::Operation *op) const;
698
699 KindMapping kindMap;
700
703 mlir::arith::FastMathFlags fastMathFlags{};
704
710 Fortran::common::FPMaxminBehavior fpMaxminBehavior{
711 Fortran::common::FPMaxminBehavior::Legacy};
712
715 mlir::arith::IntegerOverflowFlags integerOverflowFlags{};
716
719 bool complexDivisionToRuntimeFlag = true;
720
723 mlir::SymbolTable *symbolTable = nullptr;
724
728 std::unique_ptr<mlir::DataLayout> dataLayout = nullptr;
729};
730
731} // namespace fir
732
733namespace fir::factory {
734
735//===----------------------------------------------------------------------===//
736// ExtendedValue inquiry helpers
737//===----------------------------------------------------------------------===//
738
743mlir::Value readCharLen(fir::FirOpBuilder &builder, mlir::Location loc,
744 const fir::ExtendedValue &box);
745
747mlir::Value readExtent(fir::FirOpBuilder &builder, mlir::Location loc,
748 const fir::ExtendedValue &box, unsigned dim);
749
753mlir::Value readLowerBound(fir::FirOpBuilder &builder, mlir::Location loc,
754 const fir::ExtendedValue &box, unsigned dim,
755 mlir::Value defaultValue);
756
758llvm::SmallVector<mlir::Value> readExtents(fir::FirOpBuilder &builder,
759 mlir::Location loc,
760 const fir::BoxValue &box);
761
767fir::ExtendedValue readBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
768 const fir::BoxValue &box);
769
772llvm::SmallVector<mlir::Value>
773getNonDefaultLowerBounds(fir::FirOpBuilder &builder, mlir::Location loc,
774 const fir::ExtendedValue &exv);
775
779llvm::SmallVector<mlir::Value>
780getNonDeferredLenParams(const fir::ExtendedValue &exv);
781
782//===----------------------------------------------------------------------===//
783// String literal helper helpers
784//===----------------------------------------------------------------------===//
785
788fir::ExtendedValue createStringLiteral(fir::FirOpBuilder &, mlir::Location,
789 llvm::StringRef string);
790
793std::string uniqueCGIdent(llvm::StringRef prefix, llvm::StringRef name);
794
797llvm::SmallVector<mlir::Value> createExtents(fir::FirOpBuilder &builder,
798 mlir::Location loc,
799 fir::SequenceType seqTy);
800
801//===--------------------------------------------------------------------===//
802// Location helpers
803//===--------------------------------------------------------------------===//
804
806mlir::Value locationToFilename(fir::FirOpBuilder &, mlir::Location);
808mlir::Value locationToLineNo(fir::FirOpBuilder &, mlir::Location, mlir::Type);
809
810//===--------------------------------------------------------------------===//
811// ExtendedValue helpers
812//===--------------------------------------------------------------------===//
813
816fir::ExtendedValue componentToExtendedValue(fir::FirOpBuilder &builder,
817 mlir::Location loc,
818 mlir::Value component);
819
826fir::ExtendedValue arrayElementToExtendedValue(fir::FirOpBuilder &builder,
827 mlir::Location loc,
828 const fir::ExtendedValue &array,
829 mlir::Value element);
830
835fir::ExtendedValue arraySectionElementToExtendedValue(
836 fir::FirOpBuilder &builder, mlir::Location loc,
837 const fir::ExtendedValue &array, mlir::Value element, mlir::Value slice);
838
841void genScalarAssignment(fir::FirOpBuilder &builder, mlir::Location loc,
842 const fir::ExtendedValue &lhs,
843 const fir::ExtendedValue &rhs,
844 bool needFinalization = false,
845 bool isTemporaryLHS = false,
846 mlir::ArrayAttr accessGroups = {});
847
851void genRecordAssignment(fir::FirOpBuilder &builder, mlir::Location loc,
852 const fir::ExtendedValue &lhs,
853 const fir::ExtendedValue &rhs,
854 bool needFinalization = false,
855 bool isTemporaryLHS = false);
856
860mlir::TupleType getRaggedArrayHeaderType(fir::FirOpBuilder &builder);
861
866mlir::Value genLenOfCharacter(fir::FirOpBuilder &builder, mlir::Location loc,
867 fir::ArrayLoadOp arrLoad,
868 llvm::ArrayRef<mlir::Value> path,
869 llvm::ArrayRef<mlir::Value> substring);
870mlir::Value genLenOfCharacter(fir::FirOpBuilder &builder, mlir::Location loc,
871 fir::SequenceType seqTy, mlir::Value memref,
872 llvm::ArrayRef<mlir::Value> typeParams,
873 llvm::ArrayRef<mlir::Value> path,
874 llvm::ArrayRef<mlir::Value> substring);
875
878mlir::Value createZeroValue(fir::FirOpBuilder &builder, mlir::Location loc,
879 mlir::Type type);
880
883mlir::Value createOneValue(fir::FirOpBuilder &builder, mlir::Location loc,
884 mlir::Type type);
885
887std::optional<std::int64_t> getExtentFromTriplet(mlir::Value lb, mlir::Value ub,
888 mlir::Value stride);
889
892mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc,
893 mlir::Value lb, mlir::Value ub);
894mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc,
895 mlir::Value lb, mlir::Value ub, mlir::Value zero,
896 mlir::Value one);
897
899mlir::Value genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
900 mlir::Value value);
901mlir::Value genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
902 mlir::Value value, mlir::Value zero);
903
907mlir::Value genCPtrOrCFunptrAddr(fir::FirOpBuilder &builder, mlir::Location loc,
908 mlir::Value cPtr, mlir::Type ty);
909
912mlir::Value genCDevPtrAddr(fir::FirOpBuilder &builder, mlir::Location loc,
913 mlir::Value cDevPtr, mlir::Type ty);
914
916mlir::Value genCPtrOrCFunptrValue(fir::FirOpBuilder &builder,
917 mlir::Location loc, mlir::Value cPtr);
918
921fir::BoxValue createBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
922 const fir::ExtendedValue &exv);
923
925mlir::Value createNullBoxProc(fir::FirOpBuilder &builder, mlir::Location loc,
926 mlir::Type boxType);
927
930mlir::Value createConvert(mlir::OpBuilder &, mlir::Location, mlir::Type,
931 mlir::Value);
932
934void setInternalLinkage(mlir::func::FuncOp);
935
936llvm::SmallVector<mlir::Value>
937elideExtentsAlreadyInType(mlir::Type type, mlir::ValueRange shape);
938
939llvm::SmallVector<mlir::Value>
940elideLengthsAlreadyInType(mlir::Type type, mlir::ValueRange lenParams);
941
943uint64_t getAllocaAddressSpace(const mlir::DataLayout *dataLayout);
944
951llvm::SmallVector<mlir::Value> deduceOptimalExtents(mlir::ValueRange extents1,
952 mlir::ValueRange extents2);
953
954uint64_t getGlobalAddressSpace(mlir::DataLayout *dataLayout);
955
956uint64_t getProgramAddressSpace(mlir::DataLayout *dataLayout);
957
968llvm::SmallVector<mlir::Value> updateRuntimeExtentsForEmptyArrays(
969 fir::FirOpBuilder &builder, mlir::Location loc, mlir::ValueRange extents);
970
975void genDimInfoFromBox(fir::FirOpBuilder &builder, mlir::Location loc,
976 mlir::Value box,
977 llvm::SmallVectorImpl<mlir::Value> *lbounds,
978 llvm::SmallVectorImpl<mlir::Value> *extents,
979 llvm::SmallVectorImpl<mlir::Value> *strides);
980
984mlir::Value genLifetimeStart(mlir::OpBuilder &builder, mlir::Location loc,
985 fir::AllocaOp alloc, const mlir::DataLayout *dl);
986
989void genLifetimeEnd(mlir::OpBuilder &builder, mlir::Location loc,
990 mlir::Value mem);
991
997mlir::Value getDescriptorWithNewBaseAddress(fir::FirOpBuilder &builder,
998 mlir::Location loc, mlir::Value box,
999 mlir::Value newAddr);
1000
1001} // namespace fir::factory
1002
1003#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:510
mlir::Operation::result_range getResults()
End the IfOp and return the results if any.
Definition FIRBuilder.h:530
Definition FIRBuilder.h:56
IfBuilder genIfThenElse(mlir::Location loc, mlir::Value cdt)
Definition FIRBuilder.h:559
fir::StringLitOp createStringLitOp(mlir::Location loc, llvm::StringRef string)
Convert a StringRef string into a fir::StringLitOp.
Definition FIRBuilder.cpp:633
mlir::Value genExtentFromTriplet(mlir::Location loc, mlir::Value lb, mlir::Value ub, mlir::Value step, mlir::Type type, bool fold=false)
Definition FIRBuilder.cpp:872
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:448
void genStackRestore(mlir::Location loc, mlir::Value stackPointer)
Definition FIRBuilder.cpp:441
mlir::SymbolRefAttr getSymbolRefAttr(llvm::StringRef str)
Wrap str to a SymbolRefAttr.
Definition FIRBuilder.h:167
mlir::Value createRealZeroConstant(mlir::Location loc, mlir::Type realType)
Create a real constant of type realType with a value zero.
Definition FIRBuilder.h:208
void setFPMaxminBehavior(Fortran::common::FPMaxminBehavior mode)
Setter/getter for fpMaxminBehavior.
Definition FIRBuilder.h:638
mlir::Value createSlice(mlir::Location loc, const fir::ExtendedValue &exv, mlir::ValueRange triples, mlir::ValueRange path)
Definition FIRBuilder.cpp:699
mlir::Value createConvert(mlir::Location loc, mlir::Type toTy, mlir::Value val)
Lazy creation of fir.convert op.
Definition FIRBuilder.cpp:613
IfBuilder genIfOp(mlir::Location loc, mlir::TypeRange results, mlir::Value cdt, bool withElseRegion)
Definition FIRBuilder.h:544
mlir::Value genIsNullAddr(mlir::Location loc, mlir::Value addr)
Generate code testing addr is a null address.
Definition FIRBuilder.cpp:857
mlir::func::FuncOp getNamedFunction(mlir::SymbolRefAttr symbol)
Definition FIRBuilder.h:404
mlir::Value createRealConstant(mlir::Location loc, mlir::Type realType, llvm::APFloat::integerPart val)
Create a real constant from an integer value.
Definition FIRBuilder.cpp:178
mlir::Type getCharacterLengthType()
Get character length type.
Definition FIRBuilder.h:160
mlir::Value createTemporaryAlloc(mlir::Location loc, mlir::Type type, llvm::StringRef name, mlir::ValueRange lenParams={}, mlir::ValueRange shape={}, llvm::ArrayRef< mlir::NamedAttribute > attrs={}, std::optional< Fortran::common::CUDADataAttr > cudaAttr=std::nullopt)
Definition FIRBuilder.cpp:330
IfBuilder genIfThen(mlir::Location loc, mlir::Value cdt)
Definition FIRBuilder.h:552
mlir::Value genStackSave(mlir::Location loc)
Definition FIRBuilder.cpp:435
mlir::Value genShape(mlir::Location loc, const fir::AbstractArrayBox &arr)
Construct one of the two forms of shape op from an array box.
Definition FIRBuilder.cpp:665
const fir::KindMapping & getKindMap()
Get a reference to the kind map.
Definition FIRBuilder.h:123
mlir::Type getRefType(mlir::Type eleTy, bool isVolatile=false)
Safely create a reference type to the type eleTy.
Definition FIRBuilder.cpp:109
mlir::Value createAllOnesInteger(mlir::Location loc, mlir::Type integerType)
Definition FIRBuilder.cpp:167
mlir::ModuleOp getModule()
Get the current Module.
Definition FIRBuilder.h:113
std::pair< mlir::Value, bool > createAndDeclareTemp(mlir::Location loc, mlir::Type baseType, mlir::Value shape, llvm::ArrayRef< mlir::Value > extents, llvm::ArrayRef< mlir::Value > typeParams, const std::function< decltype(genTempDeclareOp)> &genDeclare, mlir::Value polymorphicMold, bool useStack, llvm::StringRef tmpName)
Definition FIRBuilder.cpp:393
fir::GlobalOp createGlobalConstant(mlir::Location loc, mlir::Type type, llvm::StringRef name, mlir::StringAttr linkage={}, mlir::Attribute value={})
Create a global constant (read-only) value.
Definition FIRBuilder.h:345
mlir::Value createMinusOneInteger(mlir::Location loc, mlir::Type integerType)
Definition FIRBuilder.h:194
mlir::Value createVolatileCast(mlir::Location loc, bool isVolatile, mlir::Value value)
Cast value to have isVolatile volatility.
Definition FIRBuilder.cpp:583
void setComplexDivisionToRuntimeFlag(bool flag)
Definition FIRBuilder.h:628
mlir::IntegerType getDefaultIntegerType()
Get the default integer type.
Definition FIRBuilder.h:129
mlir::Value createNullConstant(mlir::Location loc, mlir::Type ptrType={})
Definition FIRBuilder.cpp:139
void setFastMathFlags(mlir::arith::FastMathFlags flags)
Definition FIRBuilder.h:589
LLVM_DUMP_METHOD void dumpFunc()
Dump the current function. (debug)
Definition FIRBuilder.cpp:839
mlir::ArrayAttr create2DI64ArrayAttr(llvm::SmallVectorImpl< llvm::SmallVector< int64_t > > &intData)
Definition FIRBuilder.cpp:320
mlir::Value convertWithSemantics(mlir::Location loc, mlir::Type toTy, mlir::Value val, bool allowCharacterConversion=false, bool allowRebox=false)
Definition FIRBuilder.cpp:510
mlir::SymbolTable * getMLIRSymbolTable()
Get func.func/fir.global symbol table attached to this builder if any.
Definition FIRBuilder.h:126
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:311
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:686
mlir::Value genIsNotNullAddr(mlir::Location loc, mlir::Value addr)
Generate code testing addr is not a null address.
Definition FIRBuilder.cpp:851
mlir::Value convertToIndexType(mlir::Location loc, mlir::Value val)
Cast the input value to IndexType.
Definition FIRBuilder.h:464
void createStoreWithConvert(mlir::Location loc, mlir::Value val, mlir::Value addr)
Definition FIRBuilder.cpp:618
void setIntegerOverflowFlags(mlir::arith::IntegerOverflowFlags flags)
Definition FIRBuilder.h:617
mlir::func::FuncOp createRuntimeFunction(mlir::Location loc, llvm::StringRef name, mlir::FunctionType ty, bool isIO=false)
Definition FIRBuilder.cpp:53
mlir::Region & getRegion()
Get the current Region of the insertion point.
Definition FIRBuilder.h:110
void notifyOperationInserted(mlir::Operation *op, mlir::OpBuilder::InsertPoint previous) override
FirOpBuilder hook for creating new operation.
Definition FIRBuilder.h:649
static mlir::Value genTempDeclareOp(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value memref, llvm::StringRef name, mlir::Value shape, llvm::ArrayRef< mlir::Value > typeParams, fir::FortranVariableFlagsAttr attrs)
Definition FIRBuilder.cpp:421
mlir::func::FuncOp getNamedFunction(llvm::StringRef name)
Definition FIRBuilder.h:395
std::string getFastMathFlagsString()
Definition FIRBuilder.h:604
mlir::Value createUnsigned(mlir::Location loc, mlir::Type resultType, mlir::Value left, mlir::Value right)
Definition FIRBuilder.h:663
bool getComplexDivisionToRuntimeFlag() const
Get current ComplexDivisionToRuntimeFlag value.
Definition FIRBuilder.h:633
mlir::Value createBool(mlir::Location loc, bool b)
Create constant i1 with value 1. if b is true or 0. otherwise.
Definition FIRBuilder.h:498
mlir::arith::IntegerOverflowFlags getIntegerOverflowFlags() const
Get current IntegerOverflowFlags value.
Definition FIRBuilder.h:622
mlir::func::FuncOp getFunction()
Get the current Function.
Definition FIRBuilder.h:118
mlir::Value createTemporary(mlir::Location loc, mlir::Type type, llvm::StringRef name={}, mlir::ValueRange shape={}, mlir::ValueRange lenParams={}, llvm::ArrayRef< mlir::NamedAttribute > attrs={}, std::optional< Fortran::common::CUDADataAttr > cudaAttr=std::nullopt)
Definition FIRBuilder.cpp:354
mlir::Type getRealType(int kind)
Get the mlir float type that implements Fortran REAL(kind).
Definition FIRBuilder.cpp:119
mlir::Block * getAllocaBlock()
Get the block for adding Allocas.
Definition FIRBuilder.cpp:278
mlir::Type getVarLenSeqTy(mlir::Type eleTy, unsigned rank=1)
Create a sequence of eleTy with rank dimensions of unknown size.
Definition FIRBuilder.cpp:114
mlir::Value loadIfRef(mlir::Location loc, mlir::Value val)
Definition FIRBuilder.cpp:627
mlir::Value createHeapTemporary(mlir::Location loc, mlir::Type type, llvm::StringRef name={}, mlir::ValueRange shape={}, mlir::ValueRange lenParams={}, llvm::ArrayRef< mlir::NamedAttribute > attrs={})
Create a temporary on the heap.
Definition FIRBuilder.cpp:378
mlir::Value createConvertWithVolatileCast(mlir::Location loc, mlir::Type toTy, mlir::Value val)
Definition FIRBuilder.cpp:593
mlir::Value createShape(mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:678
mlir::Value allocateLocal(mlir::Location loc, mlir::Type ty, llvm::StringRef uniqName, llvm::StringRef name, bool pinned, llvm::ArrayRef< mlir::Value > shape, llvm::ArrayRef< mlir::Value > lenParams, bool asTarget=false)
Definition FIRBuilder.cpp:238
mlir::Value genAbsentOp(mlir::Location loc, mlir::Type argTy)
Definition FIRBuilder.cpp:891
mlir::arith::FastMathFlags getFastMathFlags() const
Get current FastMathFlags value.
Definition FIRBuilder.h:598
mlir::Value createIntegerConstant(mlir::Location loc, mlir::Type integerType, std::int64_t i)
Definition FIRBuilder.cpp:145
mlir::Value createBox(mlir::Location loc, const fir::ExtendedValue &exv, bool isPolymorphic=false, bool isAssumedType=false)
Definition FIRBuilder.cpp:750
mlir::Value createRealOneConstant(mlir::Location loc, mlir::Type realType)
Create a real constant of type realType with value one.
Definition FIRBuilder.h:213
mlir::Block * getEntryBlock()
Get the entry block of the current Function.
Definition FIRBuilder.h:146
mlir::func::FuncOp createFunction(mlir::Location loc, llvm::StringRef name, mlir::FunctionType ty)
Definition FIRBuilder.h:443
mlir::DataLayout & getDataLayout()
Construct a data layout on demand and return it.
Definition FIRBuilder.cpp:954
mlir::Value createTemporary(mlir::Location loc, mlir::Type type, mlir::ValueRange shape)
Create an unnamed and untracked temporary on the stack.
Definition FIRBuilder.h:254
mlir::Type getIntPtrType()
Definition FIRBuilder.h:164
Definition KindMapping.h:48
Definition BoxValue.h:360
Definition FIRType.h:92
Definition OpenACC.h:20
FPMaxminBehavior
Definition FPMaxminBehavior.h:29
Definition BoxValue.h:445
fir::ExtendedValue componentToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value component)
Definition FIRBuilder.cpp:1309
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:1754
mlir::Value createZeroValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type type)
Definition FIRBuilder.cpp:1674
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:1408
llvm::SmallVector< mlir::Value > deduceOptimalExtents(mlir::ValueRange extents1, mlir::ValueRange extents2)
Definition FIRBuilder.cpp:1922
mlir::Value getDescriptorWithNewBaseAddress(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value box, mlir::Value newAddr)
Definition FIRBuilder.cpp:2018
mlir::Value createOneValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type type)
Definition FIRBuilder.cpp:1693
mlir::Value readLowerBound(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &box, unsigned dim, mlir::Value defaultValue)
Definition FIRBuilder.cpp:1021
std::string uniqueCGIdent(llvm::StringRef prefix, llvm::StringRef name)
Definition FIRBuilder.cpp:1223
mlir::Value genCDevPtrAddr(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value cDevPtr, mlir::Type ty)
Definition FIRBuilder.cpp:1804
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:1119
fir::ExtendedValue createStringLiteral(fir::FirOpBuilder &, mlir::Location, llvm::StringRef string)
Definition FIRBuilder.cpp:1261
mlir::TupleType getRaggedArrayHeaderType(fir::FirOpBuilder &builder)
Definition FIRBuilder.cpp:1607
mlir::Value locationToFilename(fir::FirOpBuilder &, mlir::Location)
Generate a string literal containing the file name and return its address.
Definition FIRBuilder.cpp:1243
mlir::Value locationToLineNo(fir::FirOpBuilder &, mlir::Location, mlir::Type)
Generate a constant of the given type with the location line number.
Definition FIRBuilder.cpp:1253
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:990
mlir::Value readCharLen(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &box)
Definition FIRBuilder.cpp:965
void genLifetimeEnd(mlir::OpBuilder &builder, mlir::Location loc, mlir::Value mem)
Definition FIRBuilder.cpp:2013
mlir::Value genCPtrOrCFunptrAddr(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value cPtr, mlir::Type ty)
Definition FIRBuilder.cpp:1794
llvm::SmallVector< mlir::Value > readExtents(fir::FirOpBuilder &builder, mlir::Location loc, const fir::BoxValue &box)
Read extents from box.
Definition FIRBuilder.cpp:1051
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:1714
mlir::Value genCPtrOrCFunptrValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value cPtr)
Get the C address value.
Definition FIRBuilder.cpp:1823
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:1393
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:1616
fir::BoxValue createBoxValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:1857
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:1975
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:1553
mlir::Value createConvert(mlir::OpBuilder &, mlir::Location, mlir::Type, mlir::Value)
Definition FIRBuilder.cpp:600
fir::ExtendedValue readBoxValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::BoxValue &box)
Definition FIRBuilder.cpp:1090
mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value lb, mlir::Value ub)
Definition FIRBuilder.cpp:1771
fir::ExtendedValue arrayElementToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &array, mlir::Value element)
Definition FIRBuilder.cpp:1363
llvm::SmallVector< mlir::Value > getNonDeferredLenParams(const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:1141
llvm::SmallVector< mlir::Value > createExtents(fir::FirOpBuilder &builder, mlir::Location loc, fir::SequenceType seqTy)
Definition FIRBuilder.cpp:1283
mlir::Value genLifetimeStart(mlir::OpBuilder &builder, mlir::Location loc, fir::AllocaOp alloc, const mlir::DataLayout *dl)
Definition FIRBuilder.cpp:2001
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:44
bool isAssumedType(mlir::Type ty)
Definition FIRType.cpp:366
Definition AbstractConverter.h:32