-Special case: scrutinising a non-primitive variable. This is where we
-want to do semi-tagging. The code generated will be something like this:
-
- save volatile vars
- R1 = fun
- jump c99_ret
-
- <info table goes here>
-c99_ret:
- infoptr = R1[0]
- type = infoptr[-4] // or something
- if (type > 8) goto no_cons
- tag = infoptr[-6]
- if (tag == 1) ... etc.
-no_cons
- jump infoptr
-
-\begin{code}
-cgCase (StgApp fun [])
- live_in_whole_case live_in_alts bndr srt (AlgAlt tycon) alts
- = do { fun_info <- getCgIdInfo fun
- ; fun_amode <- idInfoToAmode fun_info
-
- ; nukeDeadBindings live_in_alts
- ; (save_assts, alts_eob_info, maybe_cc_slot)
- <- saveVolatileVarsAndRegs live_in_alts
-
- ; scrut_eob_info
- <- forkEval alts_eob_info
- (allocStackTop retAddrSizeW >> nopC)
- (do { deAllocStackTop retAddrSizeW
- ; cgEvalAltsSemiTag maybe_cc_slot bndr srt
- tycon alts })
-
- -- jump to the continuation immediately
- ; case scrut_eob_info of
- EndOfBlockInfo sp (CaseAlts lbl _ _ _) -> do
- let node_asst = oneStmt (CmmAssign nodeReg fun_amode)
- emitSimultaneously (node_asst `plusStmts` save_assts)
- let jmp = stmtC (CmmJump (CmmLit (CmmLabel lbl)) [])
- setEndOfBlockInfo scrut_eob_info $
- doFinalJump sp False jmp
- }
-\end{code}
-
-Special case: scrutinising a non-primitive application. This can be
-done a little better than the general case, because we can reuse/trim
-the stack slot holding the variables involved in the application.