Integrated: Fix jextract after removal of support for sub-byte layouts
Maurizio Cimadamore
mcimadamore at openjdk.org
Wed Feb 1 11:29:17 UTC 2023
On Mon, 30 Jan 2023 21:50:34 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> This patch fixes some test failures which are caused by https://git.openjdk.org/panama-foreign/pull/766.
>
> As that patch removes support for sub-byte layouts, we can no longer represent bitfields using group layouts (because we can no longer model group elements whose size is not a multiple off 8).
>
> In reality, jextract isn't doing much with bitfields: it just generates a bunch of padding layouts of the right size and storing them into a group layout, but this layout, of course, cannot be used for access (because sub-byte layout doesn't work with VarHandles).
>
> To fix this, I have added a new subtype of `Declaration.Variable` - namely, `Declaration.Bitfield` - this is like a variable - it has a name (but no layout), and has a type. On top of this, a `Bitfield` also stores an `offset` (relative to the contained) and a `width` (the size in bits of the bitfield).
>
> Most of the changes in this patch are caused by the fact that the underlying IR for bitfields has changed (as described above). Since bitfields are still variables (whose kind is `BITFIELD`) and since variable of that kind are ignored by the jextract backend, nothing is going to change, really. That said, should we want to add bitfield accessors one day, all the info to generate the accessor should be available in the jextract IR.
This pull request has now been integrated.
Changeset: ddff2741
Author: Maurizio Cimadamore <mcimadamore at openjdk.org>
URL: https://git.openjdk.org/jextract/commit/ddff27410fd30bcf25015bf9cdd297bcfde56416
Stats: 125 lines in 8 files changed: 80 ins; 21 del; 24 mod
Fix jextract after removal of support for sub-byte layouts
Reviewed-by: sundar
-------------
PR: https://git.openjdk.org/jextract/pull/101
More information about the jextract-dev
mailing list