OSDN Git Service

* src/powerpc/aix.S (ffi_call_AIX): Convert to more standard
[pf3gnuchains/gcc-fork.git] / libffi / src / powerpc / aix.S
index 7b73999..5b477ca 100644 (file)
@@ -104,47 +104,34 @@ ffi_call_AIX:
        .llong .ffi_call_AIX, TOC[tc0], 0
        .csect .text[PR]
 .ffi_call_AIX:
-       mr      r12,r8 // We only need r12 until the call, so it doesn't have to be saved...
-       /* Save the old stack pointer as AP.  */
-       mr      r8,r1
-
-       /* Allocate the stack space we need.  */
-       stdux   r1,r1,r4
-
        /* Save registers we use.  */
-       mflr    r9
+       mflr    r0
 
-       std     r28,-32(r8)
-       std     r29,-24(r8)
-       std     r30,-16(r8)
-       std     r31, -8(r8)
+       std     r28,-32(r1)
+       std     r29,-24(r1)
+       std     r30,-16(r1)
+       std     r31, -8(r1)
 
-       std     r9, 16(r8)
-       std     r2, 40(r1)
+       std     r0, 16(r1)
+       mr      r28, r1         /* our AP.  */
+       stdux   r1, r1, r4
 
        /* Save arguments over call...  */
-       mr      r31,r5  /* flags, */
-       mr      r30,r6  /* rvalue, */
-       mr      r29,r7  /* function address, */
-       mr      r28,r8  /* our AP. */
+       mr      r31, r5 /* flags, */
+       mr      r30, r6 /* rvalue, */
+       mr      r29, r7 /* function address.  */
+       std     r2, 40(r1)
 
        /* Call ffi_prep_args.  */
-       mr      r4,r1
-       li      r9,0
-
-       ld      r2,8(r12)
-       ld      r12,0(r12)
-       mtctr   r12 // r12 holds address of _ffi_prep_args
-       bctrl
-       ld      r2,40(r1)
+       mr      r4, r1
+       bl .ffi_prep_args
 
        /* Now do the call.  */
-       ld      r12,0(r29)
+       ld      r0, 0(r29)
+       ld      r2, 8(r29)
        /* Set up cr1 with bits 4-7 of the flags.  */
-       mtcrf   0x40,r31
-       std     r2,40(r1)
-       mtctr   r12
-       ld      r2,8(r29)
+       mtcrf   0x40, r31
+       mtctr   r0
        /* Load all those argument registers.  */
        // We have set up a nice stack frame, just load it into registers.
        ld      r3, 40+(1*8)(r1)
@@ -180,33 +167,33 @@ L1:
 L2:
        /* Make the call.  */
        bctrl
-       ld      r2,40(r1)
+       ld      r2, 40(r1)
 
        /* Now, deal with the return value.  */
-       mtcrf   0x01,r31
+       mtcrf   0x01, r31
 
-       bt      30,L(done_return_value)
-       bt      29,L(fp_return_value)
-       std     r3,0(r30)
-       bf      28,L(done_return_value)
-       std     r4,4(r30)
+       bt      30, L(done_return_value)
+       bt      29, L(fp_return_value)
+       std     r3, 0(r30)
 
        /* Fall through...  */
 
 L(done_return_value):
        /* Restore the registers we used and return.  */
-       ld      r9,16(r28)
-       ld      r31,-8(r28)
-       mtlr    r9
-       ld      r30,-16(r28)
-       ld      r29,-24(r28)
-       ld      r28,-32(r28)
-       ld      r1,0(r1)
+       mr      r1, r28
+       ld      r0, 16(r28)
+       ld      r28,-32(r1)
+       mtlr    r0
+       ld      r29,-24(r1)
+       ld      r30,-16(r1)
+       ld      r31,-8(r1)
        blr
 
 L(fp_return_value):
        bf      28,L(float_return_value)
        stfd    f1,0(r30)
+       bf      31,L(done_return_value)
+       stfd    f2,8(r30)
        b       L(done_return_value)
 L(float_return_value):
        stfs    f1,0(r30)