[pkg-d-commits] [ldc] 06/12: PPC/PPC64: Reverse parameter order for extern(D)

Matthias Klumpp mak at moszumanska.debian.org
Sun Apr 23 22:35:56 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v0.17.3
in repository ldc.

commit 73fd889ab53c9c81d7590ada1f8f8f3d6fbc46f0
Author: Martin <noone at nowhere.com>
Date:   Tue Nov 29 20:29:01 2016 +0100

    PPC/PPC64: Reverse parameter order for extern(D)
---
 gen/abi-ppc.cpp | 44 ++++++++++++++------------------------------
 1 file changed, 14 insertions(+), 30 deletions(-)

diff --git a/gen/abi-ppc.cpp b/gen/abi-ppc.cpp
index 905d8ae..eb30968 100644
--- a/gen/abi-ppc.cpp
+++ b/gen/abi-ppc.cpp
@@ -28,7 +28,6 @@
 #include "gen/tollvm.h"
 
 struct PPCTargetABI : TargetABI {
-  ExplicitByvalRewrite byvalRewrite;
   CompositeToArray32 compositeToArray32;
   CompositeToArray64 compositeToArray64;
   IntegerRewrite integerRewrite;
@@ -41,10 +40,7 @@ struct PPCTargetABI : TargetABI {
       return false;
     }
 
-    // FIXME
     Type *rt = tf->next->toBasetype();
-    if (tf->linkage == LINKd)
-      return rt->ty == Tsarray || rt->ty == Tstruct;
 
     // The ABI specifies that aggregates of size 8 bytes or less are
     // returned in r3/r4 (ppc) or in r3 (ppc64). Looking at the IR
@@ -58,38 +54,27 @@ struct PPCTargetABI : TargetABI {
     // On ppc64, they are always passed by value. However, clang
     // used byval for type > 64 bytes.
     t = t->toBasetype();
-    return (t->ty == Tsarray || t->ty == Tstruct) && (!Is64Bit || t->size() > 64);
+    return (t->ty == Tsarray || t->ty == Tstruct) &&
+           (!Is64Bit || t->size() > 64);
   }
 
   void rewriteFunctionType(TypeFunction *tf, IrFuncTy &fty) override {
-    // RETURN VALUE
-    Type *retTy = fty.ret->type->toBasetype();
+    // return value
     if (!fty.ret->byref) {
-      if (retTy->ty == Tstruct || retTy->ty == Tsarray) {
-        if (canRewriteAsInt(retTy, Is64Bit)) {
-          fty.ret->rewrite = &integerRewrite;
-          fty.ret->ltype = integerRewrite.type(fty.ret->type, fty.ret->ltype);
-        } else {
-          if (Is64Bit) {
-            fty.ret->rewrite = &compositeToArray64;
-            fty.ret->ltype =
-                compositeToArray64.type(fty.ret->type, fty.ret->ltype);
-          } else {
-            fty.ret->rewrite = &compositeToArray32;
-            fty.ret->ltype =
-                compositeToArray32.type(fty.ret->type, fty.ret->ltype);
-          }
-        }
-      } else if (retTy->isintegral())
-        fty.ret->attrs.add(retTy->isunsigned() ? LLAttribute::ZExt
-                                               : LLAttribute::SExt);
+      rewriteArgument(fty, *fty.ret);
     }
-    // EXPLICIT PARAMETERS
+
+    // explicit parameters
     for (auto arg : fty.args) {
       if (!arg->byref) {
         rewriteArgument(fty, *arg);
       }
     }
+
+    // extern(D): reverse parameter order for non variadics, for DMD-compliance
+    if (tf->linkage == LINKd && tf->varargs != 1 && fty.args.size() > 1) {
+      fty.reverseParams = true;
+    }
   }
 
   void rewriteArgument(IrFuncTy &fty, IrFuncTyArg &arg) override {
@@ -108,12 +93,11 @@ struct PPCTargetABI : TargetABI {
           arg.ltype = compositeToArray32.type(arg.type, arg.ltype);
         }
       }
-    } else if (ty->isintegral())
+    } else if (ty->isintegral()) {
       arg.attrs.add(ty->isunsigned() ? LLAttribute::ZExt : LLAttribute::SExt);
+    }
   }
 };
 
 // The public getter for abi.cpp
-TargetABI *getPPCTargetABI(bool Is64Bit) {
-  return new PPCTargetABI(Is64Bit);
-}
+TargetABI *getPPCTargetABI(bool Is64Bit) { return new PPCTargetABI(Is64Bit); }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list