qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/7] tests/tcg/aarch64: Fix inline assemblies for clang
@ 2024-06-29  8:56 Akihiko Odaki
  2024-06-29  8:56 ` [PATCH v3 1/7] tests/tcg/aarch64: Use -fno-integrated-as Akihiko Odaki
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Akihiko Odaki @ 2024-06-29  8:56 UTC (permalink / raw)
  To: Peter Maydell, Alex Bennée, Philippe Mathieu-Daudé
  Cc: qemu-arm, qemu-devel, Akihiko Odaki, Richard Henderson

Unlike GCC, clang checks if the operands in assembly matches with the
type in C. It also does not support "x" constraint for AArch64 and
complains about them.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
Changes in v3:
- Added patch "tests/tcg/aarch64: Use -fno-integrated-as".
- Added patch "tests/tcg/aarch64: Specify -Wa,-march=armv9-a+sme".
- Dropped patch "tests/docker: Specify --userns keep-id for Podman"
  as it is already queued.
- Link to v2: https://lore.kernel.org/r/20240627-tcg-v2-0-1690a813348e@daynix.com

Changes in v2:
- Removed spurious a compiler flag change for normal SME tests.
- Fixed sme-i16i64 detection.
- Link to v1: https://lore.kernel.org/r/20240626-tcg-v1-0-0bad656307d8@daynix.com

---
Akihiko Odaki (7):
      tests/tcg/aarch64: Use -fno-integrated-as
      tests/tcg/aarch64: Specify -Wa,-march=armv9-a+sme
      tests/tcg/aarch64: Fix test architecture specification
      tests/tcg/aarch64: Explicitly specify register width
      tests/tcg/aarch64: Fix irg operand type
      tests/tcg/aarch64: Do not use x constraint
      tests/tcg/arm: Manually bit-cast half-precision numbers

 tests/tcg/aarch64/bti-1.c         |  6 +++---
 tests/tcg/aarch64/bti-3.c         |  6 +++---
 tests/tcg/aarch64/mte-1.c         |  2 +-
 tests/tcg/aarch64/sme-smopa-2.c   |  2 +-
 tests/tcg/arm/fcvt.c              | 18 ++++++++++--------
 tests/tcg/aarch64/Makefile.target | 21 +++++++++++++++++++--
 6 files changed, 37 insertions(+), 18 deletions(-)
---
base-commit: 046a64b9801343e2e89eef10c7a48eec8d8c0d4f
change-id: 20240624-tcg-bf8116e80afa

Best regards,
-- 
Akihiko Odaki <akihiko.odaki@daynix.com>



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 1/7] tests/tcg/aarch64: Use -fno-integrated-as
  2024-06-29  8:56 [PATCH v3 0/7] tests/tcg/aarch64: Fix inline assemblies for clang Akihiko Odaki
@ 2024-06-29  8:56 ` Akihiko Odaki
  2024-06-29  8:56 ` [PATCH v3 2/7] tests/tcg/aarch64: Specify -Wa,-march=armv9-a+sme Akihiko Odaki
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Akihiko Odaki @ 2024-06-29  8:56 UTC (permalink / raw)
  To: Peter Maydell, Alex Bennée, Philippe Mathieu-Daudé
  Cc: qemu-arm, qemu-devel, Akihiko Odaki

clang version 18.1.6 does not respect -Wa,-march=armv9-a+sme without
-fno-integrated-as. Use it when available.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 tests/tcg/aarch64/Makefile.target | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
index 70d728ae9af7..05f98c80c88d 100644
--- a/tests/tcg/aarch64/Makefile.target
+++ b/tests/tcg/aarch64/Makefile.target
@@ -20,6 +20,9 @@ run-fcvt: fcvt
 
 config-cc.mak: Makefile
 	$(quiet-@)( \
+		if $(call cc-test, -fno-integrated-as); then fno_integrated_as=-fno-integrated-as; else \
+		fno_integrated_as=; fi; \
+		$(call cc-option,-fno-integrated-as,            CROSS_CC_HAS_FNO_INTEGRATED_AS); \
 	    $(call cc-option,-march=armv8.1-a+sve,          CROSS_CC_HAS_SVE); \
 	    $(call cc-option,-march=armv8.1-a+sve2,         CROSS_CC_HAS_SVE2); \
 	    $(call cc-option,-march=armv8.2-a,              CROSS_CC_HAS_ARMV8_2); \
@@ -27,7 +30,7 @@ config-cc.mak: Makefile
 	    $(call cc-option,-march=armv8.5-a,              CROSS_CC_HAS_ARMV8_5); \
 	    $(call cc-option,-mbranch-protection=standard,  CROSS_CC_HAS_ARMV8_BTI); \
 	    $(call cc-option,-march=armv8.5-a+memtag,       CROSS_CC_HAS_ARMV8_MTE); \
-	    $(call cc-option,-Wa$(COMMA)-march=armv9-a+sme, CROSS_AS_HAS_ARMV9_SME)) 3> config-cc.mak
+	    $(call cc-option,-Wa$(COMMA)-march=armv9-a+sme $$fno_integrated_as, CROSS_AS_HAS_ARMV9_SME)) 3> config-cc.mak
 -include config-cc.mak
 
 ifneq ($(CROSS_CC_HAS_ARMV8_2),)
@@ -69,6 +72,9 @@ endif
 # SME Tests
 ifneq ($(CROSS_AS_HAS_ARMV9_SME),)
 AARCH64_TESTS += sme-outprod1 sme-smopa-1 sme-smopa-2
+ifneq ($(CROSS_CC_HAS_FNO_INTEGRATED_AS),)
+sme-%: CFLAGS += -fno-integrated-as
+endif
 endif
 
 # System Registers Tests

-- 
2.45.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 2/7] tests/tcg/aarch64: Specify -Wa,-march=armv9-a+sme
  2024-06-29  8:56 [PATCH v3 0/7] tests/tcg/aarch64: Fix inline assemblies for clang Akihiko Odaki
  2024-06-29  8:56 ` [PATCH v3 1/7] tests/tcg/aarch64: Use -fno-integrated-as Akihiko Odaki
