Skip to contentSkip to conversation

target/microblaze: Build more files once

PATCH In review Philippe Mathieu-Daudé 2 participants 13 messages Jan 6 – Jan 7 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover target/microblaze: Build more files once

Build all hw/microblaze/ once, and most of target/microblaze/.

Philippe Mathieu-Daudé (6):
meson: Allow system binaries to not have target-specific units target/microblaze: Directly check endianness via CPUConfig::endi flag target/microblaze: Avoid target-specific migration headers in
machine.c
target/microblaze: Build system files once
hw/microblaze: Replace TARGET_BIG_ENDIAN -> target_big_endian() hw/microblaze: Build files once

 meson.build                              | 8 +++++---
 hw/microblaze/petalogix_s3adsp1800_mmu.c | 4 +++-
 target/microblaze/machine.c              | 3 ++-
 target/microblaze/translate.c            | 8 ++++----
 hw/microblaze/meson.build                | 2 +-
 target/microblaze/meson.build            | 2 +-
 6 files changed, 16 insertions(+), 11 deletions(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/6 meson: Allow system binaries to not have target-specific units

As we are moving toward a single binary, targets might end without any target-specific objects (all objects being in the 'common' source set). Allow this by checking the target_system_arch[] dictionary contains the target key before using it.

---
 meson.build | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
meson.build +5 -3
index db87358d62d..734c801cc77 100644
@@ -4275,9 +4275,11 @@ foreach target : target_dirs
   endif
   if target.endswith('-softmmu')
     target_type='system'
-    t = target_system_arch[target_base_arch].apply(config_target, strict: false)
-    arch_srcs += t.sources()
-    arch_deps += t.dependencies()
+    if target_base_arch in target_system_arch
+      t = target_system_arch[target_base_arch].apply(config_target, strict: false)
+      arch_srcs += t.sources()
+      arch_deps += t.dependencies()
+    endif
 
     hw_dir = target_name == 'sparc64' ? 'sparc64' : target_base_arch
     if hw_arch.has_key(hw_dir)
Signature · 1 line
2.52.0
Reviewed-by on v1 1/6
#2 lore raw

Re: [PATCH 1/6] meson: Allow system binaries to not have target-specific units

Quoted 20 lines · Philippe Mathieu-Daudé

As we are moving toward a single binary, targets might end without any target-specific objects (all objects being in the 'common' source set). Allow this by checking the target_system_arch[] dictionary contains the target key before using it.

---
  meson.build | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)
meson.build +0 -1
index db87358d62d..734c801cc77 100644
@@ -4275,9 +4275,11 @@ foreach target : target_dirs
    endif
    if target.endswith('-softmmu')
      target_type='system'
-    t = target_system_arch[target_base_arch].apply(config_target, strict: false)

meson.build foreach target : target_dirs · line 4285

Quoted 10 lines
meson.build +5 -2
-    arch_srcs += t.sources()
-    arch_deps += t.dependencies()
+    if target_base_arch in target_system_arch
+      t = target_system_arch[target_base_arch].apply(config_target, strict: false)
+      arch_srcs += t.sources()
+      arch_deps += t.dependencies()
+    endif
 
      hw_dir = target_name == 'sparc64' ? 'sparc64' : target_base_arch
      if hw_arch.has_key(hw_dir)
#3 lore raw

PATCH 2/6 target/microblaze: Directly check endianness via CPUConfig::endi flag

In reply to Philippe Mathieu-Daudé

The MicroBlazeCPUConfig::endi flag reports whether the CPU is configure in little endianness. Directly use this knowledge instead of evaluating MemOp from mo_endian().

---
 target/microblaze/translate.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
target/microblaze/translate.c +4 -4
index fefe5cb552a..0be3c98dc17 100644
@@ -794,7 +794,7 @@ static bool trans_lhuea(DisasContext *dc, arg_typea *arg)
 #else
     TCGv_i64 addr = compute_ldst_addr_ea(dc, arg->ra, arg->rb);
     gen_alignment_check_ea(dc, addr, arg->rb, arg->rd, MO_16, false);
-    (mo_endian(dc) == MO_BE ? gen_helper_lhuea_be : gen_helper_lhuea_le)
+    (dc->cfg->endi ? gen_helper_lhuea_le : gen_helper_lhuea_be)
         (reg_for_write(dc, arg->rd), tcg_env, addr);
     return true;
 #endif
@@ -828,7 +828,7 @@ static bool trans_lwea(DisasContext *dc, arg_typea *arg)
 #else
     TCGv_i64 addr = compute_ldst_addr_ea(dc, arg->ra, arg->rb);
     gen_alignment_check_ea(dc, addr, arg->rb, arg->rd, MO_32, false);
-    (mo_endian(dc) == MO_BE ? gen_helper_lwea_be : gen_helper_lwea_le)
+    (dc->cfg->endi ? gen_helper_lwea_le : gen_helper_lwea_be)
         (reg_for_write(dc, arg->rd), tcg_env, addr);
     return true;
 #endif
@@ -954,7 +954,7 @@ static bool trans_shea(DisasContext *dc, arg_typea *arg)
 #else
     TCGv_i64 addr = compute_ldst_addr_ea(dc, arg->ra, arg->rb);
     gen_alignment_check_ea(dc, addr, arg->rb, arg->rd, MO_16, true);
