hweight_64.S 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License as published by
  4. * the Free Software Foundation; either version 2 of the License, or
  5. * (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. *
  16. * Copyright (C) IBM Corporation, 2010
  17. *
  18. * Author: Anton Blanchard <anton@au.ibm.com>
  19. */
  20. #include <asm/processor.h>
  21. #include <asm/ppc_asm.h>
  22. /* Note: This code relies on -mminimal-toc */
  23. _GLOBAL(__arch_hweight8)
  24. BEGIN_FTR_SECTION
  25. b __sw_hweight8
  26. nop
  27. nop
  28. FTR_SECTION_ELSE
  29. PPC_POPCNTB(R3,R3)
  30. clrldi r3,r3,64-8
  31. blr
  32. ALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB)
  33. _GLOBAL(__arch_hweight16)
  34. BEGIN_FTR_SECTION
  35. b __sw_hweight16
  36. nop
  37. nop
  38. nop
  39. nop
  40. FTR_SECTION_ELSE
  41. BEGIN_FTR_SECTION_NESTED(50)
  42. PPC_POPCNTB(R3,R3)
  43. srdi r4,r3,8
  44. add r3,r4,r3
  45. clrldi r3,r3,64-8
  46. blr
  47. FTR_SECTION_ELSE_NESTED(50)
  48. clrlwi r3,r3,16
  49. PPC_POPCNTW(R3,R3)
  50. clrldi r3,r3,64-8
  51. blr
  52. ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 50)
  53. ALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB)
  54. _GLOBAL(__arch_hweight32)
  55. BEGIN_FTR_SECTION
  56. b __sw_hweight32
  57. nop
  58. nop
  59. nop
  60. nop
  61. nop
  62. nop
  63. FTR_SECTION_ELSE
  64. BEGIN_FTR_SECTION_NESTED(51)
  65. PPC_POPCNTB(R3,R3)
  66. srdi r4,r3,16
  67. add r3,r4,r3
  68. srdi r4,r3,8
  69. add r3,r4,r3
  70. clrldi r3,r3,64-8
  71. blr
  72. FTR_SECTION_ELSE_NESTED(51)
  73. PPC_POPCNTW(R3,R3)
  74. clrldi r3,r3,64-8
  75. blr
  76. ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 51)
  77. ALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB)
  78. _GLOBAL(__arch_hweight64)
  79. BEGIN_FTR_SECTION
  80. b __sw_hweight64
  81. nop
  82. nop
  83. nop
  84. nop
  85. nop
  86. nop
  87. nop
  88. nop
  89. FTR_SECTION_ELSE
  90. BEGIN_FTR_SECTION_NESTED(52)
  91. PPC_POPCNTB(R3,R3)
  92. srdi r4,r3,32
  93. add r3,r4,r3
  94. srdi r4,r3,16
  95. add r3,r4,r3
  96. srdi r4,r3,8
  97. add r3,r4,r3
  98. clrldi r3,r3,64-8
  99. blr
  100. FTR_SECTION_ELSE_NESTED(52)
  101. PPC_POPCNTD(R3,R3)
  102. clrldi r3,r3,64-8
  103. blr
  104. ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 52)
  105. ALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB)