14#ifndef FORTRAN_OPTIMIZER_HLFIR_HLFIRDIALECT_H
15#define FORTRAN_OPTIMIZER_HLFIR_HLFIRDIALECT_H
17#include "flang/Optimizer/Dialect/FIRType.h"
18#include "mlir/IR/Dialect.h"
22bool isFortranVariableType(mlir::Type);
23bool isFortranScalarCharacterType(mlir::Type);
24bool isFortranScalarCharacterExprType(mlir::Type);
25bool isFortranArrayCharacterExprType(mlir::Type);
28#include "flang/Optimizer/HLFIR/HLFIRDialect.h.inc"
30#include "flang/Optimizer/HLFIR/HLFIREnums.h.inc"
32#define GET_TYPEDEF_CLASSES
33#include "flang/Optimizer/HLFIR/HLFIRTypes.h.inc"
35#define GET_ATTRDEF_CLASSES
36#include "flang/Optimizer/HLFIR/HLFIRAttributes.h.inc"
40inline mlir::Type getFortranElementType(mlir::Type type) {
43 if (
auto exprType = mlir::dyn_cast<hlfir::ExprType>(type))
44 return exprType.getEleTy();
45 if (
auto boxCharType = mlir::dyn_cast<fir::BoxCharType>(type))
46 return boxCharType.getEleTy();
52inline mlir::Type getFortranElementOrSequenceType(mlir::Type type) {
54 if (
auto exprType = mlir::dyn_cast<hlfir::ExprType>(type)) {
55 if (exprType.isArray())
56 return fir::SequenceType::get(exprType.getShape(), exprType.getEleTy());
57 return exprType.getEleTy();
59 if (
auto boxCharType = mlir::dyn_cast<fir::BoxCharType>(type))
60 return boxCharType.getEleTy();
66mlir::Type getExprType(mlir::Type variableType);
72mlir::Type getVariableType(hlfir::ExprType exprType);
75inline bool isBoxAddressType(mlir::Type type) {
77 return type && mlir::isa<fir::BaseBoxType>(type);
81inline bool isBoxAddressOrValueType(mlir::Type type) {
82 return mlir::isa<fir::BaseBoxType>(fir::unwrapRefType(type));
85inline bool isPolymorphicType(mlir::Type type) {
86 if (
auto exprType = mlir::dyn_cast<hlfir::ExprType>(type))
87 return exprType.isPolymorphic();
92inline bool isFortranProcedurePointerType(mlir::Type type) {
96inline bool isFortranPointerObjectType(mlir::Type type) {
99 return boxTy && boxTy.isPointer();
104inline bool isFortranProcedureValue(mlir::Type type) {
105 return mlir::isa<fir::BoxProcType>(type) ||
106 (mlir::isa<mlir::TupleType>(type) &&
111inline bool isFortranValueType(mlir::Type type) {
113 isFortranProcedureValue(type);
117inline bool isFortranValue(mlir::Value value) {
118 return isFortranValueType(value.getType());
129inline bool isFortranEntity(mlir::Value value) {
130 return isFortranValue(value) || isFortranVariableType(value.getType());
133bool isFortranScalarNumericalType(mlir::Type);
134bool isFortranNumericalArrayObject(mlir::Type);
135bool isFortranNumericalOrLogicalArrayObject(mlir::Type);
136bool isFortranArrayObject(mlir::Type);
137bool isFortranLogicalArrayObject(mlir::Type);
138bool isPassByRefOrIntegerType(mlir::Type);
139bool isI1Type(mlir::Type);
141bool isMaskArgument(mlir::Type);
142bool isPolymorphicObject(mlir::Type);
146mlir::Value genExprShape(mlir::OpBuilder &builder,
const mlir::Location &loc,
147 const hlfir::ExprType &expr);
154bool mayHaveAllocatableComponent(mlir::Type ty);
157bool isFortranIntegerScalarOrArrayObject(mlir::Type type);
mlir::Type unwrapPassByRefType(mlir::Type t)
Definition FIRType.h:307
bool isCharacterProcedureTuple(mlir::Type type, bool acceptRawFunc=true)
Is this tuple type holding a character function and its result length?
Definition FIRType.cpp:1438
mlir::Type dyn_cast_ptrEleTy(mlir::Type t)
Definition FIRType.cpp:257
bool isPolymorphicType(mlir::Type ty)
Definition FIRType.cpp:410
bool isBoxProcAddressType(mlir::Type t)
Is this a fir.boxproc address type?
Definition FIRType.h:539
bool isa_trivial(mlir::Type t)
Definition FIRType.h:232
mlir::Type unwrapSequenceType(mlir::Type t)
If t is a SequenceType return its element type, otherwise return t.
Definition FIRType.h:290