Bitfield accessors
Jarrett Billingsley
kb3ctd2 at yahoo.com
Wed Nov 21 17:37:07 PST 2007
"bearophile" <bearophileHUGS at lycos.com> wrote in message
news:fi0054$2q9t$1 at digitalmars.com...
> I have compiled them with:
> DMD: v1.023
> dmd -O -inline -release bitfields1.d
>
> gcc: V. 3.4.2 (mingw-special)
> gcc -O3 -s bitfields1.c -o bitfields1
>
> ...
> Just for reference the ASM code of the following C code:
> ...
> I have no good way to see the ASM generated by dmd yet (I may buy Walter's
> utility). (Maybe some of you can show that asm, but remember to remove the
> outer j loop as in the C version).
This isn't an entirely unbiased comparison. If you used dmd and dmc, or gcc
and gdc, that would take out at least one very large variable: that dmd and
gcc have two completely different backends and optimizers. From anecdotal
evidence I'd say the gcc (and by proxy, gdc) backend is far more mature than
dmd's when it comes to optimization.
> My obvious conclusion is that I hope to see built-in bitfields in D ;-)
> The D docs say they aren't used often, but now and then I translate C code
> to D and I don't want to write many (slow) getter and setter properties
> like that :-)
I agree. Bitfields are "seldom used" but when you need them for system
programming (which is what D is supposed to be for!) they're an awful pain
to have to emulate.
More information about the Digitalmars-d-learn
mailing list