13
13
#ifndef FIR_DIALECT_FIR_TYPES
14
14
#define FIR_DIALECT_FIR_TYPES
15
15
16
+ include "flang/Optimizer/Dialect/FIRDialect.td"
17
+
16
18
//===----------------------------------------------------------------------===//
17
19
// FIR Types
18
20
//===----------------------------------------------------------------------===//
@@ -21,6 +23,33 @@ class FIR_Type<string name, string typeMnemonic> : TypeDef<fir_Dialect, name> {
21
23
let mnemonic = typeMnemonic;
22
24
}
23
25
26
+ def fir_BoxCharType : FIR_Type<"BoxChar", "boxchar"> {
27
+ let summary = "CHARACTER type descriptor.";
28
+
29
+ let description = [{
30
+ The type of a pair that describes a CHARACTER variable. Specifically, a
31
+ CHARACTER consists of a reference to a buffer (the string value) and a LEN
32
+ type parameter (the runtime length of the buffer).
33
+ }];
34
+
35
+ let parameters = (ins "KindTy":$kind);
36
+
37
+ let printer = [{
38
+ $_printer << "boxchar<" << getImpl()->kind << ">";
39
+ }];
40
+
41
+ let genAccessors = 1;
42
+
43
+ let extraClassDeclaration = [{
44
+ using KindTy = unsigned;
45
+
46
+ // a !fir.boxchar<k> always wraps a !fir.char<k, ?>
47
+ CharacterType getElementType(mlir::MLIRContext *context) const;
48
+
49
+ CharacterType getEleTy() const;
50
+ }];
51
+ }
52
+
24
53
def fir_BoxProcType : FIR_Type<"BoxProc", "boxproc"> {
25
54
let summary = "";
26
55
@@ -39,11 +68,10 @@ def fir_BoxProcType : FIR_Type<"BoxProc", "boxproc"> {
39
68
}];
40
69
41
70
let genAccessors = 1;
42
-
43
71
let genVerifyInvariantsDecl = 1;
44
72
}
45
73
46
- def BoxType : FIR_Type<"Box", "box"> {
74
+ def fir_BoxType : FIR_Type<"Box", "box"> {
47
75
let summary = "The type of a Fortran descriptor";
48
76
49
77
let description = [{
@@ -63,25 +91,39 @@ def BoxType : FIR_Type<"Box", "box"> {
63
91
}];
64
92
65
93
let genAccessors = 1;
66
-
67
94
let genVerifyInvariantsDecl = 1;
68
95
}
69
96
70
- def fir_FieldType : FIR_Type<"Field ", "field "> {
71
- let summary = "A field (in a RecordType) argument's type";
97
+ def fir_CharacterType : FIR_Type<"Character ", "char "> {
98
+ let summary = "FIR character type";
72
99
73
100
let description = [{
74
- The type of a field name. Implementations may defer the layout of a Fortran
75
- derived type until runtime. This implies that the runtime must be able to
76
- determine the offset of fields within the entity.
101
+ Model of the Fortran CHARACTER intrinsic type, including the KIND type
102
+ parameter. The model optionally includes a LEN type parameter. A
103
+ CharacterType is thus the type of both a single character value and a
104
+ character with a LEN parameter.
77
105
}];
78
106
79
- let printer = [{
80
- $_printer << "field";
81
- }];
107
+ let parameters = (ins "KindTy":$FKind, "CharacterType::LenType":$len);
82
108
83
- let parser = [{
84
- return get(context);
109
+ let extraClassDeclaration = [{
110
+ using KindTy = unsigned;
111
+ using LenType = std::int64_t;
112
+
113
+ // Return unknown length CHARACTER type.
114
+ static CharacterType getUnknownLen(mlir::MLIRContext *ctxt, KindTy kind) {
115
+ return get(ctxt, kind, unknownLen());
116
+ }
117
+
118
+ // Return length 1 CHARACTER type.
119
+ static CharacterType getSingleton(mlir::MLIRContext *ctxt, KindTy kind) {
120
+ return get(ctxt, kind, singleton());
121
+ }
122
+
123
+ // CHARACTER is a singleton and has a LEN of 1.
124
+ static constexpr LenType singleton() { return 1; }
125
+ // CHARACTER has an unknown LEN property.
126
+ static constexpr LenType unknownLen() { return -1; }
85
127
}];
86
128
}
87
129
@@ -109,7 +151,25 @@ def fir_ComplexType : FIR_Type<"Complex", "complex"> {
109
151
}];
110
152
}
111
153
112
- def ShapeType : FIR_Type<"Shape", "shape"> {
154
+ def fir_FieldType : FIR_Type<"Field", "field"> {
155
+ let summary = "A field (in a RecordType) argument's type";
156
+
157
+ let description = [{
158
+ The type of a field name. Implementations may defer the layout of a Fortran
159
+ derived type until runtime. This implies that the runtime must be able to
160
+ determine the offset of fields within the entity.
161
+ }];
162
+
163
+ let printer = [{
164
+ $_printer << "field";
165
+ }];
166
+
167
+ let parser = [{
168
+ return get(context);
169
+ }];
170
+ }
171
+
172
+ def fir_ShapeType : FIR_Type<"Shape", "shape"> {
113
173
let summary = "shape of a multidimensional array object";
114
174
115
175
let description = [{
@@ -133,7 +193,7 @@ def ShapeType : FIR_Type<"Shape", "shape"> {
133
193
}];
134
194
}
135
195
136
- def ShapeShiftType : FIR_Type<"ShapeShift", "shapeshift"> {
196
+ def fir_ShapeShiftType : FIR_Type<"ShapeShift", "shapeshift"> {
137
197
let summary = "shape and origin of a multidimensional array object";
138
198
139
199
let description = [{
@@ -150,74 +210,35 @@ def ShapeShiftType : FIR_Type<"ShapeShift", "shapeshift"> {
150
210
}];
151
211
152
212
let parser = [{
153
- if ($_parser.parseLess())
154
- return Type();
155
213
int rank;
156
- if ($_parser.parseInteger(rank))
157
- return Type();
158
- if ($_parser.parseGreater())
214
+ if ($_parser.parseLess() || $_parser.parseInteger(rank) ||
215
+ $_parser.parseGreater())
159
216
return Type();
160
217
return get(context, rank);
161
218
}];
162
219
}
163
220
164
- def fir_CharacterType : FIR_Type<"Character ", "char "> {
165
- let summary = "FIR character type ";
221
+ def fir_ShiftType : FIR_Type<"Shift ", "shift "> {
222
+ let summary = "lower bounds of a multidimensional array object ";
166
223
167
224
let description = [{
168
- Model of the Fortran CHARACTER intrinsic type, including the KIND type
169
- parameter. The model optionally includes a LEN type parameter. A
170
- CharacterType is thus the type of both a single character value and a
171
- character with a LEN parameter.
225
+ Type of a vector of runtime values that define the lower bounds of a
226
+ multidimensional array object. The vector is the lower bounds of each array
227
+ dimension. The rank of a ShiftType must be at least 1.
172
228
}];
173
229
174
- let parameters = (ins "KindTy":$FKind, "CharacterType::LenType":$len);
175
-
176
- let extraClassDeclaration = [{
177
- using KindTy = unsigned;
178
- using LenType = std::int64_t;
179
-
180
- // Return unknown length CHARACTER type.
181
- static CharacterType getUnknownLen(mlir::MLIRContext *ctxt, KindTy kind) {
182
- return get(ctxt, kind, unknownLen());
183
- }
184
-
185
- // Return length 1 CHARACTER type.
186
- static CharacterType getSingleton(mlir::MLIRContext *ctxt, KindTy kind) {
187
- return get(ctxt, kind, singleton());
188
- }
189
-
190
- // CHARACTER is a singleton and has a LEN of 1.
191
- static constexpr LenType singleton() { return 1; }
192
- // CHARACTER has an unknown LEN property.
193
- static constexpr LenType unknownLen() { return -1; }
194
- }];
195
- }
196
-
197
- def fir_BoxCharType : FIR_Type<"BoxChar", "boxchar"> {
198
- let summary = "CHARACTER type descriptor.";
199
-
200
- let description = [{
201
- The type of a pair that describes a CHARACTER variable. Specifically, a
202
- CHARACTER consists of a reference to a buffer (the string value) and a LEN
203
- type parameter (the runtime length of the buffer).
204
- }];
205
-
206
- let parameters = (ins "KindTy":$kind);
230
+ let parameters = (ins "unsigned":$rank);
207
231
208
232
let printer = [{
209
- $_printer << "boxchar <" << getImpl()->kind << ">";
233
+ $_printer << "shift <" << getImpl()->rank << ">";
210
234
}];
211
235
212
- let genAccessors = 1;
213
-
214
- let extraClassDeclaration = [{
215
- using KindTy = unsigned;
216
-
217
- // a !fir.boxchar<k> always wraps a !fir.char<k, ?>
218
- CharacterType getElementType(mlir::MLIRContext *context) const;
219
-
220
- CharacterType getEleTy() const;
236
+ let parser = [{
237
+ int rank;
238
+ if ($_parser.parseLess() || $_parser.parseInteger(rank) ||
239
+ $_parser.parseGreater())
240
+ return Type();
241
+ return get(context, rank);
221
242
}];
222
243
}
223
244
0 commit comments