diff mbox series

[meta-oe,07/13] tinymembench: Fix build with clang's integrated assembler

Message ID 20261114193733.1743149-7-khem.raj@oss.qualcomm.com
State New
Headers show
Series [meta-oe,01/13] frame: Fix build with lld without x11 | expand

Commit Message

Khem Raj Nov. 14, 2026, 7:37 p.m. UTC
The x86 assembly aliases registers with .set, and clang's integrated
assembler can not infer the operand size from such aliases:

  x86-sse2.S:124:9: error: ambiguous operand size for instruction 'add'

Define the aliases with the preprocessor instead.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 ...he-preprocessor-for-register-aliases.patch | 69 +++++++++++++++++++
 .../tinymembench/tinymembench_git.bb          |  1 +
 2 files changed, 70 insertions(+)
 create mode 100644 meta-oe/recipes-benchmark/tinymembench/tinymembench/0001-x86-sse2-Use-the-preprocessor-for-register-aliases.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-benchmark/tinymembench/tinymembench/0001-x86-sse2-Use-the-preprocessor-for-register-aliases.patch b/meta-oe/recipes-benchmark/tinymembench/tinymembench/0001-x86-sse2-Use-the-preprocessor-for-register-aliases.patch
new file mode 100644
index 0000000000..ebc9327f89
--- /dev/null
+++ b/meta-oe/recipes-benchmark/tinymembench/tinymembench/0001-x86-sse2-Use-the-preprocessor-for-register-aliases.patch
@@ -0,0 +1,69 @@ 
+From a0c69f4ab35712592194cd3839d78bfecdd4992c Mon Sep 17 00:00:00 2001
+From: Khem Raj <khem.raj@oss.qualcomm.com>
+Date: Mon, 9 Nov 2026 08:37:31 -0800
+Subject: [PATCH] x86-sse2: Use the preprocessor for register aliases
+
+clang's integrated assembler can not infer the operand size from a
+register that is aliased with .set:
+
+  x86-sse2.S:124:9: error: ambiguous operand size for instruction 'add'
+
+The aliases are the same for all functions, so define them with the
+preprocessor instead, which works with both GNU as and clang.
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ x86-sse2.S | 31 +++++++++++++++++++------------
+ 1 file changed, 19 insertions(+), 12 deletions(-)
+
+diff --git a/x86-sse2.S b/x86-sse2.S
+index 409031b..2ab9e38 100644
+--- a/x86-sse2.S
++++ b/x86-sse2.S
+@@ -28,26 +28,33 @@
+
+ #define PREFETCH_DISTANCE 256
+
+-.macro asm_function_helper function_name
+-    .global \function_name
+-\function_name:
++/*
++ * Use the preprocessor for the register aliases, clang's integrated
++ * assembler can not infer the operand size from a register set with .set
++ */
+ #ifdef __amd64__
+   #ifdef _WIN64
+-    .set DST,  rcx
+-    .set SRC,  rdx
+-    .set SIZE, r8
++    #define DST  rcx
++    #define SRC  rdx
++    #define SIZE r8
+   #else
+-    .set DST,  rdi
+-    .set SRC,  rsi
+-    .set SIZE, rdx
++    #define DST  rdi
++    #define SRC  rsi
++    #define SIZE rdx
+   #endif
+ #else
++    #define DST  eax
++    #define SRC  ecx
++    #define SIZE edx
++#endif
++
++.macro asm_function_helper function_name
++    .global \function_name
++\function_name:
++#ifndef __amd64__
+     mov  eax,  [esp + 4]
+     mov  ecx,  [esp + 8]
+     mov  edx,  [esp + 12]
+-    .set DST,  eax
+-    .set SRC,  ecx
+-    .set SIZE, edx
+ #endif
+ .endm
+
diff --git a/meta-oe/recipes-benchmark/tinymembench/tinymembench_git.bb b/meta-oe/recipes-benchmark/tinymembench/tinymembench_git.bb
index f0527a7ca3..1e6f642217 100644
--- a/meta-oe/recipes-benchmark/tinymembench/tinymembench_git.bb
+++ b/meta-oe/recipes-benchmark/tinymembench/tinymembench_git.bb
@@ -12,6 +12,7 @@  SRCREV = "a2cf6d7e382e3aea1eb39173174d9fa28cad15f3"
 UPSTREAM_CHECK_COMMITS = "1"
 SRC_URI = "git://github.com/ssvb/tinymembench.git;branch=master;protocol=https \
            file://0001-asm-Delete-.func-.endfunc-directives.patch \
+           file://0001-x86-sse2-Use-the-preprocessor-for-register-aliases.patch \
            "