[project @ 2003-02-11 11:53:51 by wolfgang]
[ghc-hetmet.git] / ghc / compiler / nativeGen / MachCode.lhs
index bba1d58..e9fbdf4 100644 (file)
@@ -41,6 +41,7 @@ import Stix           ( getNatLabelNCG, StixStmt(..), StixExpr(..),
                           NatM, thenNat, returnNat, mapNat, 
                           mapAndUnzipNat, mapAccumLNat,
                           getDeltaNat, setDeltaNat, getUniqueNat,
+                         IF_OS_darwin(addImportNat COMMA,)
                           ncgPrimopMoan,
                          ncg_target_is_32bit
                        )
@@ -512,8 +513,8 @@ iselExpr64 (StCall fn cconv kind args)
   = genCCall fn cconv kind args                        `thenNat` \ call ->
     getNewRegNCG IntRep                                `thenNat` \ r_dst_lo ->
     let r_dst_hi = getHiVRegFromLo r_dst_lo
-        mov_lo = MR r_dst_lo r3
-        mov_hi = MR r_dst_hi r4
+        mov_lo = MR r_dst_lo r4
+        mov_hi = MR r_dst_hi r3
     in
     returnNat (
        ChildCode64 (call `snocOL` mov_hi `snocOL` mov_lo) 
@@ -3473,7 +3474,7 @@ genCCall fn cconv kind args
        (argReps,argCodes,vregs) = unzip3 preppedArgs
 
            -- size of linkage area + size of arguments, in bytes
-       stackDelta = roundTo16 $ (24 +) $ (4 *) $ sum $ map getPrimRepSize argReps
+       stackDelta = roundTo16 $ (24 +) $ max 32 $ (4 *) $ sum $ map getPrimRepSize argReps
        roundTo16 x | x `mod` 16 == 0 = x
                    | otherwise = x + 16 - (x `mod` 16)
 
@@ -3491,8 +3492,14 @@ genCCall fn cconv kind args
            `appOL` moveFinalCode
     in 
        case fn of
-           Left lbl -> returnNat (     passArguments
-                           `snocOL`    BL (ImmLab False (ftext lbl)) usedRegs
+           Left lbl ->
+               addImportNat lbl                        `thenNat` \ _ ->
+               returnNat (passArguments
+                           `snocOL`    BL (ImmLit $ ftext 
+                                            (FSLIT("L_")
+                                            `appendFS` lbl
+                                            `appendFS` FSLIT("$stub")))
+                                          usedRegs
                            `appOL`     move_sp_up)
            Right dyn ->
                getRegister dyn                         `thenNat` \ dynReg ->