alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6 V2] [configure] check if the compiler is aware of the MMX technology
@ 2020-04-29 19:10 frederic.recoules
  2020-04-29 19:10 ` [PATCH 2/6 V2] [pcm_dmix assembly] change the token by symbolic names frederic.recoules
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: frederic.recoules @ 2020-04-29 19:10 UTC (permalink / raw)
  To: alsa-devel; +Cc: Frédéric Recoules

From: Frédéric Recoules <frederic.recoules@orange.fr>

Signed-off-by: Frédéric Recoules <frederic.recoules@orange.fr>
---
 configure.ac | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/configure.ac b/configure.ac
index 4b5ab662..1838e50b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -516,6 +516,13 @@ if test -z "$gcc_have_atomics"; then
 fi
 AC_MSG_RESULT($gcc_have_atomics)

+dnl check mmx register for pcm_dmix_i386
+
+AC_TRY_LINK([],
+    [__asm__ volatile ("" : : : "mm0");],
+    [AC_DEFINE([HAVE_MMX], "1", [MMX technology is enabled])],
+    [])
+
 PCM_PLUGIN_LIST="copy linear route mulaw alaw adpcm rate plug multi shm file null empty share meter hooks lfloat ladspa dmix dshare dsnoop asym iec958 softvol extplug ioplug mmap_emul"

 build_pcm_plugin="no"
--
2.17.1

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

* [PATCH 2/6 V2] [pcm_dmix assembly] change the token by symbolic names
  2020-04-29 19:10 [PATCH 1/6 V2] [configure] check if the compiler is aware of the MMX technology frederic.recoules
@ 2020-04-29 19:10 ` frederic.recoules
  2020-04-29 19:10 ` [PATCH 3/6 V2] [pcm_dmix assembly] fix the interface for safety frederic.recoules
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: frederic.recoules @ 2020-04-29 19:10 UTC (permalink / raw)
  To: alsa-devel; +Cc: Frédéric Recoules

From: Frédéric Recoules <frederic.recoules@orange.fr>

Note: produce exactly the same binary output.

Signed-off-by: Frédéric Recoules <frederic.recoules@orange.fr>
---
 src/pcm/pcm_dmix_i386.h   | 147 ++++++++++++++++++++------------------
 src/pcm/pcm_dmix_x86_64.h |  93 ++++++++++++------------
 2 files changed, 124 insertions(+), 116 deletions(-)

diff --git a/src/pcm/pcm_dmix_i386.h b/src/pcm/pcm_dmix_i386.h
index 2778cb1d..e816d5e0 100644
--- a/src/pcm/pcm_dmix_i386.h
+++ b/src/pcm/pcm_dmix_i386.h
@@ -47,14 +47,14 @@ static void MIX_AREAS_16(unsigned int size,
 	__asm__ __volatile__ (
 		"\n"

-		"\tmovl %%ebx, %7\n"	/* ebx is GOT pointer (-fPIC) */
+		"\tmovl %%ebx, %[old_ebx]\n"	/* ebx is GOT pointer (-fPIC) */
 		/*
 		 *  initialization, load ESI, EDI, EBX registers
 		 */
-		"\tmovl %1, %%edi\n"
-		"\tmovl %2, %%esi\n"
-		"\tmovl %3, %%ebx\n"
-		"\tcmpl $0, %0\n"
+		"\tmovl %[dst], %%edi\n"
+		"\tmovl %[src], %%esi\n"
+		"\tmovl %[sum], %%ebx\n"
+		"\tcmpl $0, %[size]\n"
 		"\tjnz 2f\n"
 		"\tjmp 7f\n"

@@ -64,9 +64,9 @@ static void MIX_AREAS_16(unsigned int size,
 		 */
 		"\t.p2align 4,,15\n"
 		"1:"
-		"\tadd %4, %%edi\n"
-		"\tadd %5, %%esi\n"
-		"\tadd %6, %%ebx\n"
+		"\tadd %[dst_step], %%edi\n"
+		"\tadd %[src_step], %%esi\n"
+		"\tadd %[sum_step], %%ebx\n"

 		/*
 		 *   sample = *src;
@@ -108,7 +108,7 @@ static void MIX_AREAS_16(unsigned int size,
 		/*
 		 * while (size-- > 0)
 		 */
-		"\tdecl %0\n"
+		"\tdecl %[size]\n"
 		"\tjnz 1b\n"
 		"\tjmp 7f\n"

@@ -122,7 +122,7 @@ static void MIX_AREAS_16(unsigned int size,
 		"\tmovw $0x7fff, (%%edi)\n"
 		"\tcmpl %%ecx,(%%ebx)\n"
 		"\tjnz 4b\n"
-		"\tdecl %0\n"
+		"\tdecl %[size]\n"
 		"\tjnz 1b\n"
 		"\tjmp 7f\n"

@@ -136,16 +136,17 @@ static void MIX_AREAS_16(unsigned int size,
 		"\tmovw $-0x8000, (%%edi)\n"
 		"\tcmpl %%ecx, (%%ebx)\n"
 		"\tjnz 4b\n"
-		"\tdecl %0\n"
+		"\tdecl %[size]\n"
 		"\tjnz 1b\n"
-
+
 		"7:"
-		"\tmovl %7, %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
+		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */

 		: /* no output regs */
-		: "m" (size), "m" (dst), "m" (src),
-		  "m" (sum), "m" (dst_step), "m" (src_step),
-		  "m" (sum_step), "m" (old_ebx)
+		: [size] "m" (size),
+		  [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
+		  [sum_step] "m" (sum_step), [old_ebx] "m" (old_ebx)
 		: "esi", "edi", "edx", "ecx", "eax"
 	);
 }
@@ -171,22 +172,22 @@ static void MIX_AREAS_16_MMX(unsigned int size,
 	__asm__ __volatile__ (
 		"\n"

-		"\tmovl %%ebx, %7\n"	/* ebx is GOT pointer (-fPIC) */
+		"\tmovl %%ebx, %[old_ebx]\n"	/* ebx is GOT pointer (-fPIC) */
 		/*
 		 *  initialization, load ESI, EDI, EBX registers
 		 */
-		"\tmovl %1, %%edi\n"
-		"\tmovl %2, %%esi\n"
-		"\tmovl %3, %%ebx\n"
-		"\tcmpl $0, %0\n"
+		"\tmovl %[dst], %%edi\n"
+		"\tmovl %[src], %%esi\n"
+		"\tmovl %[sum], %%ebx\n"
+		"\tcmpl $0, %[size]\n"
 		"\tjnz 2f\n"
 		"\tjmp 5f\n"

 		"\t.p2align 4,,15\n"
 		"1:"
-		"\tadd %4, %%edi\n"
-		"\tadd %5, %%esi\n"
-		"\tadd %6, %%ebx\n"
+		"\tadd %[dst_step], %%edi\n"
+		"\tadd %[src_step], %%esi\n"
+		"\tadd %[sum_step], %%ebx\n"

 		"2:"
 		/*
@@ -226,16 +227,17 @@ static void MIX_AREAS_16_MMX(unsigned int size,
 		/*
 		 * while (size-- > 0)
 		 */
-		"\tdecl %0\n"
+		"\tdecl %[size]\n"
 		"\tjnz 1b\n"
 		"\temms\n"
                 "5:"
-		"\tmovl %7, %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
+		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */

 		: /* no output regs */
-		: "m" (size), "m" (dst), "m" (src),
-		  "m" (sum), "m" (dst_step), "m" (src_step),
-		  "m" (sum_step), "m" (old_ebx)
+		: [size] "m" (size),
+		  [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
+		  [sum_step] "m" (sum_step), [old_ebx] "m" (old_ebx)
 		: "esi", "edi", "edx", "ecx", "eax"
 	);
 }
@@ -261,14 +263,14 @@ static void MIX_AREAS_32(unsigned int size,
 	__asm__ __volatile__ (
 		"\n"

-		"\tmovl %%ebx, %7\n"	/* ebx is GOT pointer (-fPIC) */
+		"\tmovl %%ebx, %[old_ebx]\n"	/* ebx is GOT pointer (-fPIC) */
 		/*
 		 *  initialization, load ESI, EDI, EBX registers
 		 */
-		"\tmovl %1, %%edi\n"
-		"\tmovl %2, %%esi\n"
-		"\tmovl %3, %%ebx\n"
-		"\tcmpl $0, %0\n"
+		"\tmovl %[dst], %%edi\n"
+		"\tmovl %[src], %%esi\n"
+		"\tmovl %[sum], %%ebx\n"
+		"\tcmpl $0, %[size]\n"
 		"\tjnz 1f\n"
 		"\tjmp 6f\n"

@@ -335,20 +337,21 @@ static void MIX_AREAS_32(unsigned int size,
 		/*
 		 * while (size-- > 0)
 		 */
-		"\tdecl %0\n"
+		"\tdecl %[size]\n"
 		"\tjz 6f\n"
-		"\tadd %4, %%edi\n"
-		"\tadd %5, %%esi\n"
-		"\tadd %6, %%ebx\n"
+		"\tadd %[dst_step], %%edi\n"
+		"\tadd %[src_step], %%esi\n"
+		"\tadd %[sum_step], %%ebx\n"
 		"\tjmp 1b\n"
-
+
 		"6:"
-		"\tmovl %7, %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
+		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */

 		: /* no output regs */
-		: "m" (size), "m" (dst), "m" (src),
-		  "m" (sum), "m" (dst_step), "m" (src_step),
-		  "m" (sum_step), "m" (old_ebx)
+		: [size] "m" (size),
+		  [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
+		  [sum_step] "m" (sum_step), [old_ebx] "m" (old_ebx)
 		: "esi", "edi", "edx", "ecx", "eax"
 	);
 }
@@ -374,14 +377,14 @@ static void MIX_AREAS_24(unsigned int size,
 	__asm__ __volatile__ (
 		"\n"

-		"\tmovl %%ebx, %7\n"	/* ebx is GOT pointer (-fPIC) */
+		"\tmovl %%ebx, %[old_ebx]\n"	/* ebx is GOT pointer (-fPIC) */
 		/*
 		 *  initialization, load ESI, EDI, EBX registers
 		 */
-		"\tmovl %1, %%edi\n"
-		"\tmovl %2, %%esi\n"
-		"\tmovl %3, %%ebx\n"
-		"\tcmpl $0, %0\n"
+		"\tmovl %[dst], %%edi\n"
+		"\tmovl %[src], %%esi\n"
+		"\tmovl %[sum], %%ebx\n"
+		"\tcmpl $0, %[size]\n"
 		"\tjnz 1f\n"
 		"\tjmp 6f\n"

@@ -441,20 +444,21 @@ static void MIX_AREAS_24(unsigned int size,
 		/*
 		 * while (size-- > 0)
 		 */
-		"\tdecl %0\n"
+		"\tdecl %[size]\n"
 		"\tjz 6f\n"
-		"\tadd %4, %%edi\n"
-		"\tadd %5, %%esi\n"
-		"\tadd %6, %%ebx\n"
+		"\tadd %[dst_step], %%edi\n"
+		"\tadd %[src_step], %%esi\n"
+		"\tadd %[sum_step], %%ebx\n"
 		"\tjmp 1b\n"
-
+
 		"6:"
-		"\tmovl %7, %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
+		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */

 		: /* no output regs */
-		: "m" (size), "m" (dst), "m" (src),
-		  "m" (sum), "m" (dst_step), "m" (src_step),
-		  "m" (sum_step), "m" (old_ebx)
+		: [size] "m" (size),
+		  [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
+		  [sum_step] "m" (sum_step), [old_ebx] "m" (old_ebx)
 		: "esi", "edi", "edx", "ecx", "eax"
 	);
 }
@@ -480,14 +484,14 @@ static void MIX_AREAS_24_CMOV(unsigned int size,
 	__asm__ __volatile__ (
 		"\n"

-		"\tmovl %%ebx, %7\n"	/* ebx is GOT pointer (-fPIC) */
+		"\tmovl %%ebx, %[old_ebx]\n"	/* ebx is GOT pointer (-fPIC) */
 		/*
 		 *  initialization, load ESI, EDI, EBX registers
 		 */
-		"\tmovl %1, %%edi\n"
-		"\tmovl %2, %%esi\n"
-		"\tmovl %3, %%ebx\n"
-		"\tcmpl $0, %0\n"
+		"\tmovl %[dst], %%edi\n"
+		"\tmovl %[src], %%esi\n"
+		"\tmovl %[sum], %%ebx\n"
+		"\tcmpl $0, %[size]\n"
 		"\tjz 6f\n"

 		"\t.p2align 4,,15\n"
@@ -541,19 +545,20 @@ static void MIX_AREAS_24_CMOV(unsigned int size,
 		/*
 		 * while (size-- > 0)
 		 */
-		"\tadd %4, %%edi\n"
-		"\tadd %5, %%esi\n"
-		"\tadd %6, %%ebx\n"
-		"\tdecl %0\n"
+		"\tadd %[dst_step], %%edi\n"
+		"\tadd %[src_step], %%esi\n"
+		"\tadd %[sum_step], %%ebx\n"
+		"\tdecl %[size]\n"
 		"\tjnz 1b\n"
-
+
 		"6:"
-		"\tmovl %7, %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
+		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */

 		: /* no output regs */
-		: "m" (size), "m" (dst), "m" (src),
-		  "m" (sum), "m" (dst_step), "m" (src_step),
-		  "m" (sum_step), "m" (old_ebx)
+		: [size] "m" (size),
+		  [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
+		  [sum_step] "m" (sum_step), [old_ebx] "m" (old_ebx)
 		: "esi", "edi", "edx", "ecx", "eax"
 	);
 }
diff --git a/src/pcm/pcm_dmix_x86_64.h b/src/pcm/pcm_dmix_x86_64.h
index 1ef608af..dc433b35 100644
--- a/src/pcm/pcm_dmix_x86_64.h
+++ b/src/pcm/pcm_dmix_x86_64.h
@@ -48,18 +48,18 @@ static void MIX_AREAS_16(unsigned int size,
 	__asm__ __volatile__ (
 		"\n"

-		"\tmovq %%rbx, %7\n"
+		"\tmovq %%rbx, %[old_rbx]\n"
 		/*
 		 *  initialization, load RSI, RDI, RBX registers
 		 */
-		"\tmovq %1, %%rdi\n"
-		"\tmovq %2, %%rsi\n"
-		"\tmovq %3, %%rbx\n"
+		"\tmovq %[dst], %%rdi\n"
+		"\tmovq %[src], %%rsi\n"
+		"\tmovq %[sum], %%rbx\n"

 		/*
 		 * while (size-- > 0) {
 		 */
-		"\tcmpl $0, %0\n"
+		"\tcmpl $0, %[size]\n"
 		"jz 6f\n"

 		"\t.p2align 4,,15\n"
@@ -103,21 +103,22 @@ static void MIX_AREAS_16(unsigned int size,
 		/*
 		 * while (size-- > 0)
 		 */
-		"\tadd %4, %%rdi\n"
-		"\tadd %5, %%rsi\n"
-		"\tadd %6, %%rbx\n"
-		"\tdecl %0\n"
+		"\tadd %[dst_step], %%rdi\n"
+		"\tadd %[src_step], %%rsi\n"
+		"\tadd %[sum_step], %%rbx\n"
+		"\tdecl %[size]\n"
 		"\tjnz 1b\n"

 		"6:"
-
+
 		"\temms\n"
-		"\tmovq %7, %%rbx\n"
+		"\tmovq %[old_rbx], %%rbx\n"

 		: /* no output regs */
-		: "m" (size), "m" (dst), "m" (src),
-		  "m" (sum), "m" (dst_step), "m" (src_step),
-		  "m" (sum_step), "m" (old_rbx)
+	        : [size] "m" (size),
+		  [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
+		  [sum_step] "m" (sum_step), [old_rbx] "m" (old_rbx)
 		: "rsi", "rdi", "edx", "ecx", "eax"
 	);
 }
@@ -143,18 +144,18 @@ static void MIX_AREAS_32(unsigned int size,
 	__asm__ __volatile__ (
 		"\n"

-		"\tmovq %%rbx, %7\n"
+		"\tmovq %%rbx, %[old_rbx]\n"
 		/*
-		 *  initialization, load ESI, EDI, EBX registers
+		 *  initialization, load RSI, RDI, RBX registers
 		 */
-		"\tmovq %1, %%rdi\n"
-		"\tmovq %2, %%rsi\n"
-		"\tmovq %3, %%rbx\n"
+		"\tmovq %[dst], %%rdi\n"
+		"\tmovq %[src], %%rsi\n"
+		"\tmovq %[sum], %%rbx\n"

 		/*
 		 * while (size-- > 0) {
 		 */
-		"\tcmpl $0, %0\n"
+		"\tcmpl $0, %[size]\n"
 		"jz 6f\n"

 		"\t.p2align 4,,15\n"
@@ -220,19 +221,20 @@ static void MIX_AREAS_32(unsigned int size,
 		/*
 		 * while (size-- > 0)
 		 */
-		"\tadd %4, %%rdi\n"
-		"\tadd %5, %%rsi\n"
-		"\tadd %6, %%rbx\n"
-		"\tdecl %0\n"
+		"\tadd %[dst_step], %%rdi\n"
+		"\tadd %[src_step], %%rsi\n"
+		"\tadd %[sum_step], %%rbx\n"
+		"\tdecl %[size]\n"
 		"\tjnz 1b\n"
-
+
 		"6:"
-		"\tmovq %7, %%rbx\n"
+		"\tmovq %[old_rbx], %%rbx\n"

 		: /* no output regs */
-		: "m" (size), "m" (dst), "m" (src),
-		  "m" (sum), "m" (dst_step), "m" (src_step),
-		  "m" (sum_step), "m" (old_rbx)
+	        : [size] "m" (size),
+		  [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
+		  [sum_step] "m" (sum_step), [old_rbx] "m" (old_rbx)
 		: "rsi", "rdi", "edx", "ecx", "eax"
 	);
 }
@@ -258,18 +260,18 @@ static void MIX_AREAS_24(unsigned int size,
 	__asm__ __volatile__ (
 		"\n"

-		"\tmovq %%rbx, %7\n"
+		"\tmovq %%rbx, %[old_rbx]\n"
 		/*
-		 *  initialization, load ESI, EDI, EBX registers
+		 *  initialization, load RSI, RDI, RBX registers
 		 */
-		"\tmovq %1, %%rdi\n"
-		"\tmovq %2, %%rsi\n"
-		"\tmovq %3, %%rbx\n"
+		"\tmovq %[dst], %%rdi\n"
+		"\tmovq %[src], %%rsi\n"
+		"\tmovq %[sum], %%rbx\n"

 		/*
 		 * while (size-- > 0) {
 		 */
-		"\tcmpl $0, %0\n"
+		"\tcmpl $0, %[size]\n"
 		"jz 6f\n"

 		"\t.p2align 4,,15\n"
@@ -316,26 +318,27 @@ static void MIX_AREAS_24(unsigned int size,
 		"\tmovw %%ax, (%%rdi)\n"
 		"\tshrl $16, %%eax\n"
 		"\tmovb %%al, 2(%%rdi)\n"
-
+
 		"\tcmpl %%ecx, (%%rbx)\n"
 		"\tjnz 3b\n"

 		/*
 		 * while (size-- > 0)
 		 */
-		"\tadd %4, %%rdi\n"
-		"\tadd %5, %%rsi\n"
-		"\tadd %6, %%rbx\n"
-		"\tdecl %0\n"
+		"\tadd %[dst_step], %%rdi\n"
+		"\tadd %[src_step], %%rsi\n"
+		"\tadd %[sum_step], %%rbx\n"
+		"\tdecl %[size]\n"
 		"\tjnz 1b\n"
-
+
 		"6:"
-		"\tmovq %7, %%rbx\n"
+		"\tmovq %[old_rbx], %%rbx\n"

 		: /* no output regs */
-		: "m" (size), "m" (dst), "m" (src),
-		  "m" (sum), "m" (dst_step), "m" (src_step),
-		  "m" (sum_step), "m" (old_rbx)
+	        : [size] "m" (size),
+		  [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
+		  [sum_step] "m" (sum_step), [old_rbx] "m" (old_rbx)
 		: "rsi", "rdi", "edx", "ecx", "eax"
 	);
 }
--
2.17.1

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

* [PATCH 3/6 V2] [pcm_dmix assembly] fix the interface for safety
  2020-04-29 19:10 [PATCH 1/6 V2] [configure] check if the compiler is aware of the MMX technology frederic.recoules
  2020-04-29 19:10 ` [PATCH 2/6 V2] [pcm_dmix assembly] change the token by symbolic names frederic.recoules
