-
- mkStkAmodes join_spa join_spb stk_arg_amodes
- `thenFC` \ (final_spa, final_spb, stk_arg_assts) ->
-
- -- Do the simultaneous assignments,
- doSimAssts join_spa live_vars
- (mkAbstractCs [pending_assts, reg_arg_assts, stk_arg_assts])
- `thenC`
-
- -- Adjust stack ptrs
- adjustRealSps final_spa final_spb `thenC`
-
- -- Jump to join point
- absC finish_code
-
- _ -> -- else: not a let-no-escape (the common case)
-
- -- Make instruction to save return address
- loadRetAddrIntoRetReg sequel `thenFC` \ ret_asst ->
-
- mkStkAmodes args_spa args_spb stk_arg_amodes
- `thenFC`
- \ (final_spa, final_spb, stk_arg_assts) ->
-
- -- The B-stack space for the pushed return addess, with any args pushed
- -- on top, is recorded in final_spb.
-
- -- Do the simultaneous assignments,
- doSimAssts args_spa live_vars
- (mkAbstractCs [pending_assts, node_asst, ret_asst,
- reg_arg_assts, stk_arg_assts])
- `thenC`
-
- -- Final adjustment of stack pointers
- adjustRealSps final_spa final_spb `thenC`
-
+ Nothing -> args_sp
+
+ (fast_stk_amodes, tagged_stk_amodes) =
+ splitAt arity stk_arg_amodes
+
+ -- eager blackholing, at the end of the basic block.
+ (r1_tmp_asst, bh_asst)
+ = case sequel of
+#if 0
+ -- no: UpdateCode doesn't tell us that we're in a thunk's entry code.
+ -- we might be in a case continuation later down the line. Also,
+ -- we might have pushed a return address on the stack, if we're in
+ -- a case scrut, and still be in the thunk's entry code.
+ UpdateCode ->
+ (CAssign node_save nodeReg,
+ CAssign (CVal (CIndex node_save (mkIntCLit 0) PtrRep)
+ PtrRep)
+ (CLbl mkBlackHoleInfoTableLabel DataPtrRep))
+ where
+ node_save = CTemp (mkPseudoUnique1 2) DataPtrRep
+#endif
+ _ -> (AbsCNop, AbsCNop)
+ in
+ -- We can omit tags on the arguments passed to the fast entry point,
+ -- but we have to be careful to fill in the tags on any *extra*
+ -- arguments we're about to push on the stack.
+
+ mkTaggedStkAmodes join_sp tagged_stk_amodes `thenFC`
+ \ (fast_sp, tagged_arg_assts, tag_assts) ->
+
+ mkTaggedStkAmodes fast_sp fast_stk_amodes `thenFC`
+ \ (final_sp, fast_arg_assts, _) ->
+
+ -- adjust the high-water mark if necessary
+ adjustStackHW final_sp `thenC`
+
+ -- The stack space for the pushed return addess,
+ -- with any args pushed on top, is recorded in final_sp.
+
+ -- Do the simultaneous assignments,
+ doSimAssts (mkAbstractCs [r1_tmp_asst,
+ pending_assts,
+ reg_arg_assts,
+ fast_arg_assts,
+ tagged_arg_assts,
+ tag_assts]) `thenC`
+ absC bh_asst `thenC`
+
+ -- push a return address if necessary
+ -- (after the assignments above, in case we clobber a live
+ -- stack location)
+
+ -- DONT push the return address when we're about
+ -- to jump to a let-no-escape: the final tail call
+ -- in the let-no-escape will do this.
+ (if (maybeToBool maybe_join_sp)
+ then nopC
+ else pushReturnAddress eob) `thenC`
+
+ -- Final adjustment of Sp/Hp
+ adjustSpAndHp final_sp `thenC`
+