Skip to content
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

Make halide_type_t and halide_type_of constexpr #6340

Merged
merged 5 commits into from
Oct 26, 2021
Merged

Conversation

steven-johnson
Copy link
Contributor

This allows us to do a bit more at compile time in some cases; e.g., we can more reliably collapse things like t == halide_type_t(int, 8) into t.as_u32() == literal-integer, avoiding temporaries.

It also makes it tractable to to do a switch on a series of halide_type_t, since we can now use halide_type_t::as_u32() as a constexpr. There were a number of places that did this in an ad-hoc manner previously; I updated those, and also converted at least one more repeated-if clause into a switch. (TBH, I'm not sure if I'm wild about the syntax, though; it is a bit weedy to scan. Suggestions welcome.)

This allows us to do a bit more at compile time in some cases; e.g., we can more reliably collapse things like `t == halide_type_t(int, 8)` into `t.as_u32() == literal-integer`, avoiding temporaries.

It also makes it tractable to to do a `switch` on a series of `halide_type_t`, since we can now use halide_type_t::as_u32() as a constexpr. There were a number of places that did this in an ad-hoc manner previously; I updated those, and also converted at least one more repeated-if clause into a switch. (TBH, I'm not sure if I'm wild about the syntax, though; it is a bit weedy to scan. Suggestions welcome.)
@steven-johnson
Copy link
Contributor Author

Monday review ping

@steven-johnson steven-johnson merged commit d6d7bbc into master Oct 26, 2021
@steven-johnson steven-johnson deleted the srj/constexpr branch October 26, 2021 17:05
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