b542280
From 14b96327143e7e519a0acc5c309460c04a16f55b Mon Sep 17 00:00:00 2001
b542280
From: Caolan McNamara <caolanm@redhat.com>
b542280
Date: Fri, 10 Jul 2015 16:36:41 +0100
b542280
Subject: [PATCH 2/2] ppc64: using a fp register also consumes a gp register
b542280
 slot
b542280
b542280
Change-Id: Idf6f40081f4598c0fa9d1e10bdc208eae49e4cd1
b542280
---
b542280
 bridges/source/cpp_uno/gcc3_linux_powerpc64/cpp2uno.cxx |  6 ++++++
b542280
 bridges/source/cpp_uno/gcc3_linux_powerpc64/uno2cpp.cxx | 16 ++++++++++------
b542280
 testtools/com/sun/star/comp/bridge/TestComponent.java   |  4 ++++
b542280
 testtools/source/bridgetest/bridgetest.cxx              |  4 ++++
b542280
 testtools/source/bridgetest/cli/cli_cs_testobj.cs       |  5 +++++
b542280
 testtools/source/bridgetest/cppobj.cxx                  |  2 ++
b542280
 testtools/source/bridgetest/idl/bridgetest.idl          |  6 ++++++
b542280
 7 files changed, 37 insertions(+), 6 deletions(-)
b542280
b542280
diff --git a/bridges/source/cpp_uno/gcc3_linux_powerpc64/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_powerpc64/cpp2uno.cxx
b542280
index 6b58246..6ac003b 100644
b542280
--- a/bridges/source/cpp_uno/gcc3_linux_powerpc64/cpp2uno.cxx
b542280
+++ b/bridges/source/cpp_uno/gcc3_linux_powerpc64/cpp2uno.cxx
b542280
@@ -133,6 +133,12 @@ static typelib_TypeClass cpp2uno_call(
b542280
                         }
b542280
                         pCppArgs[nPos] = pUnoArgs[nPos] = fpreg++;
b542280
                         nf++;
b542280
+
b542280
+                        if (ng < ppc64::MAX_GPR_REGS)
b542280
+                        {
b542280
+                            ng++;
b542280
+                            gpreg++;
b542280
+                        }
b542280
                     }
b542280
                     else
b542280
                     {
b542280
diff --git a/bridges/source/cpp_uno/gcc3_linux_powerpc64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_powerpc64/uno2cpp.cxx
b542280
index 81d3d5c..28dfaf8 100644
b542280
--- a/bridges/source/cpp_uno/gcc3_linux_powerpc64/uno2cpp.cxx
b542280
+++ b/bridges/source/cpp_uno/gcc3_linux_powerpc64/uno2cpp.cxx
b542280
@@ -229,16 +229,20 @@ static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex,
b542280
 
b542280
 // The value in %xmm register is already prepared to be retrieved as a float,
b542280
 // thus we treat float and double the same
b542280
-#define INSERT_FLOAT( pSV, nr, pFPR, pDS, bOverflow ) \
b542280
-        if ( nr < ppc64::MAX_SSE_REGS ) \
b542280
+#define INSERT_FLOAT( pSV, nr, pFPR, nGPR, pDS, bOverflow ) \
b542280
+        if ( nGPR < ppc64::MAX_GPR_REGS ) \
b542280
+                ++nGPR;                   \
b542280
+        if ( nr < ppc64::MAX_SSE_REGS )   \
b542280
                 pFPR[nr++] = *reinterpret_cast<float *>( pSV ); \
b542280
         else \
b542280
             bOverflow = true; \
b542280
         if (bOverflow) \
b542280
                 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); // verbatim!
b542280
 
b542280
-#define INSERT_DOUBLE( pSV, nr, pFPR, pDS, bOverflow ) \
b542280
-        if ( nr < ppc64::MAX_SSE_REGS ) \
b542280
+#define INSERT_DOUBLE( pSV, nr, pFPR, nGPR, pDS, bOverflow ) \
b542280
+        if ( nGPR < ppc64::MAX_GPR_REGS ) \
b542280
+                ++nGPR;                   \
b542280
+        if ( nr < ppc64::MAX_SSE_REGS )   \
b542280
                 pFPR[nr++] = *reinterpret_cast<double *>( pSV ); \
b542280
         else \
b542280
             bOverflow = true; \
