Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 2 | /* |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) IBM Corporation, 2010 |
| 5 | * |
| 6 | * Author: Anton Blanchard <anton@au.ibm.com> |
| 7 | */ |
| 8 | #include <asm/processor.h> |
| 9 | #include <asm/ppc_asm.h> |
Al Viro | 9445aa1 | 2016-01-13 23:33:46 -0500 | [diff] [blame] | 10 | #include <asm/export.h> |
Christophe Leroy | 2c86cd1 | 2018-07-05 16:25:01 +0000 | [diff] [blame] | 11 | #include <asm/feature-fixups.h> |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 12 | |
| 13 | /* Note: This code relies on -mminimal-toc */ |
| 14 | |
| 15 | _GLOBAL(__arch_hweight8) |
| 16 | BEGIN_FTR_SECTION |
Anton Blanchard | b1576fe | 2014-02-04 16:04:35 +1100 | [diff] [blame] | 17 | b __sw_hweight8 |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 18 | nop |
| 19 | nop |
| 20 | FTR_SECTION_ELSE |
Michael Neuling | c75df6f | 2012-06-25 13:33:10 +0000 | [diff] [blame] | 21 | PPC_POPCNTB(R3,R3) |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 22 | clrldi r3,r3,64-8 |
| 23 | blr |
| 24 | ALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB) |
Al Viro | 9445aa1 | 2016-01-13 23:33:46 -0500 | [diff] [blame] | 25 | EXPORT_SYMBOL(__arch_hweight8) |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 26 | |
| 27 | _GLOBAL(__arch_hweight16) |
| 28 | BEGIN_FTR_SECTION |
Anton Blanchard | b1576fe | 2014-02-04 16:04:35 +1100 | [diff] [blame] | 29 | b __sw_hweight16 |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 30 | nop |
| 31 | nop |
| 32 | nop |
| 33 | nop |
| 34 | FTR_SECTION_ELSE |
| 35 | BEGIN_FTR_SECTION_NESTED(50) |
Michael Neuling | c75df6f | 2012-06-25 13:33:10 +0000 | [diff] [blame] | 36 | PPC_POPCNTB(R3,R3) |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 37 | srdi r4,r3,8 |
| 38 | add r3,r4,r3 |
| 39 | clrldi r3,r3,64-8 |
| 40 | blr |
| 41 | FTR_SECTION_ELSE_NESTED(50) |
| 42 | clrlwi r3,r3,16 |
Michael Neuling | c75df6f | 2012-06-25 13:33:10 +0000 | [diff] [blame] | 43 | PPC_POPCNTW(R3,R3) |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 44 | clrldi r3,r3,64-8 |
| 45 | blr |
| 46 | ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 50) |
| 47 | ALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB) |
Al Viro | 9445aa1 | 2016-01-13 23:33:46 -0500 | [diff] [blame] | 48 | EXPORT_SYMBOL(__arch_hweight16) |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 49 | |
| 50 | _GLOBAL(__arch_hweight32) |
| 51 | BEGIN_FTR_SECTION |
Anton Blanchard | b1576fe | 2014-02-04 16:04:35 +1100 | [diff] [blame] | 52 | b __sw_hweight32 |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 53 | nop |
| 54 | nop |
| 55 | nop |
| 56 | nop |
| 57 | nop |
| 58 | nop |
| 59 | FTR_SECTION_ELSE |
| 60 | BEGIN_FTR_SECTION_NESTED(51) |
Michael Neuling | c75df6f | 2012-06-25 13:33:10 +0000 | [diff] [blame] | 61 | PPC_POPCNTB(R3,R3) |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 62 | srdi r4,r3,16 |
| 63 | add r3,r4,r3 |
| 64 | srdi r4,r3,8 |
| 65 | add r3,r4,r3 |
| 66 | clrldi r3,r3,64-8 |
| 67 | blr |
| 68 | FTR_SECTION_ELSE_NESTED(51) |
Michael Neuling | c75df6f | 2012-06-25 13:33:10 +0000 | [diff] [blame] | 69 | PPC_POPCNTW(R3,R3) |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 70 | clrldi r3,r3,64-8 |
| 71 | blr |
| 72 | ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 51) |
| 73 | ALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB) |
Al Viro | 9445aa1 | 2016-01-13 23:33:46 -0500 | [diff] [blame] | 74 | EXPORT_SYMBOL(__arch_hweight32) |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 75 | |
| 76 | _GLOBAL(__arch_hweight64) |
| 77 | BEGIN_FTR_SECTION |
Anton Blanchard | b1576fe | 2014-02-04 16:04:35 +1100 | [diff] [blame] | 78 | b __sw_hweight64 |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 79 | nop |
| 80 | nop |
| 81 | nop |
| 82 | nop |
| 83 | nop |
| 84 | nop |
| 85 | nop |
| 86 | nop |
| 87 | FTR_SECTION_ELSE |
| 88 | BEGIN_FTR_SECTION_NESTED(52) |
Michael Neuling | c75df6f | 2012-06-25 13:33:10 +0000 | [diff] [blame] | 89 | PPC_POPCNTB(R3,R3) |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 90 | srdi r4,r3,32 |
| 91 | add r3,r4,r3 |
| 92 | srdi r4,r3,16 |
| 93 | add r3,r4,r3 |
| 94 | srdi r4,r3,8 |
| 95 | add r3,r4,r3 |
| 96 | clrldi r3,r3,64-8 |
| 97 | blr |
| 98 | FTR_SECTION_ELSE_NESTED(52) |
Michael Neuling | c75df6f | 2012-06-25 13:33:10 +0000 | [diff] [blame] | 99 | PPC_POPCNTD(R3,R3) |
Anton Blanchard | 64ff312 | 2010-08-12 16:28:09 +0000 | [diff] [blame] | 100 | clrldi r3,r3,64-8 |
| 101 | blr |
| 102 | ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 52) |
| 103 | ALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB) |
Al Viro | 9445aa1 | 2016-01-13 23:33:46 -0500 | [diff] [blame] | 104 | EXPORT_SYMBOL(__arch_hweight64) |