Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/common/lib/libc/arch/powerpc/atomic Reduce duplication.
details: https://anonhg.NetBSD.org/src/rev/3a0700b00e2a
branches: trunk
changeset: 327431:3a0700b00e2a
user: matt <matt%NetBSD.org@localhost>
date: Fri Mar 07 07:17:54 2014 +0000
description:
Reduce duplication.
Use beqlr to quicken returns
diffstat:
common/lib/libc/arch/powerpc/atomic/atomic_add.S | 61 +++++++++--------
common/lib/libc/arch/powerpc/atomic/atomic_and.S | 47 ++++++-------
common/lib/libc/arch/powerpc/atomic/atomic_cas.S | 69 ++++++++++++++------
common/lib/libc/arch/powerpc/atomic/atomic_dec.S | 64 ++++++++++---------
common/lib/libc/arch/powerpc/atomic/atomic_inc.S | 61 +++++++++--------
common/lib/libc/arch/powerpc/atomic/atomic_op_asm.h | 52 +++++++++++++++-
common/lib/libc/arch/powerpc/atomic/atomic_or.S | 47 ++++++-------
common/lib/libc/arch/powerpc/atomic/atomic_swap.S | 36 ++++++++--
8 files changed, 266 insertions(+), 171 deletions(-)
diffs (truncated from 592 to 300 lines):
diff -r 0e794585525d -r 3a0700b00e2a common/lib/libc/arch/powerpc/atomic/atomic_add.S
--- a/common/lib/libc/arch/powerpc/atomic/atomic_add.S Fri Mar 07 06:01:34 2014 +0000
+++ b/common/lib/libc/arch/powerpc/atomic/atomic_add.S Fri Mar 07 07:17:54 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_add.S,v 1.7 2011/01/15 07:31:11 matt Exp $ */
+/* $NetBSD: atomic_add.S,v 1.8 2014/03/07 07:17:54 matt Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -31,40 +31,43 @@
#include "atomic_op_asm.h"
-__RCSID("$NetBSD: atomic_add.S,v 1.7 2011/01/15 07:31:11 matt Exp $")
+__RCSID("$NetBSD: atomic_add.S,v 1.8 2014/03/07 07:17:54 matt Exp $")
.text
-ENTRY(_atomic_add_32)
-1: lwarx %r10,0,%r3
- add %r10,%r10,%r4
- stwcx. %r10,0,%r3
- bne- 1b
- blr
-END(_atomic_add_32)
-ATOMIC_OP_ALIAS(atomic_add_32,_atomic_add_32)
+ATOMIC_OP_32(add)
+ATOMIC_OP_32_NV(add)
+
ATOMIC_OP_ALIAS(atomic_add_int,_atomic_add_32)
+ATOMIC_OP_ALIAS(atomic_add_int_nv,_atomic_add_32_nv)
+
STRONG_ALIAS(_atomic_add_int,_atomic_add_32)
-#if !defined(_LP64)
+STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv)
+
+#ifdef _LP64
+ATOMIC_OP_64(add)
+ATOMIC_OP_64_NV(add)
+
+ATOMIC_OP_ALIAS(atomic_add_long,_atomic_add_64)
+ATOMIC_OP_ALIAS(atomic_add_long_nv,_atomic_add_64_nv)
+
+ATOMIC_OP_ALIAS(atomic_add_ptr,_atomic_add_64)
+ATOMIC_OP_ALIAS(atomic_add_ptr_nv,_atomic_add_64_nv)
+
+STRONG_ALIAS(_atomic_add_long,_atomic_add_64)
+STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_64_nv)
+
+STRONG_ALIAS(_atomic_add_ptr,_atomic_add_64)
+STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_64_nv)
+#else
ATOMIC_OP_ALIAS(atomic_add_long,_atomic_add_32)
+ATOMIC_OP_ALIAS(atomic_add_long_nv,_atomic_add_32_nv)
+
+ATOMIC_OP_ALIAS(atomic_add_ptr,_atomic_add_32)
+ATOMIC_OP_ALIAS(atomic_add_ptr_nv,_atomic_add_32_nv)
+
STRONG_ALIAS(_atomic_add_long,_atomic_add_32)
-ATOMIC_OP_ALIAS(atomic_add_ptr,_atomic_add_32)
+STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_32_nv)
+
STRONG_ALIAS(_atomic_add_ptr,_atomic_add_32)
-#endif
-
-ENTRY(_atomic_add_32_nv)
-1: lwarx %r10,0,%r3
- add %r10,%r10,%r4
- stwcx. %r10,0,%r3
- bne- 1b
- mr %r3,%r10
- blr
-END(_atomic_add_32_nv)
-ATOMIC_OP_ALIAS(atomic_add_32_nv,_atomic_add_32_nv)
-ATOMIC_OP_ALIAS(atomic_add_int_nv,_atomic_add_32_nv)
-STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv)
-#if !defined(_LP64)
-ATOMIC_OP_ALIAS(atomic_add_long_nv,_atomic_add_32_nv)
-STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_32_nv)
-ATOMIC_OP_ALIAS(atomic_add_ptr_nv,_atomic_add_32_nv)
STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_32_nv)
#endif
diff -r 0e794585525d -r 3a0700b00e2a common/lib/libc/arch/powerpc/atomic/atomic_and.S
--- a/common/lib/libc/arch/powerpc/atomic/atomic_and.S Fri Mar 07 06:01:34 2014 +0000
+++ b/common/lib/libc/arch/powerpc/atomic/atomic_and.S Fri Mar 07 07:17:54 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_and.S,v 1.6 2011/01/15 07:31:11 matt Exp $ */
+/* $NetBSD: atomic_and.S,v 1.7 2014/03/07 07:17:54 matt Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -31,36 +31,31 @@
#include "atomic_op_asm.h"
-__RCSID("$NetBSD: atomic_and.S,v 1.6 2011/01/15 07:31:11 matt Exp $")
+__RCSID("$NetBSD: atomic_and.S,v 1.7 2014/03/07 07:17:54 matt Exp $")
.text
-ENTRY(_atomic_and_32)
-1: lwarx %r10,0,%r3
- and %r10,%r10,%r4
- stwcx. %r10,0,%r3
- bne- 1b
- blr
-END(_atomic_and_32)
-ATOMIC_OP_ALIAS(atomic_and_32,_atomic_and_32)
+ATOMIC_OP_32(and)
+ATOMIC_OP_32_NV(and)
+
ATOMIC_OP_ALIAS(atomic_and_uint,_atomic_and_32)
+ATOMIC_OP_ALIAS(atomic_and_uint_nv,_atomic_and_32_nv)
+
STRONG_ALIAS(_atomic_and_uint,_atomic_and_32)
-#if !defined(_LP64)
+STRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv)
+
+#if defined(_LP64)
+ATOMIC_OP_64(and)
+ATOMIC_OP_64_NV(and)
+
+ATOMIC_OP_ALIAS(atomic_and_ulong,_atomic_and_64)
+ATOMIC_OP_ALIAS(atomic_and_ulong_nv,_atomic_and_64_nv)
+
+STRONG_ALIAS(_atomic_and_ulong,_atomic_and_64)
+STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_64_nv)
+#else
ATOMIC_OP_ALIAS(atomic_and_ulong,_atomic_and_32)
+ATOMIC_OP_ALIAS(atomic_and_ulong_nv,_atomic_and_32_nv)
+
STRONG_ALIAS(_atomic_and_ulong,_atomic_and_32)
-#endif
-
-ENTRY(_atomic_and_32_nv)
-1: lwarx %r10,0,%r3
- and %r10,%r10,%r4
- stwcx. %r10,0,%r3
- bne- 1b
- mr %r3,%r10
- blr
-END(_atomic_and_32_nv)
-ATOMIC_OP_ALIAS(atomic_and_32_nv,_atomic_and_32_nv)
-ATOMIC_OP_ALIAS(atomic_and_uint_nv,_atomic_and_32_nv)
-STRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv)
-#if !defined(_LP64)
-ATOMIC_OP_ALIAS(atomic_and_ulong_nv,_atomic_and_32_nv)
STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_32_nv)
#endif
diff -r 0e794585525d -r 3a0700b00e2a common/lib/libc/arch/powerpc/atomic/atomic_cas.S
--- a/common/lib/libc/arch/powerpc/atomic/atomic_cas.S Fri Mar 07 06:01:34 2014 +0000
+++ b/common/lib/libc/arch/powerpc/atomic/atomic_cas.S Fri Mar 07 07:17:54 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_cas.S,v 1.7 2011/01/15 07:31:11 matt Exp $ */
+/* $NetBSD: atomic_cas.S,v 1.8 2014/03/07 07:17:54 matt Exp $ */
/*-
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
@@ -31,36 +31,65 @@
#include "atomic_op_asm.h"
-__RCSID("$NetBSD: atomic_cas.S,v 1.7 2011/01/15 07:31:11 matt Exp $")
+__RCSID("$NetBSD: atomic_cas.S,v 1.8 2014/03/07 07:17:54 matt Exp $")
.text
ENTRY(_atomic_cas_32)
-1: lwarx %r10,0,%r3
- cmpw %r10,%r4
- bne- 2f
- stwcx. %r5,0,%r3
- bne- 1b
-2: mr %r3,%r10
- blr
+ mr %r10,%r3
+1: lwarx %r3,0,%r10
+ cmpw %r3,%r4
+ bnelr-
+ stwcx. %r5,0,%r10
+ beqlr+
+ b 1b
END(_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32)
-ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32)
-STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32)
-#if !defined(_LP64)
-ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_32)
-STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32)
-ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_32)
-STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32)
-#endif
-
ATOMIC_OP_ALIAS(atomic_cas_32_ni,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32)
+
+ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_uint_ni,_atomic_cas_32)
+
+STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32)
-#if !defined(_LP64)
+
+#if defined(_LP64)
+ENTRY(_atomic_cas_64)
+ mr %r10,%r3
+1: ldarx %r3,0,%r10
+ cmpd %r3,%r4
+ bnelr-
+ stdcx. %r5,0,%r10
+ beqlr+
+ b 1b
+END(_atomic_cas_64)
+
+ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64)
+ATOMIC_OP_ALIAS(atomic_cas_64_ni,_atomic_cas_64)
+STRONG_ALIAS(_atomic_cas_64_ni,_atomic_cas_64)
+
+ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_64)
+ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_64)
+
+ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_64)
+ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_64)
+
+STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_64)
+STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_64)
+
+STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_64)
+STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_64)
+#else
+ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_32)
+
+ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_32)
+ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_32)
+
+STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32)
-ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_32)
+
+STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_32)
#endif
diff -r 0e794585525d -r 3a0700b00e2a common/lib/libc/arch/powerpc/atomic/atomic_dec.S
--- a/common/lib/libc/arch/powerpc/atomic/atomic_dec.S Fri Mar 07 06:01:34 2014 +0000
+++ b/common/lib/libc/arch/powerpc/atomic/atomic_dec.S Fri Mar 07 07:17:54 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_dec.S,v 1.6 2011/01/15 07:31:11 matt Exp $ */
+/* $NetBSD: atomic_dec.S,v 1.7 2014/03/07 07:17:54 matt Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -31,40 +31,42 @@
#include "atomic_op_asm.h"
-__RCSID("$NetBSD: atomic_dec.S,v 1.6 2011/01/15 07:31:11 matt Exp $")
+__RCSID("$NetBSD: atomic_dec.S,v 1.7 2014/03/07 07:17:54 matt Exp $")
.text
+ATOMIC_OP_32_ARG(dec,addi,-1)
+ATOMIC_OP_32_ARG_NV(dec,addi,-1)
+
+ATOMIC_OP_ALIAS(atomic_dec_uint,_atomic_dec_32)
+ATOMIC_OP_ALIAS(atomic_dec_uint_nv,_atomic_dec_32_nv)
+
+STRONG_ALIAS(_atomic_dec_uint,_atomic_dec_32)
+STRONG_ALIAS(_atomic_dec_uint_nv,_atomic_dec_32_nv)
+
+#if defined(_LP64)
+ATOMIC_OP_64_ARG(dec,addi,-1)
+ATOMIC_OP_64_ARG_NV(dec,addi,-1)
+
+ATOMIC_OP_ALIAS(atomic_dec_ulong,_atomic_dec_64)
+ATOMIC_OP_ALIAS(atomic_dec_ulong_nv,_atomic_dec_64_nv)
-ENTRY(_atomic_dec_32)
-1: lwarx %r10,0,%r3
- addi %r10,%r10,-1
- stwcx. %r10,0,%r3
- bne- 1b
- blr
-END(_atomic_dec_32)
-ATOMIC_OP_ALIAS(atomic_dec_32,_atomic_dec_32)
-ATOMIC_OP_ALIAS(atomic_dec_uint,_atomic_dec_32)
-STRONG_ALIAS(_atomic_dec_uint,_atomic_dec_32)
-#if !defined(_LP64)
+ATOMIC_OP_ALIAS(atomic_dec_ptr,_atomic_dec_64)
+ATOMIC_OP_ALIAS(atomic_dec_ptr_nv,_atomic_dec_64_nv)
+
+STRONG_ALIAS(_atomic_dec_ulong,_atomic_dec_64)
+STRONG_ALIAS(_atomic_dec_ulong_nv,_atomic_dec_64_nv)
+
+STRONG_ALIAS(_atomic_dec_ptr,_atomic_dec_64)
+STRONG_ALIAS(_atomic_dec_ptr_nv,_atomic_dec_64_nv)
+#else
ATOMIC_OP_ALIAS(atomic_dec_ulong,_atomic_dec_32)
+ATOMIC_OP_ALIAS(atomic_dec_ulong_nv,_atomic_dec_32_nv)
+
+ATOMIC_OP_ALIAS(atomic_dec_ptr,_atomic_dec_32)
+ATOMIC_OP_ALIAS(atomic_dec_ptr_nv,_atomic_dec_32_nv)
+
STRONG_ALIAS(_atomic_dec_ulong,_atomic_dec_32)
Home |
Main Index |
Thread Index |
Old Index