16
16
include "clang/CIR/Dialect/IR/CIRDialect.td"
17
17
include "clang/CIR/Dialect/IR/CIRTypeConstraints.td"
18
18
include "clang/CIR/Interfaces/ASTAttrInterfaces.td"
19
- include "clang/CIR/Interfaces/CIRFPTypeInterface .td"
19
+ include "clang/CIR/Interfaces/CIRTypeInterfaces .td"
20
20
include "mlir/Interfaces/DataLayoutInterfaces.td"
21
21
include "mlir/IR/AttrTypeBase.td"
22
22
include "mlir/IR/EnumAttr.td"
@@ -35,8 +35,10 @@ class CIR_Type<string name, string typeMnemonic, list<Trait> traits = [],
35
35
// IntType
36
36
//===----------------------------------------------------------------------===//
37
37
38
- def CIR_IntType : CIR_Type<"Int", "int",
39
- [DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
38
+ def CIR_IntType : CIR_Type<"Int", "int", [
39
+ DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
40
+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>,
41
+ ]> {
40
42
let summary = "Integer type with arbitrary precision up to a fixed limit";
41
43
let description = [{
42
44
CIR type that represents integer types with arbitrary precision.
@@ -81,8 +83,9 @@ def CIR_IntType : CIR_Type<"Int", "int",
81
83
//===----------------------------------------------------------------------===//
82
84
83
85
class CIR_FloatType<string name, string mnemonic> : CIR_Type<name, mnemonic, [
84
- DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
85
- DeclareTypeInterfaceMethods<CIRFPTypeInterface>
86
+ DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
87
+ DeclareTypeInterfaceMethods<CIR_FPTypeInterface>,
88
+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>
86
89
]>;
87
90
88
91
def CIR_Single : CIR_FloatType<"Single", "float"> {
@@ -151,9 +154,10 @@ def CIR_LongDouble : CIR_FloatType<"LongDouble", "long_double"> {
151
154
// ComplexType
152
155
//===----------------------------------------------------------------------===//
153
156
154
- def CIR_ComplexType : CIR_Type<"Complex", "complex",
155
- [DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
156
-
157
+ def CIR_ComplexType : CIR_Type<"Complex", "complex", [
158
+ DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
159
+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>
160
+ ]> {
157
161
let summary = "CIR complex type";
158
162
let description = [{
159
163
CIR type that represents a C complex number. `cir.complex` models the C type
@@ -194,9 +198,10 @@ def CIR_ComplexType : CIR_Type<"Complex", "complex",
194
198
// PointerType
195
199
//===----------------------------------------------------------------------===//
196
200
197
- def CIR_PointerType : CIR_Type<"Pointer", "ptr",
198
- [DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
199
-
201
+ def CIR_PointerType : CIR_Type<"Pointer", "ptr", [
202
+ DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
203
+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>
204
+ ]> {
200
205
let summary = "CIR pointer type";
201
206
let description = [{
202
207
`CIR.ptr` is a type returned by any op generating a pointer in C++.
@@ -295,9 +300,10 @@ def CIR_DataMemberType : CIR_Type<"DataMember", "data_member",
295
300
// BoolType
296
301
//===----------------------------------------------------------------------===//
297
302
298
- def CIR_BoolType : CIR_Type<"Bool", "bool",
299
- [DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
300
-
303
+ def CIR_BoolType : CIR_Type<"Bool", "bool", [
304
+ DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
305
+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>
306
+ ]> {
301
307
let summary = "CIR bool type";
302
308
let description = [{
303
309
`cir.bool` represent's C++ bool type.
@@ -308,9 +314,10 @@ def CIR_BoolType : CIR_Type<"Bool", "bool",
308
314
// ArrayType
309
315
//===----------------------------------------------------------------------===//
310
316
311
- def CIR_ArrayType : CIR_Type<"Array", "array",
312
- [DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
313
-
317
+ def CIR_ArrayType : CIR_Type<"Array", "array", [
318
+ DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
319
+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface, ["isSized"]>,
320
+ ]> {
314
321
let summary = "CIR array type";
315
322
let description = [{
316
323
`CIR.array` represents C/C++ constant arrays.
@@ -329,14 +336,22 @@ def CIR_ArrayType : CIR_Type<"Array", "array",
329
336
let assemblyFormat = [{
330
337
`<` $elementType `x` $size `>`
331
338
}];
339
+
340
+ let extraClassDefinition = [{
341
+ bool $cppClass::isSized() const {
342
+ return ::cir::isSized(getElementType());
343
+ }
344
+ }];
332
345
}
333
346
334
347
//===----------------------------------------------------------------------===//
335
348
// VectorType (fixed size)
336
349
//===----------------------------------------------------------------------===//
337
350
338
- def CIR_VectorType : CIR_Type<"Vector", "vector",
339
- [DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
351
+ def CIR_VectorType : CIR_Type<"Vector", "vector", [
352
+ DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
353
+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface, ["isSized"]>,
354
+ ]> {
340
355
341
356
let summary = "CIR vector type";
342
357
let description = [{
@@ -378,6 +393,12 @@ def CIR_VectorType : CIR_Type<"Vector", "vector",
378
393
`<` $elementType `x` $size `>`
379
394
}];
380
395
396
+ let extraClassDefinition = [{
397
+ bool $cppClass::isSized() const {
398
+ return ::cir::isSized(getElementType());
399
+ }
400
+ }];
401
+
381
402
let genVerifyDecl = 1;
382
403
}
383
404
@@ -524,11 +545,11 @@ def CIR_VoidType : CIR_Type<"Void", "void"> {
524
545
// The base type for all RecordDecls.
525
546
//===----------------------------------------------------------------------===//
526
547
527
- def CIR_RecordType : CIR_Type<"Record", "record",
528
- [
529
- DeclareTypeInterfaceMethods<DataLayoutTypeInterface >,
530
- MutableType,
531
- ]> {
548
+ def CIR_RecordType : CIR_Type<"Record", "record", [
549
+ DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
550
+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface >,
551
+ MutableType,
552
+ ]> {
532
553
let summary = "CIR record type";
533
554
let description = [{
534
555
Each unique clang::RecordDecl is mapped to a `cir.record` and any object in
0 commit comments