mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
target/loongarch: Add LASX data support
Signed-off-by: Song Gao <gaosong@loongson.cn> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20230914022645.1151356-12-gaosong@loongson.cn>
This commit is contained in:
parent
cd1006176b
commit
008a3b1662
9 changed files with 86 additions and 34 deletions
|
@ -12,6 +12,7 @@
|
||||||
#include "linux-user/trace.h"
|
#include "linux-user/trace.h"
|
||||||
|
|
||||||
#include "target/loongarch/internals.h"
|
#include "target/loongarch/internals.h"
|
||||||
|
#include "target/loongarch/vec.h"
|
||||||
|
|
||||||
/* FP context was used */
|
/* FP context was used */
|
||||||
#define SC_USED_FP (1 << 0)
|
#define SC_USED_FP (1 << 0)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "cpu-csr.h"
|
#include "cpu-csr.h"
|
||||||
#include "sysemu/reset.h"
|
#include "sysemu/reset.h"
|
||||||
#include "tcg/tcg.h"
|
#include "tcg/tcg.h"
|
||||||
|
#include "vec.h"
|
||||||
|
|
||||||
const char * const regnames[32] = {
|
const char * const regnames[32] = {
|
||||||
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
|
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
|
||||||
|
|
|
@ -251,18 +251,20 @@ FIELD(TLB_MISC, ASID, 1, 10)
|
||||||
FIELD(TLB_MISC, VPPN, 13, 35)
|
FIELD(TLB_MISC, VPPN, 13, 35)
|
||||||
FIELD(TLB_MISC, PS, 48, 6)
|
FIELD(TLB_MISC, PS, 48, 6)
|
||||||
|
|
||||||
#define LSX_LEN (128)
|
#define LSX_LEN (128)
|
||||||
|
#define LASX_LEN (256)
|
||||||
|
|
||||||
typedef union VReg {
|
typedef union VReg {
|
||||||
int8_t B[LSX_LEN / 8];
|
int8_t B[LASX_LEN / 8];
|
||||||
int16_t H[LSX_LEN / 16];
|
int16_t H[LASX_LEN / 16];
|
||||||
int32_t W[LSX_LEN / 32];
|
int32_t W[LASX_LEN / 32];
|
||||||
int64_t D[LSX_LEN / 64];
|
int64_t D[LASX_LEN / 64];
|
||||||
uint8_t UB[LSX_LEN / 8];
|
uint8_t UB[LASX_LEN / 8];
|
||||||
uint16_t UH[LSX_LEN / 16];
|
uint16_t UH[LASX_LEN / 16];
|
||||||
uint32_t UW[LSX_LEN / 32];
|
uint32_t UW[LASX_LEN / 32];
|
||||||
uint64_t UD[LSX_LEN / 64];
|
uint64_t UD[LASX_LEN / 64];
|
||||||
Int128 Q[LSX_LEN / 128];
|
Int128 Q[LASX_LEN / 128];
|
||||||
}VReg;
|
} VReg;
|
||||||
|
|
||||||
typedef union fpr_t fpr_t;
|
typedef union fpr_t fpr_t;
|
||||||
union fpr_t {
|
union fpr_t {
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "internals.h"
|
#include "internals.h"
|
||||||
#include "exec/gdbstub.h"
|
#include "exec/gdbstub.h"
|
||||||
#include "gdbstub/helpers.h"
|
#include "gdbstub/helpers.h"
|
||||||
|
#include "vec.h"
|
||||||
|
|
||||||
uint64_t read_fcc(CPULoongArchState *env)
|
uint64_t read_fcc(CPULoongArchState *env)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,28 +21,6 @@
|
||||||
/* Global bit for huge page */
|
/* Global bit for huge page */
|
||||||
#define LOONGARCH_HGLOBAL_SHIFT 12
|
#define LOONGARCH_HGLOBAL_SHIFT 12
|
||||||
|
|
||||||
#if HOST_BIG_ENDIAN
|
|
||||||
#define B(x) B[15 - (x)]
|
|
||||||
#define H(x) H[7 - (x)]
|
|
||||||
#define W(x) W[3 - (x)]
|
|
||||||
#define D(x) D[1 - (x)]
|
|
||||||
#define UB(x) UB[15 - (x)]
|
|
||||||
#define UH(x) UH[7 - (x)]
|
|
||||||
#define UW(x) UW[3 - (x)]
|
|
||||||
#define UD(x) UD[1 -(x)]
|
|
||||||
#define Q(x) Q[x]
|
|
||||||
#else
|
|
||||||
#define B(x) B[x]
|
|
||||||
#define H(x) H[x]
|
|
||||||
#define W(x) W[x]
|
|
||||||
#define D(x) D[x]
|
|
||||||
#define UB(x) UB[x]
|
|
||||||
#define UH(x) UH[x]
|
|
||||||
#define UW(x) UW[x]
|
|
||||||
#define UD(x) UD[x]
|
|
||||||
#define Q(x) Q[x]
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void loongarch_translate_init(void);
|
void loongarch_translate_init(void);
|
||||||
|
|
||||||
void loongarch_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
|
void loongarch_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "migration/cpu.h"
|
#include "migration/cpu.h"
|
||||||
#include "internals.h"
|
#include "vec.h"
|
||||||
|
|
||||||
static const VMStateDescription vmstate_fpu_reg = {
|
static const VMStateDescription vmstate_fpu_reg = {
|
||||||
.name = "fpu_reg",
|
.name = "fpu_reg",
|
||||||
|
@ -76,6 +76,39 @@ static const VMStateDescription vmstate_lsx = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const VMStateDescription vmstate_lasxh_reg = {
|
||||||
|
.name = "lasxh_reg",
|
||||||
|
.version_id = 1,
|
||||||
|
.minimum_version_id = 1,
|
||||||
|
.fields = (VMStateField[]) {
|
||||||
|
VMSTATE_UINT64(UD(2), VReg),
|
||||||
|
VMSTATE_UINT64(UD(3), VReg),
|
||||||
|
VMSTATE_END_OF_LIST()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#define VMSTATE_LASXH_REGS(_field, _state, _start) \
|
||||||
|
VMSTATE_STRUCT_SUB_ARRAY(_field, _state, _start, 32, 0, \
|
||||||
|
vmstate_lasxh_reg, fpr_t)
|
||||||
|
|
||||||
|
static bool lasx_needed(void *opaque)
|
||||||
|
{
|
||||||
|
LoongArchCPU *cpu = opaque;
|
||||||
|
|
||||||
|
return FIELD_EX64(cpu->env.cpucfg[2], CPUCFG2, LASX);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const VMStateDescription vmstate_lasx = {
|
||||||
|
.name = "cpu/lasx",
|
||||||
|
.version_id = 1,
|
||||||
|
.minimum_version_id = 1,
|
||||||
|
.needed = lasx_needed,
|
||||||
|
.fields = (VMStateField[]) {
|
||||||
|
VMSTATE_LASXH_REGS(env.fpr, LoongArchCPU, 0),
|
||||||
|
VMSTATE_END_OF_LIST()
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
/* TLB state */
|
/* TLB state */
|
||||||
const VMStateDescription vmstate_tlb = {
|
const VMStateDescription vmstate_tlb = {
|
||||||
.name = "cpu/tlb",
|
.name = "cpu/tlb",
|
||||||
|
@ -163,6 +196,7 @@ const VMStateDescription vmstate_loongarch_cpu = {
|
||||||
.subsections = (const VMStateDescription*[]) {
|
.subsections = (const VMStateDescription*[]) {
|
||||||
&vmstate_fpu,
|
&vmstate_fpu,
|
||||||
&vmstate_lsx,
|
&vmstate_lsx,
|
||||||
|
&vmstate_lasx,
|
||||||
NULL
|
NULL
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "fpu/softfloat.h"
|
#include "fpu/softfloat.h"
|
||||||
#include "translate.h"
|
#include "translate.h"
|
||||||
#include "internals.h"
|
#include "internals.h"
|
||||||
|
#include "vec.h"
|
||||||
|
|
||||||
/* Global register indices */
|
/* Global register indices */
|
||||||
TCGv cpu_gpr[32], cpu_pc;
|
TCGv cpu_gpr[32], cpu_pc;
|
||||||
|
|
33
target/loongarch/vec.h
Normal file
33
target/loongarch/vec.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
/*
|
||||||
|
* QEMU LoongArch vector utilitites
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Loongson Technology Corporation Limited
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LOONGARCH_VEC_H
|
||||||
|
#define LOONGARCH_VEC_H
|
||||||
|
|
||||||
|
#if HOST_BIG_ENDIAN
|
||||||
|
#define B(x) B[(x) ^ 15]
|
||||||
|
#define H(x) H[(x) ^ 7]
|
||||||
|
#define W(x) W[(x) ^ 3]
|
||||||
|
#define D(x) D[(x) ^ 1]
|
||||||
|
#define UB(x) UB[(x) ^ 15]
|
||||||
|
#define UH(x) UH[(x) ^ 7]
|
||||||
|
#define UW(x) UW[(x) ^ 3]
|
||||||
|
#define UD(x) UD[(x) ^ 1]
|
||||||
|
#define Q(x) Q[x]
|
||||||
|
#else
|
||||||
|
#define B(x) B[x]
|
||||||
|
#define H(x) H[x]
|
||||||
|
#define W(x) W[x]
|
||||||
|
#define D(x) D[x]
|
||||||
|
#define UB(x) UB[x]
|
||||||
|
#define UH(x) UH[x]
|
||||||
|
#define UW(x) UW[x]
|
||||||
|
#define UD(x) UD[x]
|
||||||
|
#define Q(x) Q[x]
|
||||||
|
#endif /* HOST_BIG_ENDIAN */
|
||||||
|
|
||||||
|
#endif /* LOONGARCH_VEC_H */
|
|
@ -12,6 +12,7 @@
|
||||||
#include "fpu/softfloat.h"
|
#include "fpu/softfloat.h"
|
||||||
#include "internals.h"
|
#include "internals.h"
|
||||||
#include "tcg/tcg.h"
|
#include "tcg/tcg.h"
|
||||||
|
#include "vec.h"
|
||||||
|
|
||||||
#define DO_ADD(a, b) (a + b)
|
#define DO_ADD(a, b) (a + b)
|
||||||
#define DO_SUB(a, b) (a - b)
|
#define DO_SUB(a, b) (a - b)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue