Skip to content

Commit 31d160a

Browse files
committed
tcg/arm: Split out tcg_out_ldstm
Expand these hard-coded instructions symbolically. Reviewed-by: Peter Maydell <[email protected]> Signed-off-by: Richard Henderson <[email protected]>
1 parent b87c1ad commit 31d160a

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

tcg/arm/tcg-target.c.inc

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ typedef enum {
141141
INSN_CLZ = 0x016f0f10,
142142
INSN_RBIT = 0x06ff0f30,
143143

144+
INSN_LDMIA = 0x08b00000,
145+
INSN_STMDB = 0x09200000,
146+
144147
INSN_LDR_IMM = 0x04100000,
145148
INSN_LDR_REG = 0x06100000,
146149
INSN_STR_IMM = 0x04000000,
@@ -593,6 +596,12 @@ static inline void tcg_out_dat_imm(TCGContext *s,
593596
(rn << 16) | (rd << 12) | im);
594597
}
595598

599+
static void tcg_out_ldstm(TCGContext *s, int cond, int opc,
600+
TCGReg rn, uint16_t mask)
601+
{
602+
tcg_out32(s, (cond << 28) | opc | (rn << 16) | mask);
603+
}
604+
596605
/* Note that this routine is used for both LDR and LDRH formats, so we do
597606
not wish to include an immediate shift at this point. */
598607
static void tcg_out_memop_r(TCGContext *s, int cond, ARMInsn opc, TCGReg rt,
@@ -3081,7 +3090,10 @@ static void tcg_target_qemu_prologue(TCGContext *s)
30813090
{
30823091
/* Calling convention requires us to save r4-r11 and lr. */
30833092
/* stmdb sp!, { r4 - r11, lr } */
3084-
tcg_out32(s, (COND_AL << 28) | 0x092d4ff0);
3093+
tcg_out_ldstm(s, COND_AL, INSN_STMDB, TCG_REG_CALL_STACK,
3094+
(1 << TCG_REG_R4) | (1 << TCG_REG_R5) | (1 << TCG_REG_R6) |
3095+
(1 << TCG_REG_R7) | (1 << TCG_REG_R8) | (1 << TCG_REG_R9) |
3096+
(1 << TCG_REG_R10) | (1 << TCG_REG_R11) | (1 << TCG_REG_R14));
30853097

30863098
/* Reserve callee argument and tcg temp space. */
30873099
tcg_out_dat_rI(s, COND_AL, ARITH_SUB, TCG_REG_CALL_STACK,
@@ -3109,7 +3121,10 @@ static void tcg_out_epilogue(TCGContext *s)
31093121
TCG_REG_CALL_STACK, STACK_ADDEND, 1);
31103122

31113123
/* ldmia sp!, { r4 - r11, pc } */
3112-
tcg_out32(s, (COND_AL << 28) | 0x08bd8ff0);
3124+
tcg_out_ldstm(s, COND_AL, INSN_LDMIA, TCG_REG_CALL_STACK,
3125+
(1 << TCG_REG_R4) | (1 << TCG_REG_R5) | (1 << TCG_REG_R6) |
3126+
(1 << TCG_REG_R7) | (1 << TCG_REG_R8) | (1 << TCG_REG_R9) |
3127+
(1 << TCG_REG_R10) | (1 << TCG_REG_R11) | (1 << TCG_REG_PC));
31133128
}
31143129

31153130
typedef struct {

0 commit comments

Comments
 (0)