A new implementation of the Subclass Data exposed from llvm::Value, which simplifies the process of adding new data/flags into the llvm::Value::SubclassData.
In detail, the new implementation offers the following new features:
- static assert - that the declared accumulated bitfields do not exceed the underlying subclass data size (note that int the New implementation it is automatically added on declaration)
- runtime assert - that a new value set, fits into the the bitfield (without truncation).
- typed - as opposed to using a representative type (like int) and then cast to the actual required type (like bool or enum). Typed (ordinary) bitfields cannot be implemented correctly in MSVC, as the types of all the bitfields must be of the same type. Using typed bitfields also saves us the need to synchronize the use of unsigned/signed int with the actual type needed.
- declare (a bitfield) in a single line - as opposed to the need to declare helpers or somekind, like enum (manually).
- clean bitfields - without exposing a bit manipulation enum.
- automatic inheritance of unused bits - no need to get offset from super (manually).
- automatic calculation of unused bits - changing a single bitfield doesn't require any other change, but the actual bitfield itself (as opposed to changing also the sum of the bit count used by the class, in an enum - for exmple).
- implicit reference to superclass - as opposed to the need to use the base class' info explicitly.
- no need to know anything about any of the base classes.
The core of the change is present in the 2 new files: BitField.h and SubclassData.h (while the other changed files are just refactored to use the new implementation).
An example of the run-time benefits (to add to the compile-time benefits mentioned above):
By using the new implementation, I have managed to move the SSID field (that some Instructions have) into the Subclass Data of the Instructions, and in turn reduce the size of those instructions by 8 bytes.