(_, GC ) -> getRegsWithNode
(_, PrimOpCall) -> allRegs
(_, Slow ) -> noRegs
- _ -> panic "Unknown calling convention"
+ _ -> pprPanic "Unknown calling convention" (ppr conv)
else
case (reps, conv) of
([_], _) -> allRegs
(_, NativeCall) -> getRegsWithNode
(_, NativeReturn) -> getRegsWithNode
(_, GC ) -> getRegsWithNode
- (_, PrimOpCall) -> getRegsWithNode
(_, PrimOpReturn) -> getRegsWithNode
(_, Slow ) -> noRegs
_ -> pprPanic "Unknown calling convention" (ppr conv)
mkStmts (CmmAssign l r : ss) = mkAssign l r <*> mkStmts ss
mkStmts (CmmStore l r : ss) = mkStore l r <*> mkStmts ss
mkStmts (CmmCall (CmmCallee f conv) res args (CmmSafe _) CmmMayReturn : ss) =
- mkCall f conv' (map hintlessCmm res) (map hintlessCmm args) updfr_sz
+ mkCall f (conv', conv') (map hintlessCmm res) (map hintlessCmm args) updfr_sz
<*> mkStmts ss
where conv' = Foreign (ForeignConvention conv [] []) -- JD: DUBIOUS
mkStmts (CmmCall (CmmPrim {}) _ _ (CmmSafe _) _ : _) =
mkStore :: CmmExpr -> CmmExpr -> CmmAGraph
---------- Calls
-mkCall :: CmmExpr -> Convention -> CmmFormals -> CmmActuals ->
+mkCall :: CmmExpr -> (Convention, Convention) -> CmmFormals -> CmmActuals ->
UpdFrameOffset -> CmmAGraph
mkCmmCall :: CmmExpr -> CmmFormals -> CmmActuals ->
UpdFrameOffset -> CmmAGraph
mkFinalCall f _ actuals updfr_off =
lastWithArgs Call old NativeCall actuals updfr_off $ toCall f Nothing updfr_off 0
-mkCmmCall f results actuals = mkCall f NativeCall results actuals
+mkCmmCall f results actuals = mkCall f (NativeCall, NativeReturn) results actuals
-- I'm dropping the SRT, but that should be okay: we plan to reconstruct it later.
-mkCall f conv results actuals updfr_off =
- pprTrace "mkCall" (ppr f <+> ppr actuals <+> ppr results <+> ppr conv) $
+mkCall f (callConv, retConv) results actuals updfr_off =
+ pprTrace "mkCall" (ppr f <+> ppr actuals <+> ppr results <+> ppr callConv <+>
+ ppr retConv) $
withFreshLabel "call successor" $ \k ->
let area = CallArea $ Young k
- (off, copyin) = copyInOflow conv False area results
- copyout = lastWithArgs Call area conv actuals updfr_off
+ (off, copyin) = copyInOflow retConv False area results
+ copyout = lastWithArgs Call area callConv actuals updfr_off
(toCall f (Just k) updfr_off off)
in (copyout <*> mkLabel k <*> copyin)
| NativeReturn -- Native C-- return
- | Slow -- Slow entry points: all args pushed on the stack
+ | Slow -- Slow entry points: all args pushed on the stack
- | GC -- Entry to the garbage collector: uses the node reg!
+ | GC -- Entry to the garbage collector: uses the node reg!
| PrimOpCall -- Calling prim ops
| PrimOpReturn -- Returning from prim ops
- | Foreign -- Foreign call/return
- ForeignConvention
+ | Foreign -- Foreign call/return
+ ForeignConvention
| Private
-- Used for control transfers within a (pre-CPS) procedure All
; [ret,call] <- forkAlts [
getCode $ emitReturn [fun], -- Is tagged; no need to untag
getCode $ do emit (mkAssign nodeReg fun)
- emitCall NativeCall (entryCode fun') []] -- Not tagged
+ emitCall (NativeCall, NativeReturn)
+ (entryCode fun') []] -- Not tagged
; emit (mkCmmIfThenElse (cmmIsTagged fun) ret call) }
SlowCall -> do -- A slow function call via the RTS apply routines
| otherwise = case gc_lbl (fun : args) of
Just lbl -> mkJumpGC (CmmLit (CmmLabel (mkRtsCodeLabel lbl)))
args' updfr_sz
- Nothing -> mkCall generic_gc GC [] [] updfr_sz
+ Nothing -> mkCall generic_gc (GC, GC) [] [] updfr_sz
gc_lbl :: [LocalReg] -> Maybe LitString
{-
heapCheck False (gc_call updfr_sz) code
where
gc_call updfr_sz
- | null regs = mkCall generic_gc GC [] [] updfr_sz
+ | null regs = mkCall generic_gc (GC, GC) [] [] updfr_sz
| Just gc_lbl <- rts_label regs -- Canned call
- = mkCall (CmmLit (CmmLabel (mkRtsCodeLabel gc_lbl))) GC
+ = mkCall (CmmLit (CmmLabel (mkRtsCodeLabel gc_lbl))) (GC, GC)
regs (map (CmmReg . CmmLocal) regs) updfr_sz
| otherwise -- No canned call, and non-empty live vars
- = mkCall generic_gc GC [] [] updfr_sz
+ = mkCall generic_gc (GC, GC) [] [] updfr_sz
{-
rts_label [reg]
; emit (mkMultiAssign regs results) }
}
-emitCall :: Convention -> CmmExpr -> [CmmExpr] -> FCode ()
+emitCall :: (Convention, Convention) -> CmmExpr -> [CmmExpr] -> FCode ()
-- (cgCall fun args) makes a call to the entry-code of 'fun',
-- passing 'args', and returning the results to the current sequel
-emitCall conv fun args
+emitCall convs@(callConv, _) fun args
= do { adjustHpBackwards
; sequel <- getSequel
; updfr_off <- getUpdFrameOff
; emit $ mkComment $ mkFastString ("emitCall: " ++ show sequel)
; case sequel of
- Return _ -> emit (mkForeignJump conv fun args updfr_off)
- AssignTo res_regs _ -> emit (mkCall fun conv res_regs args updfr_off)
+ Return _ -> emit (mkForeignJump callConv fun args updfr_off)
+ AssignTo res_regs _ -> emit (mkCall fun convs res_regs args updfr_off)
}
adjustHpBackwards :: FCode ()
<+> ppr args <+> ppr reps )
| null rest_reps -- Precisely the right number of arguments
- = emitCall NativeCall target args
+ = emitCall (NativeCall, NativeReturn) target args
| otherwise -- Over-saturated call
= ASSERT( arity == length initial_reps )
do { pap_id <- newTemp gcWord
; withSequel (AssignTo [pap_id] True)
- (emitCall NativeCall target fast_args)
+ (emitCall (NativeCall, NativeReturn) target fast_args)
; slow_call (CmmReg (CmmLocal pap_id))
rest_args rest_reps }
where
| primOpOutOfLine primop
= do { cmm_args <- getNonVoidArgAmodes args
; let fun = CmmLit (CmmLabel (mkRtsPrimOpLabel primop))
- ; emitCall PrimOpCall fun cmm_args }
+ ; emitCall (PrimOpCall, PrimOpReturn) fun cmm_args }
| ReturnsPrim VoidRep <- result_info
= do cgPrimOp [] primop args
where
call updfr_off =
if safe then
- mkCall fun_expr NativeCall res' args' updfr_off
+ mkCmmCall fun_expr res' args' updfr_off
else
mkUnsafeCall (ForeignTarget fun_expr
(ForeignConvention CCallConv arg_hints res_hints)) res' args'