All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/5] pcm_dmix assembly: change the token by symbolic names
@ 2020-05-06 17:19 frederic.recoules
  2020-05-06 17:19 ` [PATCH v3 2/5] pcm_dmix assembly: fix the interface for safety frederic.recoules
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: frederic.recoules @ 2020-05-06 17:19 UTC (permalink / raw)
  To: alsa-devel; +Cc: Frédéric Recoules

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

It eases the refactoring of assembly chunk since we can now
add/remove/move entries without worrying about maintaining
the token numbering in the template.

Note: does not impact the 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] 7+ messages in thread

* [PATCH v3 2/5] pcm_dmix assembly: fix the interface for safety
  2020-05-06 17:19 [PATCH v3 1/5] pcm_dmix assembly: change the token by symbolic names frederic.recoules
@ 2020-05-06 17:19 ` frederic.recoules
  2020-05-06 17:19 ` [PATCH v3 3/5] pcm_dmix assembly: fix the interface for safety (mmx) frederic.recoules
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: frederic.recoules @ 2020-05-06 17:19 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 accessed;
- (minor) add the "cc" clobber since flags are
  clobbered.

  The compiler is missing some dataflow information
  about the execution of the assembly chunks.
  For instance, it assumes that 'size' remains unchanged
  and that no input pointer is accessed.
  The compiler optimizer may take advantage of these
  assumption and produce a wrong code.

Note: currently produces 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] 7+ messages in thread

* [PATCH v3 3/5] pcm_dmix assembly: fix the interface for safety (mmx)
  2020-05-06 17:19 [PATCH v3 1/5] pcm_dmix assembly: change the token by symbolic names frederic.recoules
  2020-05-06 17:19 ` [PATCH v3 2/5] pcm_dmix assembly: fix the interface for safety frederic.recoules
@ 2020-05-06 17:19 ` frederic.recoules
  2020-05-06 17:19 ` [PATCH v3 4/5] pcm_dmix assembly: refactor the PIC mode frederic.recoules
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: frederic.recoules @ 2020-05-06 17:19 UTC (permalink / raw)
  To: alsa-devel; +Cc: Frédéric Recoules

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

- add mm0 in the clobber list if the compiler
  is aware of the mmx technology;
- otherwise, add the mmx aliased x87 floating point
  registers in the clobbers;
- the configure now checks if the compiler is aware of
  the MMX technology.

  The compiler assumes none of the mmx or x87 registers are used
  by the function. If it chooses to store some data in them, they
  will be overwritten by the chunk.
  Recall that any mmx instruction invalidate the whole set of
  x87 floating point registers.

  Note: currently does not impact the binary output.

Signed-off-by: Frédéric Recoules <frederic.recoules@orange.fr>
---
 configure.ac              | 7 +++++++
 src/pcm/pcm_dmix_i386.h   | 6 ++++++
 src/pcm/pcm_dmix_x86_64.h | 6 ++++++
 3 files changed, 19 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"
diff --git a/src/pcm/pcm_dmix_i386.h b/src/pcm/pcm_dmix_i386.h
index 3ea0737d..5c900bf1 100644
--- a/src/pcm/pcm_dmix_i386.h
+++ b/src/pcm/pcm_dmix_i386.h
@@ -237,6 +237,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"
+#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..803d3b24 100644
--- a/src/pcm/pcm_dmix_x86_64.h
+++ b/src/pcm/pcm_dmix_x86_64.h
@@ -119,6 +119,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"
+#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] 7+ messages in thread

* [PATCH v3 4/5] pcm_dmix assembly: refactor the PIC mode
  2020-05-06 17:19 [PATCH v3 1/5] pcm_dmix assembly: change the token by symbolic names frederic.recoules
  2020-05-06 17:19 ` [PATCH v3 2/5] pcm_dmix assembly: fix the interface for safety frederic.recoules
  2020-05-06 17:19 ` [PATCH v3 3/5] pcm_dmix assembly: fix the interface for safety (mmx) frederic.recoules
