admin管理员组

文章数量:1287511

The Common Lisp standard includes bit arrays and logical operations on them, such as bit-ior, bit-and,...

What the standard does not seem to offer is logical shifting of bit arrays. Of course, this could be done manually with a simple loop and sbit, but that would not be very efficient.

Looking into the sbcl source code (vm-tran.lisp), on how the other logical bit operations are implemented, the next possible way to implement it would be to mimicri the techniques, used there.

Last not least, there also seems to be a simd instruction, which allows simultaneous shifting (with carry) of 64 bit unsigned integers. This would either call for some vop hackery or to factor the problem out into a foreign library.

So, right now, I am at a cross roads, either trying to implement the function bit-logical-shift within common lisp, or to write myself a shared library and use it via ffi. Which, of course would also open a small can of worms (would need to use simple-finalizer and trivial-garbage for the opaque pointer to the self-made bit arrays...)

I cannot believe, that I am the first, facing this problem and maybe someone here can share their experience, how they solved it.

本文标签: common lispEfficient logical shift for bit arraysStack Overflow