alsa-devel.alsa-project.org archive mirror
 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 3/6 V2] [pcm_dmix assembly] fix the interface for safety
Date: Wed, 29 Apr 2020 21:10:36 +0200	[thread overview]
Message-ID: <20200429191039.28106-3-frederic.recoules@univ-grenoble-alpes.fr> (raw)
In-Reply-To: <20200429191039.28106-1-frederic.recoules@univ-grenoble-alpes.fr>

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

  parent reply	other threads:[~2020-04-29 19:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=20200429191039.28106-3-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 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).