X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FcodeGen%2FStgCmmForeign.hs;h=89a2b27833414db538f89f96fe86b3e4fdc5d89d;hb=787b08bdea84cca4bf9490d87c059453bffc5ad2;hp=a4b5cf9f15009508dfbfb24c23bca825b40695b9;hpb=6c2ae9c152d147623ac45a5fe52534c99d6ba835;p=ghc-hetmet.git diff --git a/compiler/codeGen/StgCmmForeign.hs b/compiler/codeGen/StgCmmForeign.hs index a4b5cf9..89a2b27 100644 --- a/compiler/codeGen/StgCmmForeign.hs +++ b/compiler/codeGen/StgCmmForeign.hs @@ -37,6 +37,7 @@ import StaticFlags import Maybes import Outputable import ZipCfgCmmRep +import BasicTypes import Control.Monad @@ -53,21 +54,22 @@ cgForeignCall :: [LocalReg] -- r1,r2 where to put the results cgForeignCall results result_hints (CCall (CCallSpec target cconv safety)) stg_args = do { cmm_args <- getFCallArgs stg_args - ; let (args, arg_hints) = unzip cmm_args - fc = ForeignConvention cconv arg_hints result_hints - (call_args, cmm_target) - = case target of - StaticTarget lbl -> (args, CmmLit (CmmLabel - (mkForeignLabel lbl (call_size args) False))) - DynamicTarget -> case args of - fn:rest -> (rest, fn) - [] -> panic "cgForeignCall []" - call_target = ForeignTarget cmm_target fc - - ; srt <- getSRTInfo NoSRT -- SLPJ: Not sure what SRT - -- is right here + ; let ((call_args, arg_hints), cmm_target) + = case target of + StaticTarget lbl -> + (unzip cmm_args, + CmmLit (CmmLabel (mkForeignLabel lbl (call_size cmm_args) + False IsFunction))) + DynamicTarget -> case cmm_args of + (fn,_):rest -> (unzip rest, fn) + [] -> panic "cgForeignCall []" + fc = ForeignConvention cconv arg_hints result_hints + call_target = ForeignTarget cmm_target fc + + ; srt <- getSRTInfo NoSRT -- SLPJ: Not sure what SRT + -- is right here -- JD: Does it matter in the new codegen? - ; emitForeignCall safety results call_target call_args srt CmmMayReturn } + ; emitForeignCall safety results call_target call_args srt CmmMayReturn } where -- in the stdcall calling convention, the symbol needs @size appended -- to it, where size is the total number of bytes of arguments. We @@ -78,10 +80,7 @@ cgForeignCall results result_hints (CCall (CCallSpec target cconv safety)) stg_a | otherwise = Nothing -- ToDo: this might not be correct for 64-bit API - arg_size arg = max (widthInBytes $ typeWidth $ cmmExprType arg) wORD_SIZE - -cgForeignCall _ _ (DNCall _) _ - = panic "cgForeignCall: DNCall" + arg_size (arg, _) = max (widthInBytes $ typeWidth $ cmmExprType arg) wORD_SIZE emitCCall :: [(CmmFormal,ForeignHint)] -> CmmExpr @@ -98,9 +97,9 @@ emitCCall hinted_results fn hinted_args fc = ForeignConvention CCallConv arg_hints result_hints -emitPrimCall :: CmmFormal -> CallishMachOp -> CmmActuals -> FCode () +emitPrimCall :: CmmFormals -> CallishMachOp -> CmmActuals -> FCode () emitPrimCall res op args - = emitForeignCall PlayRisky [res] (PrimTarget op) args NoC_SRT CmmMayReturn + = emitForeignCall PlayRisky res (PrimTarget op) args NoC_SRT CmmMayReturn -- alternative entry point, used by CmmParse emitForeignCall