linux/arch/sparc/lib/ffs.S
<<
>>
Prefs
   1#include <linux/linkage.h>
   2#include <asm/export.h>
   3
   4        .register       %g2,#scratch
   5
   6        .text
   7        .align  32
   8
   9ENTRY(ffs)
  10        brnz,pt %o0, 1f
  11         mov    1, %o1
  12        retl
  13         clr    %o0
  14        nop
  15        nop
  16ENTRY(__ffs)
  17        sllx    %o0, 32, %g1            /* 1  */
  18        srlx    %o0, 32, %g2
  19
  20        clr     %o1                     /* 2  */
  21        movrz   %g1, %g2, %o0
  22
  23        movrz   %g1, 32, %o1            /* 3  */
  241:      clr     %o2
  25
  26        sllx    %o0, (64 - 16), %g1     /* 4  */
  27        srlx    %o0, 16, %g2
  28
  29        movrz   %g1, %g2, %o0           /* 5  */
  30        clr     %o3
  31
  32        movrz   %g1, 16, %o2            /* 6  */
  33        clr     %o4
  34
  35        and     %o0, 0xff, %g1          /* 7  */
  36        srlx    %o0, 8, %g2
  37
  38        movrz   %g1, %g2, %o0           /* 8  */
  39        clr     %o5
  40
  41        movrz   %g1, 8, %o3             /* 9  */
  42        add     %o2, %o1, %o2
  43
  44        and     %o0, 0xf, %g1           /* 10 */
  45        srlx    %o0, 4, %g2
  46
  47        movrz   %g1, %g2, %o0           /* 11 */
  48        add     %o2, %o3, %o2
  49
  50        movrz   %g1, 4, %o4             /* 12 */
  51
  52        and     %o0, 0x3, %g1           /* 13 */
  53        srlx    %o0, 2, %g2
  54
  55        movrz   %g1, %g2, %o0           /* 14 */
  56        add     %o2, %o4, %o2
  57
  58        movrz   %g1, 2, %o5             /* 15 */
  59
  60        and     %o0, 0x1, %g1           /* 16 */
  61
  62        add     %o2, %o5, %o2           /* 17 */
  63        xor     %g1, 0x1, %g1
  64
  65        retl                            /* 18 */
  66         add    %o2, %g1, %o0
  67ENDPROC(ffs)
  68ENDPROC(__ffs)
  69EXPORT_SYMBOL(__ffs)
  70EXPORT_SYMBOL(ffs)
  71
  72        .section        .popc_6insn_patch, "ax"
  73        .word           ffs
  74        brz,pn  %o0, 98f
  75         neg    %o0, %g1
  76        xnor    %o0, %g1, %o1
  77        popc    %o1, %o0
  7898:     retl
  79         nop
  80        .word           __ffs
  81        neg     %o0, %g1
  82        xnor    %o0, %g1, %o1
  83        popc    %o1, %o0
  84        retl
  85         sub    %o0, 1, %o0
  86        nop
  87        .previous
  88