@ 2024-06-29  8:56 ` Akihiko Odaki
  2024-06-29  8:56 ` [PATCH v3 3/7] tests/tcg/aarch64: Fix test architecture specification Akihiko Odaki
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Akihiko Odaki @ 2024-06-29  8:56 UTC (permalink / raw)
  To: Peter Maydell, Alex Bennée, Philippe Mathieu-Daudé
  Cc: qemu-arm, qemu-devel, Akihiko Odaki

The availability of -Wa,-march=armv9-a+sme was checked but it was never
used. Use it for SME tests.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 tests/tcg/aarch64/Makefile.target | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
index 05f98c80c88d..d3e739b566d9 100644
--- a/tests/tcg/aarch64/Makefile.target
+++ b/tests/tcg/aarch64/Makefile.target
@@ -72,6 +72,7 @@ endif
 # SME Tests
 ifneq ($(CROSS_AS_HAS_ARMV9_SME),)
 AARCH64_TESTS += sme-outprod1 sme-smopa-1 sme-smopa-2
+sme-%: CFLAGS += -Wa,-march=armv9-a+sme
 ifneq ($(CROSS_CC_HAS_FNO_INTEGRATED_AS),)
 sme-%: CFLAGS += -fno-integrated-as
 endif

-- 
2.45.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 3/7] tests/tcg/aarch64: Fix test architecture specification
  2024-06-29  8:56 [PATCH v3 0/7] tests/tcg/aarch64: Fix inline assemblies for clang Akihiko Odaki
  2024-06-29  8:56 ` [PATCH v3 1/7] tests/tcg/aarch64: Use -fno-integrated-as Akihiko Odaki
  2024-06-29  8:56 ` [PATCH v3 2/7] tests/tcg/aarch64: Specify -Wa,-march=armv9-a+sme Akihiko Odaki
