11a59d1b8SThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-or-later */ 264ff3128SAnton Blanchard/* 364ff3128SAnton Blanchard * 464ff3128SAnton Blanchard * Copyright (C) IBM Corporation, 2010 564ff3128SAnton Blanchard * 664ff3128SAnton Blanchard * Author: Anton Blanchard <anton@au.ibm.com> 764ff3128SAnton Blanchard */ 8*39326182SMasahiro Yamada#include <linux/export.h> 964ff3128SAnton Blanchard#include <asm/processor.h> 1064ff3128SAnton Blanchard#include <asm/ppc_asm.h> 112c86cd18SChristophe Leroy#include <asm/feature-fixups.h> 1264ff3128SAnton Blanchard 1364ff3128SAnton Blanchard/* Note: This code relies on -mminimal-toc */ 1464ff3128SAnton Blanchard 1564ff3128SAnton Blanchard_GLOBAL(__arch_hweight8) 1664ff3128SAnton BlanchardBEGIN_FTR_SECTION 174e991e3cSNicholas Piggin b CFUNC(__sw_hweight8) 1864ff3128SAnton Blanchard nop 1964ff3128SAnton Blanchard nop 2064ff3128SAnton BlanchardFTR_SECTION_ELSE 21c75df6f9SMichael Neuling PPC_POPCNTB(R3,R3) 2264ff3128SAnton Blanchard clrldi r3,r3,64-8 2364ff3128SAnton Blanchard blr 2464ff3128SAnton BlanchardALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB) 259445aa1aSAl ViroEXPORT_SYMBOL(__arch_hweight8) 2664ff3128SAnton Blanchard 2764ff3128SAnton Blanchard_GLOBAL(__arch_hweight16) 2864ff3128SAnton BlanchardBEGIN_FTR_SECTION 294e991e3cSNicholas Piggin b CFUNC(__sw_hweight16) 3064ff3128SAnton Blanchard nop 3164ff3128SAnton Blanchard nop 3264ff3128SAnton Blanchard nop 3364ff3128SAnton Blanchard nop 3464ff3128SAnton BlanchardFTR_SECTION_ELSE 3564ff3128SAnton Blanchard BEGIN_FTR_SECTION_NESTED(50) 36c75df6f9SMichael Neuling PPC_POPCNTB(R3,R3) 3764ff3128SAnton Blanchard srdi r4,r3,8 3864ff3128SAnton Blanchard add r3,r4,r3 3964ff3128SAnton Blanchard clrldi r3,r3,64-8 4064ff3128SAnton Blanchard blr 4164ff3128SAnton Blanchard FTR_SECTION_ELSE_NESTED(50) 4264ff3128SAnton Blanchard clrlwi r3,r3,16 43c75df6f9SMichael Neuling PPC_POPCNTW(R3,R3) 4464ff3128SAnton Blanchard clrldi r3,r3,64-8 4564ff3128SAnton Blanchard blr 4664ff3128SAnton Blanchard ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 50) 4764ff3128SAnton BlanchardALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB) 489445aa1aSAl ViroEXPORT_SYMBOL(__arch_hweight16) 4964ff3128SAnton Blanchard 5064ff3128SAnton Blanchard_GLOBAL(__arch_hweight32) 5164ff3128SAnton BlanchardBEGIN_FTR_SECTION 524e991e3cSNicholas Piggin b CFUNC(__sw_hweight32) 5364ff3128SAnton Blanchard nop 5464ff3128SAnton Blanchard nop 5564ff3128SAnton Blanchard nop 5664ff3128SAnton Blanchard nop 5764ff3128SAnton Blanchard nop 5864ff3128SAnton Blanchard nop 5964ff3128SAnton BlanchardFTR_SECTION_ELSE 6064ff3128SAnton Blanchard BEGIN_FTR_SECTION_NESTED(51) 61c75df6f9SMichael Neuling PPC_POPCNTB(R3,R3) 6264ff3128SAnton Blanchard srdi r4,r3,16 6364ff3128SAnton Blanchard add r3,r4,r3 6464ff3128SAnton Blanchard srdi r4,r3,8 6564ff3128SAnton Blanchard add r3,r4,r3 6664ff3128SAnton Blanchard clrldi r3,r3,64-8 6764ff3128SAnton Blanchard blr 6864ff3128SAnton Blanchard FTR_SECTION_ELSE_NESTED(51) 69c75df6f9SMichael Neuling PPC_POPCNTW(R3,R3) 7064ff3128SAnton Blanchard clrldi r3,r3,64-8 7164ff3128SAnton Blanchard blr 7264ff3128SAnton Blanchard ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 51) 7364ff3128SAnton BlanchardALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB) 749445aa1aSAl ViroEXPORT_SYMBOL(__arch_hweight32) 7564ff3128SAnton Blanchard 7664ff3128SAnton Blanchard_GLOBAL(__arch_hweight64) 7764ff3128SAnton BlanchardBEGIN_FTR_SECTION 784e991e3cSNicholas Piggin b CFUNC(__sw_hweight64) 7964ff3128SAnton Blanchard nop 8064ff3128SAnton Blanchard nop 8164ff3128SAnton Blanchard nop 8264ff3128SAnton Blanchard nop 8364ff3128SAnton Blanchard nop 8464ff3128SAnton Blanchard nop 8564ff3128SAnton Blanchard nop 8664ff3128SAnton Blanchard nop 8764ff3128SAnton BlanchardFTR_SECTION_ELSE 8864ff3128SAnton Blanchard BEGIN_FTR_SECTION_NESTED(52) 89c75df6f9SMichael Neuling PPC_POPCNTB(R3,R3) 9064ff3128SAnton Blanchard srdi r4,r3,32 9164ff3128SAnton Blanchard add r3,r4,r3 9264ff3128SAnton Blanchard srdi r4,r3,16 9364ff3128SAnton Blanchard add r3,r4,r3 9464ff3128SAnton Blanchard srdi r4,r3,8 9564ff3128SAnton Blanchard add r3,r4,r3 9664ff3128SAnton Blanchard clrldi r3,r3,64-8 9764ff3128SAnton Blanchard blr 9864ff3128SAnton Blanchard FTR_SECTION_ELSE_NESTED(52) 99c75df6f9SMichael Neuling PPC_POPCNTD(R3,R3) 10064ff3128SAnton Blanchard clrldi r3,r3,64-8 10164ff3128SAnton Blanchard blr 10264ff3128SAnton Blanchard ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 52) 10364ff3128SAnton BlanchardALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB) 1049445aa1aSAl ViroEXPORT_SYMBOL(__arch_hweight64) 105