Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
January 09, 2012 [dmd-internals] Modifying the dmd compiler to add support for bitfields | ||||
---|---|---|---|---|
| ||||
[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. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.puremagic.com/pipermail/dmd-internals/attachments/20120109/1cfff264/attachment.html> |
January 08, 2012 [dmd-internals] Modifying the dmd compiler to add support for bitfields | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sandeep Datta | 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 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/20120108/7fa640a4/attachment.html> |
January 09, 2012 [dmd-internals] Modifying the dmd compiler to add support for bitfields | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | 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> |
January 09, 2012 [dmd-internals] Modifying the dmd compiler to add support for bitfields | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sandeep Datta | I'm glad you're aware of it. Anyhow, the compiler (optimizer and back end) can already deal with bit fields as it is based on a C compiler. The bitfield ops are replaced by mask and shift in the cgelem.c code. dt_t is simply a way to represent static data. On 1/9/2012 3:35 AM, Sandeep Datta wrote: > 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 <mailto: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 list >> dmd-internals at puremagic.com <mailto:dmd-internals at puremagic.com> >> http://lists.puremagic.com/mailman/listinfo/dmd-internals > > _______________________________________________ > dmd-internals mailing list > dmd-internals at puremagic.com <mailto:dmd-internals at puremagic.com> > http://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/f0b9dcef/attachment-0001.html> |
January 09, 2012 [dmd-internals] Modifying the dmd compiler to add support for bitfields | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Thanks! Sorry, forgot to ask one more detail so I know which list to put him in: is he a fee-only advisor?
Thanks,
Andrei
On 1/9/12 12:10 PM, Walter Bright wrote:
> I'm glad you're aware of it.
>
> Anyhow, the compiler (optimizer and back end) can already deal with bit fields as it is based on a C compiler. The bitfield ops are replaced by mask and shift in the cgelem.c code.
>
> dt_t is simply a way to represent static data.
>
> On 1/9/2012 3:35 AM, Sandeep Datta wrote:
>> 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 <mailto: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 list
>>> dmd-internals at puremagic.com <mailto:dmd-internals at puremagic.com>
>>> http://lists.puremagic.com/mailman/listinfo/dmd-internals
>>
>> _______________________________________________
>> dmd-internals mailing list
>> dmd-internals at puremagic.com <mailto:dmd-internals at puremagic.com>
>> http://lists.puremagic.com/mailman/listinfo/dmd-internals
>>
>>
>>
>> _______________________________________________
>> dmd-internals mailing list
>> dmd-internals at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/dmd-internals
>
>
> _______________________________________________
> dmd-internals mailing list
> dmd-internals at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-internals
|
Copyright © 1999-2021 by the D Language Foundation