powerpc sstep: Add support for cnttzw, cnttzd instructions
authorSandipan Das <sandipan@linux.ibm.com>
Fri, 22 Feb 2019 06:53:29 +0000 (12:23 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 25 Feb 2019 13:05:17 +0000 (00:05 +1100)
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>
arch/powerpc/lib/sstep.c

index ab575e02f9b87740d90713f80af057d7c34687dc..94189da4c159232f627018b4017b1cf0a29fbf77 100644 (file)
@@ -1819,6 +1819,20 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
                case 506:       /* popcntd */
                        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];