[PATCH 1/2] target/loongarch: Add loongarch vector property unconditionally

Bibo Mao posted 2 patches 6 months, 1 week ago
Maintainers: Song Gao <gaosong@loongson.cn>
There is a newer version of this series
[PATCH 1/2] target/loongarch: Add loongarch vector property unconditionally
Posted by Bibo Mao 6 months, 1 week ago
Currently LSX/LASX vector property is decided by the default value.
Instead vector property should be added unconditionally, and it is
irrelative with its default value. If vector is disabled by default,
vector also can be enabled from command line.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
 target/loongarch/cpu.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index a0cad53676..b5c1ec94af 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -645,16 +645,10 @@ static void loongarch_set_lasx(Object *obj, bool value, Error **errp)
 
 void loongarch_cpu_post_init(Object *obj)
 {
-    LoongArchCPU *cpu = LOONGARCH_CPU(obj);
-
-    if (FIELD_EX32(cpu->env.cpucfg[2], CPUCFG2, LSX)) {
-        object_property_add_bool(obj, "lsx", loongarch_get_lsx,
-                                 loongarch_set_lsx);
-    }
-    if (FIELD_EX32(cpu->env.cpucfg[2], CPUCFG2, LASX)) {
-        object_property_add_bool(obj, "lasx", loongarch_get_lasx,
-                                 loongarch_set_lasx);
-    }
+    object_property_add_bool(obj, "lsx", loongarch_get_lsx,
+                             loongarch_set_lsx);
+    object_property_add_bool(obj, "lasx", loongarch_get_lasx,
+                             loongarch_set_lasx);
 }
 
 static void loongarch_cpu_init(Object *obj)
-- 
2.39.3
Re: [PATCH 1/2] target/loongarch: Add loongarch vector property unconditionally
Posted by gaosong 6 months ago
在 2024/5/21 下午4:05, Bibo Mao 写道:
> Currently LSX/LASX vector property is decided by the default value.
> Instead vector property should be added unconditionally, and it is
> irrelative with its default value. If vector is disabled by default,
> vector also can be enabled from command line.
>
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
Reviewed-by: Song Gao <gaosong@loongson.cn>

Thanks.
Song Gao
>   target/loongarch/cpu.c | 14 ++++----------
>   1 file changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
> index a0cad53676..b5c1ec94af 100644
> --- a/target/loongarch/cpu.c
> +++ b/target/loongarch/cpu.c
> @@ -645,16 +645,10 @@ static void loongarch_set_lasx(Object *obj, bool value, Error **errp)
>   
>   void loongarch_cpu_post_init(Object *obj)
>   {
> -    LoongArchCPU *cpu = LOONGARCH_CPU(obj);
> -
> -    if (FIELD_EX32(cpu->env.cpucfg[2], CPUCFG2, LSX)) {
> -        object_property_add_bool(obj, "lsx", loongarch_get_lsx,
> -                                 loongarch_set_lsx);
> -    }
> -    if (FIELD_EX32(cpu->env.cpucfg[2], CPUCFG2, LASX)) {
> -        object_property_add_bool(obj, "lasx", loongarch_get_lasx,
> -                                 loongarch_set_lasx);
> -    }
> +    object_property_add_bool(obj, "lsx", loongarch_get_lsx,
> +                             loongarch_set_lsx);
> +    object_property_add_bool(obj, "lasx", loongarch_get_lasx,
> +                             loongarch_set_lasx);
>   }
>   
>   static void loongarch_cpu_init(Object *obj)