@ 2024-06-29  8:56 ` Akihiko Odaki
  2024-06-29  8:56 ` [PATCH v3 4/7] tests/tcg/aarch64: Explicitly specify register width Akihiko Odaki
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Akihiko Odaki @ 2024-06-29  8:56 UTC (permalink / raw)
  To: Peter Maydell, Alex Bennée, Philippe Mathieu-Daudé
  Cc: qemu-arm, qemu-devel, Akihiko Odaki

sme-smopa-2.c requires sme-i16i64 but the compiler option used not to
specify it. Instead, the extension was specified with the inline
assembly, resulting in mixing assembly code targeting sme-i1664 and C
code that does not target sme-i1664.

clang version 18.1.6 does not support such mixing so properly specify
the extension with the compiler option instead.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 tests/tcg/aarch64/sme-smopa-2.c   |  2 +-
 tests/tcg/aarch64/Makefile.target | 18 ++++++++++++++----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/tests/tcg/aarch64/sme-smopa-2.c b/tests/tcg/aarch64/sme-smopa-2.c
index c9f48c3bfca2..2c9707065992 100644
--- a/tests/tcg/aarch64/sme-smopa-2.c
+++ b/tests/tcg/aarch64/sme-smopa-2.c
@@ -14,7 +14,7 @@ int main()
     long svl;
 
     /* Validate that we have a wide enough vector for 4 elements. */
-    asm(".arch armv8-r+sme-i64\n\trdsvl %0, #1" : "=r"(svl));
+    asm("rdsvl %0, #1" : "=r"(svl));
     if (svl < 32) {
         return 0;
     }
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
index d3e739b566d9..0a527a9821c2 100644
--- a/tests/tcg/aarch64/Makefile.target
+++ b/tests/tcg/aarch64/Makefile.target
@@ -30,7 +30,8 @@ config-cc.mak: Makefile
 	    $(call cc-option,-march=armv8.5-a,              CROSS_CC_HAS_ARMV8_5); \
 	    $(call cc-option,-mbranch-protection=standard,  CROSS_CC_HAS_ARMV8_BTI); \
 	    $(call cc-option,-march=armv8.5-a+memtag,       CROSS_CC_HAS_ARMV8_MTE); \
-	    $(call cc-option,-Wa$(COMMA)-march=armv9-a+sme $$fno_integrated_as, CROSS_AS_HAS_ARMV9_SME)) 3> config-cc.mak
+	    $(call cc-option,-Wa$(COMMA)-march=armv9-a+sme $$fno_integrated_as, CROSS_AS_HAS_ARMV9_SME); \
+	    $(call cc-option,-march=armv9-a+sme-i16i64 $$fno_integrated_as,     CROSS_AS_HAS_ARMV9_SME_I1664)) 3> config-cc.mak
 -include config-cc.mak
 
 ifneq ($(CROSS_CC_HAS_ARMV8_2),)
@@ -71,10 +72,19 @@ endif
 
 # SME Tests
 ifneq ($(CROSS_AS_HAS_ARMV9_SME),)
-AARCH64_TESTS += sme-outprod1 sme-smopa-1 sme-smopa-2
-sme-%: CFLAGS += -Wa,-march=armv9-a+sme
+AARCH64_TESTS += sme-outprod1 sme-smopa-1
+sme-outprod1 sme-smopa-1: CFLAGS += -Wa,-march=armv9-a+sme
 ifneq ($(CROSS_CC_HAS_FNO_INTEGRATED_AS),)
-sme-%: CFLAGS += -fno-integrated-as
+sme-outprod1 sme-smopa-1: CFLAGS += -fno-integrated-as
+endif
+endif
+
+# SME I16I64 Tests
+ifneq ($(CROSS_AS_HAS_ARMV9_SME_I1664),)
+AARCH64_TESTS += sme-smopa-2
+sme-smopa-2: CFLAGS += -march=armv9-a+sme-i16i64
+ifneq ($(CROSS_CC_HAS_FNO_INTEGRATED_AS),)
+sme-smopa-2: CFLAGS += -fno-integrated-as
 endif
 endif
 

