This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

adding fast bitops to egcs?



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 



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]