@ 2020-05-06 17:19 ` frederic.recoules
  2020-05-06 17:19 ` [PATCH v3 5/5] pcm_dmix assembly: give more freedom over the constraints frederic.recoules
  2020-05-06 20:36 ` [PATCH v3 1/5] pcm_dmix assembly: change the token by symbolic names Takashi Iwai
  4 siblings, 0 replies; 7+ messages in thread
From: frederic.recoules @ 2020-05-06 17:19 UTC (permalink / raw)
  To: alsa-devel; +Cc: Frédéric Recoules

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

Newer versions of GCC (> 5.0) accept that ebx is declared
in the clobber list even in PIC mode. Meanwhile, even
unlikely, the compiler may use ebx as base address of
one of the memory entry, making subsequent access to
them unreliable ('size', 'dst_step', 'src_step', 'sum_step').

Adding ebx in the clobber solves the problem.
By the way, the entry 'old_ebx' is no longer required.

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 5c900bf1..bd1d6644 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
 		 */
@@ -230,13 +245,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"
 #else
@@ -254,8 +276,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
@@ -266,8 +289,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
 		 */
@@ -349,13 +373,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
 	);
 }
 
@@ -367,8 +398,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
@@ -379,8 +411,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
 		 */
@@ -455,13 +488,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
 	);
 }
 
@@ -473,8 +513,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
@@ -485,8 +526,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
 		 */
@@ -554,12 +596,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 803d3b24..fff07529 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
 		 */
@@ -112,13 +118,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"
 #else
@@ -136,8 +149,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
@@ -148,8 +162,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
 		 */
@@ -233,13 +248,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
 	);
 }
 
@@ -251,8 +273,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
@@ -263,8 +286,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
 		 */
@@ -336,12 +360,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


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

* [PATCH v3 5/5] pcm_dmix assembly: give more freedom over the constraints
  2020-05-06 17:19 [PATCH v3 1/5] pcm_dmix assembly: change the token by symbolic names frederic.recoules
                   ` (2 preceding siblings ...)
  2020-05-06 17:19 ` [PATCH v3 4/5] pcm_dmix assembly: refactor the PIC mode frederic.recoules
@ 2020-05-06 17:19 ` frederic.recoules
  2020-05-06 20:36 ` [PATCH v3 1/5] pcm_dmix assembly: change the token by symbolic names Takashi Iwai
  4 siblings, 0 replies; 7+ messages in thread
From: frederic.recoules @ 2020-05-06 17:19 UTC (permalink / raw)
  To: alsa-devel; +Cc: Frédéric Recoules

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

Minor changes that could help the compiler to produce a
better (smaller/faster) code.

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 bd1d6644..8dcba3d8 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"
@@ -248,13 +248,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"
@@ -376,13 +376,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"
@@ -491,13 +491,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"
@@ -599,13 +599,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 fff07529..aef5d90c 100644
--- a/src/pcm/pcm_dmix_x86_64.h
+++ b/src/pcm/pcm_dmix_x86_64.h
@@ -121,13 +121,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"
@@ -251,13 +251,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"
@@ -363,13 +363,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] 7+ messages in thread

* Re: [PATCH v3 1/5] pcm_dmix assembly: change the token by symbolic names
  2020-05-06 17:19 [PATCH v3 1/5] pcm_dmix assembly: change the token by symbolic names frederic.recoules
                   ` (3 preceding siblings ...)
  2020-05-06 17:19 ` [PATCH v3 5/5] pcm_dmix assembly: give more freedom over the constraints frederic.recoules
@ 2020-05-06 20:36 ` Takashi Iwai
  2020-05-14 17:33   ` FRÉDÉRIC RECOULES
  4 siblings, 1 reply; 7+ messages in thread
From: Takashi Iwai @ 2020-05-06 20:36 UTC (permalink / raw)
  To: frederic.recoules; +Cc: alsa-devel, Frédéric Recoules

On Wed, 06 May 2020 19:19:20 +0200,
frederic.recoules@univ-grenoble-alpes.fr wrote:
> 
> From: Frédéric Recoules <frederic.recoules@orange.fr>
> 
> It eases the refactoring of assembly chunk since we can now
> add/remove/move entries without worrying about maintaining
> the token numbering in the template.
> 
> Note: does not impact the binary output.
> 
> Signed-off-by: Frédéric Recoules <frederic.recoules@orange.fr>

Now I applied all five patches.
Thanks!

Takashi

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

* Re: [PATCH v3 1/5] pcm_dmix assembly: change the token by symbolic names
  2020-05-06 20:36 ` [PATCH v3 1/5] pcm_dmix assembly: change the token by symbolic names Takashi Iwai
@ 2020-05-14 17:33   ` FRÉDÉRIC RECOULES
  0 siblings, 0 replies; 7+ messages in thread
From: FRÉDÉRIC RECOULES @ 2020-05-14 17:33 UTC (permalink / raw)
  To: tiwai; +Cc: alsa-devel, frederic recoules

Hi Takashi, 

I am quite late (I was very busy these days) but thank you for applying the patches. 

I wish you well, 
Regards, 

Frédéric 


De: "tiwai" <tiwai@suse.de> 
À: "frederic recoules" <frederic.recoules@univ-grenoble-alpes.fr> 
Cc: "alsa-devel" <alsa-devel@alsa-project.org>, "frederic recoules" <frederic.recoules@orange.fr> 
Envoyé: Mercredi 6 Mai 2020 22:36:37 
Objet: Re: [PATCH v3 1/5] pcm_dmix assembly: change the token by symbolic names 

On Wed, 06 May 2020 19:19:20 +0200, 
frederic.recoules@univ-grenoble-alpes.fr wrote: 
> 
> From: Frédéric Recoules <frederic.recoules@orange.fr> 
> 
> It eases the refactoring of assembly chunk since we can now 
> add/remove/move entries without worrying about maintaining 
> the token numbering in the template. 
> 
> Note: does not impact the binary output. 
> 
> Signed-off-by: Frédéric Recoules <frederic.recoules@orange.fr> 

Now I applied all five patches. 
Thanks! 

Takashi 

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

end of thread, other threads:[~2020-05-14 17:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-06 17:19 [PATCH v3 1/5] pcm_dmix assembly: change the token by symbolic names frederic.recoules
2020-05-06 17:19 ` [PATCH v3 2/5] pcm_dmix assembly: fix the interface for safety frederic.recoules
2020-05-06 17:19 ` [PATCH v3 3/5] pcm_dmix assembly: fix the interface for safety (mmx) frederic.recoules
2020-05-06 17:19 ` [PATCH v3 4/5] pcm_dmix assembly: refactor the PIC mode frederic.recoules
2020-05-06 17:19 ` [PATCH v3 5/5] pcm_dmix assembly: give more freedom over the constraints frederic.recoules
2020-05-06 20:36 ` [PATCH v3 1/5] pcm_dmix assembly: change the token by symbolic names Takashi Iwai
2020-05-14 17:33   ` FRÉDÉRIC RECOULES

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.