-- 
2.45.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 4/7] tests/tcg/aarch64: Explicitly specify register width
  2024-06-29  8:56 [PATCH v3 0/7] tests/tcg/aarch64: Fix inline assemblies for clang Akihiko Odaki
                   ` (2 preceding siblings ...)
  2024-06-29  8:56 ` [PATCH v3 3/7] tests/tcg/aarch64: Fix test architecture specification Akihiko Odaki
@ 2024-06-29  8:56 ` Akihiko Odaki
  2024-06-29  8:56 ` [PATCH v3 5/7] tests/tcg/aarch64: Fix irg operand type Akihiko Odaki
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Akihiko Odaki @ 2024-06-29  8:56 UTC (permalink / raw)
  To: Peter Maydell, Alex Bennée, Philippe Mathieu-Daudé
  Cc: qemu-arm, qemu-devel, Akihiko Odaki, Richard Henderson

clang version 18.1.6 assumes a register is 64-bit by default and
complains if a 32-bit value is given. Explicitly specify register width
when passing a 32-bit value.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 tests/tcg/aarch64/bti-1.c | 6 +++---
 tests/tcg/aarch64/bti-3.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/tcg/aarch64/bti-1.c b/tests/tcg/aarch64/bti-1.c
index 99a879af23d4..1fada8108d22 100644
--- a/tests/tcg/aarch64/bti-1.c
+++ b/tests/tcg/aarch64/bti-1.c
@@ -17,15 +17,15 @@ static void skip2_sigill(int sig, siginfo_t *info, ucontext_t *uc)
 #define BTI_JC    "hint #38"
 
 #define BTYPE_1(DEST) \
