mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-11 01:15:37 +00:00
target/arm: Move some functions used only in translate-neon.inc.c to that file
The functions neon_element_offset(), neon_load_element(), neon_load_element64(), neon_store_element() and neon_store_element64() are used only in the translate-neon.inc.c file, so move their definitions there. Since the .inc.c file is #included in translate.c this doesn't make much difference currently, but it's a more logical place to put the functions and it might be helpful if we ever decide to try to make the .inc.c files genuinely separate compilation units. Backports commit 6fb5787898aab6aa04887fed9cf3220dd4c3f36a from qemu
This commit is contained in:
parent
0b06317dc4
commit
083d207fb0
|
@ -54,6 +54,111 @@ static inline int rsub_8(DisasContext *s, int x)
|
|||
#include "decode-neon-ls.inc.c"
|
||||
#include "decode-neon-shared.inc.c"
|
||||
|
||||
/* Return the offset of a 2**SIZE piece of a NEON register, at index ELE,
|
||||
* where 0 is the least significant end of the register.
|
||||
*/
|
||||
static inline long
|
||||
neon_element_offset(int reg, int element, MemOp size)
|
||||
{
|
||||
int element_size = 1 << size;
|
||||
int ofs = element * element_size;
|
||||
#ifdef HOST_WORDS_BIGENDIAN
|
||||
/* Calculate the offset assuming fully little-endian,
|
||||
* then XOR to account for the order of the 8-byte units.
|
||||
*/
|
||||
if (element_size < 8) {
|
||||
ofs ^= 8 - element_size;
|
||||
}
|
||||
#endif
|
||||
return neon_reg_offset(reg, 0) + ofs;
|
||||
}
|
||||
|
||||
static void neon_load_element(DisasContext *s, TCGv_i32 var, int reg, int ele, MemOp mop)
|
||||
{
|
||||
TCGContext *tcg_ctx = s->uc->tcg_ctx;
|
||||
long offset = neon_element_offset(reg, ele, mop & MO_SIZE);
|
||||
|
||||
switch (mop) {
|
||||
case MO_UB:
|
||||
tcg_gen_ld8u_i32(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_UW:
|
||||
tcg_gen_ld16u_i32(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_UL:
|
||||
tcg_gen_ld_i32(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
static void neon_load_element64(DisasContext *s, TCGv_i64 var, int reg, int ele, MemOp mop)
|
||||
{
|
||||
TCGContext *tcg_ctx = s->uc->tcg_ctx;
|
||||
long offset = neon_element_offset(reg, ele, mop & MO_SIZE);
|
||||
|
||||
switch (mop) {
|
||||
case MO_UB:
|
||||
tcg_gen_ld8u_i64(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_UW:
|
||||
tcg_gen_ld16u_i64(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_UL:
|
||||
tcg_gen_ld32u_i64(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_Q:
|
||||
tcg_gen_ld_i64(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
static void neon_store_element(DisasContext *s, int reg, int ele, MemOp size, TCGv_i32 var)
|
||||
{
|
||||
TCGContext *tcg_ctx = s->uc->tcg_ctx;
|
||||
long offset = neon_element_offset(reg, ele, size);
|
||||
|
||||
switch (size) {
|
||||
case MO_8:
|
||||
tcg_gen_st8_i32(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_16:
|
||||
tcg_gen_st16_i32(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_32:
|
||||
tcg_gen_st_i32(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
static void neon_store_element64(DisasContext *s, int reg, int ele, MemOp size, TCGv_i64 var)
|
||||
{
|
||||
TCGContext *tcg_ctx = s->uc->tcg_ctx;
|
||||
long offset = neon_element_offset(reg, ele, size);
|
||||
|
||||
switch (size) {
|
||||
case MO_8:
|
||||
tcg_gen_st8_i64(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_16:
|
||||
tcg_gen_st16_i64(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_32:
|
||||
tcg_gen_st32_i64(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_64:
|
||||
tcg_gen_st_i64(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
static bool trans_VCMLA(DisasContext *s, arg_VCMLA *a)
|
||||
{
|
||||
int opr_sz;
|
||||
|
|
|
@ -1178,25 +1178,6 @@ neon_reg_offset (int reg, int n)
|
|||
return vfp_reg_offset(0, sreg);
|
||||
}
|
||||
|
||||
/* Return the offset of a 2**SIZE piece of a NEON register, at index ELE,
|
||||
* where 0 is the least significant end of the register.
|
||||
*/
|
||||
static inline long
|
||||
neon_element_offset(int reg, int element, MemOp size)
|
||||
{
|
||||
int element_size = 1 << size;
|
||||
int ofs = element * element_size;
|
||||
#ifdef HOST_WORDS_BIGENDIAN
|
||||
/* Calculate the offset assuming fully little-endian,
|
||||
* then XOR to account for the order of the 8-byte units.
|
||||
*/
|
||||
if (element_size < 8) {
|
||||
ofs ^= 8 - element_size;
|
||||
}
|
||||
#endif
|
||||
return neon_reg_offset(reg, 0) + ofs;
|
||||
}
|
||||
|
||||
static TCGv_i32 neon_load_reg(DisasContext *s, int reg, int pass)
|
||||
{
|
||||
TCGContext *tcg_ctx = s->uc->tcg_ctx;
|
||||
|
@ -1205,49 +1186,6 @@ static TCGv_i32 neon_load_reg(DisasContext *s, int reg, int pass)
|
|||
return tmp;
|
||||
}
|
||||
|
||||
static void neon_load_element(DisasContext *s, TCGv_i32 var, int reg, int ele, MemOp mop)
|
||||
{
|
||||
TCGContext *tcg_ctx = s->uc->tcg_ctx;
|
||||
long offset = neon_element_offset(reg, ele, mop & MO_SIZE);
|
||||
|
||||
switch (mop) {
|
||||
case MO_UB:
|
||||
tcg_gen_ld8u_i32(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_UW:
|
||||
tcg_gen_ld16u_i32(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_UL:
|
||||
tcg_gen_ld_i32(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
static void neon_load_element64(DisasContext *s, TCGv_i64 var, int reg, int ele, MemOp mop)
|
||||
{
|
||||
TCGContext *tcg_ctx = s->uc->tcg_ctx;
|
||||
long offset = neon_element_offset(reg, ele, mop & MO_SIZE);
|
||||
|
||||
switch (mop) {
|
||||
case MO_UB:
|
||||
tcg_gen_ld8u_i64(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_UW:
|
||||
tcg_gen_ld16u_i64(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_UL:
|
||||
tcg_gen_ld32u_i64(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_Q:
|
||||
tcg_gen_ld_i64(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
static void neon_store_reg(DisasContext *s, int reg, int pass, TCGv_i32 var)
|
||||
{
|
||||
TCGContext *tcg_ctx = s->uc->tcg_ctx;
|
||||
|
@ -1255,49 +1193,6 @@ static void neon_store_reg(DisasContext *s, int reg, int pass, TCGv_i32 var)
|
|||
tcg_temp_free_i32(tcg_ctx, var);
|
||||
}
|
||||
|
||||
static void neon_store_element(DisasContext *s, int reg, int ele, MemOp size, TCGv_i32 var)
|
||||
{
|
||||
TCGContext *tcg_ctx = s->uc->tcg_ctx;
|
||||
long offset = neon_element_offset(reg, ele, size);
|
||||
|
||||
switch (size) {
|
||||
case MO_8:
|
||||
tcg_gen_st8_i32(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_16:
|
||||
tcg_gen_st16_i32(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_32:
|
||||
tcg_gen_st_i32(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
static void neon_store_element64(DisasContext *s, int reg, int ele, MemOp size, TCGv_i64 var)
|
||||
{
|
||||
TCGContext *tcg_ctx = s->uc->tcg_ctx;
|
||||
long offset = neon_element_offset(reg, ele, size);
|
||||
|
||||
switch (size) {
|
||||
case MO_8:
|
||||
tcg_gen_st8_i64(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_16:
|
||||
tcg_gen_st16_i64(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_32:
|
||||
tcg_gen_st32_i64(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
case MO_64:
|
||||
tcg_gen_st_i64(tcg_ctx, var, tcg_ctx->cpu_env, offset);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
static inline void neon_load_reg64(DisasContext *s, TCGv_i64 var, int reg)
|
||||
{
|
||||
TCGContext *tcg_ctx = s->uc->tcg_ctx;
|
||||
|
|
Loading…
Reference in a new issue