Skip to content

Conversation

@steffenlarsen
Copy link
Contributor

This commit adds the implementation logic for merging sycl_detail::add_ir_attributes_* attributes, which will enable the ability to apply multiple of the same attribute to the same declaration/definition, as long as the values associated to the same names in the attributes do not conflict.

This is needed for SYCL free function support as the way SYCL properties are applied are through macros expanding to
sycl_detail::add_ir_attributes_* with a single name-value-pair.

This commit adds the implementation logic for merging
__sycl_detail__::add_ir_attributes_* attributes, which will enable the
ability to apply multiple of the same attribute to the same
declaration/definition, as long as the values associated to the same
names in the attributes do not conflict.

This is needed for SYCL free function support as the way SYCL properties
are applied are through macros expanding to
__sycl_detail__::add_ir_attributes_* with a single name-value-pair.

Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
if (checkSYCLAddIRAttributesMergeability(A, *ExistingAttr, *this))
return nullptr;

D->dropAttr<SYCLAddIRAttributesFunctionAttr>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully recall how this code works but are you required to drop here if you're dropping in the add function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Since merge is used in multiple places, it makes the most sense to me to remove the attribute dropping in the add function.

Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]]
[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]]
[[__sycl_detail__::add_ir_attributes_function("Attr2", "Attr1", true, 1)]]
[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, false)]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you should include invalid tests in AST checks. Unless you're checking the attribute does not get added in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now the two tests have the same set of cases, but I don't necessarily disagree. Would you like me to remove the existing invalid cases as part of this PR or in a follow-up?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants