FLANG
ConvertType.h
1//===-- Lower/ConvertType.h -- lowering of types ----------------*- 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// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
10//
11//===----------------------------------------------------------------------===//
19//===----------------------------------------------------------------------===//
20
21#ifndef FORTRAN_LOWER_CONVERT_TYPE_H
22#define FORTRAN_LOWER_CONVERT_TYPE_H
23
24#include "flang/Evaluate/type.h"
25#include "flang/Support/Fortran.h"
26#include "mlir/Dialect/Arith/IR/Arith.h"
27#include "mlir/IR/BuiltinTypes.h"
28
29namespace mlir {
30class Location;
31class MLIRContext;
32class Type;
33} // namespace mlir
34
35namespace Fortran {
36namespace common {
37template <typename>
38class Reference;
39} // namespace common
40
41namespace evaluate {
42template <typename>
43class Expr;
44template <typename>
45class FunctionRef;
46struct SomeType;
47} // namespace evaluate
48
49namespace semantics {
50class Symbol;
51class DerivedTypeSpec;
53class Scope;
54} // namespace semantics
55
56namespace lower {
58namespace pft {
59struct Variable;
60}
61
62using SomeExpr = evaluate::Expr<evaluate::SomeType>;
63using SymbolRef = common::Reference<const semantics::Symbol>;
64
65// Type for compile time constant length type parameters.
66using LenParameterTy = std::int64_t;
67
69mlir::Type getFIRType(mlir::MLIRContext *ctxt, common::TypeCategory tc,
71
73mlir::Type
76
79 const SomeExpr &expr);
80
83 const SymbolRef symbol);
84
87 const pft::Variable &variable);
88
90mlir::Type convertReal(mlir::MLIRContext *ctxt, int KIND);
91
92bool isDerivedTypeWithLenParameters(const semantics::Symbol &);
93
94template <typename T>
96public:
97 static mlir::Type genType(Fortran::lower::AbstractConverter &,
99};
100using namespace evaluate;
101FOR_EACH_SPECIFIC_TYPE(extern template class TypeBuilder, )
102
103
106class ComponentReverseIterator {
107public:
108 ComponentReverseIterator(const Fortran::semantics::DerivedTypeSpec &derived) {
109 setCurrentType(derived);
110 }
114 bool lookup(const Fortran::parser::CharBlock &name) {
115 componentIt = std::find(componentIt, componentItEnd, name);
116 return componentIt != componentItEnd;
117 };
118
121
124
125private:
126 void setCurrentType(const Fortran::semantics::DerivedTypeSpec &derived);
127 const Fortran::semantics::DerivedTypeSpec *currentParentType = nullptr;
128 const Fortran::semantics::DerivedTypeDetails *currentTypeDetails = nullptr;
129 using name_iterator =
130 std::list<Fortran::parser::CharBlock>::const_reverse_iterator;
131 name_iterator componentIt{};
132 name_iterator componentItEnd{};
133};
134
135mlir::arith::CmpIPredicate
136translateSignedRelational(Fortran::common::RelationalOperator rop);
137mlir::arith::CmpIPredicate
138translateUnsignedRelational(Fortran::common::RelationalOperator rop);
139mlir::arith::CmpFPredicate
140translateFloatRelational(Fortran::common::RelationalOperator rop);
141} // namespace lower
142} // namespace Fortran
143
144#endif // FORTRAN_LOWER_CONVERT_TYPE_H
Definition reference.h:18
Definition common.h:215
Definition call.h:294
Definition AbstractConverter.h:87
const Fortran::semantics::DerivedTypeSpec & advanceToParentType()
Advance iterator to the last components of the current type parent.
Definition ConvertType.cpp:644
const Fortran::semantics::Symbol * getParentComponent() const
Get the parent component symbol for the current type.
Definition ConvertType.cpp:654
Definition ConvertType.h:95
Definition char-block.h:28
Definition scope.h:68
Definition symbol.h:881
Definition FIRType.h:103
Definition bit-population-count.h:20
Definition call.h:34
Definition ParserActions.h:24
mlir::Type translateVariableToFIRType(Fortran::lower::AbstractConverter &, const pft::Variable &variable)
Translate a Fortran::lower::pft::Variable to an mlir::Type.
Definition ConvertType.cpp:617
mlir::Type translateSomeExprToFIRType(Fortran::lower::AbstractConverter &, const SomeExpr &expr)
Translate a SomeExpr to an mlir::Type.
Definition ConvertType.cpp:607
mlir::Type getFIRType(mlir::MLIRContext *ctxt, common::TypeCategory tc, int kind, llvm::ArrayRef< LenParameterTy >)
Get a FIR type based on a category and kind.
mlir::Type convertReal(mlir::MLIRContext *ctxt, int KIND)
Translate a REAL of KIND to the mlir::Type.
Definition ConvertType.cpp:623
mlir::Type translateSymbolToFIRType(Fortran::lower::AbstractConverter &, const SymbolRef symbol)
Translate a Fortran::semantics::Symbol to an mlir::Type.
Definition ConvertType.cpp:612
mlir::Type translateDerivedTypeToFIRType(Fortran::lower::AbstractConverter &, const Fortran::semantics::DerivedTypeSpec &)
Get a FIR type for a derived type.
Definition ConvertType.cpp:601
Definition bit-population-count.h:20
Definition AbstractConverter.h:32
Definition type.h:418
Definition PFTBuilder.h:410