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);
69inline bool isBoxAddressType(mlir::Type type) {
71 return type && mlir::isa<fir::BaseBoxType>(type);
75inline bool isBoxAddressOrValueType(mlir::Type type) {
76 return mlir::isa<fir::BaseBoxType>(fir::unwrapRefType(type));
80 if (
auto exprType = mlir::dyn_cast<hlfir::ExprType>(type))
81 return exprType.isPolymorphic();
87inline bool isFortranProcedureValue(mlir::Type type) {
88 return mlir::isa<fir::BoxProcType>(type) ||
89 (mlir::isa<mlir::TupleType>(type) &&
94inline bool isFortranValueType(mlir::Type type) {
96 isFortranProcedureValue(type);
100inline bool isFortranValue(mlir::Value value) {
101 return isFortranValueType(value.getType());
112inline bool isFortranEntity(mlir::Value value) {
113 return isFortranValue(value) || isFortranVariableType(value.getType());
116bool isFortranScalarNumericalType(mlir::Type);
117bool isFortranNumericalArrayObject(mlir::Type);
118bool isFortranNumericalOrLogicalArrayObject(mlir::Type);
119bool isFortranArrayObject(mlir::Type);
120bool isFortranLogicalArrayObject(mlir::Type);
121bool isPassByRefOrIntegerType(mlir::Type);
122bool isI1Type(mlir::Type);
124bool isMaskArgument(mlir::Type);
125bool isPolymorphicObject(mlir::Type);
129mlir::Value genExprShape(mlir::OpBuilder &builder,
const mlir::Location &loc,
130 const hlfir::ExprType &expr);
137bool mayHaveAllocatableComponent(mlir::Type ty);
140bool isFortranIntegerScalarOrArrayObject(mlir::Type type);
mlir::Type unwrapPassByRefType(mlir::Type t)
Definition: FIRType.h:266
bool isCharacterProcedureTuple(mlir::Type type, bool acceptRawFunc=true)
Is this tuple type holding a character function and its result length?
Definition: FIRType.cpp:1230
mlir::Type dyn_cast_ptrEleTy(mlir::Type t)
Definition: FIRType.cpp:216
bool isPolymorphicType(mlir::Type ty)
Definition: FIRType.cpp:358
bool isa_trivial(mlir::Type t)
Definition: FIRType.h:195
mlir::Type unwrapSequenceType(mlir::Type t)
If t is a SequenceType return its element type, otherwise return t.
Definition: FIRType.h:249