16#ifndef FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
17#define FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
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"
46 return builder.getI64Type();
55class FirOpBuilder :
public mlir::OpBuilder,
public mlir::OpBuilder::Listener {
58 mlir::SymbolTable *symbolTable =
nullptr)
59 : OpBuilder{op,
this}, kindMap{std::move(kindMap)},
60 symbolTable{symbolTable} {
61 auto fmi = mlir::dyn_cast<mlir::arith::ArithFastMathInterface>(*op);
68 mlir::SymbolTable *symbolTable =
nullptr)
69 : OpBuilder(builder), OpBuilder::Listener(), kindMap{std::move(kindMap)},
70 symbolTable{symbolTable} {
73 explicit FirOpBuilder(mlir::OpBuilder &builder, mlir::ModuleOp mod)
74 : OpBuilder(builder), OpBuilder::Listener(),
80 : OpBuilder(builder), OpBuilder::Listener(), kindMap{std::move(kindMap)} {
82 auto fmi = mlir::dyn_cast<mlir::arith::ArithFastMathInterface>(*op);
88 FirOpBuilder(mlir::OpBuilder &builder, mlir::Operation *op)
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} {
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} {
109 mlir::Region &
getRegion() {
return *getBlock()->getParent(); }
113 return getRegion().getParentOfType<mlir::ModuleOp>();
118 return getRegion().getParentOfType<mlir::func::FuncOp>();
129 return getIntegerType(
141 bool allowCharacterConversion =
false,
142 bool allowRebox =
false);
153 mlir::Type
getRefType(mlir::Type eleTy,
bool isVolatile =
false);
167 return mlir::SymbolRefAttr::get(getContext(), str);
173 fir::BoxProcType getBoxProcType(mlir::FunctionType funcTy) {
174 return fir::BoxProcType::get(getContext(), funcTy);
194 mlir::Type integerType) {
200 llvm::APFloat::integerPart val);
204 const llvm::APFloat &val);
214 llvm::StringRef uniqName, llvm::StringRef name,
217 bool asTarget =
false);
219 llvm::StringRef uniqName, llvm::StringRef name,
222 bool asTarget =
false);
233 mlir::Location loc, mlir::Type type, llvm::StringRef name,
234 mlir::ValueRange lenParams = {}, mlir::ValueRange shape = {},
235 llvm::ArrayRef<mlir::NamedAttribute> attrs = {},
236 std::optional<Fortran::common::CUDADataAttr> cudaAttr = std::nullopt);
242 mlir::Location loc, mlir::Type type, llvm::StringRef name = {},
243 mlir::ValueRange shape = {}, mlir::ValueRange lenParams = {},
244 llvm::ArrayRef<mlir::NamedAttribute> attrs = {},
245 std::optional<Fortran::common::CUDADataAttr> cudaAttr = std::nullopt);
249 mlir::ValueRange shape) {
259 llvm::StringRef name,
260 llvm::ArrayRef<mlir::NamedAttribute> attrs) {
267 llvm::StringRef name = {}, mlir::ValueRange shape = {},
268 mlir::ValueRange lenParams = {},
269 llvm::ArrayRef<mlir::NamedAttribute> attrs = {});
276 mlir::Location loc, mlir::Value memref,
277 llvm::StringRef name, mlir::Value shape,
278 llvm::ArrayRef<mlir::Value> typeParams,
279 fir::FortranVariableFlagsAttr attrs);
298 mlir::Location loc, mlir::Type baseType, mlir::Value shape,
299 llvm::ArrayRef<mlir::Value> extents,
300 llvm::ArrayRef<mlir::Value> typeParams,
302 mlir::Value polymorphicMold,
bool useStack, llvm::StringRef tmpName);
304 std::pair<mlir::Value, bool>
309 mlir::Value polymorphicMold,
bool useStack =
false,
310 llvm::StringRef tmpName =
".tmp.array") {
312 genDeclare, polymorphicMold, useStack, tmpName);
325 fir::GlobalOp
createGlobal(mlir::Location loc, mlir::Type type,
326 llvm::StringRef name,
327 mlir::StringAttr linkage = {},
328 mlir::Attribute value = {},
bool isConst =
false,
329 bool isTarget =
false,
330 cuf::DataAttributeAttr dataAttr = {});
332 fir::GlobalOp
createGlobal(mlir::Location loc, mlir::Type type,
333 llvm::StringRef name,
bool isConst,
bool isTarget,
334 std::function<
void(FirOpBuilder &)> bodyBuilder,
335 mlir::StringAttr linkage = {},
336 cuf::DataAttributeAttr dataAttr = {});
340 llvm::StringRef name,
341 mlir::StringAttr linkage = {},
342 mlir::Attribute value = {}) {
343 return createGlobal(loc, type, name, linkage, value,
true,
349 llvm::StringRef name,
350 std::function<
void(FirOpBuilder &)> bodyBuilder,
351 mlir::StringAttr linkage = {}) {
353 bodyBuilder, linkage);
358 llvm::StringRef
string);
360 std::pair<fir::TypeInfoOp, mlir::OpBuilder::InsertPoint>
361 createTypeInfoOp(mlir::Location loc, fir::RecordType recordType,
362 fir::RecordType parentType);
368 static mlir::StringAttr createCommonLinkage(mlir::MLIRContext *context) {
369 return mlir::StringAttr::get(context,
"common");
371 mlir::StringAttr createCommonLinkage() {
372 return createCommonLinkage(getContext());
375 mlir::StringAttr createExternalLinkage() {
return getStringAttr(
"external"); }
377 mlir::StringAttr createInternalLinkage() {
return getStringAttr(
"internal"); }
379 mlir::StringAttr createLinkOnceLinkage() {
return getStringAttr(
"linkonce"); }
381 mlir::StringAttr createLinkOnceODRLinkage() {
382 return getStringAttr(
"linkonce_odr");
385 mlir::StringAttr createWeakLinkage() {
return getStringAttr(
"weak"); }
392 static mlir::func::FuncOp
393 getNamedFunction(mlir::ModuleOp module,
const mlir::SymbolTable *symbolTable,
394 llvm::StringRef name);
401 static mlir::func::FuncOp
402 getNamedFunction(mlir::ModuleOp module,
const mlir::SymbolTable *symbolTable,
403 mlir::SymbolRefAttr symbol);
405 fir::GlobalOp getNamedGlobal(llvm::StringRef name) {
409 static fir::GlobalOp getNamedGlobal(mlir::ModuleOp module,
410 const mlir::SymbolTable *symbolTable,
411 llvm::StringRef name);
414 mlir::Value
createConvert(mlir::Location loc, mlir::Type toTy,
433 mlir::Value
loadIfRef(mlir::Location loc, mlir::Value val);
438 mlir::FunctionType ty) {
443 mlir::ModuleOp module,
444 llvm::StringRef name,
445 mlir::FunctionType ty,
446 mlir::SymbolTable *);
453 llvm::StringRef name,
454 mlir::FunctionType ty,
476 mlir::ValueRange triples, mlir::ValueRange path);
487 mlir::Value
createBox(mlir::Location loc, mlir::Type boxType,
488 mlir::Value addr, mlir::Value shape, mlir::Value slice,
506 IfBuilder(fir::IfOp ifOp, FirOpBuilder &builder)
507 : ifOp{ifOp}, builder{builder} {}
508 template <
typename CC>
509 IfBuilder &genThen(CC func) {
510 builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
514 template <
typename CC>
515 IfBuilder &genElse(CC func) {
516 assert(!ifOp.getElseRegion().empty() &&
"must have else region");
517 builder.setInsertionPointToStart(&ifOp.getElseRegion().front());
521 void end() { builder.setInsertionPointAfter(ifOp); }
526 return ifOp.getResults();
529 fir::IfOp &getIfOp() {
return ifOp; };
539 mlir::Value cdt,
bool withElseRegion) {
540 auto op = fir::IfOp::create(*
this, loc, results, cdt, withElseRegion);
547 auto op = fir::IfOp::create(*
this, loc, mlir::TypeRange(), cdt,
false);
554 auto op = fir::IfOp::create(*
this, loc, mlir::TypeRange(), cdt,
true);
558 mlir::Value genNot(mlir::Location loc, mlir::Value
boolean) {
559 return mlir::arith::CmpIOp::create(*
this, loc,
560 mlir::arith::CmpIPredicate::eq,
boolean,
568 mlir::Value
genIsNullAddr(mlir::Location loc, mlir::Value addr);
573 mlir::Value ub, mlir::Value step,
578 mlir::Value
genAbsentOp(mlir::Location loc, mlir::Type argTy);
584 fastMathFlags = flags;
600 if (flags == mlir::arith::FastMathFlags::none)
603 std::string fmfString{mlir::arith::stringifyFastMathFlags(flags)};
604 std::replace(fmfString.begin(), fmfString.end(),
',',
'_');
612 integerOverflowFlags = flags;
617 return integerOverflowFlags;
623 complexDivisionToRuntimeFlag = flag;
628 return complexDivisionToRuntimeFlag;
636 mlir::OpBuilder::InsertPoint previous)
override {
638 if (previous.isSet())
640 setCommonAttributes(op);
648 template <
typename OpTy>
650 mlir::Value left, mlir::Value right) {
651 if (!resultType.isIntOrFloat())
652 return OpTy::create(*
this, loc, resultType, left, right);
653 mlir::Type signlessType = mlir::IntegerType::get(
654 getContext(), resultType.getIntOrFloatBitWidth(),
655 mlir::IntegerType::SignednessSemantics::Signless);
656 mlir::Type opResType = resultType;
657 if (left.getType().isUnsignedInteger()) {
659 opResType = signlessType;
661 if (right.getType().isUnsignedInteger()) {
663 opResType = signlessType;
665 mlir::Value result = OpTy::create(*
this, loc, opResType, left, right);
666 if (resultType.isUnsignedInteger())
673 mlir::arith::CmpIPredicate predicate,
674 mlir::Value ptr1, mlir::Value ptr2) {
677 return mlir::arith::CmpIOp::create(*
this, loc, predicate, ptr1, ptr2);
683 void setCommonAttributes(mlir::Operation *op)
const;
689 mlir::arith::FastMathFlags fastMathFlags{};
693 mlir::arith::IntegerOverflowFlags integerOverflowFlags{};
697 bool complexDivisionToRuntimeFlag =
true;
701 mlir::SymbolTable *symbolTable =
nullptr;
706 std::unique_ptr<mlir::DataLayout> dataLayout =
nullptr;
721mlir::Value
readCharLen(fir::FirOpBuilder &builder, mlir::Location loc,
722 const fir::ExtendedValue &box);
725mlir::Value
readExtent(fir::FirOpBuilder &builder, mlir::Location loc,
726 const fir::ExtendedValue &box,
unsigned dim);
731mlir::Value
readLowerBound(fir::FirOpBuilder &builder, mlir::Location loc,
732 const fir::ExtendedValue &box,
unsigned dim,
733 mlir::Value defaultValue);
736llvm::SmallVector<mlir::Value>
readExtents(fir::FirOpBuilder &builder,
738 const fir::BoxValue &box);
745fir::ExtendedValue
readBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
746 const fir::BoxValue &box);
750llvm::SmallVector<mlir::Value>
752 const fir::ExtendedValue &exv);
757llvm::SmallVector<mlir::Value>
767 llvm::StringRef
string);
771std::string
uniqueCGIdent(llvm::StringRef prefix, llvm::StringRef name);
775llvm::SmallVector<mlir::Value>
createExtents(fir::FirOpBuilder &builder,
777 fir::SequenceType seqTy);
786mlir::Value
locationToLineNo(fir::FirOpBuilder &, mlir::Location, mlir::Type);
796 mlir::Value component);
806 const fir::ExtendedValue &array,
807 mlir::Value element);
814 fir::FirOpBuilder &builder, mlir::Location loc,
815 const fir::ExtendedValue &array, mlir::Value element, mlir::Value slice);
820 const fir::ExtendedValue &lhs,
821 const fir::ExtendedValue &rhs,
822 bool needFinalization =
false,
823 bool isTemporaryLHS =
false);
829 const fir::ExtendedValue &lhs,
830 const fir::ExtendedValue &rhs,
831 bool needFinalization =
false,
832 bool isTemporaryLHS =
false);
844 fir::ArrayLoadOp arrLoad,
845 llvm::ArrayRef<mlir::Value> path,
846 llvm::ArrayRef<mlir::Value> substring);
848 fir::SequenceType seqTy, mlir::Value memref,
849 llvm::ArrayRef<mlir::Value> typeParams,
850 llvm::ArrayRef<mlir::Value> path,
851 llvm::ArrayRef<mlir::Value> substring);
855mlir::Value
createZeroValue(fir::FirOpBuilder &builder, mlir::Location loc,
864mlir::Value
computeExtent(fir::FirOpBuilder &builder, mlir::Location loc,
865 mlir::Value lb, mlir::Value ub);
866mlir::Value
computeExtent(fir::FirOpBuilder &builder, mlir::Location loc,
867 mlir::Value lb, mlir::Value ub, mlir::Value zero,
871mlir::Value
genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
873mlir::Value
genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
874 mlir::Value value, mlir::Value zero);
880 mlir::Value cPtr, mlir::Type ty);
884mlir::Value
genCDevPtrAddr(fir::FirOpBuilder &builder, mlir::Location loc,
885 mlir::Value cDevPtr, mlir::Type ty);
889 mlir::Location loc, mlir::Value cPtr);
893fir::BoxValue
createBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
894 const fir::ExtendedValue &exv);
902mlir::Value
createConvert(mlir::OpBuilder &, mlir::Location, mlir::Type,
908llvm::SmallVector<mlir::Value>
909elideExtentsAlreadyInType(mlir::Type type, mlir::ValueRange shape);
911llvm::SmallVector<mlir::Value>
912elideLengthsAlreadyInType(mlir::Type type, mlir::ValueRange lenParams);
924 mlir::ValueRange extents2);
926uint64_t getGlobalAddressSpace(mlir::DataLayout *dataLayout);
928uint64_t getProgramAddressSpace(mlir::DataLayout *dataLayout);
941 fir::FirOpBuilder &builder, mlir::Location loc, mlir::ValueRange extents);
949 llvm::SmallVectorImpl<mlir::Value> *lbounds,
950 llvm::SmallVectorImpl<mlir::Value> *extents,
951 llvm::SmallVectorImpl<mlir::Value> *strides);
957 fir::AllocaOp alloc,
const mlir::DataLayout *dl);
970 mlir::Location loc, mlir::Value box,
971 mlir::Value newAddr);
Definition MathOptionsBase.h:22
Definition BoxValue.h:125
Definition BoxValue.h:291
Definition BoxValue.h:478
Definition FIRBuilder.h:504
mlir::Operation::result_range getResults()
End the IfOp and return the results if any.
Definition FIRBuilder.h:524
Definition FIRBuilder.h:55
IfBuilder genIfThenElse(mlir::Location loc, mlir::Value cdt)
Definition FIRBuilder.h:553
fir::StringLitOp createStringLitOp(mlir::Location loc, llvm::StringRef string)
Convert a StringRef string into a fir::StringLitOp.
Definition FIRBuilder.cpp:631
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:446
void genStackRestore(mlir::Location loc, mlir::Value stackPointer)
Definition FIRBuilder.cpp:439
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:697
mlir::Value createConvert(mlir::Location loc, mlir::Type toTy, mlir::Value val)
Lazy creation of fir.convert op.
Definition FIRBuilder.cpp:611
IfBuilder genIfOp(mlir::Location loc, mlir::TypeRange results, mlir::Value cdt, bool withElseRegion)
Definition FIRBuilder.h:538
mlir::Value genIsNullAddr(mlir::Location loc, mlir::Value addr)
Generate code testing addr is a null address.
Definition FIRBuilder.cpp:855
mlir::func::FuncOp getNamedFunction(mlir::SymbolRefAttr symbol)
Definition FIRBuilder.h:398
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:546
mlir::Value genStackSave(mlir::Location loc)
Definition FIRBuilder.cpp:433
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:663
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:339
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:581
void setComplexDivisionToRuntimeFlag(bool flag)
Definition FIRBuilder.h:622
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:583
LLVM_DUMP_METHOD void dumpFunc()
Dump the current function. (debug)
Definition FIRBuilder.cpp:837
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:508
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:305
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:672
mlir::Value genIsNotNullAddr(mlir::Location loc, mlir::Value addr)
Generate code testing addr is not a null address.
Definition FIRBuilder.cpp:849
mlir::Value convertToIndexType(mlir::Location loc, mlir::Value val)
Cast the input value to IndexType.
Definition FIRBuilder.h:458
void createStoreWithConvert(mlir::Location loc, mlir::Value val, mlir::Value addr)
Definition FIRBuilder.cpp:616
void setIntegerOverflowFlags(mlir::arith::IntegerOverflowFlags flags)
Definition FIRBuilder.h:611
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:635
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:389
mlir::Value genExtentFromTriplet(mlir::Location loc, mlir::Value lb, mlir::Value ub, mlir::Value step, mlir::Type type)
Definition FIRBuilder.cpp:861
std::string getFastMathFlagsString()
Definition FIRBuilder.h:598
mlir::Value createUnsigned(mlir::Location loc, mlir::Type resultType, mlir::Value left, mlir::Value right)
Definition FIRBuilder.h:649
bool getComplexDivisionToRuntimeFlag() const
Get current ComplexDivisionToRuntimeFlag value.
Definition FIRBuilder.h:627
mlir::Value createBool(mlir::Location loc, bool b)
Create constant i1 with value 1. if b is true or 0. otherwise.
Definition FIRBuilder.h:492
mlir::arith::IntegerOverflowFlags getIntegerOverflowFlags() const
Get current IntegerOverflowFlags value.
Definition FIRBuilder.h:616
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:625
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:591
mlir::Value createShape(mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:676
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:878
mlir::arith::FastMathFlags getFastMathFlags() const
Get current FastMathFlags value.
Definition FIRBuilder.h:592
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:748
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:437
mlir::DataLayout & getDataLayout()
Construct a data layout on demand and return it.
Definition FIRBuilder.cpp:941
mlir::Value createTemporary(mlir::Location loc, mlir::Type type, mlir::ValueRange shape)
Create an unnamed and untracked temporary on the stack.
Definition FIRBuilder.h:248
mlir::Type getIntPtrType()
Definition FIRBuilder.h:163
Definition KindMapping.h:48
Definition BoxValue.h:360
Definition BoxValue.h:445
fir::ExtendedValue componentToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value component)
Definition FIRBuilder.cpp:1296
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:1714
mlir::Value createZeroValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type type)
Definition FIRBuilder.cpp:1654
llvm::SmallVector< mlir::Value > deduceOptimalExtents(mlir::ValueRange extents1, mlir::ValueRange extents2)
Definition FIRBuilder.cpp:1882
mlir::Value getDescriptorWithNewBaseAddress(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value box, mlir::Value newAddr)
Definition FIRBuilder.cpp:1978
mlir::Value readLowerBound(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &box, unsigned dim, mlir::Value defaultValue)
Definition FIRBuilder.cpp:1008
std::string uniqueCGIdent(llvm::StringRef prefix, llvm::StringRef name)
Definition FIRBuilder.cpp:1210
mlir::Value genCDevPtrAddr(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value cDevPtr, mlir::Type ty)
Definition FIRBuilder.cpp:1764
llvm::SmallVector< mlir::Value > updateRuntimeExtentsForEmptyArrays(fir::FirOpBuilder &builder, mlir::Location loc, mlir::ValueRange extents)
Definition FIRBuilder.cpp:1909
void genScalarAssignment(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &lhs, const fir::ExtendedValue &rhs, bool needFinalization=false, bool isTemporaryLHS=false)
Definition FIRBuilder.cpp:1395
llvm::SmallVector< mlir::Value > getNonDefaultLowerBounds(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:1106
fir::ExtendedValue createStringLiteral(fir::FirOpBuilder &, mlir::Location, llvm::StringRef string)
Definition FIRBuilder.cpp:1248
mlir::TupleType getRaggedArrayHeaderType(fir::FirOpBuilder &builder)
Definition FIRBuilder.cpp:1587
mlir::Value locationToFilename(fir::FirOpBuilder &, mlir::Location)
Generate a string literal containing the file name and return its address.
Definition FIRBuilder.cpp:1230
mlir::Value locationToLineNo(fir::FirOpBuilder &, mlir::Location, mlir::Type)
Generate a constant of the given type with the location line number.
Definition FIRBuilder.cpp:1240
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:977
mlir::Value readCharLen(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &box)
Definition FIRBuilder.cpp:952
void genLifetimeEnd(mlir::OpBuilder &builder, mlir::Location loc, mlir::Value mem)
Definition FIRBuilder.cpp:1973
mlir::Value genCPtrOrCFunptrAddr(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value cPtr, mlir::Type ty)
Definition FIRBuilder.cpp:1754
llvm::SmallVector< mlir::Value > readExtents(fir::FirOpBuilder &builder, mlir::Location loc, const fir::BoxValue &box)
Read extents from box.
Definition FIRBuilder.cpp:1038
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:1674
mlir::Value genCPtrOrCFunptrValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value cPtr)
Get the C address value.
Definition FIRBuilder.cpp:1783
uint64_t getAllocaAddressSpace(const mlir::DataLayout *dataLayout)
Get the address space which should be used for allocas.
Definition FIRBuilder.cpp:1874
void setInternalLinkage(mlir::func::FuncOp)
Set internal linkage attribute on a function.
Definition FIRBuilder.cpp:1866
mlir::Value createNullBoxProc(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type boxType)
Generate Null BoxProc for procedure pointer null initialization.
Definition FIRBuilder.cpp:1855
fir::ExtendedValue arraySectionElementToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &array, mlir::Value element, mlir::Value slice)
Definition FIRBuilder.cpp:1380
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:1596
fir::BoxValue createBoxValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:1817
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:1935
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:1540
mlir::Value createConvert(mlir::OpBuilder &, mlir::Location, mlir::Type, mlir::Value)
Definition FIRBuilder.cpp:598
fir::ExtendedValue readBoxValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::BoxValue &box)
Definition FIRBuilder.cpp:1077
mlir::Value computeExtent(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value lb, mlir::Value ub)
Definition FIRBuilder.cpp:1731
fir::ExtendedValue arrayElementToExtendedValue(fir::FirOpBuilder &builder, mlir::Location loc, const fir::ExtendedValue &array, mlir::Value element)
Definition FIRBuilder.cpp:1350
llvm::SmallVector< mlir::Value > getNonDeferredLenParams(const fir::ExtendedValue &exv)
Definition FIRBuilder.cpp:1128
llvm::SmallVector< mlir::Value > createExtents(fir::FirOpBuilder &builder, mlir::Location loc, fir::SequenceType seqTy)
Definition FIRBuilder.cpp:1270
mlir::Value genLifetimeStart(mlir::OpBuilder &builder, mlir::Location loc, fir::AllocaOp alloc, const mlir::DataLayout *dl)
Definition FIRBuilder.cpp:1961
Definition AbstractConverter.h:34
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:353
Definition AbstractConverter.h:29