@@ -27,6 +27,20 @@ class CIR_Attr<string name, string attrMnemonic, list<Trait> traits = []>
2727 let mnemonic = attrMnemonic;
2828}
2929
30+ class CIR_TypedAttr<string name, string attrMnemonic, list<Trait> traits = []>
31+ : CIR_Attr<name, attrMnemonic, !listconcat(traits, [TypedAttrInterface])> {
32+
33+ let parameters = (ins AttributeSelfTypeParameter<"">:$type);
34+
35+ let builders = [
36+ AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
37+ return $_get(type.getContext(), type);
38+ }]>
39+ ];
40+
41+ let assemblyFormat = [{}];
42+ }
43+
3044class CIRUnitAttr<string name, string attrMnemonic, list<Trait> traits = []>
3145 : CIR_Attr<name, attrMnemonic, traits> {
3246 let returnType = "bool";
@@ -64,43 +78,23 @@ def CIR_BoolAttr : CIR_Attr<"Bool", "bool", [TypedAttrInterface]> {
6478// ZeroAttr
6579//===----------------------------------------------------------------------===//
6680
67- def ZeroAttr : CIR_Attr <"Zero", "zero", [TypedAttrInterface] > {
81+ def ZeroAttr : CIR_TypedAttr <"Zero", "zero"> {
6882 let summary = "Attribute to represent zero initialization";
6983 let description = [{
7084 The ZeroAttr is used to indicate zero initialization on structs.
7185 }];
72-
73- let parameters = (ins AttributeSelfTypeParameter<"">:$type);
74-
75- let builders = [
76- AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
77- return $_get(type.getContext(), type);
78- }]>
79- ];
80-
81- let assemblyFormat = [{}];
8286}
8387
8488//===----------------------------------------------------------------------===//
8589// UndefAttr
8690//===----------------------------------------------------------------------===//
8791
88- def UndefAttr : CIR_Attr <"Undef", "undef", [TypedAttrInterface] > {
92+ def UndefAttr : CIR_TypedAttr <"Undef", "undef"> {
8993 let summary = "Represent an undef constant";
9094 let description = [{
9195 The UndefAttr represents an undef constant, corresponding to LLVM's notion
9296 of undef.
9397 }];
94-
95- let parameters = (ins AttributeSelfTypeParameter<"">:$type);
96-
97- let builders = [
98- AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
99- return $_get(type.getContext(), type);
100- }]>
101- ];
102-
103- let assemblyFormat = [{}];
10498}
10599
106100//===----------------------------------------------------------------------===//
0 commit comments