powerpc: Rework PPC_RAW_xxx() macros for prefixed instructions
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Thu, 20 May 2021 10:23:00 +0000 (10:23 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 15 Jun 2021 14:16:47 +0000 (00:16 +1000)
At the time being, we have PPC_RAW_PLXVP() and PPC_RAW_PSTXVP() which
provide a 64 bits value, and then it gets split by open coding to
format it into a 'struct ppc_inst' instruction.

Instead, define a PPC_RAW_xxx_P() and a PPC_RAW_xxx_S() to be used
as is.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/5d146b31b943e7ad674894421db4feef54804b9b.1621506159.git.christophe.leroy@csgroup.eu
arch/powerpc/include/asm/ppc-opcode.h
arch/powerpc/lib/test_emulate_step.c

index 927551d..212f014 100644 (file)
 #define PPC_RAW_STXVP(xsp, a, i)       (0x18000001 | __PPC_XSP(xsp) | ___PPC_RA(a) | IMM_DQ(i))
 #define PPC_RAW_LXVPX(xtp, a, b)       (0x7c00029a | __PPC_XTP(xtp) | ___PPC_RA(a) | ___PPC_RB(b))
 #define PPC_RAW_STXVPX(xsp, a, b)      (0x7c00039a | __PPC_XSP(xsp) | ___PPC_RA(a) | ___PPC_RB(b))
-#define PPC_RAW_PLXVP(xtp, i, a, pr) \
-       ((PPC_PREFIX_8LS | __PPC_PRFX_R(pr) | IMM_D0(i)) << 32 | (0xe8000000 | __PPC_XTP(xtp) | ___PPC_RA(a) | IMM_D1(i)))
-#define PPC_RAW_PSTXVP(xsp, i, a, pr) \
-       ((PPC_PREFIX_8LS | __PPC_PRFX_R(pr) | IMM_D0(i)) << 32 | (0xf8000000 | __PPC_XSP(xsp) | ___PPC_RA(a) | IMM_D1(i)))
+#define PPC_RAW_PLXVP_P(xtp, i, a, pr) (PPC_PREFIX_8LS | __PPC_PRFX_R(pr) | IMM_D0(i))
+#define PPC_RAW_PLXVP_S(xtp, i, a, pr) (0xe8000000 | __PPC_XTP(xtp) | ___PPC_RA(a) | IMM_D1(i))
+#define PPC_RAW_PSTXVP_P(xsp, i, a, pr)        (PPC_PREFIX_8LS | __PPC_PRFX_R(pr) | IMM_D0(i))
+#define PPC_RAW_PSTXVP_S(xsp, i, a, pr)        (0xf8000000 | __PPC_XSP(xsp) | ___PPC_RA(a) | IMM_D1(i))
 #define PPC_RAW_NAP                    (0x4c000364)
 #define PPC_RAW_SLEEP                  (0x4c0003a4)
 #define PPC_RAW_WINKLE                 (0x4c0003e4)
index a0a52fe..6aef002 100644 (file)
@@ -826,8 +826,7 @@ static void __init test_plxvp_pstxvp(void)
         * XTp = 32xTX + 2xTp
         * let RA=3 R=0 D=d0||d1=0 R=0 Tp=1 TX=1
         */
-       instr = ppc_inst_prefix(PPC_RAW_PLXVP(34, 0, 3, 0) >> 32,
-                       PPC_RAW_PLXVP(34, 0, 3, 0) & 0xffffffff);
+       instr = ppc_inst_prefix(PPC_RAW_PLXVP_P(34, 0, 3, 0), PPC_RAW_PLXVP_S(34, 0, 3, 0));
 
        stepped = emulate_step(&regs, instr);
        if (stepped == 1 && cpu_has_feature(CPU_FTR_VSX)) {
@@ -855,8 +854,7 @@ static void __init test_plxvp_pstxvp(void)
         * XSp = 32xSX + 2xSp
         * let RA=3 D=d0||d1=0 R=0 Sp=1 SX=1
         */
-       instr = ppc_inst_prefix(PPC_RAW_PSTXVP(34, 0, 3, 0) >> 32,
-                       PPC_RAW_PSTXVP(34, 0, 3, 0) & 0xffffffff);
+       instr = ppc_inst_prefix(PPC_RAW_PSTXVP_P(34, 0, 3, 0), PPC_RAW_PSTXVP_S(34, 0, 3, 0));
 
        stepped = emulate_step(&regs, instr);