mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
target/loongarch: Add CRC feature flag and use it to gate CRC instructions
This patch replaces the obsolete IOCSR_BRD bit with CRC in cpucfg1[25], in both LA464 and LA132 CPU initialization functions. The corresponding field macro in `cpu.h` is updated to reflect this change. Additionally, the availability macro `avail_CRC()` is introduced in `translate.h` to check the CRC feature flag. All CRC-related instruction translations are updated to be gated by the new CRC feature flag instead of hardcoded CPU features. This ensures correctness and configurability when enabling CRC instructions based on hardware capabilities. Signed-off-by: WANG Rui <wangrui@loongson.cn> Reviewed-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20250418082103.447780-2-wangrui@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn>
This commit is contained in:
@@ -432,7 +432,7 @@ static void loongarch_la464_initfn(Object *obj)
|
||||
data = FIELD_DP32(data, CPUCFG1, EP, 1);
|
||||
data = FIELD_DP32(data, CPUCFG1, RPLV, 1);
|
||||
data = FIELD_DP32(data, CPUCFG1, HP, 1);
|
||||
data = FIELD_DP32(data, CPUCFG1, IOCSR_BRD, 1);
|
||||
data = FIELD_DP32(data, CPUCFG1, CRC, 1);
|
||||
env->cpucfg[1] = data;
|
||||
|
||||
data = 0;
|
||||
@@ -531,7 +531,7 @@ static void loongarch_la132_initfn(Object *obj)
|
||||
data = FIELD_DP32(data, CPUCFG1, EP, 0);
|
||||
data = FIELD_DP32(data, CPUCFG1, RPLV, 0);
|
||||
data = FIELD_DP32(data, CPUCFG1, HP, 1);
|
||||
data = FIELD_DP32(data, CPUCFG1, IOCSR_BRD, 1);
|
||||
data = FIELD_DP32(data, CPUCFG1, CRC, 1);
|
||||
env->cpucfg[1] = data;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ FIELD(CPUCFG1, RI, 21, 1)
|
||||
FIELD(CPUCFG1, EP, 22, 1)
|
||||
FIELD(CPUCFG1, RPLV, 23, 1)
|
||||
FIELD(CPUCFG1, HP, 24, 1)
|
||||
FIELD(CPUCFG1, IOCSR_BRD, 25, 1)
|
||||
FIELD(CPUCFG1, CRC, 25, 1)
|
||||
FIELD(CPUCFG1, MSG_INT, 26, 1)
|
||||
|
||||
/* cpucfg[1].arch */
|
||||
|
||||
@@ -97,11 +97,11 @@ static bool gen_crc(DisasContext *ctx, arg_rrr *a,
|
||||
return true;
|
||||
}
|
||||
|
||||
TRANS(crc_w_b_w, 64, gen_crc, gen_helper_crc32, tcg_constant_tl(1))
|
||||
TRANS(crc_w_h_w, 64, gen_crc, gen_helper_crc32, tcg_constant_tl(2))
|
||||
TRANS(crc_w_w_w, 64, gen_crc, gen_helper_crc32, tcg_constant_tl(4))
|
||||
TRANS(crc_w_d_w, 64, gen_crc, gen_helper_crc32, tcg_constant_tl(8))
|
||||
TRANS(crcc_w_b_w, 64, gen_crc, gen_helper_crc32c, tcg_constant_tl(1))
|
||||
TRANS(crcc_w_h_w, 64, gen_crc, gen_helper_crc32c, tcg_constant_tl(2))
|
||||
TRANS(crcc_w_w_w, 64, gen_crc, gen_helper_crc32c, tcg_constant_tl(4))
|
||||
TRANS(crcc_w_d_w, 64, gen_crc, gen_helper_crc32c, tcg_constant_tl(8))
|
||||
TRANS(crc_w_b_w, CRC, gen_crc, gen_helper_crc32, tcg_constant_tl(1))
|
||||
TRANS(crc_w_h_w, CRC, gen_crc, gen_helper_crc32, tcg_constant_tl(2))
|
||||
TRANS(crc_w_w_w, CRC, gen_crc, gen_helper_crc32, tcg_constant_tl(4))
|
||||
TRANS(crc_w_d_w, CRC, gen_crc, gen_helper_crc32, tcg_constant_tl(8))
|
||||
TRANS(crcc_w_b_w, CRC, gen_crc, gen_helper_crc32c, tcg_constant_tl(1))
|
||||
TRANS(crcc_w_h_w, CRC, gen_crc, gen_helper_crc32c, tcg_constant_tl(2))
|
||||
TRANS(crcc_w_w_w, CRC, gen_crc, gen_helper_crc32c, tcg_constant_tl(4))
|
||||
TRANS(crcc_w_d_w, CRC, gen_crc, gen_helper_crc32c, tcg_constant_tl(8))
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#define avail_LSX(C) (FIELD_EX32((C)->cpucfg2, CPUCFG2, LSX))
|
||||
#define avail_LASX(C) (FIELD_EX32((C)->cpucfg2, CPUCFG2, LASX))
|
||||
#define avail_IOCSR(C) (FIELD_EX32((C)->cpucfg1, CPUCFG1, IOCSR))
|
||||
#define avail_CRC(C) (FIELD_EX32((C)->cpucfg1, CPUCFG1, CRC))
|
||||
|
||||
/*
|
||||
* If an operation is being performed on less than TARGET_LONG_BITS,
|
||||
|
||||
Reference in New Issue
Block a user