-    asm("mov %0,#1; adr x16, 1f; br x16; 1: " DEST "; mov %0,#0" \
+    asm("mov %w0,#1; adr x16, 1f; br x16; 1: " DEST "; mov %w0,#0" \
         : "=r"(skipped) : : "x16")
 
 #define BTYPE_2(DEST) \
-    asm("mov %0,#1; adr x16, 1f; blr x16; 1: " DEST "; mov %0,#0" \
+    asm("mov %w0,#1; adr x16, 1f; blr x16; 1: " DEST "; mov %w0,#0" \
         : "=r"(skipped) : : "x16", "x30")
 
 #define BTYPE_3(DEST) \
-    asm("mov %0,#1; adr x15, 1f; br x15; 1: " DEST "; mov %0,#0" \
+    asm("mov %w0,#1; adr x15, 1f; br x15; 1: " DEST "; mov %w0,#0" \
         : "=r"(skipped) : : "x15")
 
 #define TEST(WHICH, DEST, EXPECT) \
diff --git a/tests/tcg/aarch64/bti-3.c b/tests/tcg/aarch64/bti-3.c
index 8c534c09d784..6a3bd037bcd6 100644
--- a/tests/tcg/aarch64/bti-3.c
+++ b/tests/tcg/aarch64/bti-3.c
@@ -11,15 +11,15 @@ static void skip2_sigill(int sig, siginfo_t *info, ucontext_t *uc)
 }
 
 #define BTYPE_1() \
-    asm("mov %0,#1; adr x16, 1f; br x16; 1: hint #25; mov %0,#0" \
+    asm("mov %w0,#1; adr x16, 1f; br x16; 1: hint #25; mov %w0,#0" \
         : "=r"(skipped) : : "x16", "x30")
 
 #define BTYPE_2() \
-    asm("mov %0,#1; adr x16, 1f; blr x16; 1: hint #25; mov %0,#0" \
+    asm("mov %w0,#1; adr x16, 1f; blr x16; 1: hint #25; mov %w0,#0" \
         : "=r"(skipped) : : "x16", "x30")
 
 #define BTYPE_3() \
-    asm("mov %0,#1; adr x15, 1f; br x15; 1: hint #25; mov %0,#0" \
+    asm("mov %w0,#1; adr x15, 1f; br x15; 1: hint #25; mov %w0,#0" \
         : "=r"(skipped) : : "x15", "x30")
 
 #define TEST(WHICH, EXPECT) \

-- 
2.45.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 5/7] tests/tcg/aarch64: Fix irg operand type
  2024-06-29  8:56 [PATCH v3 0/7] tests/tcg/aarch64: Fix inline assemblies for clang Akihiko Odaki
                   ` (3 preceding siblings ...)
  2024-06-29  8:56 ` [PATCH v3 4/7] tests/tcg/aarch64: Explicitly specify register width Akihiko Odaki
@ 2024-06-29  8:56 ` Akihiko Odaki
  2024-06-29  8:56 ` [PATCH v3 6/7] tests/tcg/aarch64: Do not use x constraint Akihiko Odaki
  2024-06-29  8:56 ` [PATCH v3 7/7] tests/tcg/arm: Manually bit-cast half-precision numbers Akihiko Odaki
  6 siblings, 0 replies; 9+ messages in thread
From: Akihiko Odaki @ 2024-06-29  8:56 UTC (permalink / raw)
  To: Peter Maydell, Alex Bennée, Philippe Mathieu-Daudé
  Cc: qemu-arm, qemu-devel, Akihiko Odaki, Richard Henderson

irg expects 64-bit integers. Passing a 32-bit integer results in
compilation failure with clang version 18.1.6.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 tests/tcg/aarch64/mte-1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/tcg/aarch64/mte-1.c b/tests/tcg/aarch64/mte-1.c
index 88dcd617addc..146cad4a0499 100644
--- a/tests/tcg/aarch64/mte-1.c
+++ b/tests/tcg/aarch64/mte-1.c
@@ -15,7 +15,7 @@ int main(int ac, char **av)
     enable_mte(PR_MTE_TCF_NONE);
     p0 = alloc_mte_mem(sizeof(*p0));
 
-    asm("irg %0,%1,%2" : "=r"(p1) : "r"(p0), "r"(1));
+    asm("irg %0,%1,%2" : "=r"(p1) : "r"(p0), "r"(1l));
     assert(p1 != p0);
     asm("subp %0,%1,%2" : "=r"(c) : "r"(p0), "r"(p1));
     assert(c == 0);

-- 
2.45.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 6/7] tests/tcg/aarch64: Do not use x constraint
  2024-06-29  8:56 [PATCH v3 0/7] tests/tcg/aarch64: Fix inline assemblies for clang Akihiko Odaki
                   ` (4 preceding siblings ...)
  2024-06-29  8:56 ` [PATCH v3 5/7] tests/tcg/aarch64: Fix irg operand type Akihiko Odaki
@ 2024-06-29  8:56 ` Akihiko Odaki
  2024-06-29  8:56 ` [PATCH v3 7/7] tests/tcg/arm: Manually bit-cast half-precision numbers Akihiko Odaki
  6 siblings, 0 replies; 9+ messages in thread
From: Akihiko Odaki @ 2024-06-29  8:56 UTC (permalink / raw)
  To: Peter Maydell, Alex Bennée, Philippe Mathieu-Daudé
  Cc: qemu-arm, qemu-devel, Akihiko Odaki, Richard Henderson

clang version 18.1.6 does not support x constraint for AArch64.
Use w instead.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 tests/tcg/arm/fcvt.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tests/tcg/arm/fcvt.c b/tests/tcg/arm/fcvt.c
index 7ac47b564e24..f631197287a1 100644
--- a/tests/tcg/arm/fcvt.c
+++ b/tests/tcg/arm/fcvt.c
@@ -126,7 +126,7 @@ static void convert_single_to_half(void)
         asm("vcvtb.f16.f32 %0, %1" : "=t" (output) : "x" (input));
 #else
         uint16_t output;
-        asm("fcvt %h0, %s1" : "=w" (output) : "x" (input));
+        asm("fcvt %h0, %s1" : "=w" (output) : "w" (input));
 #endif
         print_half_number(i, output);
     }
@@ -149,7 +149,7 @@ static void convert_single_to_double(void)
 #if defined(__arm__)
         asm("vcvt.f64.f32 %P0, %1" : "=w" (output) : "t" (input));
 #else
-        asm("fcvt %d0, %s1" : "=w" (output) : "x" (input));
+        asm("fcvt %d0, %s1" : "=w" (output) : "w" (input));
 #endif
         print_double_number(i, output);
     }
@@ -244,7 +244,7 @@ static void convert_double_to_half(void)
         /* asm("vcvtb.f16.f64 %0, %P1" : "=t" (output) : "x" (input)); */
         output = input;
 #else
-        asm("fcvt %h0, %d1" : "=w" (output) : "x" (input));
+        asm("fcvt %h0, %d1" : "=w" (output) : "w" (input));
 #endif
         print_half_number(i, output);
     }
@@ -267,7 +267,7 @@ static void convert_double_to_single(void)
 #if defined(__arm__)
         asm("vcvt.f32.f64 %0, %P1" : "=w" (output) : "x" (input));
 #else
-        asm("fcvt %s0, %d1" : "=w" (output) : "x" (input));
+        asm("fcvt %s0, %d1" : "=w" (output) : "w" (input));
 #endif
 
         print_single_number(i, output);
@@ -335,7 +335,7 @@ static void convert_half_to_double(void)
         /* asm("vcvtb.f64.f16 %P0, %1" : "=w" (output) : "t" (input)); */
         output = input;
 #else
-        asm("fcvt %d0, %h1" : "=w" (output) : "x" (input));
+        asm("fcvt %d0, %h1" : "=w" (output) : "w" (input));
 #endif
         print_double_number(i, output);
     }
@@ -357,7 +357,7 @@ static void convert_half_to_single(void)
 #if defined(__arm__)
         asm("vcvtb.f32.f16 %0, %1" : "=w" (output) : "x" ((uint32_t)input));
 #else
-        asm("fcvt %s0, %h1" : "=w" (output) : "x" (input));
+        asm("fcvt %s0, %h1" : "=w" (output) : "w" (input));
 #endif
         print_single_number(i, output);
     }
@@ -380,7 +380,7 @@ static void convert_half_to_integer(void)
         /* asm("vcvt.s32.f16 %0, %1" : "=t" (output) : "t" (input)); v8.2*/
         output = input;
 #else
-        asm("fcvt %s0, %h1" : "=w" (output) : "x" (input));
+        asm("fcvt %s0, %h1" : "=w" (output) : "w" (input));
 #endif
         print_int64(i, output);
     }

-- 
2.45.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 7/7] tests/tcg/arm: Manually bit-cast half-precision numbers
  2024-06-29  8:56 [PATCH v3 0/7] tests/tcg/aarch64: Fix inline assemblies for clang Akihiko Odaki
                   ` (5 preceding siblings ...)
  2024-06-29  8:56 ` [PATCH v3 6/7] tests/tcg/aarch64: Do not use x constraint Akihiko Odaki
@ 2024-06-29  8:56 ` Akihiko Odaki
  2024-06-29 16:21   ` Richard Henderson
  6 siblings, 1 reply; 9+ messages in thread
From: Akihiko Odaki @ 2024-06-29  8:56 UTC (permalink / raw)
  To: Peter Maydell, Alex Bennée, Philippe Mathieu-Daudé
  Cc: qemu-arm, qemu-devel, Akihiko Odaki

clang version 18.1.6 does not allow specifying an integer as the value
of a single-precision register. Manually bit-cast into float with vmov
first.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 tests/tcg/arm/fcvt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/tcg/arm/fcvt.c b/tests/tcg/arm/fcvt.c
index f631197287a1..5263f607b59c 100644
--- a/tests/tcg/arm/fcvt.c
+++ b/tests/tcg/arm/fcvt.c
@@ -355,7 +355,9 @@ static void convert_half_to_single(void)
 
         print_half_number(i, input);
 #if defined(__arm__)
-        asm("vcvtb.f32.f16 %0, %1" : "=w" (output) : "x" ((uint32_t)input));
+        float tmp;
+        asm("vmov %0, %1" : "=w" (tmp) : "r" (input));
+        asm("vcvtb.f32.f16 %0, %1" : "=w" (output) : "x" (tmp));
 #else
         asm("fcvt %s0, %h1" : "=w" (output) : "w" (input));
 #endif

-- 
2.45.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 7/7] tests/tcg/arm: Manually bit-cast half-precision numbers
  2024-06-29  8:56 ` [PATCH v3 7/7] tests/tcg/arm: Manually bit-cast half-precision numbers Akihiko Odaki
@ 2024-06-29 16:21   ` Richard Henderson
  0 siblings, 0 replies; 9+ messages in thread
From: Richard Henderson @ 2024-06-29 16:21 UTC (permalink / raw)
  To: Akihiko Odaki, Peter Maydell, Alex Bennée,
	Philippe Mathieu-Daudé
  Cc: qemu-arm, qemu-devel

On 6/29/24 01:56, Akihiko Odaki wrote:
> clang version 18.1.6 does not allow specifying an integer as the value
> of a single-precision register. Manually bit-cast into float with vmov
> first.
> 
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
>   tests/tcg/arm/fcvt.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/tcg/arm/fcvt.c b/tests/tcg/arm/fcvt.c
> index f631197287a1..5263f607b59c 100644
> --- a/tests/tcg/arm/fcvt.c
> +++ b/tests/tcg/arm/fcvt.c
> @@ -355,7 +355,9 @@ static void convert_half_to_single(void)
>   
>           print_half_number(i, input);
>   #if defined(__arm__)
> -        asm("vcvtb.f32.f16 %0, %1" : "=w" (output) : "x" ((uint32_t)input));
> +        float tmp;
> +        asm("vmov %0, %1" : "=w" (tmp) : "r" (input));
> +        asm("vcvtb.f32.f16 %0, %1" : "=w" (output) : "x" (tmp));
>   #else
>           asm("fcvt %s0, %h1" : "=w" (output) : "w" (input));
>   #endif

Better as

  #if defined(__arm__)
-        asm("vcvtb.f32.f16 %0, %1" : "=w" (output) : "x" ((uint32_t)input));
+        /*
+         * Clang refuses to allocate an integer to a fp register.
+         * Perform the move from a general register by hand.
+         */
+        asm("vmov %0, %1\n\t"
+            "vcvtb.f32.f16 %0, %0" : "=w" (output) : "r" (input));
  #else

without the C temporary.  With that,

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-06-29 16:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-29  8:56 [PATCH v3 0/7] tests/tcg/aarch64: Fix inline assemblies for clang Akihiko Odaki
2024-06-29  8:56 ` [PATCH v3 1/7] tests/tcg/aarch64: Use -fno-integrated-as Akihiko Odaki
2024-06-29  8:56 ` [PATCH v3 2/7] tests/tcg/aarch64: Specify -Wa,-march=armv9-a+sme Akihiko Odaki
2024-06-29  8:56 ` [PATCH v3 3/7] tests/tcg/aarch64: Fix test architecture specification Akihiko Odaki
2024-06-29  8:56 ` [PATCH v3 4/7] tests/tcg/aarch64: Explicitly specify register width Akihiko Odaki
2024-06-29  8:56 ` [PATCH v3 5/7] tests/tcg/aarch64: Fix irg operand type Akihiko Odaki
2024-06-29  8:56 ` [PATCH v3 6/7] tests/tcg/aarch64: Do not use x constraint Akihiko Odaki
2024-06-29  8:56 ` [PATCH v3 7/7] tests/tcg/arm: Manually bit-cast half-precision numbers Akihiko Odaki
2024-06-29 16:21   ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).