Skip to content

Make halide_type_t and halide_type_of constexpr#6340

Merged
steven-johnson merged 5 commits intomasterfrom
srj/constexpr
Oct 26, 2021
Merged

Make halide_type_t and halide_type_of constexpr#6340
steven-johnson merged 5 commits intomasterfrom
srj/constexpr

Conversation

@steven-johnson
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Monday review ping

Comment thread src/runtime/HalideRuntime.h Outdated
@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