public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: libffi-discuss@sourceware.org
Cc: David Edelsohn <dje.gcc@gmail.com>
Subject: [RS6000] libffi little-endian
Date: Fri, 07 Jun 2013 10:28:00 -0000	[thread overview]
Message-ID: <20130607102829.GO6878@bubble.grove.modra.org> (raw)

This adds support for powerpcle-linux and powerpc64le-linux.  I
haven't attempted to add the same for darwin_closure.S since I'm not
aware of a little-endian darwin powerpc port.  Bootstrapped and
regression tested on powerpc64-linux.  powerpc64le-linux tests still
in progress.

	* src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Support
	little-endian.
	* src/powerpc/ppc_closure.S (ffi_closure_SYSV): Likewise.

Index: libffi/src/powerpc/linux64_closure.S
===================================================================
--- libffi/src/powerpc/linux64_closure.S	(revision 199718)
+++ libffi/src/powerpc/linux64_closure.S	(working copy)
@@ -132,7 +132,11 @@
 	blr
 	nop
 # case FFI_TYPE_INT
+#ifdef __LITTLE_ENDIAN__
+	lwa %r3, 112+0(%r1)
+#else
 	lwa %r3, 112+4(%r1)
+#endif
 	mtlr %r0
 	addi %r1, %r1, 240
 	blr
@@ -152,33 +156,57 @@
 	lfd %f2, 112+8(%r1)
 	b .Lfinish
 # case FFI_TYPE_UINT8
+#ifdef __LITTLE_ENDIAN__
+	lbz %r3, 112+0(%r1)
+#else
 	lbz %r3, 112+7(%r1)
+#endif
 	mtlr %r0
 	addi %r1, %r1, 240
 	blr
 # case FFI_TYPE_SINT8
+#ifdef __LITTLE_ENDIAN__
+	lbz %r3, 112+0(%r1)
+#else
 	lbz %r3, 112+7(%r1)
+#endif
 	extsb %r3,%r3
 	mtlr %r0
 	b .Lfinish
 # case FFI_TYPE_UINT16
+#ifdef __LITTLE_ENDIAN__
+	lhz %r3, 112+0(%r1)
+#else
 	lhz %r3, 112+6(%r1)
+#endif
 	mtlr %r0
 .Lfinish:
 	addi %r1, %r1, 240
 	blr
 # case FFI_TYPE_SINT16
+#ifdef __LITTLE_ENDIAN__
+	lha %r3, 112+0(%r1)
+#else
 	lha %r3, 112+6(%r1)
+#endif
 	mtlr %r0
 	addi %r1, %r1, 240
 	blr
 # case FFI_TYPE_UINT32
+#ifdef __LITTLE_ENDIAN__
+	lwz %r3, 112+0(%r1)
+#else
 	lwz %r3, 112+4(%r1)
+#endif
 	mtlr %r0
 	addi %r1, %r1, 240
 	blr
 # case FFI_TYPE_SINT32
+#ifdef __LITTLE_ENDIAN__
+	lwa %r3, 112+0(%r1)
+#else
 	lwa %r3, 112+4(%r1)
+#endif
 	mtlr %r0
 	addi %r1, %r1, 240
 	blr
Index: libffi/src/powerpc/ppc_closure.S
===================================================================
--- libffi/src/powerpc/ppc_closure.S	(revision 199718)
+++ libffi/src/powerpc/ppc_closure.S	(working copy)
@@ -159,25 +159,41 @@
 #endif
 
 # case FFI_TYPE_UINT8
+#ifdef __LITTLE_ENDIAN__
+	lbz %r3,112+0(%r1)
+#else
 	lbz %r3,112+3(%r1)
+#endif
 	mtlr %r0
 	addi %r1,%r1,144
 	blr
 
 # case FFI_TYPE_SINT8
+#ifdef __LITTLE_ENDIAN__
+	lbz %r3,112+0(%r1)
+#else
 	lbz %r3,112+3(%r1)
+#endif
 	extsb %r3,%r3
 	mtlr %r0
 	b .Lfinish
 
 # case FFI_TYPE_UINT16
+#ifdef __LITTLE_ENDIAN__
+	lhz %r3,112+0(%r1)
+#else
 	lhz %r3,112+2(%r1)
+#endif
 	mtlr %r0
 	addi %r1,%r1,144
 	blr
 
 # case FFI_TYPE_SINT16
+#ifdef __LITTLE_ENDIAN__
+	lha %r3,112+0(%r1)
+#else
 	lha %r3,112+2(%r1)
+#endif
 	mtlr %r0
 	addi %r1,%r1,144
 	blr
@@ -239,9 +255,15 @@
 
 # case FFI_SYSV_TYPE_SMALL_STRUCT + 3. Three byte struct.
 	lwz %r3,112+0(%r1)
+#ifdef __LITTLE_ENDIAN__
+	mtlr %r0
+	addi %r1,%r1,144
+	blr
+#else
 	srwi %r3,%r3,8
 	mtlr %r0
 	b .Lfinish
+#endif
 
 # case FFI_SYSV_TYPE_SMALL_STRUCT + 4. Four byte struct.
 	lwz %r3,112+0(%r1)
@@ -252,20 +274,35 @@
 # case FFI_SYSV_TYPE_SMALL_STRUCT + 5. Five byte struct.
 	lwz %r3,112+0(%r1)
 	lwz %r4,112+4(%r1)
+#ifdef __LITTLE_ENDIAN__
+	mtlr %r0
+	b .Lfinish
+#else
 	li %r5,24
 	b .Lstruct567
+#endif
 
 # case FFI_SYSV_TYPE_SMALL_STRUCT + 6. Six byte struct.
 	lwz %r3,112+0(%r1)
 	lwz %r4,112+4(%r1)
+#ifdef __LITTLE_ENDIAN__
+	mtlr %r0
+	b .Lfinish
+#else
 	li %r5,16
 	b .Lstruct567
+#endif
 
 # case FFI_SYSV_TYPE_SMALL_STRUCT + 7. Seven byte struct.
 	lwz %r3,112+0(%r1)
 	lwz %r4,112+4(%r1)
+#ifdef __LITTLE_ENDIAN__
+	mtlr %r0
+	b .Lfinish
+#else
 	li %r5,8
 	b .Lstruct567
+#endif
 
 # case FFI_SYSV_TYPE_SMALL_STRUCT + 8. Eight byte struct.
 	lwz %r3,112+0(%r1)
@@ -273,6 +310,7 @@
 	mtlr %r0
 	b .Lfinish
 
+#ifndef __LITTLE_ENDIAN__
 .Lstruct567:
 	subfic %r6,%r5,32
 	srw %r4,%r4,%r5
@@ -282,6 +320,7 @@
 	mtlr %r0
 	addi %r1,%r1,144
 	blr
+#endif
 
 .Luint128:
 	lwz %r6,112+12(%r1)

-- 
Alan Modra
Australia Development Lab, IBM

             reply	other threads:[~2013-06-07 10:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-07 10:28 Alan Modra [this message]
     [not found] <20130607013408.GI6878@bubble.grove.modra.org>
     [not found] ` <CAGWvnynZsHaM+EaHQMOTiQKb6Pg5gT4OY8B1ZtwLEV+iGih7bw@mail.gmail.com>
2013-06-24  0:26   ` Alan Modra
2013-06-24  2:32     ` David Edelsohn
2013-06-24 15:12       ` Anthony Green
2013-06-25  0:11         ` Alan Modra

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=20130607102829.GO6878@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=dje.gcc@gmail.com \
    --cc=libffi-discuss@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).