@ 2020-04-29 19:10 ` frederic.recoules
  2020-04-29 19:10 ` [PATCH 4/6 V2] [pcm_dmix assembly] fix the interface for safety (mmx) frederic.recoules
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: frederic.recoules @ 2020-04-29 19:10 UTC (permalink / raw)
  To: alsa-devel; +Cc: Frédéric Recoules

From: Frédéric Recoules <frederic.recoules@orange.fr>

- move 'size' and 'old_ebx' in the output section
  since they are clobbered;
- add the "memory" clobber since input pointers
  are dereferenced;
- (minor) add the "cc" clobber since flags are
  clobbered.

Note: produce exactly the same binary output.

Signed-off-by: Frédéric Recoules <frederic.recoules@orange.fr>
---
 src/pcm/pcm_dmix_i386.h   | 45 +++++++++++++++++----------------------
 src/pcm/pcm_dmix_x86_64.h | 27 +++++++++++------------
 2 files changed, 32 insertions(+), 40 deletions(-)

diff --git a/src/pcm/pcm_dmix_i386.h b/src/pcm/pcm_dmix_i386.h
index e816d5e0..3ea0737d 100644
--- a/src/pcm/pcm_dmix_i386.h
+++ b/src/pcm/pcm_dmix_i386.h
@@ -142,12 +142,11 @@ static void MIX_AREAS_16(unsigned int size,
 		"7:"
 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */

-		: /* no output regs */
-		: [size] "m" (size),
-		  [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+		: [size] "+m" (size), [old_ebx] "=m" (old_ebx)
+		: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-		  [sum_step] "m" (sum_step), [old_ebx] "m" (old_ebx)
-		: "esi", "edi", "edx", "ecx", "eax"
+		  [sum_step] "m" (sum_step)
+		: "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
 	);
 }

