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"
26#include "mlir/IR/Builders.h"
27#include "mlir/IR/BuiltinOps.h"
28#include "llvm/ADT/DenseMap.h"
47 return builder.getI64Type();
56class FirOpBuilder :
public mlir::OpBuilder,
public mlir::OpBuilder::Listener {
59 mlir::SymbolTable *symbolTable =
nullptr)
60 : OpBuilder{op,
this}, kindMap{std::move(kindMap)},
61 symbolTable{symbolTable} {
62 auto fmi = mlir::dyn_cast<mlir::arith::ArithFastMathInterface>(*op);
69 mlir::SymbolTable *symbolTable =
nullptr)
70 : OpBuilder(builder), OpBuilder::Listener(), kindMap{std::move(kindMap)},
71 symbolTable{symbolTable} {
74 explicit FirOpBuilder(mlir::OpBuilder &builder, mlir::ModuleOp mod)
75 : OpBuilder(builder), OpBuilder::Listener(),
81 : OpBuilder(builder), OpBuilder::Listener(), kindMap{std::move(kindMap)} {
83 auto fmi = mlir::dyn_cast<mlir::arith::ArithFastMathInterface>(*op);
89 FirOpBuilder(mlir::OpBuilder &builder, mlir::Operation *op)
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} {
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} {
110 mlir::Region &
getRegion() {
return *getBlock()->getParent(); }
114 return getRegion().getParentOfType<mlir::ModuleOp>();
119 return getRegion().getParentOfType<mlir::func::FuncOp>();
130 return getIntegerType(
142 bool allowCharacterConversion =
false,
143 bool allowRebox =
false);
154 mlir::Type
getRefType(mlir::Type eleTy,
bool isVolatile =
false);
168 return mlir::SymbolRefAttr::get(getContext(), str);
174 fir::BoxProcType getBoxProcType(mlir::FunctionType funcTy) {
175 return fir::BoxProcType::get(getContext(), funcTy);
195 mlir::Type integerType) {
201 llvm::APFloat::integerPart val);
205 const llvm::APFloat &val);
220 llvm::StringRef uniqName, llvm::StringRef name,
223 bool asTarget =
false);
225 llvm::StringRef uniqName, llvm::StringRef name,
228 bool asTarget =
false);
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);
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);
255 mlir::ValueRange shape) {
265 llvm::StringRef name,
266 llvm::ArrayRef<mlir::NamedAttribute> attrs) {
273 llvm::StringRef name = {}, mlir::ValueRange shape = {},
274 mlir::ValueRange lenParams = {},
275 llvm::ArrayRef<mlir::NamedAttribute> attrs = {});
282 mlir::Location loc, mlir::Value memref,
283 llvm::StringRef name, mlir::Value shape,
284 llvm::ArrayRef<mlir::Value> typeParams,
285 fir::FortranVariableFlagsAttr attrs);
304 mlir::Location loc, mlir::Type baseType, mlir::Value shape,
305 llvm::ArrayRef<mlir::Value> extents,
306 llvm::ArrayRef<mlir::Value> typeParams,
308 mlir::Value polymorphicMold,
bool useStack, llvm::StringRef tmpName);
310 std::pair<mlir::Value, bool>
315 mlir::Value polymorphicMold,
bool useStack =
false,
316 llvm::StringRef tmpName =
".tmp.array") {
318 genDeclare, polymorphicMold, useStack, tmpName);
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 = {});
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 = {});
346 llvm::StringRef name,
347 mlir::StringAttr linkage = {},
348 mlir::Attribute value = {}) {
349 return createGlobal(loc, type, name, linkage, value,
true,
355 llvm::StringRef name,
356 std::function<
void(FirOpBuilder &)> bodyBuilder,
357 mlir::StringAttr linkage = {}) {
359 bodyBuilder, linkage);
364 llvm::StringRef
string);
366 std::pair<fir::TypeInfoOp, mlir::OpBuilder::InsertPoint>
367 createTypeInfoOp(mlir::Location loc, fir::RecordType recordType,
368 fir::RecordType parentType);
374 static mlir::StringAttr createCommonLinkage(mlir::MLIRContext *context) {
375 return mlir::StringAttr::get(context,
"common");
377 mlir::StringAttr createCommonLinkage() {
378 return createCommonLinkage(getContext());
381 mlir::StringAttr createExternalLinkage() {
return getStringAttr(
"external"); }
383 mlir::StringAttr createInternalLinkage() {
return getStringAttr(
"internal"); }
385 mlir::StringAttr createLinkOnceLinkage() {
return getStringAttr(
"linkonce"); }
387 mlir::StringAttr createLinkOnceODRLinkage() {
388 return getStringAttr(
"linkonce_odr");
391 mlir::StringAttr createWeakLinkage() {
return getStringAttr(
"weak"); }
398 static mlir::func::FuncOp
399 getNamedFunction(mlir::ModuleOp module,
const mlir::SymbolTable *symbolTable,
400 llvm::StringRef name);
407 static mlir::func::FuncOp
408 getNamedFunction(mlir::ModuleOp module,
const mlir::SymbolTable *symbolTable,
409 mlir::SymbolRefAttr symbol);
411 fir::GlobalOp getNamedGlobal(llvm::StringRef name) {
415 static fir::GlobalOp getNamedGlobal(mlir::ModuleOp module,
416 const mlir::SymbolTable *symbolTable,
417 llvm::StringRef name);
420 mlir::Value
createConvert(mlir::Location loc, mlir::Type toTy,
439 mlir::Value
loadIfRef(mlir::Location loc, mlir::Value val);
444 mlir::FunctionType ty) {
449 mlir::ModuleOp module,
450 llvm::StringRef name,
451 mlir::FunctionType ty,
452 mlir::SymbolTable *);
459 llvm::StringRef name,
460 mlir::FunctionType ty,
482 mlir::ValueRange triples, mlir::ValueRange path);
493 mlir::Value
createBox(mlir::Location loc, mlir::Type boxType,
494 mlir::Value addr, mlir::Value shape, mlir::Value slice,
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());
520 template <
typename CC>
521 IfBuilder &genElse(CC func) {
522 assert(!ifOp.getElseRegion().empty() &&
"must have else region");
523 builder.setInsertionPointToStart(&ifOp.getElseRegion().front());
527 void end() { builder.setInsertionPointAfter(ifOp); }
532 return ifOp.getResults();
535 fir::IfOp &getIfOp() {
return ifOp; };
545 mlir::Value cdt,
bool withElseRegion) {
546 auto op = fir::IfOp::create(*
this, loc, results, cdt, withElseRegion);
553 auto op = fir::IfOp::create(*
this, loc, mlir::TypeRange(), cdt,
false);
560 auto op = fir::IfOp::create(*
this, loc, mlir::TypeRange(), cdt,
true);
564 mlir::Value genNot(mlir::Location loc, mlir::Value
boolean) {
565 return mlir::arith::CmpIOp::create(*
this, loc,
566 mlir::arith::CmpIPredicate::eq,
boolean,
574 mlir::Value
genIsNullAddr(mlir::Location loc, mlir::Value addr);
579 mlir::Value ub, mlir::Value step,
580 mlir::Type type,
bool fold =
false);
584 mlir::Value
genAbsentOp(mlir::Location loc, mlir::Type argTy);
590 fastMathFlags = flags;
606 if (flags == mlir::arith::FastMathFlags::none)
609 std::string fmfString{mlir::arith::stringifyFastMathFlags(flags)};
610 std::replace(fmfString.begin(), fmfString.end(),
',',
'_');
618 integerOverflowFlags = flags;
623 return integerOverflowFlags;
629 complexDivisionToRuntimeFlag = flag;
634 return complexDivisionToRuntimeFlag;
639 fpMaxminBehavior = mode;
642 return fpMaxminBehavior;
650 mlir::OpBuilder::InsertPoint previous)
override {
652 if (previous.isSet())
654 setCommonAttributes(op);
662 template <
typename OpTy>
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()) {
673 opResType = signlessType;
675 if (right.getType().isUnsignedInteger()) {
677 opResType = signlessType;
679 mlir::Value result = OpTy::create(*
this, loc, opResType, left, right);
680 if (resultType.isUnsignedInteger())
687 mlir::arith::CmpIPredicate predicate,
688 mlir::Value ptr1, mlir::Value ptr2) {
691 return mlir::arith::CmpIOp::create(*
this, loc, predicate, ptr1, ptr2);
697 void setCommonAttributes(mlir::Operation *op)
const;
703 mlir::arith::FastMathFlags fastMathFlags{};
711 Fortran::common::FPMaxminBehavior::Legacy};
715 mlir::arith::IntegerOverflowFlags integerOverflowFlags{};
719 bool complexDivisionToRuntimeFlag =
true;
723 mlir::SymbolTable *symbolTable =
nullptr;
728 std::unique_ptr<mlir::DataLayout> dataLayout =
nullptr;
743mlir::Value
readCharLen(fir::FirOpBuilder &builder, mlir::Location loc,
744 const fir::ExtendedValue &box);
747mlir::Value
readExtent(fir::FirOpBuilder &builder, mlir::Location loc,
748 const fir::ExtendedValue &box,
unsigned dim);
753mlir::Value
readLowerBound(fir::FirOpBuilder &builder, mlir::Location loc,
754 const fir::ExtendedValue &box,
unsigned dim,
755 mlir::Value defaultValue);
758llvm::SmallVector<mlir::Value>
readExtents(fir::FirOpBuilder &builder,
760 const fir::BoxValue &box);
767fir::ExtendedValue
readBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
768 const fir::BoxValue &box);
772llvm::SmallVector<mlir::Value>
774 const fir::ExtendedValue &exv);
779llvm::SmallVector<mlir::Value>
789 llvm::StringRef
string);
793std::string
uniqueCGIdent(llvm::StringRef prefix, llvm::StringRef name);
797llvm::SmallVector<mlir::Value>
createExtents(fir::FirOpBuilder &builder,
799 fir::SequenceType seqTy);
808mlir::Value
locationToLineNo(fir::FirOpBuilder &, mlir::Location, mlir::Type);
818 mlir::Value component);
828 const fir::ExtendedValue &array,
829 mlir::Value element);
836 fir::FirOpBuilder &builder, mlir::Location loc,
837 const fir::ExtendedValue &array, mlir::Value element, mlir::Value slice);
842 const fir::ExtendedValue &lhs,
843 const fir::ExtendedValue &rhs,
844 bool needFinalization =
false,
845 bool isTemporaryLHS =
false,
846 mlir::ArrayAttr accessGroups = {});
852 const fir::ExtendedValue &lhs,
853 const fir::ExtendedValue &rhs,
854 bool needFinalization =
false,
855 bool isTemporaryLHS =
false);
867 fir::ArrayLoadOp arrLoad,
868 llvm::ArrayRef<mlir::Value> path,
869 llvm::ArrayRef<mlir::Value> substring);
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);
878mlir::Value
createZeroValue(fir::FirOpBuilder &builder, mlir::Location loc,
883mlir::Value
createOneValue(fir::FirOpBuilder &builder, mlir::Location loc,
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,
899mlir::Value
genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
901mlir::Value
genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
902 mlir::Value value, mlir::Value zero);
908 mlir::Value cPtr, mlir::Type ty);
912mlir::Value
genCDevPtrAddr(fir::FirOpBuilder &builder, mlir::Location loc,
913 mlir::Value cDevPtr, mlir::Type ty);
917 mlir::Location loc, mlir::Value cPtr);
921fir::BoxValue
createBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
922 const fir::ExtendedValue &exv);
930mlir::Value
createConvert(mlir::OpBuilder &, mlir::Location, mlir::Type,
936llvm::SmallVector<mlir::Value>
937elideExtentsAlreadyInType(mlir::Type type, mlir::ValueRange shape);
939llvm::SmallVector<mlir::Value>
940elideLengthsAlreadyInType(mlir::Type type, mlir::ValueRange lenParams);
952 mlir::ValueRange extents2);
954uint64_t getGlobalAddressSpace(mlir::DataLayout *dataLayout);
956uint64_t getProgramAddressSpace(mlir::DataLayout *dataLayout);
969 fir::FirOpBuilder &builder, mlir::Location loc, mlir::ValueRange extents);
977 llvm::SmallVectorImpl<mlir::Value> *lbounds,
978 llvm::SmallVectorImpl<mlir::Value> *extents,
979 llvm::SmallVectorImpl<mlir::Value> *strides);
985 fir::AllocaOp alloc,
const mlir::DataLayout *dl);
998 mlir::Location loc, mlir::Value box,
999 mlir::Value newAddr);
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
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