1616include "clang/CIR/Dialect/IR/CIRDialect.td"
1717include "clang/CIR/Dialect/IR/CIRTypeConstraints.td"
1818include "clang/CIR/Interfaces/ASTAttrInterfaces.td"
19- include "clang/CIR/Interfaces/CIRFPTypeInterface .td"
19+ include "clang/CIR/Interfaces/CIRTypeInterfaces .td"
2020include "mlir/Interfaces/DataLayoutInterfaces.td"
2121include "mlir/IR/AttrTypeBase.td"
2222include "mlir/IR/EnumAttr.td"
@@ -35,8 +35,10 @@ class CIR_Type<string name, string typeMnemonic, list<Trait> traits = [],
3535// IntType
3636//===----------------------------------------------------------------------===//
3737
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+ ]> {
4042 let summary = "Integer type with arbitrary precision up to a fixed limit";
4143 let description = [{
4244 CIR type that represents integer types with arbitrary precision.
@@ -81,8 +83,9 @@ def CIR_IntType : CIR_Type<"Int", "int",
8183//===----------------------------------------------------------------------===//
8284
8385class 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>
8689]>;
8790
8891def CIR_Single : CIR_FloatType<"Single", "float"> {
@@ -151,9 +154,10 @@ def CIR_LongDouble : CIR_FloatType<"LongDouble", "long_double"> {
151154// ComplexType
152155//===----------------------------------------------------------------------===//
153156
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+ ]> {
157161 let summary = "CIR complex type";
158162 let description = [{
159163 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",
194198// PointerType
195199//===----------------------------------------------------------------------===//
196200
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+ ]> {
200205 let summary = "CIR pointer type";
201206 let description = [{
202207 `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",
295300// BoolType
296301//===----------------------------------------------------------------------===//
297302
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+ ]> {
301307 let summary = "CIR bool type";
302308 let description = [{
303309 `cir.bool` represent's C++ bool type.
@@ -308,9 +314,10 @@ def CIR_BoolType : CIR_Type<"Bool", "bool",
308314// ArrayType
309315//===----------------------------------------------------------------------===//
310316
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+ ]> {
314321 let summary = "CIR array type";
315322 let description = [{
316323 `CIR.array` represents C/C++ constant arrays.
@@ -329,14 +336,22 @@ def CIR_ArrayType : CIR_Type<"Array", "array",
329336 let assemblyFormat = [{
330337 `<` $elementType `x` $size `>`
331338 }];
339+
340+ let extraClassDefinition = [{
341+ bool $cppClass::isSized() const {
342+ return ::cir::isSized(getElementType());
343+ }
344+ }];
332345}
333346
334347//===----------------------------------------------------------------------===//
335348// VectorType (fixed size)
336349//===----------------------------------------------------------------------===//
337350
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+ ]> {
340355
341356 let summary = "CIR vector type";
342357 let description = [{
@@ -378,6 +393,12 @@ def CIR_VectorType : CIR_Type<"Vector", "vector",
378393 `<` $elementType `x` $size `>`
379394 }];
380395
396+ let extraClassDefinition = [{
397+ bool $cppClass::isSized() const {
398+ return ::cir::isSized(getElementType());
399+ }
400+ }];
401+
381402 let genVerifyDecl = 1;
382403}
383404
@@ -524,11 +545,11 @@ def CIR_VoidType : CIR_Type<"Void", "void"> {
524545// The base type for all RecordDecls.
525546//===----------------------------------------------------------------------===//
526547
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+ ]> {
532553 let summary = "CIR record type";
533554 let description = [{
534555 Each unique clang::RecordDecl is mapped to a `cir.record` and any object in
0 commit comments