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 //----------------------------------------------------------------------------//
17 //----------------------------------------------------------------------------//
18
19 #ifndef FORTRAN_LOWER_CONVERT_TYPE_H
20 #define FORTRAN_LOWER_CONVERT_TYPE_H
21
22 #include "flang/Common/Fortran.h"
23 #include "mlir/IR/Types.h"
24
25 namespace mlir {
26 class Location;
27 class MLIRContext;
28 class Type;
29 } // namespace mlir
30
31 namespace Fortran {
32 namespace common {
33 class IntrinsicTypeDefaultKinds;
34 template <typename>
35 class Reference;
36 } // namespace common
37
38 namespace evaluate {
39 struct DataRef;
40 template <typename>
41 class Designator;
42 template <typename>
43 class Expr;
44 template <common::TypeCategory>
45 struct SomeKind;
46 struct SomeType;
47 template <common::TypeCategory, int>
48 class Type;
49 } // namespace evaluate
50
51 namespace parser {
52 class CharBlock;
53 class CookedSource;
54 } // namespace parser
55
56 namespace semantics {
57 class Symbol;
58 } // namespace semantics
59
60 namespace lower {
61 namespace pft {
62 struct Variable;
63 }
64
65 using SomeExpr = evaluate::Expr<evaluate::SomeType>;
66 using SymbolRef = common::Reference<const semantics::Symbol>;
67
69 mlir::Type getFIRType(mlir::MLIRContext *ctxt,
70 common::IntrinsicTypeDefaultKinds const &defaults,
71 common::TypeCategory tc, int kind);
72
74 mlir::Type getFIRType(mlir::MLIRContext *ctxt,
75 common::IntrinsicTypeDefaultKinds const &defaults,
76 common::TypeCategory tc);
77
79 mlir::Type
80 translateDataRefToFIRType(mlir::MLIRContext *ctxt,
81 common::IntrinsicTypeDefaultKinds const &defaults,
82 const evaluate::DataRef &dataRef);
83
85 template <common::TypeCategory TC, int KIND>
86 inline mlir::Type translateDesignatorToFIRType(
87 mlir::MLIRContext *ctxt, common::IntrinsicTypeDefaultKinds const &defaults,
88 const evaluate::Designator<evaluate::Type<TC, KIND>> &) {
89 return getFIRType(ctxt, defaults, TC, KIND);
90 }
91
93 template <common::TypeCategory TC>
94 inline mlir::Type translateDesignatorToFIRType(
95 mlir::MLIRContext *ctxt, common::IntrinsicTypeDefaultKinds const &defaults,
96 const evaluate::Designator<evaluate::SomeKind<TC>> &) {
97 return getFIRType(ctxt, defaults, TC);
98 }
99
101 mlir::Type
102 translateSomeExprToFIRType(mlir::MLIRContext *ctxt,
103 common::IntrinsicTypeDefaultKinds const &defaults,
104 const SomeExpr *expr);
105
107 mlir::Type
108 translateSymbolToFIRType(mlir::MLIRContext *ctxt,
109 common::IntrinsicTypeDefaultKinds const &defaults,
110 const SymbolRef symbol);
111
113 mlir::Type
114 translateVariableToFIRType(mlir::MLIRContext *ctxt,
115 common::IntrinsicTypeDefaultKinds const &defaults,
116 const pft::Variable &variable);
117
119 mlir::Type convertReal(mlir::MLIRContext *ctxt, int KIND);
120
121 // Given a ReferenceType of a base type, returns the ReferenceType to
122 // the SequenceType of this base type.
123 // The created SequenceType has one dimension of unknown extent.
124 // This is useful to do pointer arithmetic using fir::CoordinateOp that requires
125 // a memory reference to a sequence type.
126 mlir::Type getSequenceRefType(mlir::Type referenceType);
127
128 } // namespace lower
129 } // namespace Fortran
130
131 #endif // FORTRAN_LOWER_CONVERT_TYPE_H
mlir
Definition: ConvertType.h:25