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/IR/BuiltinTypes.h"
27
28namespace mlir {
29class Location;
30class MLIRContext;
31class Type;
32} // namespace mlir
33
34namespace Fortran {
35namespace common {
36template <typename>
37class Reference;
38} // namespace common
39
40namespace evaluate {
41template <typename>
42class Expr;
43template <typename>
44class FunctionRef;
45struct SomeType;
46} // namespace evaluate
47
48namespace semantics {
49class Symbol;
50class DerivedTypeSpec;
51class DerivedTypeDetails;
52class Scope;
53} // namespace semantics
54
55namespace lower {
56class AbstractConverter;
57namespace pft {
58struct Variable;
59}
60
61using SomeExpr = evaluate::Expr<evaluate::SomeType>;
62using SymbolRef = common::Reference<const semantics::Symbol>;
63
64// Type for compile time constant length type parameters.
65using LenParameterTy = std::int64_t;
66
68mlir::Type getFIRType(mlir::MLIRContext *ctxt, common::TypeCategory tc,
70
72mlir::Type
75
78 const SomeExpr &expr);
79
82 const SymbolRef symbol);
83
86 const pft::Variable &variable);
87
89mlir::Type convertReal(mlir::MLIRContext *ctxt, int KIND);
90
91bool isDerivedTypeWithLenParameters(const semantics::Symbol &);
92
93template <typename T>
95public:
96 static mlir::Type genType(Fortran::lower::AbstractConverter &,
98};
99using namespace evaluate;
100FOR_EACH_SPECIFIC_TYPE(extern template class TypeBuilder, )
101
102
106public:
108 setCurrentType(derived);
109 }
113 bool lookup(const Fortran::parser::CharBlock &name) {
114 componentIt = std::find(componentIt, componentItEnd, name);
115 return componentIt != componentItEnd;
116 };
117
119 const Fortran::semantics::DerivedTypeSpec &advanceToParentType();
120
122 const Fortran::semantics::Symbol *getParentComponent() const;
123
124private:
125 void setCurrentType(const Fortran::semantics::DerivedTypeSpec &derived);
126 const Fortran::semantics::DerivedTypeSpec *currentParentType = nullptr;
127 const Fortran::semantics::DerivedTypeDetails *currentTypeDetails = nullptr;
128 using name_iterator =
129 std::list<Fortran::parser::CharBlock>::const_reverse_iterator;
130 name_iterator componentIt{};
131 name_iterator componentItEnd{};
132};
133} // namespace lower
134} // namespace Fortran
135
136#endif // FORTRAN_LOWER_CONVERT_TYPE_H
Definition: call.h:282
Definition: AbstractConverter.h:85
Definition: ConvertType.h:105
Definition: ConvertType.h:94
Definition: char-block.h:28
Definition: symbol.h:778
Definition: FIRType.h:89
mlir::Type translateVariableToFIRType(Fortran::lower::AbstractConverter &, const pft::Variable &variable)
Translate a Fortran::lower::pft::Variable to an mlir::Type.
Definition: ConvertType.cpp:636
mlir::Type translateSomeExprToFIRType(Fortran::lower::AbstractConverter &, const SomeExpr &expr)
Translate a SomeExpr to an mlir::Type.
Definition: ConvertType.cpp:626
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:642
mlir::Type translateSymbolToFIRType(Fortran::lower::AbstractConverter &, const SymbolRef symbol)
Translate a Fortran::semantics::Symbol to an mlir::Type.
Definition: ConvertType.cpp:631
mlir::Type translateDerivedTypeToFIRType(Fortran::lower::AbstractConverter &, const Fortran::semantics::DerivedTypeSpec &)
Get a FIR type for a derived type.
Definition: ConvertType.cpp:620
Definition: bit-population-count.h:20
Definition: AbstractConverter.h:29
Definition: PFTBuilder.h:410