mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
target/arm: Implement MVE VLDR/VSTR (non-widening forms)
Implement the forms of the MVE VLDR and VSTR insns which perform non-widening loads of bytes, halfwords or words from memory into vector elements of the same width (encodings T5, T6, T7). (At the moment we know for MVE and M-profile in general that vfp_access_check() can never return false, but we include the conventional return-true-on-failure check for consistency with non-M-profile translation code.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20210617121628.20116-2-peter.maydell@linaro.org
This commit is contained in:
parent
88137f787f
commit
507b6a500c
7 changed files with 351 additions and 0 deletions
|
@ -27,3 +27,122 @@
|
|||
|
||||
/* Include the generated decoder */
|
||||
#include "decode-mve.c.inc"
|
||||
|
||||
typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32);
|
||||
|
||||
/* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */
|
||||
static inline long mve_qreg_offset(unsigned reg)
|
||||
{
|
||||
return offsetof(CPUARMState, vfp.zregs[reg].d[0]);
|
||||
}
|
||||
|
||||
static TCGv_ptr mve_qreg_ptr(unsigned reg)
|
||||
{
|
||||
TCGv_ptr ret = tcg_temp_new_ptr();
|
||||
tcg_gen_addi_ptr(ret, cpu_env, mve_qreg_offset(reg));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool mve_check_qreg_bank(DisasContext *s, int qmask)
|
||||
{
|
||||
/*
|
||||
* Check whether Qregs are in range. For v8.1M only Q0..Q7
|
||||
* are supported, see VFPSmallRegisterBank().
|
||||
*/
|
||||
return qmask < 8;
|
||||
}
|
||||
|
||||
static bool mve_eci_check(DisasContext *s)
|
||||
{
|
||||
/*
|
||||
* This is a beatwise insn: check that ECI is valid (not a
|
||||
* reserved value) and note that we are handling it.
|
||||
* Return true if OK, false if we generated an exception.
|
||||
*/
|
||||
s->eci_handled = true;
|
||||
switch (s->eci) {
|
||||
case ECI_NONE:
|
||||
case ECI_A0:
|
||||
case ECI_A0A1:
|
||||
case ECI_A0A1A2:
|
||||
case ECI_A0A1A2B0:
|
||||
return true;
|
||||
default:
|
||||
/* Reserved value: INVSTATE UsageFault */
|
||||
gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
|
||||
default_exception_el(s));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void mve_update_eci(DisasContext *s)
|
||||
{
|
||||
/*
|
||||
* The helper function will always update the CPUState field,
|
||||
* so we only need to update the DisasContext field.
|
||||
*/
|
||||
if (s->eci) {
|
||||
s->eci = (s->eci == ECI_A0A1A2B0) ? ECI_A0 : ECI_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn)
|
||||
{
|
||||
TCGv_i32 addr;
|
||||
uint32_t offset;
|
||||
TCGv_ptr qreg;
|
||||
|
||||
if (!dc_isar_feature(aa32_mve, s) ||
|
||||
!mve_check_qreg_bank(s, a->qd) ||
|
||||
!fn) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* CONSTRAINED UNPREDICTABLE: we choose to UNDEF */
|
||||
if (a->rn == 15 || (a->rn == 13 && a->w)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mve_eci_check(s) || !vfp_access_check(s)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
offset = a->imm << a->size;
|
||||
if (!a->a) {
|
||||
offset = -offset;
|
||||
}
|
||||
addr = load_reg(s, a->rn);
|
||||
if (a->p) {
|
||||
tcg_gen_addi_i32(addr, addr, offset);
|
||||
}
|
||||
|
||||
qreg = mve_qreg_ptr(a->qd);
|
||||
fn(cpu_env, qreg, addr);
|
||||
tcg_temp_free_ptr(qreg);
|
||||
|
||||
/*
|
||||
* Writeback always happens after the last beat of the insn,
|
||||
* regardless of predication
|
||||
*/
|
||||
if (a->w) {
|
||||
if (!a->p) {
|
||||
tcg_gen_addi_i32(addr, addr, offset);
|
||||
}
|
||||
store_reg(s, a->rn, addr);
|
||||
} else {
|
||||
tcg_temp_free_i32(addr);
|
||||
}
|
||||
mve_update_eci(s);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool trans_VLDR_VSTR(DisasContext *s, arg_VLDR_VSTR *a)
|
||||
{
|
||||
static MVEGenLdStFn * const ldstfns[4][2] = {
|
||||
{ gen_helper_mve_vstrb, gen_helper_mve_vldrb },
|
||||
{ gen_helper_mve_vstrh, gen_helper_mve_vldrh },
|
||||
{ gen_helper_mve_vstrw, gen_helper_mve_vldrw },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
return do_ldst(s, a, ldstfns[a->size][a->l]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue