Skip to content

Commit 00e5503

Browse files
author
Jeremy Fitzhardinge
committed
Add const-generic bitfield accessors for compile-time optimization
Add a specialized impl block for `__BindgenBitfieldUnit<[u8; N]>` with const-generic methods: `get_const`, `set_const`, `raw_get_const`, and `raw_set_const`. These methods take bit offset and width as const generic parameters, allowing the compiler to fully optimize bitfield access at compile time. Update codegen to use the new const-generic methods for generated bitfield accessors. Since all bitfield offsets and widths are known at code generation time, this enables better optimization. The original runtime-parameter methods are preserved for backwards compatibility with users who provide custom implementations via the blocklist mechanism.
1 parent c993830 commit 00e5503

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+16722
-4266
lines changed

bindgen-tests/tests/expectations/tests/bitfield-32bit-overflow.rs

Lines changed: 967 additions & 584 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/bitfield-large.rs

Lines changed: 337 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/bitfield-linux-32.rs

Lines changed: 316 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/bitfield-method-same-name.rs

Lines changed: 297 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)