This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
adding fast bitops to egcs?
- To: egcs at egcs dot cygnus dot com
- Subject: adding fast bitops to egcs?
- From: Alfred Perlstein <bright at rush dot net>
- Date: Mon, 26 Apr 1999 18:33:28 -0500 (EST)
Maybe it's too much coffee today, but i've always wondered why C
doesn't support stronger bit manipulation routines.
Such as:
1) return position of first set/unset bit from MSB to LSB or LSB to MSB
2) number of bits set
3) bit rotation
this could be done in the optimizer but would be hard to identify afaik...
would it make any sense to add such functionality as an egcs C extention?
as in:
/* assign x the position of the most signifigant bit set in y */
x = msbs(y);
/* assign x the position of the least signifigant unbit set in y */
x = lsbus(y);
The reason is that the C primatives for bit ops are quite poor for scanning
bit strings and most modern hardware supports some of these ops with a
single fast instruction (instead of forcing the coder to use a clumsy
for loop).
This can really help people doing low end harware work that have to decode
bit encoded registers...
thanks,
-Alfred