Bit rotation intrinsics

Todor Totev umbra.tenebris at list.ru
Fri Dec 29 13:16:20 PST 2006


Hello,
I'm playing with some crypto algorithms, mainly to understand what's
going on :-)
I'm trying to implement SHA-2 & friends algorithms in D.
But they are using bit rotations extensively!
So I have 3 choices:
  * emulate rol/ror with shifts & ors - i didn't like this because
i feel uncomfortable replacing one processor instruction with
multi-line function :-(
  * use inline assembler - well, the truth is that I didn't understand
how exactly to use this beast but I love to self-delude that it'll
hurt code portability ;-)
  * kindly request compiler intrinsics for these operations in D.
What is your opinion? Obviously this cannot be done for 1.0 but is it
easy enough to be done at all? Obviously bit rotation is heavily used
in crypto code but it is used occasionally for other purposes too.
And frankly I think that the compiler knows better than me how to order
the instructions for best results so this is a pro-intrinsics too.
Regards,
Todor



More information about the Digitalmars-d mailing list