@@ -401,52 +401,51 @@ def VoidPtr : Type<
401401}
402402
403403//===----------------------------------------------------------------------===//
404- // StructType
404+ // RecordType
405405//
406406// The base type for all RecordDecls.
407407//===----------------------------------------------------------------------===//
408408
409- def CIR_StructType : CIR_Type<"Struct ", "struct ",
409+ def CIR_RecordType : CIR_Type<"Record ", "record ",
410410 [
411411 DeclareTypeInterfaceMethods<DataLayoutTypeInterface>,
412412 MutableType,
413413 ]> {
414- let summary = "CIR struct type";
414+ let summary = "CIR record type";
415415 let description = [{
416- Each unique clang::RecordDecl is mapped to a `cir.struct ` and any object in
417- C/C++ that has a struct type will have a `cir.struct ` in CIR.
416+ Each unique clang::RecordDecl is mapped to a `cir.record ` and any object in
417+ C/C++ that has a struct or class type will have a `cir.record ` in CIR.
418418
419419 There are three possible formats for this type:
420420
421- - Identified and complete structs : unique name and a known body.
422- - Identified and incomplete structs : unique name and unknown body.
423- - Anonymous structs : no name and a known body.
421+ - Identified and complete records : unique name and a known body.
422+ - Identified and incomplete records : unique name and unknown body.
423+ - Anonymous records : no name and a known body.
424424
425- Identified structs are uniqued by their name, and anonymous structs are
426- uniqued by their body. This means that two anonymous structs with the same
427- body will be the same type, and two identified structs with the same name
428- will be the same type. Attempting to build a struct with an existing name,
425+ Identified records are uniqued by their name, and anonymous records are
426+ uniqued by their body. This means that two anonymous records with the same
427+ body will be the same type, and two identified records with the same name
428+ will be the same type. Attempting to build a record with an existing name,
429429 but a different body will result in an error.
430430
431431 A few examples:
432432
433433 ```mlir
434- !complete = !cir.struct <struct "complete" {!cir.int<u, 8>}>
435- !incomplete = !cir.struct <struct "incomplete" incomplete>
436- !anonymous = !cir.struct <struct {!cir.int<u, 8>}>
434+ !complete = !cir.record <struct "complete" {!cir.int<u, 8>}>
435+ !incomplete = !cir.record <struct "incomplete" incomplete>
436+ !anonymous = !cir.record <struct {!cir.int<u, 8>}>
437437 ```
438438
439- Incomplete structs are mutable, meaning they can be later completed with a
439+ Incomplete records are mutable, meaning they can be later completed with a
440440 body automatically updating in place every type in the code that uses the
441- incomplete struct . Mutability allows for recursive types to be represented,
442- meaning the struct can have members that refer to itself. This is useful for
441+ incomplete record . Mutability allows for recursive types to be represented,
442+ meaning the record can have members that refer to itself. This is useful for
443443 representing recursive records and is implemented through a special syntax.
444- In the example below, the `Node` struct has a member that is a pointer to a
445- `Node` struct :
444+ In the example below, the `Node` record has a member that is a pointer to a
445+ `Node` record :
446446
447447 ```mlir
448- !struct = !cir.struct<struct "Node" {!cir.ptr<!cir.struct<struct
449- "Node">>}>
448+ !s = !cir.record<struct "Node" {!cir.ptr<!cir.record<struct "Node">>}>
450449 ```
451450 }];
452451
@@ -456,18 +455,18 @@ def CIR_StructType : CIR_Type<"Struct", "struct",
456455 "bool":$incomplete,
457456 "bool":$packed,
458457 "bool":$padded,
459- "StructType ::RecordKind":$kind
458+ "RecordType ::RecordKind":$kind
460459 );
461460
462461 // StorageClass is defined in C++ for mutability.
463- let storageClass = "StructTypeStorage ";
462+ let storageClass = "RecordTypeStorage ";
464463 let genStorageClass = 0;
465464
466465 let skipDefaultBuilders = 1;
467466 let genVerifyDecl = 1;
468467
469468 let builders = [
470- // Create an identified and incomplete struct type.
469+ // Create an identified and incomplete record type.
471470 TypeBuilder<(ins
472471 "mlir::StringAttr":$name,
473472 "RecordKind":$kind
@@ -480,9 +479,8 @@ def CIR_StructType : CIR_Type<"Struct", "struct",
480479 let extraClassDeclaration = [{
481480 using Base::verifyInvariants;
482481
483- enum RecordKind : uint32_t { Class , Union, Struct };
482+ enum RecordKind : uint32_t { Struct , Union };
484483
485- bool isClass() const { return getKind() == RecordKind::Class; };
486484 bool isStruct() const { return getKind() == RecordKind::Struct; };
487485 bool isUnion() const { return getKind() == RecordKind::Union; };
488486 bool isComplete() const { return !isIncomplete(); };
@@ -491,14 +489,12 @@ def CIR_StructType : CIR_Type<"Struct", "struct",
491489 size_t getNumElements() const { return getMembers().size(); };
492490 std::string getKindAsStr() {
493491 switch (getKind()) {
494- case RecordKind::Class:
495- return "class";
496492 case RecordKind::Union:
497493 return "union";
498494 case RecordKind::Struct:
499495 return "struct";
500496 }
501- llvm_unreachable("Invalid value for StructType ::getKind()");
497+ llvm_unreachable("Invalid value for RecordType ::getKind()");
502498 }
503499 std::string getPrefixedName() {
504500 return getKindAsStr() + "." + getName().getValue().str();
@@ -508,18 +504,18 @@ def CIR_StructType : CIR_Type<"Struct", "struct",
508504 let hasCustomAssemblyFormat = 1;
509505}
510506
511- // Note CIRStructType is used instead of CIR_StructType
507+ // Note CIRRecordType is used instead of CIR_RecordType
512508// because of tablegen conflicts.
513- def CIRStructType : Type<
514- CPred<"::mlir::isa<::cir::StructType >($_self)">, "CIR struct type">;
509+ def CIRRecordType : Type<
510+ CPred<"::mlir::isa<::cir::RecordType >($_self)">, "CIR record type">;
515511
516512//===----------------------------------------------------------------------===//
517513// Global type constraints
518514//===----------------------------------------------------------------------===//
519515
520516def CIR_AnyType : AnyTypeOf<[
521517 CIR_VoidType, CIR_BoolType, CIR_ArrayType, CIR_IntType, CIR_AnyFloat,
522- CIR_PointerType, CIR_FuncType, CIR_StructType
518+ CIR_PointerType, CIR_FuncType, CIR_RecordType
523519]>;
524520
525521#endif // MLIR_CIR_DIALECT_CIR_TYPES
0 commit comments