-    (mo_endian(dc) == MO_BE ? gen_helper_shea_be : gen_helper_shea_le)
+    (dc->cfg->endi ? gen_helper_shea_le : gen_helper_shea_be)
         (tcg_env, reg_for_read(dc, arg->rd), addr);
     return true;
 #endif
@@ -988,7 +988,7 @@ static bool trans_swea(DisasContext *dc, arg_typea *arg)
 #else
     TCGv_i64 addr = compute_ldst_addr_ea(dc, arg->ra, arg->rb);
     gen_alignment_check_ea(dc, addr, arg->rb, arg->rd, MO_32, true);
-    (mo_endian(dc) == MO_BE ? gen_helper_swea_be : gen_helper_swea_le)
+    (dc->cfg->endi ? gen_helper_swea_le : gen_helper_swea_be)
         (tcg_env, reg_for_read(dc, arg->rd), addr);
     return true;
 #endif
Signature · 1 line
2.52.0
Reviewed-by on v1 2/6
#4 lore raw

Re: [PATCH 2/6] target/microblaze: Directly check endianness via CPUConfig::endi flag

Quoted 9 lines · Philippe Mathieu-Daudé

The MicroBlazeCPUConfig::endi flag reports whether the CPU is configure in little endianness. Directly use this knowledge instead of evaluating MemOp from mo_endian().

---
  target/microblaze/translate.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
#5 lore raw

PATCH 3/6 target/microblaze: Avoid target-specific migration headers in machine.c

In reply to Philippe Mathieu-Daudé

machine.c doesn't use any target-specific macro defined by the "migration/cpu.h" header. Use the minimum header requiered:
"migration/qemu-file-types.h" and "migration/vmstate.h", which are not target-specific.

---
 target/microblaze/machine.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
target/microblaze/machine.c +2 -1
index 48efa546d39..f930ff86091 100644
@@ -19,7 +19,8 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
-#include "migration/cpu.h"
+#include "migration/qemu-file-types.h"
+#include "migration/vmstate.h"
 
 
 static const VMStateField vmstate_mmu_fields[] = {
Signature · 1 line
2.52.0
Reviewed-by on v1 3/6
#6 lore raw

Re: [PATCH 3/6] target/microblaze: Avoid target-specific migration headers in machine.c

Quoted 10 lines · Philippe Mathieu-Daudé

machine.c doesn't use any target-specific macro defined by the "migration/cpu.h" header. Use the minimum header requiered:
"migration/qemu-file-types.h" and "migration/vmstate.h", which are not target-specific.

---
  target/microblaze/machine.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
#7 lore raw

PATCH 4/6 target/microblaze: Build system files once

In reply to Philippe Mathieu-Daudé

Previous commit removed the last target-specific use in system units, we can now build them once.

---
 target/microblaze/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/microblaze/meson.build +1 -1
index 3ed4fbb67a7..b30b8f70ace 100644
@@ -17,4 +17,4 @@ microblaze_system_ss.add(files(
 ))
 
 target_arch += {'microblaze': microblaze_ss}
-target_system_arch += {'microblaze': microblaze_system_ss}
+target_common_system_arch += {'microblaze': microblaze_system_ss}
Signature · 1 line
2.52.0
#9 lore raw

PATCH 5/6 hw/microblaze: Replace TARGET_BIG_ENDIAN -> target_big_endian()

In reply to Philippe Mathieu-Daudé

Check endianness at runtime to remove the target-specific TARGET_BIG_ENDIAN definition.

---
 hw/microblaze/petalogix_s3adsp1800_mmu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/microblaze/petalogix_s3adsp1800_mmu.c +3 -1
index 2a853a7fa5f..0c9a6bf2529 100644
@@ -24,6 +24,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/target-info.h"
 #include "qemu/units.h"
 #include "qapi/error.h"
 #include "cpu.h"
@@ -177,7 +178,8 @@ static void petalogix_s3adsp1800_machine_class_init(ObjectClass *oc,
                                           &EndianMode_lookup,
                                           machine_get_endianness,
                                           machine_set_endianness);
-    object_property_set_default_str(prop, TARGET_BIG_ENDIAN ? "big" : "little");
+    object_property_set_default_str(prop, target_big_endian() ? "big"
+                                                              : "little");
     object_class_property_set_description(oc, "endianness",
             "Defines whether the machine runs in big or little endian mode");
 }
Signature · 1 line
2.52.0
#11 lore raw

PATCH 6/6 hw/microblaze: Build files once

In reply to Philippe Mathieu-Daudé

Previous commit removed the last target-specific use in hw model units, we can now build them once.

---
 hw/microblaze/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/microblaze/meson.build +1 -1
index bb9e4eb8f47..d8e7dfbe0e9 100644
@@ -4,4 +4,4 @@ microblaze_ss.add(when: 'CONFIG_PETALOGIX_S3ADSP1800', if_true: files('petalogix
 microblaze_ss.add(when: 'CONFIG_PETALOGIX_ML605', if_true: files('petalogix_ml605_mmu.c'))
 microblaze_ss.add(when: 'CONFIG_XLNX_ZYNQMP_PMU', if_true: files('xlnx-zynqmp-pmu.c'))
 
-hw_arch += {'microblaze': microblaze_ss}
+hw_common_arch += {'microblaze': microblaze_ss}
Signature · 1 line
2.52.0