@samitouri / QOSamiQemu / commits / e98b7d5371

target/ppc: Move lmw, stmw instructions to decodetree

Moving the following instructions to decodetree specification: lmw : D-form stmw : D-form The changes were verified by validating that the tcg ops generated by those instructions remain the same, which were captured with the "-d in_asm,op" flag. Additionally, validated using small assembly tests confirming the the correct register store/load behavior. Also, confirmed the register values are same before and after the change. Signed-off-by: Tanushree Shah <tshah@linux.ibm.com> Reviewed-by: Glenn Miles <milesg@linux.ibm.com> Reviewed-by: Amit Machhiwal <amachhiw@linux.ibm.com> Signed-off-by: Chinmay Rath <rathc@linux.ibm.com> Tested-by: Aniket Sahu <asahu1x@linux.ibm.com> Link: https://lore.kernel.org/qemu-devel/20260827133010.278889-27-rathc@linux.ibm.com Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>

Tanushree Shah committed Aug 27, 2026 at 18:59 UTC e98b7d5371228c2bf8c7e81ccd6ab448770b7656
5 files changed +39 -43
target/ppc/helper.h
+2 -2
@@ -43,8 +43,8 @@ DEF_HELPER_1(check_tlb_flush_local, void, env)
43 DEF_HELPER_1(check_tlb_flush_global, void, env)
44 #endif
45
46 -DEF_HELPER_3(lmw, void, env, tl, i32)
47 -DEF_HELPER_FLAGS_3(stmw, TCG_CALL_NO_WG, void, env, tl, i32)
46 +DEF_HELPER_3(LMW, void, env, tl, i32)
47 +DEF_HELPER_FLAGS_3(STMW, TCG_CALL_NO_WG, void, env, tl, i32)
48 DEF_HELPER_4(LSW, void, env, tl, i32, i32)
49 DEF_HELPER_5(LSWX, void, env, tl, i32, i32, i32)
50 DEF_HELPER_FLAGS_4(STSW, TCG_CALL_NO_WG, void, env, tl, i32, i32)
target/ppc/insn32.decode
+3
@@ -354,6 +354,7 @@ LVDX 011111 ..... ..... ..... 0000010001 - @X
354 LSKU 111010 ..... ..... ............. 0 11 @DD
355 LCXU 111010 ..... ..... ............. 1 11 @DD
356
357 +LMW 101110 ..... ..... ................ @D
358
359 ### Fixed-Point Atomic Load/Store Instructions
360
@@ -399,6 +400,8 @@ STBCIX 011111 ..... ..... ..... 1111010101 - @X
400 STHBRX 011111 ..... ..... ..... 1110010110 - @X
401 STWBRX 011111 ..... ..... ..... 1010010110 - @X
402
403 +STMW 101111 ..... ..... ................ @D
404 +
405 ### Fixed-Point Compare Instructions
406
407 CMP 011111 ... - . ..... ..... 0000000000 - @X_bfl
target/ppc/mem_helper.c
+2 -2
@@ -73,7 +73,7 @@ static void *probe_contiguous(CPUPPCState *env, target_ulong addr, uint32_t nb,
73 return NULL;
74 }
75
76 -void helper_lmw(CPUPPCState *env, target_ulong addr, uint32_t reg)
76 +void helper_LMW(CPUPPCState *env, target_ulong addr, uint32_t reg)
77 {
78 uintptr_t raddr = GETPC();
79 int mmu_idx = ppc_env_mmu_index(env, false);
@@ -98,7 +98,7 @@ void helper_lmw(CPUPPCState *env, target_ulong addr, uint32_t reg)
98 }
99 }
100
101 -void helper_stmw(CPUPPCState *env, target_ulong addr, uint32_t reg)
101 +void helper_STMW(CPUPPCState *env, target_ulong addr, uint32_t reg)
102 {
103 uintptr_t raddr = GETPC();
104 int mmu_idx = ppc_env_mmu_index(env, false);
target/ppc/translate.c
-39
@@ -2455,43 +2455,6 @@ GEN_LDX(lwbr, ld32ur, 0x16, 0x10, PPC_INTEGER);
2455 GEN_LDX_E(ldbr, ld64ur_i64, 0x14, 0x10, PPC_NONE, PPC2_DBRX, CHK_NONE);
2456 #endif /* TARGET_PPC64 */
2457
2458 -/*** Integer load and store multiple ***/
2459 -
2460 -/* lmw */
2461 -static void gen_lmw(DisasContext *ctx)
2462 -{
2463 - TCGv t0;
2464 - TCGv_i32 t1;
2465 -
2466 - if (ctx->le_mode) {
2467 - gen_align_no_le(ctx);
2468 - return;
2469 - }
2470 - gen_set_access_type(ctx, ACCESS_INT);
2471 - t0 = tcg_temp_new();
2472 - t1 = tcg_constant_i32(rD(ctx->opcode));
2473 - gen_addr_imm_index(ctx, t0, 0);
2474 - gen_helper_lmw(tcg_env, t0, t1);
2475 -}
2476 -
2477 -/* stmw */
2478 -static void gen_stmw(DisasContext *ctx)
2479 -{
2480 - TCGv t0;
2481 - TCGv_i32 t1;
2482 -
2483 - if (ctx->le_mode) {
2484 - gen_align_no_le(ctx);
2485 - return;
2486 - }
2487 - gen_set_access_type(ctx, ACCESS_INT);
2488 - t0 = tcg_temp_new();
2489 - t1 = tcg_constant_i32(rS(ctx->opcode));
2490 - gen_addr_imm_index(ctx, t0, 0);
2491 - gen_helper_stmw(tcg_env, t0, t1);
2492 -}
2493 -
2494 -
2458 #if !defined(CONFIG_USER_ONLY)
2459 static inline void gen_check_tlb_flush(DisasContext *ctx, bool global)
2460 {
@@ -4695,8 +4658,6 @@ GEN_HANDLER(rlwnm, 0x17, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
4658 GEN_HANDLER_E(dform39, 0x39, 0xFF, 0xFF, 0x00000000, PPC_NONE, PPC2_ISA205),
4659 /* handles stfdp, stxsd, stxssp */
4660 GEN_HANDLER_E(dform3D, 0x3D, 0xFF, 0xFF, 0x00000000, PPC_NONE, PPC2_ISA205),
4698 -GEN_HANDLER(lmw, 0x2E, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
4699 -GEN_HANDLER(stmw, 0x2F, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
4661 /* ISA v3.0 changed the extended opcode from 62 to 30 */
4662 GEN_HANDLER(rfi, 0x13, 0x12, 0x01, 0x03FF8001, PPC_FLOW),
4663 #if defined(TARGET_PPC64)
target/ppc/translate/fixedpoint-impl.c.inc
+32
@@ -288,6 +288,38 @@ static bool trans_STQCX(DisasContext *ctx, arg_STQCX *a)
288 return true;
289 }
290
291 +/* Load/Store Multiple Word */
292 +static bool do_ldst_multiple(DisasContext *ctx, arg_D *a, bool store)
293 +{
294 + TCGv ea;
295 + TCGv_i32 reg;
296 +
297 + REQUIRE_INSNS_FLAGS(ctx, INTEGER);
298 +
299 + /* Little-endian mode is not supported for multiple word operations */
300 + if (ctx->le_mode) {
301 + gen_align_no_le(ctx);
302 + return true;
303 + }
304 +
305 + gen_set_access_type(ctx, ACCESS_INT);
306 +
307 + reg = tcg_constant_i32(a->rt);
308 + ea = do_ea_calc(ctx, a->ra, tcg_constant_tl(a->si));
309 +
310 + /* Call the appropriate helper function */
311 + if (store) {
312 + gen_helper_STMW(tcg_env, ea, reg);
313 + } else {
314 + gen_helper_LMW(tcg_env, ea, reg);
315 + }
316 +
317 + return true;
318 +}
319 +
320 +TRANS(LMW, do_ldst_multiple, false)
321 +TRANS(STMW, do_ldst_multiple, true)
322 +
323 /*
324 * Fixed-Point Compare Instructions
325 */