@@ -27,6 +27,20 @@ class CIR_Attr<string name, string attrMnemonic, list<Trait> traits = []>
27
27
let mnemonic = attrMnemonic;
28
28
}
29
29
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
+
30
44
class CIRUnitAttr<string name, string attrMnemonic, list<Trait> traits = []>
31
45
: CIR_Attr<name, attrMnemonic, traits> {
32
46
let returnType = "bool";
@@ -64,43 +78,23 @@ def CIR_BoolAttr : CIR_Attr<"Bool", "bool", [TypedAttrInterface]> {
64
78
// ZeroAttr
65
79
//===----------------------------------------------------------------------===//
66
80
67
- def ZeroAttr : CIR_Attr <"Zero", "zero", [TypedAttrInterface] > {
81
+ def ZeroAttr : CIR_TypedAttr <"Zero", "zero"> {
68
82
let summary = "Attribute to represent zero initialization";
69
83
let description = [{
70
84
The ZeroAttr is used to indicate zero initialization on structs.
71
85
}];
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 = [{}];
82
86
}
83
87
84
88
//===----------------------------------------------------------------------===//
85
89
// UndefAttr
86
90
//===----------------------------------------------------------------------===//
87
91
88
- def UndefAttr : CIR_Attr <"Undef", "undef", [TypedAttrInterface] > {
92
+ def UndefAttr : CIR_TypedAttr <"Undef", "undef"> {
89
93
let summary = "Represent an undef constant";
90
94
let description = [{
91
95
The UndefAttr represents an undef constant, corresponding to LLVM's notion
92
96
of undef.
93
97
}];
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 = [{}];
104
98
}
105
99
106
100
//===----------------------------------------------------------------------===//
0 commit comments