target/arm: Introduce finalize_memop_{atom,pair}

Let finalize_memop_atom be the new basic function, with
finalize_memop and finalize_memop_pair testing FEAT_LSE2
to apply the appropriate atomicity.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20230530191438.411344-4-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Richard Henderson 2023-06-06 10:19:35 +01:00 committed by Peter Maydell
parent cf1cbf50e8
commit e452ca5af8
3 changed files with 37 additions and 5 deletions

View File

@ -14098,6 +14098,8 @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase,
tcg_debug_assert(dc->tbid & 1); tcg_debug_assert(dc->tbid & 1);
#endif #endif
dc->lse2 = dc_isar_feature(aa64_lse2, dc);
/* Single step state. The code-generation logic here is: /* Single step state. The code-generation logic here is:
* SS_ACTIVE == 0: * SS_ACTIVE == 0:
* generate code with no special handling for single-stepping (except * generate code with no special handling for single-stepping (except

View File

@ -9168,6 +9168,7 @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
dc->sme_trap_nonstreaming = dc->sme_trap_nonstreaming =
EX_TBFLAG_A32(tb_flags, SME_TRAP_NONSTREAMING); EX_TBFLAG_A32(tb_flags, SME_TRAP_NONSTREAMING);
} }
dc->lse2 = false; /* applies only to aarch64 */
dc->cp_regs = cpu->cp_regs; dc->cp_regs = cpu->cp_regs;
dc->features = env->features; dc->features = env->features;

View File

@ -90,6 +90,7 @@ typedef struct DisasContext {
uint64_t features; /* CPU features bits */ uint64_t features; /* CPU features bits */
bool aarch64; bool aarch64;
bool thumb; bool thumb;
bool lse2;
/* Because unallocated encodings generate different exception syndrome /* Because unallocated encodings generate different exception syndrome
* information from traps due to FP being disabled, we can't do a single * information from traps due to FP being disabled, we can't do a single
* "is fp access disabled" check at a high level in the decode tree. * "is fp access disabled" check at a high level in the decode tree.
@ -557,12 +558,13 @@ static inline TCGv_ptr fpstatus_ptr(ARMFPStatusFlavour flavour)
} }
/** /**
* finalize_memop: * finalize_memop_atom:
* @s: DisasContext * @s: DisasContext
* @opc: size+sign+align of the memory operation * @opc: size+sign+align of the memory operation
* @atom: atomicity of the memory operation
* *
* Build the complete MemOp for a memory operation, including alignment * Build the complete MemOp for a memory operation, including alignment,
* and endianness. * endianness, and atomicity.
* *
* If (op & MO_AMASK) then the operation already contains the required * If (op & MO_AMASK) then the operation already contains the required
* alignment, e.g. for AccType_ATOMIC. Otherwise, this an optionally * alignment, e.g. for AccType_ATOMIC. Otherwise, this an optionally
@ -572,12 +574,39 @@ static inline TCGv_ptr fpstatus_ptr(ARMFPStatusFlavour flavour)
* and this is applied here. Note that there is no way to indicate that * and this is applied here. Note that there is no way to indicate that
* no alignment should ever be enforced; this must be handled manually. * no alignment should ever be enforced; this must be handled manually.
*/ */
static inline MemOp finalize_memop(DisasContext *s, MemOp opc) static inline MemOp finalize_memop_atom(DisasContext *s, MemOp opc, MemOp atom)
{ {
if (s->align_mem && !(opc & MO_AMASK)) { if (s->align_mem && !(opc & MO_AMASK)) {
opc |= MO_ALIGN; opc |= MO_ALIGN;
} }
return opc | s->be_data; return opc | atom | s->be_data;
}
/**
* finalize_memop:
* @s: DisasContext
* @opc: size+sign+align of the memory operation
*
* Like finalize_memop_atom, but with default atomicity.
*/
static inline MemOp finalize_memop(DisasContext *s, MemOp opc)
{
MemOp atom = s->lse2 ? MO_ATOM_WITHIN16 : MO_ATOM_IFALIGN;
return finalize_memop_atom(s, opc, atom);
}
/**
* finalize_memop_pair:
* @s: DisasContext
* @opc: size+sign+align of the memory operation
*
* Like finalize_memop_atom, but with atomicity for a pair.
* C.f. Pseudocode for Mem[], operand ispair.
*/
static inline MemOp finalize_memop_pair(DisasContext *s, MemOp opc)
{
MemOp atom = s->lse2 ? MO_ATOM_WITHIN16_PAIR : MO_ATOM_IFALIGN_PAIR;
return finalize_memop_atom(s, opc, atom);
} }
/** /**