Skip to content

[libclc] Define macros for users of gentype.inc #128012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

frasercrmck
Copy link
Contributor

Several users of (mostly math/) gentype.inc rely on types other than the 'gentype'. This is commonly intN as several maths builtins expose this as a return or paramter type. We were previously explicitly defining this type for every gentype.

Other implementations rely on integer types of the same size and element width as the gentype, such as short/ushort for half, long/ulong for double, etc.

Users might also rely on as_type or convert_type builtins to/from these types.

The previous method we used to define intN was unscalable if we wanted to expose more types and helpers.

This commit introduces a simpler system whereby several macros are defined at the beginning of gentype.inc. These rely on concatenating with the vector size. To facilitate this system, scalar gentypes now define an empty vector size. It was previously undefined, which was dangerous. An added benefit is that it matches how the integer gentype.inc vector size has been working.

These macros will be especially helpful for the definitions of logb/ilogb in an upcoming patch.

Several users of (mostly math/) gentype.inc rely on types other than the
'gentype'. This is commonly intN as several maths builtins expose this
as a return or paramter type. We were previously explicitly defining
this type for every gentype.

Other implementations rely on integer types of the same size and
element width as the gentype, such as short/ushort for half, long/ulong
for double, etc.

Users might also rely on as_type or convert_type builtins to/from these
types.

The previous method we used to define intN was unscalable if we wanted
to expose more types and helpers.

This commit introduces a simpler system whereby several macros are
defined at the beginning of gentype.inc. These rely on concatenating
with the vector size. To facilitate this system, scalar gentypes now
define an empty vector size. It was previously undefined, which was
dangerous. An added benefit is that it matches how the integer
gentype.inc vector size has been working.

These macros will be especially helpful for the definitions of
logb/ilogb in an upcoming patch.
@frasercrmck frasercrmck added the libclc libclc OpenCL library label Feb 20, 2025
@frasercrmck frasercrmck requested a review from arsenm February 20, 2025 14:51
@frasercrmck frasercrmck merged commit ae57854 into llvm:main Feb 20, 2025
10 checks passed
@frasercrmck frasercrmck deleted the libclc-gentype-macros branch February 20, 2025 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libclc libclc OpenCL library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants