public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-15] libphobos: Fix build fails for powerpc-linux
@ 2021-04-21  0:29 Iain Buclaw
  0 siblings, 0 replies; only message in thread
From: Iain Buclaw @ 2021-04-21  0:29 UTC (permalink / raw)
  To: gcc-cvs

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

commit r12-15-gea7b1cf534a7a653e1221bcd9004c2d0f5418e88
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Wed Apr 21 01:15:33 2021 +0200

    libphobos: Fix build fails for powerpc-linux
    
    As register names are required for darwin, but not accepted by gas
    unless you use `-mregnames', they have been conditionally removed on
    non-darwin targets.
    
    To avoid duplicating large blocks of almost identical code, the inline
    assembly is now statically generated.
    
    libphobos/ChangeLog:
    
            * libdruntime/core/thread/osthread.d (callWithStackShell): Statically
            generate PPC and PPC64 asm implementations, and conditionally remove
            PPC register names on non-Darwin targets.

Diff:
---
 libphobos/libdruntime/core/thread/osthread.d | 68 ++++++++++------------------
 1 file changed, 24 insertions(+), 44 deletions(-)

diff --git a/libphobos/libdruntime/core/thread/osthread.d b/libphobos/libdruntime/core/thread/osthread.d
index 31764e69691..9fcd30e50fb 100644
--- a/libphobos/libdruntime/core/thread/osthread.d
+++ b/libphobos/libdruntime/core/thread/osthread.d
@@ -1444,55 +1444,35 @@ in (fn)
         else version (PPC)
         {
             void*[19] regs = void;
-            asm pure nothrow @nogc
-            {
-                "stw r13, %0" : "=m" (regs[ 0]);
-                "stw r14, %0" : "=m" (regs[ 1]);
-                "stw r15, %0" : "=m" (regs[ 2]);
-                "stw r16, %0" : "=m" (regs[ 3]);
-                "stw r17, %0" : "=m" (regs[ 4]);
-                "stw r18, %0" : "=m" (regs[ 5]);
-                "stw r19, %0" : "=m" (regs[ 6]);
-                "stw r20, %0" : "=m" (regs[ 7]);
-                "stw r21, %0" : "=m" (regs[ 9]);
-                "stw r22, %0" : "=m" (regs[ 9]);
-                "stw r23, %0" : "=m" (regs[10]);
-                "stw r24, %0" : "=m" (regs[11]);
-                "stw r25, %0" : "=m" (regs[12]);
-                "stw r26, %0" : "=m" (regs[13]);
-                "stw r27, %0" : "=m" (regs[14]);
-                "stw r28, %0" : "=m" (regs[15]);
-                "stw r29, %0" : "=m" (regs[16]);
-                "stw r30, %0" : "=m" (regs[17]);
-                "stw r31, %0" : "=m" (regs[18]);
-            }
+            version (Darwin)
+                enum regname = "r";
+            else
+                enum regname = "";
+            static foreach (i; 0 .. regs.length)
+            {{
+                enum int j = 13 + i; // source register
+                asm pure nothrow @nogc
+                {
+                    "stw "~regname~j.stringof~", %0" : "=m" (regs[i]);
+                }
+            }}
             sp = cast(void*)&regs[0];
         }
         else version (PPC64)
         {
             void*[19] regs = void;
-            asm pure nothrow @nogc
-            {
-                "std r13, %0" : "=m" (regs[ 0]);
-                "std r14, %0" : "=m" (regs[ 1]);
-                "std r15, %0" : "=m" (regs[ 2]);
-                "std r16, %0" : "=m" (regs[ 3]);
-                "std r17, %0" : "=m" (regs[ 4]);
-                "std r18, %0" : "=m" (regs[ 5]);
-                "std r19, %0" : "=m" (regs[ 6]);
-                "std r20, %0" : "=m" (regs[ 7]);
-                "std r21, %0" : "=m" (regs[ 8]);
-                "std r22, %0" : "=m" (regs[ 9]);
-                "std r23, %0" : "=m" (regs[10]);
-                "std r24, %0" : "=m" (regs[11]);
-                "std r25, %0" : "=m" (regs[12]);
-                "std r26, %0" : "=m" (regs[13]);
-                "std r27, %0" : "=m" (regs[14]);
-                "std r28, %0" : "=m" (regs[15]);
-                "std r29, %0" : "=m" (regs[16]);
-                "std r30, %0" : "=m" (regs[17]);
-                "std r31, %0" : "=m" (regs[18]);
-            }
+            version (Darwin)
+                enum regname = "r";
+            else
+                enum regname = "";
+            static foreach (i; 0 .. regs.length)
+            {{
+                enum int j = 13 + i; // source register
+                asm pure nothrow @nogc
+                {
+                    "std "~regname~j.stringof~", %0" : "=m" (regs[i]);
+                }
+            }}
             sp = cast(void*)&regs[0];
         }
         else


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-21  0:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-21  0:29 [gcc r12-15] libphobos: Fix build fails for powerpc-linux Iain Buclaw

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).