Support for bit fields and large integers
Radosław Smogura
mail at smogura.eu
Mon Dec 19 17:40:49 UTC 2016
Hi all,
Can I propose updated generator to handle bit fields, scalars, and large integer types (i.e. 128 bits __int128_t __uint128_t)?
The generator implements get/set methods and takes care about: narrowing and widening conversions, sign promotion for C signed / unsigned types, handling of unmodified bits in ‘true' bit fields and conversion to/from BigInteger.
For bit fields, algorithm is based on shifting and masking. Intermediate values are kept in JVM locals to reduce time-window when operation is scheduled for few region operations - can lead to various bit-mixes on concurrent systems. Using locals actually limits the support to values not larger than ~15k bits (limit can be easily increased, by using temporary array).
Implementation is bit long, but it’s rather straight-forward and lot of it is about boring choosing appropriate byte code depending on value size.
http://smogura.eu/webrevs/bit-fields-builder/webrev/
Best regards
Radek
More information about the panama-dev
mailing list