@@ -233,12 +232,11 @@ static void MIX_AREAS_16_MMX(unsigned int size,
                 "5:"
 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */

-		: /* no output regs */
-		: [size] "m" (size),
-		  [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+	        : [size] "+m" (size), [old_ebx] "=m" (old_ebx)
+		: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-		  [sum_step] "m" (sum_step), [old_ebx] "m" (old_ebx)
-		: "esi", "edi", "edx", "ecx", "eax"
+		  [sum_step] "m" (sum_step)
+		: "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
 	);
 }

@@ -347,12 +345,11 @@ static void MIX_AREAS_32(unsigned int size,
 		"6:"
 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */

-		: /* no output regs */
-		: [size] "m" (size),
-		  [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+		: [size] "+m" (size), [old_ebx] "=m" (old_ebx)
+		: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-		  [sum_step] "m" (sum_step), [old_ebx] "m" (old_ebx)
-		: "esi", "edi", "edx", "ecx", "eax"
+		  [sum_step] "m" (sum_step)
+		: "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
 	);
 }

@@ -454,12 +451,11 @@ static void MIX_AREAS_24(unsigned int size,
 		"6:"
 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */

-		: /* no output regs */
-		: [size] "m" (size),
-		  [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+	        : [size] "+m" (size), [old_ebx] "=m" (old_ebx)
+		: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-		  [sum_step] "m" (sum_step), [old_ebx] "m" (old_ebx)
-		: "esi", "edi", "edx", "ecx", "eax"
+		  [sum_step] "m" (sum_step)
+		: "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
 	);
 }

