fls.S 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* fls.S: SPARC default fls definition.
  2. *
  3. * SPARC default fls definition, which follows the same algorithm as
  4. * in generic fls(). This function will be boot time patched on T4
  5. * and onward.
  6. */
  7. #include <linux/linkage.h>
  8. #include <asm/export.h>
  9. .text
  10. .register %g2, #scratch
  11. .register %g3, #scratch
  12. ENTRY(fls)
  13. brz,pn %o0, 6f
  14. mov 0, %o1
  15. sethi %hi(0xffff0000), %g3
  16. mov %o0, %g2
  17. andcc %o0, %g3, %g0
  18. be,pt %icc, 8f
  19. mov 32, %o1
  20. sethi %hi(0xff000000), %g3
  21. andcc %g2, %g3, %g0
  22. bne,pt %icc, 3f
  23. sethi %hi(0xf0000000), %g3
  24. sll %o0, 8, %o0
  25. 1:
  26. add %o1, -8, %o1
  27. sra %o0, 0, %o0
  28. mov %o0, %g2
  29. 2:
  30. sethi %hi(0xf0000000), %g3
  31. 3:
  32. andcc %g2, %g3, %g0
  33. bne,pt %icc, 4f
  34. sethi %hi(0xc0000000), %g3
  35. sll %o0, 4, %o0
  36. add %o1, -4, %o1
  37. sra %o0, 0, %o0
  38. mov %o0, %g2
  39. 4:
  40. andcc %g2, %g3, %g0
  41. be,a,pt %icc, 7f
  42. sll %o0, 2, %o0
  43. 5:
  44. xnor %g0, %o0, %o0
  45. srl %o0, 31, %o0
  46. sub %o1, %o0, %o1
  47. 6:
  48. jmp %o7 + 8
  49. sra %o1, 0, %o0
  50. 7:
  51. add %o1, -2, %o1
  52. ba,pt %xcc, 5b
  53. sra %o0, 0, %o0
  54. 8:
  55. sll %o0, 16, %o0
  56. sethi %hi(0xff000000), %g3
  57. sra %o0, 0, %o0
  58. mov %o0, %g2
  59. andcc %g2, %g3, %g0
  60. bne,pt %icc, 2b
  61. mov 16, %o1
  62. ba,pt %xcc, 1b
  63. sll %o0, 8, %o0
  64. ENDPROC(fls)
  65. EXPORT_SYMBOL(fls)