summaryrefslogtreecommitdiff
path: root/arch/powerpc
diff options
context:
space:
mode:
authorSandipan Das <sandipan@linux.ibm.com>2019-02-22 09:53:29 +0300
committerMichael Ellerman <mpe@ellerman.id.au>2019-02-25 16:05:17 +0300
commit32628b5cf3bcdf31d7e00b0e8229051ee2afe96e (patch)
treeeff0fafa6b77197669758dd1698a0efab2784b3d /arch/powerpc
parenta23987ef267a3549667fed5d69c0174e7fc15910 (diff)
downloadlinux-32628b5cf3bcdf31d7e00b0e8229051ee2afe96e.tar.xz
powerpc sstep: Add support for cnttzw, cnttzd instructions
This adds emulation support for the following integer instructions: * Count Trailing Zeros Word (cnttzw[.]) * Count Trailing Zeros Doubleword (cnttzd[.]) Signed-off-by: Sandipan Das <sandipan@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/lib/sstep.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index ab575e02f9b8..94189da4c159 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1820,6 +1820,20 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
do_popcnt(regs, op, regs->gpr[rd], 64);
goto logical_done_nocc;
#endif
+ case 538: /* cnttzw */
+ if (!cpu_has_feature(CPU_FTR_ARCH_300))
+ return -1;
+ val = (unsigned int) regs->gpr[rd];
+ op->val = (val ? __builtin_ctz(val) : 32);
+ goto logical_done;
+#ifdef __powerpc64__
+ case 570: /* cnttzd */
+ if (!cpu_has_feature(CPU_FTR_ARCH_300))
+ return -1;
+ val = regs->gpr[rd];
+ op->val = (val ? __builtin_ctzl(val) : 64);
+ goto logical_done;
+#endif
case 922: /* extsh */
op->val = (signed short) regs->gpr[rd];
goto logical_done;