###### `params` Directive
-This directive is used to refer to all parameters of an attribute or type. When
-used as a top-level directive, `params` generates a parser and printer for a
+This directive is used to refer to all parameters of an attribute or type, except
+for the attribute self type (which is handled separately from normal parameters).
+When used as a top-level directive, `params` generates a parser and printer for a
comma-separated list of the parameters. For example:
```tablegen
let assemblyFormat = "`<` $a `>`";
}
+def TestAttrSelfTypeParameterStructFormat
+ : Test_Attr<"TestAttrSelfTypeParameterStructFormat", [TypedAttrInterface]> {
+ let parameters = (ins "int":$a, AttributeSelfTypeParameter<"">:$type);
+
+ let mnemonic = "attr_self_type_struct_format";
+ let assemblyFormat = "`<` struct(params) `>`";
+}
+
// Test overridding attribute builders with a custom builder.
def TestOverrideBuilderAttr : Test_Attr<"TestOverrideBuilder"> {
let mnemonic = "override_builder";
attr4 = #test.attr_with_type<i32, vector<4xi32>>,
// CHECK: #test.attr_self_type_format<5> : i32
attr5 = #test.attr_self_type_format<5> : i32,
+ // CHECK: #test.attr_self_type_struct_format<a = 5> : i32
+ attr6 = #test.attr_self_type_struct_format<a = 5> : i32,
// CHECK: #test.custom_anchor<5>
- attr6 = #test.custom_anchor<5>,
+ attr7 = #test.custom_anchor<5>,
// CHECK: #test.custom_anchor<5, true>
- attr7 = #test.custom_anchor<5, true>
+ attr8 = #test.custom_anchor<5, true>
}
// CHECK-LABEL: @test_roundtrip_default_parsers_struct
return emitError(loc, "`params` captures duplicate parameter: " +
it.value().getName());
}
+ // Self-type parameters are handled separately from the rest of the
+ // parameters.
+ if (isa<AttributeSelfTypeParameter>(it.value()))
+ continue;
seenParams.set(it.index());
vars.push_back(create<ParameterElement>(it.value()));
}