[dmd-internals] Modifying the dmd compiler to add support for bitfields

Sandeep Datta datta.sandeep at gmail.com
Mon Jan 9 03:35:13 PST 2012


Hi Walter,

Thanks for the reply. I am aware of the mixin based solution but the main
motivation for me at this point is getting to know the D compiler well. And
IMHO native support for bitfields will be a welcome new change. I am trying
to write an OS/kernel (https://github.com/SDX2000/Deimos) in D and as far
as machine hugging code is concerned bitfields and unions are a mainstay.
The mixin syntax looks jarring and alien. Please see
https://github.com/SDX2000/Deimos/issues/1 for what I am trying to
accomplish.

I am particularly curious about the dt_t data structure you seem to be
using how does this work?

Regards,
Sandeep Datta.

On Mon, Jan 9, 2012 at 5:53 AM, Walter Bright <walter at digitalmars.com>wrote:

> **
> Bit fields are already done in D using a library solution:
>
> http://d.digitalmars.com/2.0/phobos/std_bitmanip.html
>
>
> On 1/8/2012 7:49 AM, Sandeep Datta wrote:
>
> [Cross post from the D news group]
>
>  Hi All,
>
>  To gain a better understanding of how the D compiler works I am
> trying to implement support for bit fields in structures. I have
> modified the parser code to admit the following syntax (for now)...
>
>  struct A{
>     uint:8 a;
>     uint:5 b;
>     uint:* unused; //Takes up the remaining space.
>     //Raise an error when the computed size is zero.
> }
>
>  You can see my changes here...https://github.com/SDX2000/dmd
>
>  I have been trying to work out a strategy for modifying the compiler
> code generation for quite some time now but haven't been able to
> make much headway in this direction.
>
>  I would appreciate any help at this point.
>
>  Regards,
> Sandeep Datta.
>
>
> _______________________________________________
> dmd-internals mailing listdmd-internals at puremagic.comhttp://lists.puremagic.com/mailman/listinfo/dmd-internals
>
>
> _______________________________________________
> dmd-internals mailing list
> dmd-internals at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-internals
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-internals/attachments/20120109/63b72b44/attachment.html>


More information about the dmd-internals mailing list