question about __builtin_ctz

Hi, I have a question. I used '__builtin_ctz' function in arm compiler and it worked well, but I don't know  which header file contains '__builtin_ctz' function. Do you know which header file is needed to use '__builtin_ctz' function?

Parents
  • You can apparently find it (eventually) in the gcc source code.  It wasn't as easy as it should have been.
    Check out ...gcc-arm-src-10.3-2021.10/src/gcc/libgcc/config/arm/lib1funcs.S

    the 32bit function is actually called "ctzsi2":

    ARM_FUNC_START ctzsi2
        rsb    r1, r0, #0
        and    r0, r0, r1
    # if defined (__ARM_FEATURE_CLZ)
        clz    r0, r0
        rsb    r0, r0, #31
        RET

    The source code is rather obscured by conditionals for the various ARM architectures, and doesn't seem to have any comments.  You may be better off compiling for your desired target system and looking at the disassembly.

Reply
  • You can apparently find it (eventually) in the gcc source code.  It wasn't as easy as it should have been.
    Check out ...gcc-arm-src-10.3-2021.10/src/gcc/libgcc/config/arm/lib1funcs.S

    the 32bit function is actually called "ctzsi2":

    ARM_FUNC_START ctzsi2
        rsb    r1, r0, #0
        and    r0, r0, r1
    # if defined (__ARM_FEATURE_CLZ)
        clz    r0, r0
        rsb    r0, r0, #31
        RET

    The source code is rather obscured by conditionals for the various ARM architectures, and doesn't seem to have any comments.  You may be better off compiling for your desired target system and looking at the disassembly.

Children
No data