--
-----------------------------------------------------------------------------
+{-# 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
+
module CgForeignCall (
cgForeignCall,
emitForeignCall,
-- 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
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
= do vols <- getVolatileRegs live
srt <- getSRTInfo
emitForeignCall' safety results
- (CmmCallee 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
-- 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))
stmtC (CmmCall (CmmCallee suspendThread CCallConv)
[ (id,PtrHint) ]
[ (CmmReg (CmmGlobal BaseReg), PtrHint) ]
- CmmUnsafe)
- stmtC (CmmCall temp_target results temp_args CmmUnsafe)
+ 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)))