mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
target/arm: Use asimd_imm_const for A64 decode
The A64 AdvSIMD modified-immediate grouping uses almost the same constant encoding that A32 Neon does; reuse asimd_imm_const() (to which we add the AArch64-specific case for cmode 15 op 1) instead of reimplementing it all. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20210628135835.6690-5-peter.maydell@linaro.org
This commit is contained in:
parent
dfd66bc0f3
commit
2c0286dba4
3 changed files with 24 additions and 82 deletions
|
@ -8190,8 +8190,6 @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
|
|||
{
|
||||
int rd = extract32(insn, 0, 5);
|
||||
int cmode = extract32(insn, 12, 4);
|
||||
int cmode_3_1 = extract32(cmode, 1, 3);
|
||||
int cmode_0 = extract32(cmode, 0, 1);
|
||||
int o2 = extract32(insn, 11, 1);
|
||||
uint64_t abcdefgh = extract32(insn, 5, 5) | (extract32(insn, 16, 3) << 5);
|
||||
bool is_neg = extract32(insn, 29, 1);
|
||||
|
@ -8210,83 +8208,13 @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
|
|||
return;
|
||||
}
|
||||
|
||||
/* See AdvSIMDExpandImm() in ARM ARM */
|
||||
switch (cmode_3_1) {
|
||||
case 0: /* Replicate(Zeros(24):imm8, 2) */
|
||||
case 1: /* Replicate(Zeros(16):imm8:Zeros(8), 2) */
|
||||
case 2: /* Replicate(Zeros(8):imm8:Zeros(16), 2) */
|
||||
case 3: /* Replicate(imm8:Zeros(24), 2) */
|
||||
{
|
||||
int shift = cmode_3_1 * 8;
|
||||
imm = bitfield_replicate(abcdefgh << shift, 32);
|
||||
break;
|
||||
}
|
||||
case 4: /* Replicate(Zeros(8):imm8, 4) */
|
||||
case 5: /* Replicate(imm8:Zeros(8), 4) */
|
||||
{
|
||||
int shift = (cmode_3_1 & 0x1) * 8;
|
||||
imm = bitfield_replicate(abcdefgh << shift, 16);
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
if (cmode_0) {
|
||||
/* Replicate(Zeros(8):imm8:Ones(16), 2) */
|
||||
imm = (abcdefgh << 16) | 0xffff;
|
||||
} else {
|
||||
/* Replicate(Zeros(16):imm8:Ones(8), 2) */
|
||||
imm = (abcdefgh << 8) | 0xff;
|
||||
}
|
||||
imm = bitfield_replicate(imm, 32);
|
||||
break;
|
||||
case 7:
|
||||
if (!cmode_0 && !is_neg) {
|
||||
imm = bitfield_replicate(abcdefgh, 8);
|
||||
} else if (!cmode_0 && is_neg) {
|
||||
int i;
|
||||
imm = 0;
|
||||
for (i = 0; i < 8; i++) {
|
||||
if ((abcdefgh) & (1 << i)) {
|
||||
imm |= 0xffULL << (i * 8);
|
||||
}
|
||||
}
|
||||
} else if (cmode_0) {
|
||||
if (is_neg) {
|
||||
imm = (abcdefgh & 0x3f) << 48;
|
||||
if (abcdefgh & 0x80) {
|
||||
imm |= 0x8000000000000000ULL;
|
||||
}
|
||||
if (abcdefgh & 0x40) {
|
||||
imm |= 0x3fc0000000000000ULL;
|
||||
} else {
|
||||
imm |= 0x4000000000000000ULL;
|
||||
}
|
||||
} else {
|
||||
if (o2) {
|
||||
/* FMOV (vector, immediate) - half-precision */
|
||||
imm = vfp_expand_imm(MO_16, abcdefgh);
|
||||
/* now duplicate across the lanes */
|
||||
imm = bitfield_replicate(imm, 16);
|
||||
} else {
|
||||
imm = (abcdefgh & 0x3f) << 19;
|
||||
if (abcdefgh & 0x80) {
|
||||
imm |= 0x80000000;
|
||||
}
|
||||
if (abcdefgh & 0x40) {
|
||||
imm |= 0x3e000000;
|
||||
} else {
|
||||
imm |= 0x40000000;
|
||||
}
|
||||
imm |= (imm << 32);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
if (cmode_3_1 != 7 && is_neg) {
|
||||
imm = ~imm;
|
||||
if (cmode == 15 && o2 && !is_neg) {
|
||||
/* FMOV (vector, immediate) - half-precision */
|
||||
imm = vfp_expand_imm(MO_16, abcdefgh);
|
||||
/* now duplicate across the lanes */
|
||||
imm = bitfield_replicate(imm, 16);
|
||||
} else {
|
||||
imm = asimd_imm_const(abcdefgh, cmode, is_neg);
|
||||
}
|
||||
|
||||
if (!((cmode & 0x9) == 0x1 || (cmode & 0xd) == 0x9)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue