fls64.S 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* fls64.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. mov -1, %g2
  14. sllx %g2, 32, %g2
  15. and %o0, %g2, %g2
  16. brnz,pt %g2, 1f
  17. mov 63, %g1
  18. sllx %o0, 32, %o0
  19. mov 31, %g1
  20. 1:
  21. mov -1, %g2
  22. sllx %g2, 48, %g2
  23. and %o0, %g2, %g2
  24. brnz,pt %g2, 2f
  25. mov -1, %g2
  26. sllx %o0, 16, %o0
  27. add %g1, -16, %g1
  28. 2:
  29. mov -1, %g2
  30. sllx %g2, 56, %g2
  31. and %o0, %g2, %g2
  32. brnz,pt %g2, 3f
  33. mov -1, %g2
  34. sllx %o0, 8, %o0
  35. add %g1, -8, %g1
  36. 3:
  37. sllx %g2, 60, %g2
  38. and %o0, %g2, %g2
  39. brnz,pt %g2, 4f
  40. mov -1, %g2
  41. sllx %o0, 4, %o0
  42. add %g1, -4, %g1
  43. 4:
  44. sllx %g2, 62, %g2
  45. and %o0, %g2, %g2
  46. brnz,pt %g2, 5f
  47. mov -1, %g3
  48. sllx %o0, 2, %o0
  49. add %g1, -2, %g1
  50. 5:
  51. mov 0, %g2
  52. sllx %g3, 63, %g3
  53. and %o0, %g3, %o0
  54. movre %o0, 1, %g2
  55. sub %g1, %g2, %g1
  56. jmp %o7+8
  57. sra %g1, 0, %o0
  58. ENDPROC(__fls)
  59. EXPORT_SYMBOL(__fls)