@@ -33,8 +33,10 @@ class CIR_Type<string name, string typeMnemonic, list<Trait> traits = [],
3333// IntType
3434//===----------------------------------------------------------------------===//
3535
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+ ]> {
3840 let summary = "Integer type with arbitrary precision up to a fixed limit";
3941 let description = [{
4042 CIR type that represents integer types with arbitrary precision, including
@@ -82,7 +84,8 @@ def CIR_IntType : CIR_Type<"Int", "int",
8284
8385class CIR_FloatType<string name, string mnemonic> : CIR_Type<name, mnemonic, [
8486 DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
85- DeclareTypeInterfaceMethods<CIR_FPTypeInterface>
87+ DeclareTypeInterfaceMethods<CIR_FPTypeInterface>,
88+ DeclareTypeInterfaceMethods<CIR_SizedTypeInterface>
8689]>;
8790
8891def CIR_Single : CIR_FloatType<"Single", "float"> {
@@ -165,9 +168,10 @@ def CIR_LongDouble : CIR_FloatType<"LongDouble", "long_double"> {
165168// ComplexType
166169//===----------------------------------------------------------------------===//
167170
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+ ]> {
171175 let summary = "CIR complex type";
172176 let description = [{
173177 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",
215219// PointerType
216220//===----------------------------------------------------------------------===//
217221
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+ ]> {
221226 let summary = "CIR pointer type";
222227 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
224229 types, other than pointers-to-members. The `pointee` type is the type
225230 pointed to.
226231
@@ -279,26 +284,27 @@ def CIR_PointerType : CIR_Type<"Pointer", "ptr",
279284// BoolType
280285//===----------------------------------------------------------------------===//
281286
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+ ]> {
286291 let summary = "CIR bool type";
287292 let description = [{
288- `cir.bool` represents C++ bool type.
293+ `! cir.bool` represents C++ bool type.
289294 }];
290295}
291296
292297//===----------------------------------------------------------------------===//
293298// ArrayType
294299//===----------------------------------------------------------------------===//
295300
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+ ]> {
299305 let summary = "CIR array type";
300306 let description = [{
301- `CIR .array` represents C/C++ constant arrays.
307+ `!cir .array` represents C/C++ constant arrays.
302308 }];
303309
304310 let parameters = (ins "mlir::Type":$elementType, "uint64_t":$size);
@@ -314,15 +320,22 @@ def CIR_ArrayType : CIR_Type<"Array", "array",
314320 let assemblyFormat = [{
315321 `<` $elementType `x` $size `>`
316322 }];
323+
324+ let extraClassDefinition = [{
325+ bool $cppClass::isSized() const {
326+ return ::cir::isSized(getElementType());
327+ }
328+ }];
317329}
318330
319331//===----------------------------------------------------------------------===//
320332// VectorType (fixed size)
321333//===----------------------------------------------------------------------===//
322334
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+ ]> {
326339 let summary = "CIR vector type";
327340 let description = [{
328341 The `!cir.vector` type represents a fixed-size, one-dimensional vector.
@@ -363,6 +376,12 @@ def CIR_VectorType : CIR_Type<"Vector", "vector",
363376 }]>,
364377 ];
365378
379+ let extraClassDefinition = [{
380+ bool $cppClass::isSized() const {
381+ return ::cir::isSized(getElementType());
382+ }
383+ }];
384+
366385 let genVerifyDecl = 1;
367386}
368387
@@ -459,11 +478,11 @@ def CIR_VoidType : CIR_Type<"Void", "void"> {
459478// The base type for all RecordDecls.
460479//===----------------------------------------------------------------------===//
461480
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+ ]> {
467486 let summary = "CIR record type";
468487 let description = [{
469488 Each unique clang::RecordDecl is mapped to a `cir.record` and any object in
0 commit comments