在 2023/10/19 下午8:58, Song Gao 写道:
CPULoongArchState adds cpu feature flags features.
Intrduce loongarch_feature() to check feature and
set_feature() to set feature.
Signed-off-by: Song Gao <gaosong@loongson.cn>
---
target/loongarch/cpu.c | 4 ++++
target/loongarch/cpu.h | 32 ++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index ef6922e812..87fcd08110 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -366,6 +366,10 @@ static void loongarch_la464_initfn(Object *obj)
CPULoongArchState *env = &cpu->env;
int i;
+ env->features = 0;
+ set_feature(env, CPU_FEATURE_LSX);
+ set_feature(env, CPU_FEATURE_LASX);
+
for (i = 0; i < 21; i++) {
env->cpucfg[i] = 0x0;
}
diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
index 8b54cf109c..b98064945a 100644
--- a/target/loongarch/cpu.h
+++ b/target/loongarch/cpu.h
@@ -295,6 +295,8 @@ typedef struct CPUArchState {
uint64_t lladdr; /* LL virtual address compared against SC */
uint64_t llval;
+ uint64_t features;
Like what Richard says, it is not necessary to use features here,
cpucfg2 can be used directly.