@@ -554,11 +550,10 @@ static void MIX_AREAS_24_CMOV(unsigned int size,
 		"6:"
 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */

-		: /* no output regs */
-		: [size] "m" (size),
-		  [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+	        : [size] "+m" (size), [old_ebx] "=m" (old_ebx)
+		: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-		  [sum_step] "m" (sum_step), [old_ebx] "m" (old_ebx)
-		: "esi", "edi", "edx", "ecx", "eax"
+		  [sum_step] "m" (sum_step)
+		: "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
 	);
 }
diff --git a/src/pcm/pcm_dmix_x86_64.h b/src/pcm/pcm_dmix_x86_64.h
index dc433b35..7f711547 100644
--- a/src/pcm/pcm_dmix_x86_64.h
+++ b/src/pcm/pcm_dmix_x86_64.h
@@ -114,12 +114,11 @@ static void MIX_AREAS_16(unsigned int size,
 		"\temms\n"
 		"\tmovq %[old_rbx], %%rbx\n"

-		: /* no output regs */
-	        : [size] "m" (size),
-		  [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+		: [size] "+m" (size), [old_rbx] "=m" (old_rbx)
+	        : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-		  [sum_step] "m" (sum_step), [old_rbx] "m" (old_rbx)
-		: "rsi", "rdi", "edx", "ecx", "eax"
+		  [sum_step] "m" (sum_step)
+		: "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
 	);
 }

@@ -230,12 +229,11 @@ static void MIX_AREAS_32(unsigned int size,
 		"6:"
 		"\tmovq %[old_rbx], %%rbx\n"

-		: /* no output regs */
-	        : [size] "m" (size),
-		  [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+		: [size] "+m" (size), [old_rbx] "=m" (old_rbx)
+	        : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-		  [sum_step] "m" (sum_step), [old_rbx] "m" (old_rbx)
-		: "rsi", "rdi", "edx", "ecx", "eax"
+		  [sum_step] "m" (sum_step)
+		: "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
 	);
 }

@@ -334,11 +332,10 @@ static void MIX_AREAS_24(unsigned int size,
 		"6:"
 		"\tmovq %[old_rbx], %%rbx\n"

-		: /* no output regs */
-	        : [size] "m" (size),
-		  [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+		: [size] "+m" (size), [old_rbx] "=m" (old_rbx)
+	        : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-		  [sum_step] "m" (sum_step), [old_rbx] "m" (old_rbx)
-		: "rsi", "rdi", "edx", "ecx", "eax"
+		  [sum_step] "m" (sum_step)
+		: "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
 	);
 }
