-flatAbsC stmt@(CMacroStmt macro amodes)
- = flatAmodes amodes `thenFlt` \ (amodes_here, tops) ->
- returnFlt (CMacroStmt macro amodes_here, tops)
-
-flatAbsC stmt@(CCallProfCtrMacro str amodes)
- = flatAmodes amodes `thenFlt` \ (amodes_here, tops) ->
- returnFlt (CCallProfCtrMacro str amodes_here, tops)
-
-flatAbsC stmt@(CCallProfCCMacro str amodes)
- = flatAmodes amodes `thenFlt` \ (amodes_here, tops) ->
- returnFlt (CCallProfCCMacro str amodes_here, tops)
-
-flatAbsC stmt@(CSplitMarker) = returnFlt (AbsCNop, stmt)
-\end{code}
-
-%************************************************************************
-%* *
-\subsection[flat-amodes]{Flattening addressing modes}
-%* *
-%************************************************************************
-
-\begin{code}
-flatAmode :: CAddrMode -> FlatM (CAddrMode, AbstractC)
-
--- easy ones first
-flatAmode amode@(CVal _ _) = returnFlt (amode, AbsCNop)
-
-flatAmode amode@(CAddr _) = returnFlt (amode, AbsCNop)
-flatAmode amode@(CReg _) = returnFlt (amode, AbsCNop)
-flatAmode amode@(CTemp _ _) = returnFlt (amode, AbsCNop)
-flatAmode amode@(CLbl _ _) = returnFlt (amode, AbsCNop)
-flatAmode amode@(CUnVecLbl _ _) = returnFlt (amode, AbsCNop)
-flatAmode amode@(CString _) = returnFlt (amode, AbsCNop)
-flatAmode amode@(CLit _) = returnFlt (amode, AbsCNop)
-flatAmode amode@(CLitLit _ _) = returnFlt (amode, AbsCNop)
-flatAmode amode@(COffset _) = returnFlt (amode, AbsCNop)
-
--- CIntLike must be a literal -- no flattening
-flatAmode amode@(CIntLike int) = returnFlt(amode, AbsCNop)
-
--- CCharLike may be arbitrary value -- have to flatten
-flatAmode amode@(CCharLike char)
- = flatAmode char `thenFlt` \ (flat_char, tops) ->
- returnFlt(CCharLike flat_char, tops)
-
-flatAmode (CJoinPoint _ _) = panic "flatAmode:CJoinPoint"
-
-flatAmode (CLabelledCode label abs_C)
- -- Push the code (with this label) to the top level
- = flatAbsC abs_C `thenFlt` \ (body_code, tops) ->
- returnFlt (CLbl label CodePtrRep,
- tops `mkAbsCStmts` CCodeBlock label body_code)
-
-flatAmode (CCode abs_C)
- = case mkAbsCStmtList abs_C of
- [CJump amode] -> flatAmode amode -- Elide redundant labels
- _ ->
- -- de-anonymous-ise the code and push it (labelled) to the top level
- getUniqFlt `thenFlt` \ new_uniq ->
- case (mkReturnPtLabel new_uniq) of { return_pt_label ->
- flatAbsC abs_C `thenFlt` \ (body_code, tops) ->
- returnFlt (
- CLbl return_pt_label CodePtrRep,
- tops `mkAbsCStmts` CCodeBlock return_pt_label body_code
- -- DO NOT TOUCH the stuff sent to the top...
- ) }
-
-flatAmode (CTableEntry base index kind)
- = flatAmode base `thenFlt` \ (base_amode, base_tops) ->
- flatAmode index `thenFlt` \ (ix_amode, ix_tops) ->
- returnFlt ( CTableEntry base_amode ix_amode kind, mkAbsCStmts base_tops ix_tops )
-
-flatAmode (CMacroExpr pk macro amodes)
- = flatAmodes amodes `thenFlt` \ (amodes_here, tops) ->
- returnFlt ( CMacroExpr pk macro amodes_here, tops )
-
-flatAmode amode@(CCostCentre _ _) = returnFlt (amode, AbsCNop)
+flatAbsC stmt@(CCheck macro amodes code)
+ = flatAbsC code `thenFlt` \ (code_here, code_tops) ->
+ returnFlt (CCheck macro amodes code_here, code_tops)
+
+-- Some statements need no flattening at all:
+flatAbsC stmt@(CMacroStmt macro amodes) = returnFlt (stmt, AbsCNop)
+flatAbsC stmt@(CCallProfCtrMacro str amodes) = returnFlt (stmt, AbsCNop)
+flatAbsC stmt@(CCallProfCCMacro str amodes) = returnFlt (stmt, AbsCNop)
+flatAbsC stmt@(CAssign dest source) = returnFlt (stmt, AbsCNop)
+flatAbsC stmt@(CJump target) = returnFlt (stmt, AbsCNop)
+flatAbsC stmt@(CFallThrough target) = returnFlt (stmt, AbsCNop)
+flatAbsC stmt@(CReturn target return_info) = returnFlt (stmt, AbsCNop)
+flatAbsC stmt@(CInitHdr a b cc) = returnFlt (stmt, AbsCNop)
+flatAbsC stmt@(COpStmt results op args vol_regs)= returnFlt (stmt, AbsCNop)
+
+-- Some statements only make sense at the top level, so we always float
+-- them. This probably isn't necessary.
+flatAbsC stmt@(CStaticClosure _ _ _ _) = returnFlt (AbsCNop, stmt)
+flatAbsC stmt@(CSRT _ _) = returnFlt (AbsCNop, stmt)
+flatAbsC stmt@(CBitmap _ _) = returnFlt (AbsCNop, stmt)
+flatAbsC stmt@(CCostCentreDecl _ _) = returnFlt (AbsCNop, stmt)
+flatAbsC stmt@(CCostCentreStackDecl _) = returnFlt (AbsCNop, stmt)
+flatAbsC stmt@(CSplitMarker) = returnFlt (AbsCNop, stmt)
+flatAbsC stmt@(CRetVector _ _ _ _) = returnFlt (AbsCNop, stmt)