@@ -30,6 +30,20 @@ class CIR_Attr<string name, string attrMnemonic, list<Trait> traits = [],
3030 let mnemonic = attrMnemonic;
3131}
3232
33+ class CIR_TypedAttr<string name, string attrMnemonic, list<Trait> traits = []>
34+ : CIR_Attr<name, attrMnemonic, !listconcat(traits, [TypedAttrInterface])> {
35+
36+ let parameters = (ins AttributeSelfTypeParameter<"">:$type);
37+
38+ let builders = [
39+ AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
40+ return $_get(type.getContext(), type);
41+ }]>
42+ ];
43+
44+ let assemblyFormat = [{}];
45+ }
46+
3347class CIRUnitAttr<string name, string attrMnemonic, list<Trait> traits = []>
3448 : CIR_Attr<name, attrMnemonic, traits> {
3549 let returnType = "bool";
@@ -224,65 +238,35 @@ def CIR_BoolAttr : CIR_Attr<"Bool", "bool", [TypedAttrInterface]> {
224238// ZeroAttr
225239//===----------------------------------------------------------------------===//
226240
227- def ZeroAttr : CIR_Attr <"Zero", "zero", [TypedAttrInterface] > {
241+ def ZeroAttr : CIR_TypedAttr <"Zero", "zero"> {
228242 let summary = "Attribute to represent zero initialization";
229243 let description = [{
230244 The ZeroAttr is used to indicate zero initialization on structs.
231245 }];
232-
233- let parameters = (ins AttributeSelfTypeParameter<"">:$type);
234-
235- let builders = [
236- AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
237- return $_get(type.getContext(), type);
238- }]>
239- ];
240-
241- let assemblyFormat = [{}];
242246}
243247
244248//===----------------------------------------------------------------------===//
245249// UndefAttr
246250//===----------------------------------------------------------------------===//
247251
248- def UndefAttr : CIR_Attr <"Undef", "undef", [TypedAttrInterface] > {
252+ def UndefAttr : CIR_TypedAttr <"Undef", "undef"> {
249253 let summary = "Represent an undef constant";
250254 let description = [{
251255 The UndefAttr represents an undef constant, corresponding to LLVM's notion
252256 of undef.
253257 }];
254-
255- let parameters = (ins AttributeSelfTypeParameter<"">:$type);
256-
257- let builders = [
258- AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
259- return $_get(type.getContext(), type);
260- }]>
261- ];
262-
263- let assemblyFormat = [{}];
264258}
265259
266260//===----------------------------------------------------------------------===//
267261// PoisonAttr
268262//===----------------------------------------------------------------------===//
269263
270- def PoisonAttr : CIR_Attr <"Poison", "poison", [TypedAttrInterface] > {
264+ def PoisonAttr : CIR_TypedAttr <"Poison", "poison"> {
271265 let summary = "Represent a typed poison constant";
272266 let description = [{
273267 The PoisonAttr represents a typed poison constant, corresponding to LLVM's
274268 notion of poison.
275269 }];
276-
277- let parameters = (ins AttributeSelfTypeParameter<"">:$type);
278-
279- let builders = [
280- AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
281- return $_get(type.getContext(), type);
282- }]>
283- ];
284-
285- let assemblyFormat = [{}];
286270}
287271
288272//===----------------------------------------------------------------------===//
0 commit comments