This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
Re: [PATCH 3/4] s390: Reorganize assembly
- From: Dominik Vogt <vogt at linux dot vnet dot ibm dot com>
- To: libffi-discuss at sourceware dot org
- Date: Mon, 22 Dec 2014 13:12:50 +0100
- Subject: Re: [PATCH 3/4] s390: Reorganize assembly
- Authentication-results: sourceware.org; auth=none
- References: <1418938403-15836-1-git-send-email-rth at twiddle dot net> <1418938403-15836-4-git-send-email-rth at twiddle dot net>
- Reply-to: libffi-discuss at sourceware dot org
On Thu, Dec 18, 2014 at 03:33:22PM -0600, Richard Henderson wrote:
> -#define FFI390_RET_VOID 0
> -#define FFI390_RET_STRUCT 1
> -#define FFI390_RET_FLOAT 2
> -#define FFI390_RET_DOUBLE 3
> -#define FFI390_RET_INT32 4
> -#define FFI390_RET_INT64 5
> +#define FFI390_RET_DOUBLE 0
> +#define FFI390_RET_FLOAT 1
> +#define FFI390_RET_INT64 2
> +#define FFI390_RET_INT32 3
> +#define FFI390_RET_VOID 4
While we're at renumbering this list of values, if
FFI390_RET_INT32 had the value 0, this bit of assembly code would
not be necessary for s390x:
> + .balign 8
> +# FFI390_RET_INT32
> + # Never used, as we always store type ffi_arg.
> + # But the stg above is 6 bytes and we cannot
> + # jump around this case, so fall through.
> + nop
> + nop
(See attached patch.)
> + ffi_call_SYSV (frame, ret_type & FFI360_RET_MASK, rvalue, fn, closure);
...
> +#define FFI360_RET_MASK 7
^^^
Shouldn't that be "390"?
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
IBM Germany
>From 28c7949be357e6912add914c0574b107d3464e78 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Mon, 22 Dec 2014 12:51:59 +0100
Subject: [PATCH] s390: Optimize return type table in ffi_call_SYSV.
---
src/s390/internal.h | 8 ++++----
src/s390/sysv.S | 22 +++++++---------------
2 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/src/s390/internal.h b/src/s390/internal.h
index b875578..33246e9 100644
--- a/src/s390/internal.h
+++ b/src/s390/internal.h
@@ -1,8 +1,8 @@
/* If these values change, sysv.S must be adapted! */
-#define FFI390_RET_DOUBLE 0
-#define FFI390_RET_FLOAT 1
-#define FFI390_RET_INT64 2
-#define FFI390_RET_INT32 3
+#define FFI390_RET_INT32 0
+#define FFI390_RET_DOUBLE 1
+#define FFI390_RET_FLOAT 2
+#define FFI390_RET_INT64 3
#define FFI390_RET_VOID 4
#define FFI360_RET_MASK 7
diff --git a/src/s390/sysv.S b/src/s390/sysv.S
index c4b5006..6015404 100644
--- a/src/s390/sysv.S
+++ b/src/s390/sysv.S
@@ -76,6 +76,10 @@ ffi_call_SYSV:
.balign 8
.Ltable:
+# FFI390_RET_INT32
+ st %r2,0(%r12)
+ j .Ldone
+
# FFI390_RET_DOUBLE
std %f0,0(%r12)
j .Ldone
@@ -87,16 +91,11 @@ ffi_call_SYSV:
.balign 8
# FFI390_RET_INT64
- st %r3,4(%r12)
+ stm %r2,%r3,0(%r12)
nop
# fallthru
.balign 8
-# FFI390_RET_INT32
- st %r2,0(%r12)
- nop
- # fallthru
-
.balign 8
# FFI390_RET_VOID
.Ldone:
@@ -209,7 +208,7 @@ ffi_call_SYSV:
.cfi_rel_offset r14, 112
.cfi_def_cfa_register r13
stg %r2,0(%r15) # Set up back chain
- larl %r14,.Ltable # Set up return address
+ larl %r14,.Ltable-8 # Set up return address
slag %r3,%r3,3 # ret_type *= 8
lgr %r12,%r4 # Save ret_addr
lgr %r1,%r5 # Save fun
@@ -223,6 +222,7 @@ ffi_call_SYSV:
br %r1 # ... and call function
.balign 8
+# FFI390_RET_INT32 is not used, table starts at entry 1, not entry 0
.Ltable:
# FFI390_RET_DOUBLE
std %f0,0(%r12)
@@ -238,14 +238,6 @@ ffi_call_SYSV:
stg %r2,0(%r12)
.balign 8
-# FFI390_RET_INT32
- # Never used, as we always store type ffi_arg.
- # But the stg above is 6 bytes and we cannot
- # jump around this case, so fall through.
- nop
- nop
-
- .balign 8
# FFI390_RET_VOID
.Ldone:
lg %r14,112(%r13)
--
1.8.3.1