BitVector does not currently provide any operators for shifting left and right by a specified amount. This patch adds them.
The logic here is surprisingly headache-inducing, but I believe I got it correct.
Differential D32244
[BitVector] Add << and >> operators zturner on Apr 19 2017, 2:31 PM. Authored by
Details BitVector does not currently provide any operators for shifting left and right by a specified amount. This patch adds them. The logic here is surprisingly headache-inducing, but I believe I got it correct.
Diff Detail
Event Timeline
Comment Actions Deleted some miscellaneous functions in MathExtras.h that I ended up not using, and added some comments to the implementation to clarify a few minor points. Comment Actions Generally this looks pretty awesome. Thanks for all of this. Minor nitpicks inline. I'd let Craig have a look as well just in case I'm not seeing anything, but good to submit if he's happy as well.
Comment Actions BitVector's word size is dependent on target as it is using "unsigned long" not uint32_t/uint64_t. tcShiftRight is hardcoded to uint64_t though we could probably make it a template. |
This sounds like exactly what APInt:tcShiftRight does. Would it be possible to reuse that code?
In general, it seems like a lot of what BitVector does is also implemented in APInt. Craig, what do you think?