From: Richard Henderson <rth@twiddle.net>
To: libffi-discuss@sourceware.org
Cc: Ulrich.Weigand@de.ibm.com, vogt@linux.vnet.ibm.com,
krebbel@linux.vnet.ibm.com, Richard Henderson <rth@redhat.com>
Subject: [PATCH 4/4] s390: Use pc-relative insns in 31-bit mode
Date: Thu, 18 Dec 2014 21:33:00 -0000 [thread overview]
Message-ID: <1418938403-15836-5-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1418938403-15836-1-git-send-email-rth@twiddle.net>
From: Richard Henderson <rth@redhat.com>
It's silly to stick to esa/390 features when the compiler won't.
Detect when brasl and larl are used by the compiler and then use
them in the assembly.
---
configure.ac | 17 +++++++++++++++++
src/s390/sysv.S | 19 +++++++++++++++++--
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index d5414f9..2941cd7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -183,6 +183,23 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64
fi
fi
+if test x$TARGET = xS390; then
+ AC_CACHE_CHECK([compiler uses zarch features],
+ libffi_cv_as_s390_zarch, [
+ libffi_cv_as_s390_zarch=no
+ echo 'void foo(void) { bar(); bar(); }' > conftest.c
+ if $CC $CFLAGS -S conftest.c > /dev/null 2>&1; then
+ if grep -q brasl conftest.s; then
+ libffi_cv_as_s390_zarch=yes
+ fi
+ fi
+ ])
+ if test "x$libffi_cv_as_s390_zarch" = xyes; then
+ AC_DEFINE(HAVE_AS_S390_ZARCH, 1,
+ [Define if the compiler uses zarch features.])
+ fi
+fi
+
# On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC.
AC_ARG_ENABLE(pax_emutramp,
[ --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC],
diff --git a/src/s390/sysv.S b/src/s390/sysv.S
index df9083e..1869269 100644
--- a/src/s390/sysv.S
+++ b/src/s390/sysv.S
@@ -55,13 +55,21 @@ ffi_call_SYSV:
.cfi_rel_offset r14, 56
.cfi_def_cfa_register r13
l %r15,60(%r2) # Set up outgoing stack
+#ifdef HAVE_AS_S390_ZARCH
+ larl %r14,.Ltable
+#else
basr %r14,0 # Set up base register
.Lbase:
+#endif
sla %r3,3 # ret_type *= 8
lr %r12,%r4 # Save ret_addr
lr %r1,%r5 # Save fun
lr %r0,%r6 # Install static chain
+#ifdef HAVE_AS_S390_ZARCH
+ la %r14,0(%r14,%r3) # Set return address
+#else
la %r14,.Ltable-.Lbase(%r14,%r3) # Set return address
+#endif
lm %r2,%r6,8(%r13) # Load arguments
ld %f0,64(%r13)
ld %f2,72(%r13)
@@ -141,10 +149,12 @@ ffi_closure_SYSV:
.cfi_rel_offset r13, 52
.cfi_rel_offset r14, 56
.cfi_rel_offset r15, 60
+#ifndef HAVE_AS_S390_ZARCH
basr %r13,0 # Set up base register
.Lcbase:
- ahi %r15,-96-8 # Set up stack frame
l %r1,.Lchelper-.Lcbase(%r13) # Get helper function
+#endif
+ ahi %r15,-96-8 # Set up stack frame
st %r12,0(%r15) # Set up back chain
std %f0,64(%r12) # Save fp arguments
@@ -154,7 +164,11 @@ ffi_closure_SYSV:
st %r5,96(%r15)
la %r6,64(%r12) # FPRs
la %r5,8(%r12) # GPRs
+#ifdef HAVE_AS_S390_ZARCH
+ brasl %r14,ffi_closure_helper_SYSV
+#else
bas %r14,0(%r1,%r13) # Call helper
+#endif
lr %r15,%r12
.cfi_def_cfa_register r15
@@ -165,10 +179,11 @@ ffi_closure_SYSV:
br %r14
.cfi_endproc
+#ifndef HAVE_AS_S390_ZARCH
.align 4
.Lchelper:
.long ffi_closure_helper_SYSV-.Lcbase
-
+#endif
.size ffi_closure_SYSV,.-ffi_closure_SYSV
--
2.1.0
next prev parent reply other threads:[~2014-12-18 21:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-18 21:33 [PATCH 0/4] s390 improvements Richard Henderson
2014-12-18 21:33 ` [PATCH 2/4] s390: Avoid aliasing warnings Richard Henderson
2014-12-18 21:33 ` Richard Henderson [this message]
2014-12-18 21:33 ` [PATCH 1/4] s390: Kill trailing whitespace Richard Henderson
2014-12-18 21:33 ` [PATCH 3/4] s390: Reorganize assembly Richard Henderson
2014-12-22 12:12 ` Dominik Vogt
2014-12-22 12:25 ` Dominik Vogt
2014-12-22 16:30 ` Richard Henderson
2014-12-23 9:54 ` Dominik Vogt
2014-12-19 15:07 ` [PATCH 0/4] s390 improvements Ulrich Weigand
2014-12-19 15:33 ` Richard Henderson
2014-12-19 16:15 ` Ulrich Weigand
2014-12-19 16:37 ` Richard Henderson
2014-12-19 17:08 ` Ulrich Weigand
2014-12-19 16:43 ` [PATCH 5/4] s390: Inline and tidy ffi_prep_args Richard Henderson
2014-12-22 11:34 ` [PATCH 0/4] s390 improvements Dominik Vogt
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=1418938403-15836-5-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=Ulrich.Weigand@de.ibm.com \
--cc=krebbel@linux.vnet.ibm.com \
--cc=libffi-discuss@sourceware.org \
--cc=rth@redhat.com \
--cc=vogt@linux.vnet.ibm.com \
/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).