From 596478d791a0d1aba1bccdd94c5c6674b1c956c4 Mon Sep 17 00:00:00 2001 From: lazymio Date: Mon, 14 Apr 2025 23:09:01 +0800 Subject: [PATCH] Fix use_lsx_instructions --- qemu/include/tcg/tcg.h | 3 +++ qemu/tcg/loongarch64/tcg-target.h | 6 ++---- qemu/tcg/loongarch64/tcg-target.inc.c | 6 ++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/qemu/include/tcg/tcg.h b/qemu/include/tcg/tcg.h index e3b02c1a..bbeb4b9a 100644 --- a/qemu/include/tcg/tcg.h +++ b/qemu/include/tcg/tcg.h @@ -815,6 +815,9 @@ struct TCGContext { char s390x_cpu_reg_names[16][4]; // renamed from original cpu_reg_names[][] to avoid name clash with m68k TCGv_i64 regs[16]; + + // loongarch + bool use_lsx_instructions; }; static inline size_t temp_idx(TCGContext *tcg_ctx, TCGTemp *ts) diff --git a/qemu/tcg/loongarch64/tcg-target.h b/qemu/tcg/loongarch64/tcg-target.h index 60990426..4900a996 100644 --- a/qemu/tcg/loongarch64/tcg-target.h +++ b/qemu/tcg/loongarch64/tcg-target.h @@ -97,8 +97,6 @@ typedef enum { TCG_VEC_TMP0 = TCG_REG_V23, } TCGReg; -extern bool use_lsx_instructions; - /* used for function call generation */ #define TCG_REG_CALL_STACK TCG_REG_SP #define TCG_TARGET_STACK_ALIGN 16 @@ -187,10 +185,10 @@ extern bool use_lsx_instructions; #define TCG_TARGET_HAS_mulsh_i64 1 #define TCG_TARGET_HAS_direct_jump 0 -#define TCG_TARGET_HAS_qemu_ldst_i128 use_lsx_instructions +#define TCG_TARGET_HAS_qemu_ldst_i128 s->use_lsx_instructions #define TCG_TARGET_HAS_v64 0 -#define TCG_TARGET_HAS_v128 use_lsx_instructions +#define TCG_TARGET_HAS_v128 s->use_lsx_instructions #define TCG_TARGET_HAS_v256 0 #define TCG_TARGET_HAS_not_vec 1 diff --git a/qemu/tcg/loongarch64/tcg-target.inc.c b/qemu/tcg/loongarch64/tcg-target.inc.c index aed5e007..cdcd1180 100644 --- a/qemu/tcg/loongarch64/tcg-target.inc.c +++ b/qemu/tcg/loongarch64/tcg-target.inc.c @@ -32,8 +32,6 @@ #include "../tcg-ldst.inc.c" #include -bool use_lsx_instructions; - #ifdef CONFIG_DEBUG_TCG static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { "zero", @@ -2604,10 +2602,10 @@ static void tcg_target_init(TCGContext *s) } if (hwcap & HWCAP_LOONGARCH_LSX) { - use_lsx_instructions = 1; + s->use_lsx_instructions = 1; } #else - use_lsx_instructions = 1; + s->use_lsx_instructions = 1; #endif s->tcg_target_available_regs[TCG_TYPE_I32] = ALL_GENERAL_REGS;