X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FcodeGen%2FCgForeignCall.hs;h=fec1a8f058981729f412bfbf539850e8773e759c;hb=f6e429f8f5a533d699a69ffc733a56be5ddff5a9;hp=ce272e9a86e8c94b9265fc2295ea3f7e92c2ca22;hpb=95e67967d9abbef73e8d355d0e168759b4ee0590;p=ghc-hetmet.git diff --git a/compiler/codeGen/CgForeignCall.hs b/compiler/codeGen/CgForeignCall.hs index ce272e9..fec1a8f 100644 --- a/compiler/codeGen/CgForeignCall.hs +++ b/compiler/codeGen/CgForeignCall.hs @@ -1,3 +1,10 @@ +{-# OPTIONS -w #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings +-- for details + ----------------------------------------------------------------------------- -- -- Code generation for foreign calls. @@ -43,7 +50,7 @@ import Control.Monad -- Code generation for Foreign Calls cgForeignCall - :: CmmHintFormals -- where to put the results + :: CmmFormals -- where to put the results -> ForeignCall -- the op -> [StgArg] -- arguments -> StgLiveVars -- live vars, in case we need to save them @@ -63,7 +70,7 @@ cgForeignCall results fcall stg_args live emitForeignCall - :: CmmHintFormals -- where to put the results + :: CmmFormals -- where to put the results -> ForeignCall -- the op -> [(CmmExpr,MachHint)] -- arguments -> StgLiveVars -- live vars, in case we need to save them @@ -73,7 +80,7 @@ emitForeignCall results (CCall (CCallSpec target cconv safety)) args live = do vols <- getVolatileRegs live srt <- getSRTInfo emitForeignCall' safety results - (CmmForeignCall cmm_target cconv) call_args (Just vols) srt + (CmmCallee cmm_target cconv) call_args (Just vols) srt CmmMayReturn where (call_args, cmm_target) = case target of @@ -99,22 +106,23 @@ emitForeignCall _ (DNCall _) _ _ -- alternative entry point, used by CmmParse emitForeignCall' :: Safety - -> CmmHintFormals -- where to put the results + -> CmmFormals -- where to put the results -> CmmCallTarget -- the op -> [(CmmExpr,MachHint)] -- arguments -> Maybe [GlobalReg] -- live vars, in case we need to save them -> C_SRT -- the SRT of the calls continuation + -> CmmReturnInfo -> Code -emitForeignCall' safety results target args vols srt +emitForeignCall' safety results target args vols srt ret | not (playSafe safety) = do temp_args <- load_args_into_temps args let (caller_save, caller_load) = callerSaveVolatileRegs vols stmtsC caller_save - stmtC (CmmCall target results temp_args CmmUnsafe) + stmtC (CmmCall target results temp_args CmmUnsafe ret) stmtsC caller_load | otherwise = do - -- Both 'id' and 'new_base' are KindNonPtr because they're + -- Both 'id' and 'new_base' are GCKindNonPtr because they're -- RTS only objects and are not subject to garbage collection id <- newNonPtrTemp wordRep new_base <- newNonPtrTemp (cmmRegRep (CmmGlobal BaseReg)) @@ -128,15 +136,15 @@ emitForeignCall' safety results target args vols srt -- Once that happens, this function will just emit a (CmmSafe srt) call, -- and the CPS will will be the one to convert that -- to this sequence of three CmmUnsafe calls. - stmtC (CmmCall (CmmForeignCall suspendThread CCallConv) + stmtC (CmmCall (CmmCallee suspendThread CCallConv) [ (id,PtrHint) ] [ (CmmReg (CmmGlobal BaseReg), PtrHint) ] - CmmUnsafe) - stmtC (CmmCall temp_target results temp_args CmmUnsafe) - stmtC (CmmCall (CmmForeignCall resumeThread CCallConv) + CmmUnsafe ret) + stmtC (CmmCall temp_target results temp_args CmmUnsafe ret) + stmtC (CmmCall (CmmCallee resumeThread CCallConv) [ (new_base, PtrHint) ] [ (CmmReg (CmmLocal id), PtrHint) ] - CmmUnsafe) + CmmUnsafe ret) -- Assign the result to BaseReg: we -- might now have a different Capability! stmtC (CmmAssign (CmmGlobal BaseReg) (CmmReg (CmmLocal new_base))) @@ -159,9 +167,9 @@ load_args_into_temps = mapM arg_assign_temp tmp <- maybe_assign_temp e return (tmp,hint) -load_target_into_temp (CmmForeignCall expr conv) = do +load_target_into_temp (CmmCallee expr conv) = do tmp <- maybe_assign_temp expr - return (CmmForeignCall tmp conv) + return (CmmCallee tmp conv) load_target_into_temp other_target = return other_target