Now, the check-extension() macro has 1 argument instead of 2.
This change helps to reduce redundancy around usage of extensions
name (in the case of the zbb extension, the name was used 3 times).
To implement this, a new variable was introduced:
<extension name>-insn
which represents the instruction support that is being checked.
Additionally, zbb-insn is updated to use $(comma) instead of ",".
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Suggested-by: Jan Beulich <jbeulich@suse.com>
---
xen/arch/riscv/arch.mk | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/xen/arch/riscv/arch.mk b/xen/arch/riscv/arch.mk
index dd242c91d1..17827c302c 100644
--- a/xen/arch/riscv/arch.mk
+++ b/xen/arch/riscv/arch.mk
@@ -13,12 +13,21 @@ riscv-generic-flags := $(riscv-abi-y) -march=$(riscv-march-y)
# check-extension: Check whether extenstion is supported by a compiler and
# an assembler.
-# Usage: $(call check-extension,extension_name,"instr")
-check-extension = $(call as-insn,$(CC) $(riscv-generic-flags)_$(1),$(2),_$(1))
-
-zbb-insn := "andn t0, t0, t0"
-zbb := $(call check-extension,zbb,$(zbb-insn))
-zihintpause := $(call check-extension,zihintpause,"pause")
+# Usage: $(call check-extension,extension_name).
+# it should be defined variable with following name:
+# <extension name>-insn := "insn"
+# which represents an instruction of extension support of which is
+# going to be checked.
+define check-extension =
+$(eval $(1) := \
+ $(call as-insn,$(CC) $(riscv-generic-flags)_$(1),$(value $(1)-insn),_$(1)))
+endef
+
+zbb-insn := "andn t0$(comma)t0$(comma)t0"
+$(call check-extension,zbb)
+
+zihintpause-insn := "pause"
+$(call check-extension,zihintpause)
extensions := $(zbb) $(zihintpause)
--
2.44.0
On 26.04.2024 17:23, Oleksii Kurochko wrote: > Now, the check-extension() macro has 1 argument instead of 2. > This change helps to reduce redundancy around usage of extensions > name (in the case of the zbb extension, the name was used 3 times). > > To implement this, a new variable was introduced: > <extension name>-insn > which represents the instruction support that is being checked. > > Additionally, zbb-insn is updated to use $(comma) instead of ",". Which is merely just-in-case, I suppose, but not strictly necessary anymore? > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> > Suggested-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Just as a remark: Tags want to be put in chronological order. Jan
On Mon, 2024-04-29 at 15:30 +0200, Jan Beulich wrote: > On 26.04.2024 17:23, Oleksii Kurochko wrote: > > Now, the check-extension() macro has 1 argument instead of 2. > > This change helps to reduce redundancy around usage of extensions > > name (in the case of the zbb extension, the name was used 3 times). > > > > To implement this, a new variable was introduced: > > <extension name>-insn > > which represents the instruction support that is being checked. > > > > Additionally, zbb-insn is updated to use $(comma) instead of ",". > > Which is merely just-in-case, I suppose, but not strictly necessary > anymore? Sorry for late reply, you are right, this is not strictly necessary anymore. ~ Oleksii > > > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> > > Suggested-by: Jan Beulich <jbeulich@suse.com> > > Reviewed-by: Jan Beulich <jbeulich@suse.com> > > Just as a remark: Tags want to be put in chronological order. > > Jan
© 2016 - 2024 Red Hat, Inc.