On 7/14/11 12:12 PM, Piotr Szturmaj wrote:
Yesterday, I had to write my own bswap for ulong because intrinsic
version supports only uints. Is there any implementation obstacle
preventing ulong and ushort bswap in core.bitop?

Btw. How compiler intrinsics work? I see there's only bswap declaration
(without body) in core.bitop. Where can I find compiler code which
actually substitutes bswap() into real instructions?

The point of the bswap() intrinsic is to allow accessing the x86 bswap instruction directly – if I am not mistaken, it should be equivalent to:

int bswap(int val) {
  asm {
    naked;
    bswap EAX;
    ret;
  }
}

David

Reply via email to