b542280
@@ -390,10 +394,10 @@ static void cpp_call(
b542280
                                 INSERT_INT8( pCppArgs[nPos], nGPR, pGPR, pStack, bOverflow );
b542280
                                 break;
b542280
                         case typelib_TypeClass_FLOAT:
b542280
-                                INSERT_FLOAT( pCppArgs[nPos], nFPR, pFPR, pStack, bOverflow );
b542280
+                                INSERT_FLOAT( pCppArgs[nPos], nFPR, pFPR, nGPR, pStack, bOverflow );
b542280
                                 break;
b542280
                         case typelib_TypeClass_DOUBLE:
b542280
-                                INSERT_DOUBLE( pCppArgs[nPos], nFPR, pFPR, pStack, bOverflow );
b542280
+                                INSERT_DOUBLE( pCppArgs[nPos], nFPR, pFPR, nGPR, pStack, bOverflow );
b542280
                                 break;
b542280
                         default:
b542280
                                 break;
b542280
diff --git a/testtools/com/sun/star/comp/bridge/TestComponent.java b/testtools/com/sun/star/comp/bridge/TestComponent.java
b542280
index a6966eb..f8b50f2 100644
b542280
--- a/testtools/com/sun/star/comp/bridge/TestComponent.java
b542280
+++ b/testtools/com/sun/star/comp/bridge/TestComponent.java
b542280
@@ -498,6 +498,10 @@ public class TestComponent {
b542280
             return i2;
b542280
         }
b542280
 
b542280
+        public int testPPC64Alignment( double d1, double d2, double d3, int i1 ) throws com.sun.star.uno.RuntimeException {
b542280
+            return i1;
b542280
+        }
b542280
+
b542280
         public double testTenDoubles( double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10 ) {
b542280
             return d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d9 + d10;
b542280
         }
b542280
diff --git a/testtools/source/bridgetest/bridgetest.cxx b/testtools/source/bridgetest/bridgetest.cxx
b542280
index 52e337f..d17900f 100644
b542280
--- a/testtools/source/bridgetest/bridgetest.cxx
b542280
+++ b/testtools/source/bridgetest/bridgetest.cxx
b542280
@@ -529,6 +529,10 @@ static bool performTest(
b542280
                 bRet &= check(i2 == 0xBEAF, "ppc-style alignment test");
b542280
             }
b542280
             {
b542280
+                sal_Int32 i1 = xLBT->testPPC64Alignment(1.0, 2.0, 3.0, 0xBEAF);
b542280
+                bRet &= check(i1 == 0xBEAF, "ppc64-style alignment test");
b542280
+            }
b542280
+            {
b542280
                 double d1 = xLBT->testTenDoubles(0.1, 0.2, 0.3, 0.4, 0.5,
b542280
                     0.6, 0.7, 0.8, 0.9, 1.0);
b542280
                 bRet &= check(d1 == 5.5, "armhf doubles test");
b542280
diff --git a/testtools/source/bridgetest/cli/cli_cs_testobj.cs b/testtools/source/bridgetest/cli/cli_cs_testobj.cs
b542280
index 9d0ac7a..8f396c9 100644
b542280
--- a/testtools/source/bridgetest/cli/cli_cs_testobj.cs
b542280
+++ b/testtools/source/bridgetest/cli/cli_cs_testobj.cs
b542280
@@ -255,6 +255,11 @@ public class BridgeTestObject : WeakBase, XRecursiveCall, XBridgeTest2
b542280
         return i2;
b542280
     }
b542280
 
b542280
+    public int testPPC64Alignment( double d1, double d2, double d3, int i1 )
b542280
+    {
b542280
+        return i1;
b542280
+    }
b542280
+
b542280
     public double testTenDoubles( double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10 )
b542280
     {
b542280
         return d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d9 + d10;
b542280
diff --git a/testtools/source/bridgetest/cppobj.cxx b/testtools/source/bridgetest/cppobj.cxx
b542280
index d21d753..d39f854 100644
b542280
--- a/testtools/source/bridgetest/cppobj.cxx
b542280
+++ b/testtools/source/bridgetest/cppobj.cxx
b542280
@@ -220,6 +220,8 @@ public:
b542280
         { return rStruct; }
b542280
     virtual sal_Int32 SAL_CALL testPPCAlignment( sal_Int64, sal_Int64, sal_Int32, sal_Int64, sal_Int32 i2 ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
b542280
         { return i2; }
b542280
+    virtual sal_Int32 SAL_CALL testPPC64Alignment( double f1, double f2, double f3, sal_Int32 i1 ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
b542280
+        { return i1; }
b542280
     virtual double SAL_CALL testTenDoubles( double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10 ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
b542280
         { return d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d9 + d10; }
b542280
     virtual sal_Bool SAL_CALL getBool() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
b542280
diff --git a/testtools/source/bridgetest/idl/bridgetest.idl b/testtools/source/bridgetest/idl/bridgetest.idl
b542280
index a11ba28..22612b8 100644
b542280
--- a/testtools/source/bridgetest/idl/bridgetest.idl
b542280
+++ b/testtools/source/bridgetest/idl/bridgetest.idl
b542280
@@ -307,6 +307,12 @@ interface XBridgeTestBase : com::sun::star::uno::XInterface
b542280
     long testPPCAlignment( [in] hyper l1, [in] hyper l2, [in] long i1, [in] hyper l3, [in] long i2 );
b542280
 
b542280
     /**
b542280
+     * PPC64 Alignment test
b542280
+     */
b542280
+    long testPPC64Alignment( [in] double d1, [in] double d2, [in] double d3, [in] long i1 );
b542280
+
b542280
+
b542280
+    /**
b542280
      * VFP ABI (armhf) doubles test
b542280
      */
b542280
     double testTenDoubles( [in] double d1, [in] double d2, [in] double d3, [in] double d4, [in] double d5, [in] double d6, [in] double d7, [in] double d8, [in] double d9, [in] double d10 );
b542280
-- 
b542280
2.4.0
b542280