diff mbox series

[4/6,V2,pcm_dmix,assembly] fix the interface for safety (mmx)

Message ID 20200429191039.28106-4-frederic.recoules@univ-grenoble-alpes.fr
State New
Headers show
Series None | expand

Commit Message

frederic.recoules@univ-grenoble-alpes.fr April 29, 2020, 7:10 p.m. UTC
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(-)

--
2.17.1
diff mbox series

Patch

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
 	);
 }