@@ -822,6 +822,120 @@ def CIR_GlobalDtorAttr : CIR_GlobalCtorDtor<"Dtor", "dtor"> {
822822 }];
823823}
824824
825+ //===----------------------------------------------------------------------===//
826+ // CXX SpecialMemberAttr
827+ //===----------------------------------------------------------------------===//
828+
829+ def CIR_CtorKind : CIR_I32EnumAttr<"CtorKind", "CXX Constructor Kind", [
830+ I32EnumAttrCase<"Custom", 0, "custom">,
831+ I32EnumAttrCase<"Default", 1, "default">,
832+ I32EnumAttrCase<"Copy", 2, "copy">,
833+ I32EnumAttrCase<"Move", 3, "move">,
834+ ]> {
835+ let genSpecializedAttr = 0;
836+ }
837+
838+
839+ def CIR_CXXCtorAttr : CIR_Attr<"CXXCtor", "cxx_ctor"> {
840+ let summary = "Marks a function as a C++ constructor";
841+ let description = [{
842+ This attribute identifies a C++ constructor and classifies its kind:
843+
844+ - `custom`: a user-defined constructor
845+ - `default`: a default constructor
846+ - `copy`: a copy constructor
847+ - `move`: a move constructor
848+
849+ Example:
850+ ```mlir
851+ #cir.cxx_ctor<!rec_a, copy>
852+ #cir.cxx_ctor<!rec_b, default, trivial>
853+ ```
854+ }];
855+
856+ let parameters = (ins
857+ "mlir::Type":$type,
858+ EnumParameter<CIR_CtorKind>:$ctor_kind,
859+ DefaultValuedParameter<"bool", "false">:$is_trivial
860+ );
861+
862+ let builders = [
863+ AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
864+ CArg<"CtorKind", "cir::CtorKind::Custom">:$ctorKind,
865+ CArg<"bool", "false">:$isTrivial), [{
866+ return $_get(type.getContext(), type, ctorKind, isTrivial);
867+ }]>,
868+ ];
869+
870+ let assemblyFormat = [{
871+ `<` $type `,` $ctor_kind (`,` `trivial` $is_trivial^)? `>`
872+ }];
873+ }
874+
875+ def CIR_CXXDtorAttr : CIR_Attr<"CXXDtor", "cxx_dtor"> {
876+ let summary = "Marks a function as a CXX destructor";
877+ let description = [{
878+ This attribute identifies a C++ destructor.
879+ }];
880+
881+ let parameters = (ins
882+ "mlir::Type":$type,
883+ DefaultValuedParameter<"bool", "false">:$is_trivial
884+ );
885+
886+ let builders = [
887+ AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
888+ CArg<"bool", "false">:$isTrivial), [{
889+ return $_get(type.getContext(), type, isTrivial);
890+ }]>
891+ ];
892+
893+ let assemblyFormat = [{
894+ `<` $type (`,` `trivial` $is_trivial^)? `>`
895+ }];
896+ }
897+
898+ def CIR_AssignKind : CIR_I32EnumAttr<"AssignKind", "CXX Assignment Operator Kind", [
899+ I32EnumAttrCase<"Copy", 0, "copy">,
900+ I32EnumAttrCase<"Move", 1, "move">,
901+ ]> {
902+ let genSpecializedAttr = 0;
903+ }
904+
905+ def CIR_CXXAssignAttr : CIR_Attr<"CXXAssign", "cxx_assign"> {
906+ let summary = "Marks a function as a CXX assignment operator";
907+ let description = [{
908+ This attribute identifies a C++ assignment operator and classifies its kind:
909+
910+ - `copy`: a copy assignment
911+ - `move`: a move assignment
912+ }];
913+
914+ let parameters = (ins
915+ "mlir::Type":$type,
916+ EnumParameter<CIR_AssignKind>:$assign_kind,
917+ DefaultValuedParameter<"bool", "false">:$is_trivial
918+ );
919+
920+ let builders = [
921+ AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
922+ CArg<"AssignKind">:$assignKind,
923+ CArg<"bool", "false">:$isTrivial), [{
924+ return $_get(type.getContext(), type, assignKind, isTrivial);
925+ }]>
926+ ];
927+
928+ let assemblyFormat = [{
929+ `<` $type `,` $assign_kind (`,` `trivial` $is_trivial^)? `>`
930+ }];
931+ }
932+
933+ def CIR_CXXSpecialMemberAttr : AnyAttrOf<[
934+ CIR_CXXCtorAttr,
935+ CIR_CXXDtorAttr,
936+ CIR_CXXAssignAttr
937+ ]>;
938+
825939//===----------------------------------------------------------------------===//
826940// BitfieldInfoAttr
827941//===----------------------------------------------------------------------===//
0 commit comments