--
2.17.1

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

* [PATCH 4/6 V2] [pcm_dmix assembly] fix the interface for safety (mmx)
  2020-04-29 19:10 [PATCH 1/6 V2] [configure] check if the compiler is aware of the MMX technology frederic.recoules
  2020-04-29 19:10 ` [PATCH 2/6 V2] [pcm_dmix assembly] change the token by symbolic names frederic.recoules
  2020-04-29 19:10 ` [PATCH 3/6 V2] [pcm_dmix assembly] fix the interface for safety frederic.recoules
@ 2020-04-29 19:10 ` frederic.recoules
  2020-04-29 19:10 ` [PATCH 5/6 V2] [pcm_dmix assembly] refactor the PIC mode frederic.recoules
  2020-04-29 19:10 ` [PATCH 6/6 V2] [pcm_dmix assembly] (minor) give more freedom over the constraints frederic.recoules
  4 siblings, 0 replies; 6+ messages in thread
From: frederic.recoules @ 2020-04-29 19:10 UTC (permalink / raw)
  To: alsa-devel; +Cc: Frédéric Recoules

From: Frédéric Recoules <frederic.recoules@orange.fr>

- initialize mm1 with 0s;
- add mm0 and mm1 in the clobber list if the compiler
  is aware of the mmx technology;
- otherwise, add the mmx aliased x87 floating point
  register in the clobbers.

Note: produce exactly the same binary output except
      for mm1 initialization implying address shifts.

Signed-off-by: Frédéric Recoules <frederic.recoules@orange.fr>
---
 src/pcm/pcm_dmix_i386.h   | 9 ++++++++-
 src/pcm/pcm_dmix_x86_64.h | 9 ++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/pcm/pcm_dmix_i386.h b/src/pcm/pcm_dmix_i386.h
index 3ea0737d..d9bf8f50 100644
--- a/src/pcm/pcm_dmix_i386.h
+++ b/src/pcm/pcm_dmix_i386.h
@@ -173,8 +173,9 @@ static void MIX_AREAS_16_MMX(unsigned int size,

 		"\tmovl %%ebx, %[old_ebx]\n"	/* ebx is GOT pointer (-fPIC) */
 		/*
-		 *  initialization, load ESI, EDI, EBX registers
+		 *  initialization, load ESI, EDI, EBX registers and clear MM1
 		 */
+		"\tpxor %%mm1, %%mm1\n"
 		"\tmovl %[dst], %%edi\n"
 		"\tmovl %[src], %%esi\n"
 		"\tmovl %[sum], %%ebx\n"
@@ -237,6 +238,12 @@ static void MIX_AREAS_16_MMX(unsigned int size,
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
 		  [sum_step] "m" (sum_step)
 		: "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
+#               ifdef HAVE_MMX
+		  , "mm0", "mm1"
+#               else
+		  , "st", "st(1)", "st(2)", "st(3)",
+		  "st(4)", "st(5)", "st(6)", "st(7)"
+#               endif
 	);
 }

diff --git a/src/pcm/pcm_dmix_x86_64.h b/src/pcm/pcm_dmix_x86_64.h
index 7f711547..8ad1b2a0 100644
--- a/src/pcm/pcm_dmix_x86_64.h
+++ b/src/pcm/pcm_dmix_x86_64.h
@@ -50,8 +50,9 @@ static void MIX_AREAS_16(unsigned int size,

 		"\tmovq %%rbx, %[old_rbx]\n"
 		/*
-		 *  initialization, load RSI, RDI, RBX registers
+		 *  initialization, load RSI, RDI, RBX registers and clear MM1
 		 */
+		"\tpxor %%mm1, %%mm1\n"
 		"\tmovq %[dst], %%rdi\n"
 		"\tmovq %[src], %%rsi\n"
 		"\tmovq %[sum], %%rbx\n"
@@ -119,6 +120,12 @@ static void MIX_AREAS_16(unsigned int size,
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
 		  [sum_step] "m" (sum_step)
 		: "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
+#               ifdef HAVE_MMX
+		  , "mm0", "mm1"
+#               else
+		  , "st", "st(1)", "st(2)", "st(3)",
+		  "st(4)", "st(5)", "st(6)", "st(7)"
+#               endif
 	);
 }

--
2.17.1

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

* [PATCH 5/6 V2] [pcm_dmix assembly] refactor the PIC mode
  2020-04-29 19:10 [PATCH 1/6 V2] [configure] check if the compiler is aware of the MMX technology frederic.recoules
                   ` (2 preceding siblings ...)
  2020-04-29 19:10 ` [PATCH 4/6 V2] [pcm_dmix assembly] fix the interface for safety (mmx) frederic.recoules
@ 2020-04-29 19:10 ` frederic.recoules
  2020-04-29 19:10 ` [PATCH 6/6 V2] [pcm_dmix assembly] (minor) give more freedom over the constraints frederic.recoules
  4 siblings, 0 replies; 6+ messages in thread
From: frederic.recoules @ 2020-04-29 19:10 UTC (permalink / raw)
  To: alsa-devel; +Cc: Frédéric Recoules

From: Frédéric Recoules <frederic.recoules@orange.fr>

Note: newer versions of GCC accept that ebx is declared
      in the clobber list.

Signed-off-by: Frédéric Recoules <frederic.recoules@orange.fr>
---
 src/pcm/pcm_dmix_i386.h   | 93 ++++++++++++++++++++++++++++++---------
 src/pcm/pcm_dmix_x86_64.h | 59 ++++++++++++++++++++-----
 2 files changed, 120 insertions(+), 32 deletions(-)

diff --git a/src/pcm/pcm_dmix_i386.h b/src/pcm/pcm_dmix_i386.h
index d9bf8f50..b28ae787 100644
--- a/src/pcm/pcm_dmix_i386.h
+++ b/src/pcm/pcm_dmix_i386.h
@@ -26,6 +26,10 @@
  *
  */

+#if defined(__GNUC__) && __GNUC__ < 5 && defined(__PIC__)
+#  define BOUNDED_EBX
+#endif
+
 /*
  *  for plain i386
  */
@@ -34,8 +38,9 @@ static void MIX_AREAS_16(unsigned int size,
 			 volatile signed int *sum, size_t dst_step,
 			 size_t src_step, size_t sum_step)
 {
+#     ifdef BOUNDED_EBX
 	unsigned int old_ebx;
-
+#     endif
 	/*
 	 *  ESI - src
 	 *  EDI - dst
@@ -46,8 +51,9 @@ static void MIX_AREAS_16(unsigned int size,
 	 */
 	__asm__ __volatile__ (
 		"\n"
-
+#            ifdef BOUNDED_EBX
 		"\tmovl %%ebx, %[old_ebx]\n"	/* ebx is GOT pointer (-fPIC) */
+#            endif
 		/*
 		 *  initialization, load ESI, EDI, EBX registers
 		 */
@@ -140,13 +146,20 @@ static void MIX_AREAS_16(unsigned int size,
 		"\tjnz 1b\n"

 		"7:"
+#            ifdef BOUNDED_EBX
 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
-
-		: [size] "+m" (size), [old_ebx] "=m" (old_ebx)
+#            endif
+		: [size] "+m" (size)
+#               ifdef BOUNDED_EBX
+		  , [old_ebx] "=m" (old_ebx)
+#               endif
 		: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
 		  [sum_step] "m" (sum_step)
 		: "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
+#               ifndef BOUNDED_EBX
+		  , "ebx"
+#               endif
 	);
 }

@@ -158,8 +171,9 @@ static void MIX_AREAS_16_MMX(unsigned int size,
 			     volatile signed int *sum, size_t dst_step,
 			     size_t src_step, size_t sum_step)
 {
+#     ifdef BOUNDED_EBX
 	unsigned int old_ebx;
-
+#     endif
 	/*
 	 *  ESI - src
 	 *  EDI - dst
@@ -170,8 +184,9 @@ static void MIX_AREAS_16_MMX(unsigned int size,
 	 */
 	__asm__ __volatile__ (
 		"\n"
-
+#            ifdef BOUNDED_EBX
 		"\tmovl %%ebx, %[old_ebx]\n"	/* ebx is GOT pointer (-fPIC) */
+#            endif
 		/*
 		 *  initialization, load ESI, EDI, EBX registers and clear MM1
 		 */
@@ -231,13 +246,20 @@ static void MIX_AREAS_16_MMX(unsigned int size,
 		"\tjnz 1b\n"
 		"\temms\n"
                 "5:"
+#            ifdef BOUNDED_EBX
 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
-
-	        : [size] "+m" (size), [old_ebx] "=m" (old_ebx)
+#            endif
+		: [size] "+m" (size)
+#               ifdef BOUNDED_EBX
+		  , [old_ebx] "=m" (old_ebx)
+#               endif
 		: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
 		  [sum_step] "m" (sum_step)
 		: "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
+#               ifndef BOUNDED_EBX
+		  , "ebx"
+#               endif
 #               ifdef HAVE_MMX
 		  , "mm0", "mm1"
 #               else
@@ -255,8 +277,9 @@ static void MIX_AREAS_32(unsigned int size,
 			 volatile signed int *sum, size_t dst_step,
 			 size_t src_step, size_t sum_step)
 {
+#     ifdef BOUNDED_EBX
 	unsigned int old_ebx;
-
+#     endif
 	/*
 	 *  ESI - src
 	 *  EDI - dst
@@ -267,8 +290,9 @@ static void MIX_AREAS_32(unsigned int size,
 	 */
 	__asm__ __volatile__ (
 		"\n"
-
+#            ifdef BOUNDED_EBX
 		"\tmovl %%ebx, %[old_ebx]\n"	/* ebx is GOT pointer (-fPIC) */
+#            endif
 		/*
 		 *  initialization, load ESI, EDI, EBX registers
 		 */
@@ -350,13 +374,20 @@ static void MIX_AREAS_32(unsigned int size,
 		"\tjmp 1b\n"

 		"6:"
+#            ifdef BOUNDED_EBX
 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
-
-		: [size] "+m" (size), [old_ebx] "=m" (old_ebx)
+#            endif
+		: [size] "+m" (size)
+#               ifdef BOUNDED_EBX
+		  , [old_ebx] "=m" (old_ebx)
+#               endif
 		: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
 		  [sum_step] "m" (sum_step)
 		: "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
+#               ifndef BOUNDED_EBX
+		  , "ebx"
+#               endif
 	);
 }

@@ -368,8 +399,9 @@ static void MIX_AREAS_24(unsigned int size,
 			 volatile signed int *sum, size_t dst_step,
 			 size_t src_step, size_t sum_step)
 {
+#     ifdef BOUNDED_EBX
 	unsigned int old_ebx;
-
+#     endif
 	/*
 	 *  ESI - src
 	 *  EDI - dst
@@ -380,8 +412,9 @@ static void MIX_AREAS_24(unsigned int size,
 	 */
 	__asm__ __volatile__ (
 		"\n"
-
+#            ifdef BOUNDED_EBX
 		"\tmovl %%ebx, %[old_ebx]\n"	/* ebx is GOT pointer (-fPIC) */
+#            endif
 		/*
 		 *  initialization, load ESI, EDI, EBX registers
 		 */
@@ -456,13 +489,20 @@ static void MIX_AREAS_24(unsigned int size,
 		"\tjmp 1b\n"

 		"6:"
+#            ifdef BOUNDED_EBX
 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
-
-	        : [size] "+m" (size), [old_ebx] "=m" (old_ebx)
+#            endif
+		: [size] "+m" (size)
+#               ifdef BOUNDED_EBX
+		  , [old_ebx] "=m" (old_ebx)
+#               endif
 		: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
 		  [sum_step] "m" (sum_step)
 		: "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
+#               ifndef BOUNDED_EBX
+		  , "ebx"
+#               endif
 	);
 }

@@ -474,8 +514,9 @@ static void MIX_AREAS_24_CMOV(unsigned int size,
 			      volatile signed int *sum, size_t dst_step,
 			      size_t src_step, size_t sum_step)
 {
+#     ifdef BOUNDED_EBX
 	unsigned int old_ebx;
-
+#     endif
 	/*
 	 *  ESI - src
 	 *  EDI - dst
@@ -486,8 +527,9 @@ static void MIX_AREAS_24_CMOV(unsigned int size,
 	 */
 	__asm__ __volatile__ (
 		"\n"
-
+#            ifdef BOUNDED_EBX
 		"\tmovl %%ebx, %[old_ebx]\n"	/* ebx is GOT pointer (-fPIC) */
+#            endif
 		/*
 		 *  initialization, load ESI, EDI, EBX registers
 		 */
@@ -555,12 +597,23 @@ static void MIX_AREAS_24_CMOV(unsigned int size,
 		"\tjnz 1b\n"

 		"6:"
+#            ifdef BOUNDED_EBX
 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
-
-	        : [size] "+m" (size), [old_ebx] "=m" (old_ebx)
+#            endif
+		: [size] "+m" (size)
+#               ifdef BOUNDED_EBX
+		  , [old_ebx] "=m" (old_ebx)
+#               endif
 		: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
 		  [sum_step] "m" (sum_step)
 		: "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
+#               ifndef BOUNDED_EBX
+		  , "ebx"
+#               endif
 	);
 }
+
+#ifdef BOUNDED_EBX
+#  undef BOUNDED_EBX
+#endif
diff --git a/src/pcm/pcm_dmix_x86_64.h b/src/pcm/pcm_dmix_x86_64.h
index 8ad1b2a0..f543a134 100644
--- a/src/pcm/pcm_dmix_x86_64.h
+++ b/src/pcm/pcm_dmix_x86_64.h
@@ -27,6 +27,10 @@
  *
  */

+#if defined(__GNUC__) && __GNUC__ < 5 && defined(__PIC__)
+#  define BOUNDED_RBX
+#endif
+
 /*
  *  MMX optimized
  */
@@ -35,8 +39,9 @@ static void MIX_AREAS_16(unsigned int size,
 			 volatile signed int *sum, size_t dst_step,
 			 size_t src_step, size_t sum_step)
 {
+#     ifdef BOUNDED_RBX
 	unsigned long long old_rbx;
-
+#     endif
 	/*
 	 *  RSI - src
 	 *  RDI - dst
@@ -47,8 +52,9 @@ static void MIX_AREAS_16(unsigned int size,
 	 */
 	__asm__ __volatile__ (
 		"\n"
-
+#            ifdef BOUNDED_RBX
 		"\tmovq %%rbx, %[old_rbx]\n"
+#            endif
 		/*
 		 *  initialization, load RSI, RDI, RBX registers and clear MM1
 		 */
@@ -113,13 +119,20 @@ static void MIX_AREAS_16(unsigned int size,
 		"6:"

 		"\temms\n"
+#            ifdef BOUNDED_RBX
 		"\tmovq %[old_rbx], %%rbx\n"
-
-		: [size] "+m" (size), [old_rbx] "=m" (old_rbx)
+#            endif
+		: [size] "+m" (size)
+#               ifdef BOUNDED_RBX
+		  , [old_rbx] "=m" (old_rbx)
+#               endif
 	        : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
 		  [sum_step] "m" (sum_step)
 		: "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
+#               ifndef BOUNDED_RBX
+		  , "rbx"
+#               endif
 #               ifdef HAVE_MMX
 		  , "mm0", "mm1"
 #               else
@@ -137,8 +150,9 @@ static void MIX_AREAS_32(unsigned int size,
 			 volatile signed int *sum, size_t dst_step,
 			 size_t src_step, size_t sum_step)
 {
+#     ifdef BOUNDED_RBX
 	unsigned long long old_rbx;
-
+#     endif
 	/*
 	 *  RSI - src
 	 *  RDI - dst
@@ -149,8 +163,9 @@ static void MIX_AREAS_32(unsigned int size,
 	 */
 	__asm__ __volatile__ (
 		"\n"
-
+#            ifdef BOUNDED_RBX
 		"\tmovq %%rbx, %[old_rbx]\n"
+#            endif
 		/*
 		 *  initialization, load RSI, RDI, RBX registers
 		 */
@@ -234,13 +249,20 @@ static void MIX_AREAS_32(unsigned int size,
 		"\tjnz 1b\n"

 		"6:"
+#            ifdef BOUNDED_RBX
 		"\tmovq %[old_rbx], %%rbx\n"
-
-		: [size] "+m" (size), [old_rbx] "=m" (old_rbx)
+#            endif
+		: [size] "+m" (size)
+#               ifdef BOUNDED_RBX
+		  , [old_rbx] "=m" (old_rbx)
+#               endif
 	        : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
 		  [sum_step] "m" (sum_step)
 		: "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
+#               ifndef BOUNDED_RBX
+		  , "rbx"
+#               endif
 	);
 }

@@ -252,8 +274,9 @@ static void MIX_AREAS_24(unsigned int size,
 			 volatile signed int *sum, size_t dst_step,
 			 size_t src_step, size_t sum_step)
 {
+#     ifdef BOUNDED_RBX
 	unsigned long long old_rbx;
-
+#     endif
 	/*
 	 *  RSI - src
 	 *  RDI - dst
@@ -264,8 +287,9 @@ static void MIX_AREAS_24(unsigned int size,
 	 */
 	__asm__ __volatile__ (
 		"\n"
-
+#            ifdef BOUNDED_RBX
 		"\tmovq %%rbx, %[old_rbx]\n"
+#            endif
 		/*
 		 *  initialization, load RSI, RDI, RBX registers
 		 */
@@ -337,12 +361,23 @@ static void MIX_AREAS_24(unsigned int size,
 		"\tjnz 1b\n"

 		"6:"
+#            ifdef BOUNDED_RBX
 		"\tmovq %[old_rbx], %%rbx\n"
-
-		: [size] "+m" (size), [old_rbx] "=m" (old_rbx)
+#            endif
+		: [size] "+m" (size)
+#               ifdef BOUNDED_RBX
+		  , [old_rbx] "=m" (old_rbx)
+#               endif
 	        : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
 		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
 		  [sum_step] "m" (sum_step)
 		: "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
+#               ifndef BOUNDED_RBX
+		  , "rbx"
+#               endif
 	);
 }
+
+#ifdef BOUNDED_RBX
+#  undef BOUNDED_RBX
+#endif
--
2.17.1

Note: it has not been tested but I can not figure out it could break
something because the compiler is now aware that ebx is clobbered.
Curiously, it seems it significantly reduces the size of the code.

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

* [PATCH 6/6 V2] [pcm_dmix assembly] (minor) give more freedom over the constraints
  2020-04-29 19:10 [PATCH 1/6 V2] [configure] check if the compiler is aware of the MMX technology frederic.recoules
                   ` (3 preceding siblings ...)
  2020-04-29 19:10 ` [PATCH 5/6 V2] [pcm_dmix assembly] refactor the PIC mode frederic.recoules
@ 2020-04-29 19:10 ` frederic.recoules
  4 siblings, 0 replies; 6+ messages in thread
