Browse code

- ppc fixes (s/stw/stwx/, s/lwz/lwzx) - missing early clobbers added for x86, sparc*, armv6, ppc*, alpha

Andrei Pelinescu-Onciul authored on 05/04/2006 08:49:57
Showing 1 changed files
... ...
@@ -51,6 +51,8 @@
51 51
  *               fix (andrei)
52 52
  * 2006-04-04  sparc* optimizations, sparc32 smp support, armv6 no smp support,
53 53
  *              ppc, mips*, alpha optimizations (andrei)
54
+ * 2006-04-05  ppc fixes (s/stw/stwx/, s/lwz/lwzx), early clobber added
55
+ *             where needed (andrei)
54 56
  *
55 57
  */
56 58
 
... ...
@@ -170,7 +172,7 @@ inline static int tsl(fl_lock_t* lock)
170 170
 		" xor %0, %0 \n\t"
171 171
 		" btsl $0, %2 \n\t"
172 172
 		" setc %b0 \n\t"
173
-		: "=q" (val), "=m" (*lock) : "m"(*lock) : "memory", "cc"
173
+		: "=&q" (val), "=m" (*lock) : "m"(*lock) : "memory", "cc"
174 174
 	);
175 175
 #else
176 176
 	asm volatile(
... ...
@@ -183,7 +185,7 @@ inline static int tsl(fl_lock_t* lock)
183 183
 #endif
184 184
 		" xchgb %2, %b0 \n\t"
185 185
 		"1: \n\t"
186
-		: "=q" (val), "=m" (*lock) : "m"(*lock) : "memory"
186
+		: "=&q" (val), "=m" (*lock) : "m"(*lock) : "memory"
187 187
 #ifdef SPIN_OPTIMIZE
188 188
 				, "cc"
189 189
 #endif
... ...
@@ -199,7 +201,7 @@ inline static int tsl(fl_lock_t* lock)
199 199
 			"   ldstub [%2], %0 \n\t"
200 200
 			"1: \n\t"
201 201
 			/* membar_getlock must be  called outside this function */
202
-			: "=r"(val), "=m"(*lock) : "r"(lock): "memory"
202
+			: "=&r"(val), "=m"(*lock) : "r"(lock): "memory"
203 203
 	);
204 204
 #elif defined(__CPU_sparc)
205 205
 	asm volatile(
... ...
@@ -212,7 +214,7 @@ inline static int tsl(fl_lock_t* lock)
212 212
 			"   ldstub [%2], %0 \n\t"
213 213
 			"1: \n\t"
214 214
 			/* membar_getlock must be  called outside this function */
215
-			: "=r"(val), "=m"(*lock) : "r"(lock): "memory"
215
+			: "=&r"(val), "=m"(*lock) : "r"(lock): "memory"
216 216
 #ifdef SPIN_OPTIMIZE
217 217
 				, "cc"
218 218
 #endif
... ...
@@ -230,13 +232,13 @@ inline static int tsl(fl_lock_t* lock)
230 230
 			/* if %0!=0 => either it was 1 initially or was 0
231 231
 			 * and somebody changed it just before the strexeq (so the 
232 232
 			 * lock is taken) => it's safe to return %0 */
233
-			: "=r"(val), "=m"(*lock) : "r"(lock), "r"(1) : "cc"
233
+			: "=&r"(val), "=m"(*lock) : "r"(lock), "r"(1) : "cc"
234 234
 	);
235 235
 #elif defined(__CPU_ppc) || defined(__CPU_ppc64)
236 236
 	asm volatile(
237 237
 			"1: \n\t"
238 238
 #ifdef SPIN_OPTIMIZE
239
-			"   lwz %0, 0, (%2) \n\t"
239
+			"   lwzx %0, 0, %2 \n\t"
240 240
 			"   cmpwi %0, 0 \n\t"
241 241
 			"   bne- 2f \n\t" /* predict: not taken */
242 242
 #endif
... ...
@@ -247,7 +249,7 @@ inline static int tsl(fl_lock_t* lock)
247 247
 			"   bne-   1b\n\t"
248 248
 			/* membar_getlock must be  called outside this function */
249 249
 			"2:\n\t"
250
-			: "=r" (val), "=m"(*lock) :  "r" (lock), "r"(1) : "memory", "cc"
250
+			: "=&r" (val), "=m"(*lock) :  "r"(lock), "r"(1) : "memory", "cc"
251 251
         );
252 252
 #elif defined __CPU_mips2 || ( defined __CPU_mips && defined MIPS_HAS_LLSC ) \
253 253
 	|| defined __CPU_mips64
... ...
@@ -293,7 +295,7 @@ inline static int tsl(fl_lock_t* lock)
293 293
 		".subsection 2 \n\t"
294 294
 		"3:  br 1b \n\t"
295 295
 		".previous \n\t"
296
-		:"=&r" (val), "=m"(*lock), "=r"(tmp)
296
+		:"=&r" (val), "=m"(*lock), "=&r"(tmp)
297 297
 		:"m"(*lock) 
298 298
 		: "memory"
299 299
 	);
... ...
@@ -388,8 +390,8 @@ inline static void release_lock(fl_lock_t* lock)
388 388
 			 *             [IBM Prgramming Environments Manual, D.4.2.2]
389 389
 			 */
390 390
 			"lwsync\n\t"
391
-			"stw %1, 0(%2)\n\t"
392
-			: "=m"(*lock) : "r"(0), "r" (lock) : "memory"
391
+			"stwx %1, 0, %2\n\t"
392
+			: "=m"(*lock) : "r"(0), "r"(lock) : "memory"
393 393
 	);
394 394
 #elif defined __CPU_mips2 || ( defined __CPU_mips && defined MIPS_HAS_LLSC ) \
395 395
 	|| defined __CPU_mips64