From: Richard Henderson <rth@twiddle.net>
To: libc-ports@sourceware.org
Cc: joseph@codesourcery.com
Subject: [PATCH v2 10/14] arm: Implement hard-tp for GET_TLS
Date: Fri, 01 Mar 2013 17:36:00 -0000 [thread overview]
Message-ID: <1362159320-5934-11-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1362159320-5934-1-git-send-email-rth@twiddle.net>
---
* sysdeps/arm/sysdep.h (ARCH_HAS_HARD_TP): New macro.
(GET_TLS): Use hard-tp if ARCH_HAS_HARD_TP.
* sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S: Likewise.
* sysdeps/unix/sysv/linux/arm/sysdep.h (GET_TLS): Don't override
the default definition if ARCH_HAS_HARD_TP.
---
ports/sysdeps/arm/sysdep.h | 14 +++++++++++---
ports/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S | 5 ++++-
ports/sysdeps/unix/sysv/linux/arm/sysdep.h | 16 +++++++++-------
3 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/ports/sysdeps/arm/sysdep.h b/ports/sysdeps/arm/sysdep.h
index c09e680..03739a4 100644
--- a/ports/sysdeps/arm/sysdep.h
+++ b/ports/sysdeps/arm/sysdep.h
@@ -47,6 +47,9 @@
#if __ARM_ARCH > 4
# define ARCH_HAS_BLX
#endif
+#if __ARM_ARCH > 6 || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6ZK__)
+# define ARCH_HAS_HARD_TP
+#endif
#if __ARM_ARCH > 6 || defined(__ARM_ARCH_6T2__)
# define ARCH_HAS_T2
#endif
@@ -184,10 +187,14 @@
/* Helper to get the TLS base pointer. The interface is that TMP is a
register that may be used to hold the LR, if necessary. TMP may be
LR itself to indicate that LR need not be saved. The base pointer
- is returned in R0. Only R0 and TMP are modified.
+ is returned in R0. Only R0 and TMP are modified. */
- At this generic level we have no tricks to pull. Call the ABI routine. */
-# define GET_TLS(TMP) \
+# ifdef ARCH_HAS_HARD_TP
+/* If the cpu has cp15 available, use it. */
+# define GET_TLS(TMP) mrc p15, 0, r0, c13, c0, 3
+# else
+/* At this generic level we have no tricks to pull. Call the ABI routine. */
+# define GET_TLS(TMP) \
push { r1, r2, r3, lr }; \
cfi_remember_state; \
cfi_adjust_cfa_offset (16); \
@@ -198,6 +205,7 @@
bl __aeabi_read_tp; \
pop { r1, r2, r3, lr }; \
cfi_restore_state
+# endif /* ARCH_HAS_HARD_TP */
#endif /* __ASSEMBLER__ */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S b/ports/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S
index ecdc322..21e3229 100644
--- a/ports/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S
+++ b/ports/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S
@@ -41,7 +41,10 @@
.hidden __aeabi_read_tp
ENTRY (__aeabi_read_tp)
-#ifdef __thumb2__
+#ifdef ARCH_HAS_HARD_TP
+ mrc p15, 0, r0, c13, c0, 3
+ bx lr
+#elif defined(__thumb2__)
movw r0, #0x0fe0
movt r0, #0xffff
bx r0
diff --git a/ports/sysdeps/unix/sysv/linux/arm/sysdep.h b/ports/sysdeps/unix/sysv/linux/arm/sysdep.h
index 39872b8..89fea7a 100644
--- a/ports/sysdeps/unix/sysv/linux/arm/sysdep.h
+++ b/ports/sysdeps/unix/sysv/linux/arm/sysdep.h
@@ -45,26 +45,27 @@
#ifdef __ASSEMBLER__
+#ifndef ARCH_HAS_HARD_TP
/* Internal macro calling the linux kernel kuser_get_tls helper.
Note that in thumb mode, a constant pool break is often out of range, so
we always expand the constant inline. */
-#ifdef __thumb2__
-# define GET_TLS_BODY \
+# ifdef __thumb2__
+# define GET_TLS_BODY \
movw r0, #0x0fe0; \
movt r0, #0xffff; \
blx r0
-#else
-# define GET_TLS_BODY \
+# else
+# define GET_TLS_BODY \
mov r0, #0xffff0fff; /* Point to the high page. */ \
mov lr, pc; /* Save our return address. */ \
sub pc, r0, #31 /* Jump to the TLS entry. */
-#endif
+# endif
/* Helper to get the TLS base pointer. Save LR in TMP, return in R0,
and no other registers clobbered. TMP may be LR itself to indicate
that no save is necessary. */
-#undef GET_TLS
-#define GET_TLS(TMP) \
+# undef GET_TLS
+# define GET_TLS(TMP) \
.ifnc TMP, lr; \
mov TMP, lr; \
cfi_register (lr, TMP); \
@@ -74,6 +75,7 @@
.else; \
GET_TLS_BODY; \
.endif
+#endif /* ARCH_HAS_HARD_TP */
/* Linux uses a negative return value to indicate syscall errors,
unlike most Unices, which use the condition codes' carry flag.
--
1.8.1.2
next prev parent reply other threads:[~2013-03-01 17:36 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-01 17:36 [PATCH v2 00/14] ARM improvements Richard Henderson
2013-03-01 17:36 ` [PATCH v2 09/14] arm: Tidy architecture selection Richard Henderson
2013-03-01 17:55 ` Roland McGrath
2013-03-05 2:01 ` Joseph S. Myers
2013-03-01 17:36 ` [PATCH v2 05/14] arm: Use push/pop mnemonics Richard Henderson
2013-03-01 17:36 ` [PATCH v2 08/14] arm: Unless arm4t, pop return address directly into pc Richard Henderson
2013-03-01 17:36 ` [PATCH v2 02/14] arm: Introduce and use NEGOFF series of macros Richard Henderson
2013-03-01 17:57 ` Roland McGrath
2013-03-05 1:42 ` Joseph S. Myers
2013-03-01 17:36 ` [PATCH v2 03/14] arm: Introduce and use GET_TLS Richard Henderson
2013-03-01 17:57 ` Roland McGrath
2013-03-05 1:45 ` Joseph S. Myers
2013-03-01 17:36 ` [PATCH v2 12/14] arm: Add optimized addmul_1 Richard Henderson
2013-03-01 17:58 ` Roland McGrath
2013-03-01 18:00 ` Roland McGrath
2013-03-06 1:18 ` Joseph S. Myers
2013-10-25 22:13 ` Roland McGrath
2013-03-06 1:11 ` Joseph S. Myers
2013-03-01 17:36 ` [PATCH v2 11/14] arm: Add optimized ffs for armv6t2 Richard Henderson
2013-03-05 2:08 ` Joseph S. Myers
2013-03-06 15:52 ` Richard Henderson
2013-03-01 17:36 ` [PATCH v2 07/14] arm: Commonize BX conditionals Richard Henderson
2013-03-01 17:36 ` [PATCH v2 01/14] arm: Introduce and use LDST_PCREL Richard Henderson
2013-03-04 17:47 ` Joseph S. Myers
2013-03-01 17:36 ` Richard Henderson [this message]
2013-03-01 17:55 ` [PATCH v2 10/14] arm: Implement hard-tp for GET_TLS Roland McGrath
2013-03-05 2:01 ` Joseph S. Myers
2013-03-01 17:36 ` [PATCH v2 06/14] arm: Delete LOADREGS macro Richard Henderson
2013-03-01 17:36 ` [PATCH v2 13/14] arm: Add optimized submul_1 Richard Henderson
2013-03-01 17:58 ` Roland McGrath
2013-03-06 1:14 ` Joseph S. Myers
2013-03-01 17:36 ` [PATCH v2 14/14] arm: Add optimized add_n and sub_n Richard Henderson
2013-03-01 17:59 ` Roland McGrath
2013-03-06 0:53 ` Joseph S. Myers
2013-03-01 17:36 ` [PATCH v2 04/14] arm: Enable thumb2 mode in assembly files Richard Henderson
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=1362159320-5934-11-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=joseph@codesourcery.com \
--cc=libc-ports@sourceware.org \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).