@@ -33,8 +33,10 @@ class CIR_Type<string name, string typeMnemonic, list<Trait> traits = [],
33
33
// IntType
34
34
//===----------------------------------------------------------------------===//
35
35
36
- def CIR_IntType : CIR_Type<"Int", "int",
37
- [DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
36
+ def CIR_IntType : CIR_Type<"Int", "int", [
37
+ DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
38
+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>
39
+ ]> {
38
40
let summary = "Integer type with arbitrary precision up to a fixed limit";
39
41
let description = [{
40
42
CIR type that represents integer types with arbitrary precision, including
@@ -82,7 +84,8 @@ def CIR_IntType : CIR_Type<"Int", "int",
82
84
83
85
class CIR_FloatType<string name, string mnemonic> : CIR_Type<name, mnemonic, [
84
86
DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
85
- DeclareTypeInterfaceMethods<CIR_FPTypeInterface>
87
+ DeclareTypeInterfaceMethods<CIR_FPTypeInterface>,
88
+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>
86
89
]>;
87
90
88
91
def CIR_Single : CIR_FloatType<"Single", "float"> {
@@ -165,9 +168,10 @@ def CIR_LongDouble : CIR_FloatType<"LongDouble", "long_double"> {
165
168
// ComplexType
166
169
//===----------------------------------------------------------------------===//
167
170
168
- def CIR_ComplexType : CIR_Type<"Complex", "complex",
169
- [DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
170
-
171
+ def CIR_ComplexType : CIR_Type<"Complex", "complex", [
172
+ DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
173
+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>
174
+ ]> {
171
175
let summary = "CIR complex type";
172
176
let description = [{
173
177
CIR type that represents a C complex number. `cir.complex` models the C type
@@ -215,12 +219,13 @@ def CIR_ComplexType : CIR_Type<"Complex", "complex",
215
219
// PointerType
216
220
//===----------------------------------------------------------------------===//
217
221
218
- def CIR_PointerType : CIR_Type<"Pointer", "ptr",
219
- [DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
220
-
222
+ def CIR_PointerType : CIR_Type<"Pointer", "ptr", [
223
+ DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
224
+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>
225
+ ]> {
221
226
let summary = "CIR pointer type";
222
227
let description = [{
223
- The `cir.ptr` type represents C and C++ pointer types and C++ reference
228
+ The `! cir.ptr` type represents C and C++ pointer types and C++ reference
224
229
types, other than pointers-to-members. The `pointee` type is the type
225
230
pointed to.
226
231
@@ -279,26 +284,27 @@ def CIR_PointerType : CIR_Type<"Pointer", "ptr",
279
284
// BoolType
280
285
//===----------------------------------------------------------------------===//
281
286
282
- def CIR_BoolType :
283
- CIR_Type<"Bool", "bool" ,
284
- [ DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
285
-
287
+ def CIR_BoolType : CIR_Type<"Bool", "bool", [
288
+ DeclareTypeInterfaceMethods<DataLayoutTypeInterface> ,
289
+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>
290
+ ]> {
286
291
let summary = "CIR bool type";
287
292
let description = [{
288
- `cir.bool` represents C++ bool type.
293
+ `! cir.bool` represents C++ bool type.
289
294
}];
290
295
}
291
296
292
297
//===----------------------------------------------------------------------===//
293
298
// ArrayType
294
299
//===----------------------------------------------------------------------===//
295
300
296
- def CIR_ArrayType : CIR_Type<"Array", "array",
297
- [DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
298
-
301
+ def CIR_ArrayType : CIR_Type<"Array", "array", [
302
+ DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
303
+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface, ["isSized"]>,
304
+ ]> {
299
305
let summary = "CIR array type";
300
306
let description = [{
301
- `CIR .array` represents C/C++ constant arrays.
307
+ `!cir .array` represents C/C++ constant arrays.
302
308
}];
303
309
304
310
let parameters = (ins "mlir::Type":$elementType, "uint64_t":$size);
@@ -314,15 +320,22 @@ def CIR_ArrayType : CIR_Type<"Array", "array",
314
320
let assemblyFormat = [{
315
321
`<` $elementType `x` $size `>`
316
322
}];
323
+
324
+ let extraClassDefinition = [{
325
+ bool $cppClass::isSized() const {
326
+ return ::cir::isSized(getElementType());
327
+ }
328
+ }];
317
329
}
318
330
319
331
//===----------------------------------------------------------------------===//
320
332
// VectorType (fixed size)
321
333
//===----------------------------------------------------------------------===//
322
334
323
- def CIR_VectorType : CIR_Type<"Vector", "vector",
324
- [DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
325
-
335
+ def CIR_VectorType : CIR_Type<"Vector", "vector", [
336
+ DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
337
+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface, ["isSized"]>,
338
+ ]> {
326
339
let summary = "CIR vector type";
327
340
let description = [{
328
341
The `!cir.vector` type represents a fixed-size, one-dimensional vector.
@@ -363,6 +376,12 @@ def CIR_VectorType : CIR_Type<"Vector", "vector",
363
376
}]>,
364
377
];
365
378
379
+ let extraClassDefinition = [{
380
+ bool $cppClass::isSized() const {
381
+ return ::cir::isSized(getElementType());
382
+ }
383
+ }];
384
+
366
385
let genVerifyDecl = 1;
367
386
}
368
387
@@ -459,11 +478,11 @@ def CIR_VoidType : CIR_Type<"Void", "void"> {
459
478
// The base type for all RecordDecls.
460
479
//===----------------------------------------------------------------------===//
461
480
462
- def CIR_RecordType : CIR_Type<"Record", "record",
463
- [
464
- DeclareTypeInterfaceMethods<DataLayoutTypeInterface >,
465
- MutableType,
466
- ]> {
481
+ def CIR_RecordType : CIR_Type<"Record", "record", [
482
+ DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
483
+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface >,
484
+ MutableType,
485
+ ]> {
467
486
let summary = "CIR record type";
468
487
let description = [{
469
488
Each unique clang::RecordDecl is mapped to a `cir.record` and any object in
0 commit comments