All of lore.kernel.org
 help / color / mirror / Atom feed
From: frederic.recoules@univ-grenoble-alpes.fr
To: alsa-devel@alsa-project.org
Cc: "Frédéric Recoules" <frederic.recoules@orange.fr>
Subject: [PATCH v3 1/5] pcm_dmix assembly: change the token by symbolic names
Date: Wed,  6 May 2020 19:19:20 +0200	[thread overview]
Message-ID: <20200506171924.2644-1-frederic.recoules@univ-grenoble-alpes.fr> (raw)

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


             reply	other threads:[~2020-05-06 17:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06 17:19 frederic.recoules [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200506171924.2644-1-frederic.recoules@univ-grenoble-alpes.fr \
    --to=frederic.recoules@univ-grenoble-alpes.fr \
    --cc=alsa-devel@alsa-project.org \
    --cc=frederic.recoules@orange.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.