From: frederic.recoules @ 2020-04-29 19:10 UTC (permalink / raw)
  To: alsa-devel; +Cc: Frédéric Recoules

From: Frédéric Recoules <frederic.recoules@orange.fr>

Signed-off-by: Frédéric Recoules <frederic.recoules@orange.fr>
---
 src/pcm/pcm_dmix_i386.h   | 30 +++++++++++++++---------------
 src/pcm/pcm_dmix_x86_64.h | 18 +++++++++---------
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/src/pcm/pcm_dmix_i386.h b/src/pcm/pcm_dmix_i386.h
index b28ae787..65ed6d43 100644
--- a/src/pcm/pcm_dmix_i386.h
+++ b/src/pcm/pcm_dmix_i386.h
@@ -149,13 +149,13 @@ static void MIX_AREAS_16(unsigned int size,
 #            ifdef BOUNDED_EBX
 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
 #            endif
-		: [size] "+m" (size)
+		: [size] "+&rm" (size)
 #               ifdef BOUNDED_EBX
 		  , [old_ebx] "=m" (old_ebx)
 #               endif
 		: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
-		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-		  [sum_step] "m" (sum_step)
+		  [dst_step] "im" (dst_step),  [src_step] "im" (src_step),
+		  [sum_step] "im" (sum_step)
 		: "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
 #               ifndef BOUNDED_EBX
 		  , "ebx"
@@ -249,13 +249,13 @@ static void MIX_AREAS_16_MMX(unsigned int size,
 #            ifdef BOUNDED_EBX
 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
 #            endif
-		: [size] "+m" (size)
+		: [size] "+&rm" (size)
 #               ifdef BOUNDED_EBX
 		  , [old_ebx] "=m" (old_ebx)
 #               endif
 		: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
-		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-		  [sum_step] "m" (sum_step)
+		  [dst_step] "im" (dst_step),  [src_step] "im" (src_step),
+		  [sum_step] "im" (sum_step)
 		: "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
 #               ifndef BOUNDED_EBX
 		  , "ebx"
@@ -377,13 +377,13 @@ static void MIX_AREAS_32(unsigned int size,
 #            ifdef BOUNDED_EBX
 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
 #            endif
-		: [size] "+m" (size)
+		: [size] "+&rm" (size)
 #               ifdef BOUNDED_EBX
 		  , [old_ebx] "=m" (old_ebx)
 #               endif
 		: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
-		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-		  [sum_step] "m" (sum_step)
+		  [dst_step] "im" (dst_step),  [src_step] "im" (src_step),
+		  [sum_step] "im" (sum_step)
 		: "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
 #               ifndef BOUNDED_EBX
 		  , "ebx"
@@ -492,13 +492,13 @@ static void MIX_AREAS_24(unsigned int size,
 #            ifdef BOUNDED_EBX
 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
 #            endif
-		: [size] "+m" (size)
+		: [size] "+&rm" (size)
 #               ifdef BOUNDED_EBX
 		  , [old_ebx] "=m" (old_ebx)
 #               endif
 		: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
-		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-		  [sum_step] "m" (sum_step)
+		  [dst_step] "im" (dst_step),  [src_step] "im" (src_step),
+		  [sum_step] "im" (sum_step)
 		: "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
 #               ifndef BOUNDED_EBX
 		  , "ebx"
@@ -600,13 +600,13 @@ static void MIX_AREAS_24_CMOV(unsigned int size,
 #            ifdef BOUNDED_EBX
 		"\tmovl %[old_ebx], %%ebx\n"	/* ebx is GOT pointer (-fPIC) */
 #            endif
-		: [size] "+m" (size)
+		: [size] "+&rm" (size)
 #               ifdef BOUNDED_EBX
 		  , [old_ebx] "=m" (old_ebx)
 #               endif
 		: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
-		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-		  [sum_step] "m" (sum_step)
+		  [dst_step] "im" (dst_step),  [src_step] "im" (src_step),
+		  [sum_step] "im" (sum_step)
 		: "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
 #               ifndef BOUNDED_EBX
 		  , "ebx"
diff --git a/src/pcm/pcm_dmix_x86_64.h b/src/pcm/pcm_dmix_x86_64.h
index f543a134..4848ff80 100644
--- a/src/pcm/pcm_dmix_x86_64.h
+++ b/src/pcm/pcm_dmix_x86_64.h
@@ -122,13 +122,13 @@ static void MIX_AREAS_16(unsigned int size,
 #            ifdef BOUNDED_RBX
 		"\tmovq %[old_rbx], %%rbx\n"
 #            endif
-		: [size] "+m" (size)
+		: [size] "+&rm" (size)
 #               ifdef BOUNDED_RBX
 		  , [old_rbx] "=m" (old_rbx)
 #               endif
 	        : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
-		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-		  [sum_step] "m" (sum_step)
+		  [dst_step] "im" (dst_step),  [src_step] "im" (src_step),
+		  [sum_step] "im" (sum_step)
 		: "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
 #               ifndef BOUNDED_RBX
 		  , "rbx"
@@ -252,13 +252,13 @@ static void MIX_AREAS_32(unsigned int size,
 #            ifdef BOUNDED_RBX
 		"\tmovq %[old_rbx], %%rbx\n"
 #            endif
-		: [size] "+m" (size)
+		: [size] "+&rm" (size)
 #               ifdef BOUNDED_RBX
 		  , [old_rbx] "=m" (old_rbx)
 #               endif
 	        : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
-		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-		  [sum_step] "m" (sum_step)
+		  [dst_step] "im" (dst_step),  [src_step] "im" (src_step),
+		  [sum_step] "im" (sum_step)
 		: "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
 #               ifndef BOUNDED_RBX
 		  , "rbx"
@@ -364,13 +364,13 @@ static void MIX_AREAS_24(unsigned int size,
 #            ifdef BOUNDED_RBX
 		"\tmovq %[old_rbx], %%rbx\n"
 #            endif
-		: [size] "+m" (size)
+		: [size] "+&rm" (size)
 #               ifdef BOUNDED_RBX
 		  , [old_rbx] "=m" (old_rbx)
 #               endif
 	        : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
-		  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-		  [sum_step] "m" (sum_step)
+		  [dst_step] "im" (dst_step),  [src_step] "im" (src_step),
+		  [sum_step] "im" (sum_step)
 		: "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
 #               ifndef BOUNDED_RBX
 		  , "rbx"
--
2.17.1

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

end of thread, other threads:[~2020-04-29 19:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29 19:10 [PATCH 1/6 V2] [configure] check if the compiler is aware of the MMX technology frederic.recoules
2020-04-29 19:10 ` [PATCH 2/6 V2] [pcm_dmix assembly] change the token by symbolic names frederic.recoules
2020-04-29 19:10 ` [PATCH 3/6 V2] [pcm_dmix assembly] fix the interface for safety frederic.recoules
2020-04-29 19:10 ` [PATCH 4/6 V2] [pcm_dmix assembly] fix the interface for safety (mmx) frederic.recoules
2020-04-29 19:10 ` [PATCH 5/6 V2] [pcm_dmix assembly] refactor the PIC mode frederic.recoules
2020-04-29 19:10 ` [PATCH 6/6 V2] [pcm_dmix assembly] (minor) give more freedom over the constraints frederic.recoules

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).