public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: YunQiang Su <syq@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-3219] libffi: Fix MIPS r6 support
Date: Mon, 30 Aug 2021 08:05:31 +0000 (GMT)	[thread overview]
Message-ID: <20210830080531.CE01C3857807@sourceware.org> (raw)

https://gcc.gnu.org/g:d7e56b084d0b230ae5ee280f569d679fa0f09f4d

commit r12-3219-gd7e56b084d0b230ae5ee280f569d679fa0f09f4d
Author: YunQiang Su <yunqiang.su@cipunited.com>
Date:   Sat Aug 28 08:17:18 2021 -0400

    libffi: Fix MIPS r6 support
    
    for some instructions, MIPS r6 uses different encoding other than
    the previous releases.
    
    1. mips/n32.S disable .set mips4: since it casuses old insn encoding
       is used.
       https://github.com/libffi/libffi/pull/396 has been accepted as:
         94c102aa69b04337f63498e0e6551fcdce549ae5
    2. mips/ffi.c: the encoding for JR is hardcoded: we need to use
       different value for r6 and pre-r6.
       https://github.com/libffi/libffi/pull/401 has been accpeted as:
         746dbe3a6a79a41931c03b51df2972be4d5e5028
    
    libffi/
            PR libffi/83636
            * src/mips/n32.S: disable .set mips4
            * src/mips/ffi.c: use different JR encoding for r6.

Diff:
---
 libffi/src/mips/ffi.c | 8 ++++++++
 libffi/src/mips/n32.S | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/libffi/src/mips/ffi.c b/libffi/src/mips/ffi.c
index 5d0dd70cb32..ecd783a56c5 100644
--- a/libffi/src/mips/ffi.c
+++ b/libffi/src/mips/ffi.c
@@ -698,7 +698,11 @@ ffi_prep_closure_loc (ffi_closure *closure,
   /* lui  $12,high(codeloc) */
   tramp[2] = 0x3c0c0000 | ((unsigned)codeloc >> 16);
   /* jr   $25          */
+#if !defined(__mips_isa_rev) || (__mips_isa_rev<6)
   tramp[3] = 0x03200008;
+#else
+  tramp[3] = 0x03200009;
+#endif
   /* ori  $12,low(codeloc)  */
   tramp[4] = 0x358c0000 | ((unsigned)codeloc & 0xffff);
 #else
@@ -726,7 +730,11 @@ ffi_prep_closure_loc (ffi_closure *closure,
   /* ori  $25,low(fn)  */
   tramp[10] = 0x37390000 | ((unsigned long)fn  & 0xffff);
   /* jr   $25          */
+#if !defined(__mips_isa_rev) || (__mips_isa_rev<6)
   tramp[11] = 0x03200008;
+#else
+  tramp[11] = 0x03200009;
+#endif
   /* ori  $12,low(codeloc)  */
   tramp[12] = 0x358c0000 | ((unsigned long)codeloc & 0xffff);
 
diff --git a/libffi/src/mips/n32.S b/libffi/src/mips/n32.S
index c6985d30a6f..06e6c46076b 100644
--- a/libffi/src/mips/n32.S
+++ b/libffi/src/mips/n32.S
@@ -43,7 +43,9 @@
 #ifdef __GNUC__
 	.abicalls
 #endif
+#if !defined(__mips_isa_rev) || (__mips_isa_rev<6)
 	.set mips4
+#endif
 	.text
 	.align	2
 	.globl	ffi_call_N32


                 reply	other threads:[~2021-08-30  8:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210830080531.CE01C3857807@sourceware.org \
    --to=syq@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.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).