[llvm-dev] [RFC] Small Bitfield utilities
Guillaume Chatelet via llvm-dev
llvm-dev at lists.llvm.org
Thu Jun 11 09:04:05 PDT 2020
TL;DR: Have support in ADT for typed values packing into opaque scalar types
- Code & design choices: https://reviews.llvm.org/D81580
- Example of rewrite: https://reviews.llvm.org/D81662
There are places in LLVM where we need to pack typed fields into opaque
For instance, the `XXXInst` classes in
`llvm/include/llvm/IR/Instructions.h` that extract information from
`Value::SubclassData` via `getSubclassDataFromInstruction()`.
The bit twiddling is done manually: this impairs readability and prevent
consistent handling of out of range values (e.g.
More importantly, the bit pattern is scattered throughout the
implementation making it hard to pack additional fields or check for
I think it would be useful to have first class support for this use case in
LLVM so here is a patch to get the discussion started
https://reviews.llvm.org/D81580. And here the `Instruction` code rewritten
with it https://reviews.llvm.org/D81662, I've added comments to highlight
problems in the existing logic.
Feedback would be highly appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev