- curr_format = maybe unknown_block id $ lookup curr_ident formats
- unknown_block = panic "unknown BlockId in constructContinuation"
- prefix = case entry of
- ControlEntry -> []
- FunctionEntry _ _ -> []
- ContinuationEntry formals ->
- unpack_continuation curr_format
- postfix = case exit of
- FinalBranch next -> [CmmBranch next]
- FinalSwitch expr targets -> [CmmSwitch expr targets]
- FinalReturn arguments ->
- exit_function curr_format
- (CmmLoad (CmmReg spReg) wordRep)
- arguments
- FinalJump target arguments ->
- exit_function curr_format target arguments
- -- TODO: do something about global saves
- FinalCall next (CmmForeignCall target CmmCallConv)
+ continuationToProc' :: CLabel -> [(CLabel, StackFormat)] -> BrokenBlock
+ -> CmmBasicBlock
+ continuationToProc' curr_ident formats (BrokenBlock ident entry stmts _ exit) =
+ BasicBlock ident (prefix++stmts++postfix)
+ where
+ curr_format = maybe unknown_block id $ lookup curr_ident formats
+ unknown_block = panic "unknown BlockId in continuationToProc"
+ prefix = case entry of
+ ControlEntry -> []
+ FunctionEntry _ _ -> []
+ ContinuationEntry formals ->
+ unpack_continuation curr_format
+ postfix = case exit of
+ FinalBranch next -> [CmmBranch next]
+ FinalSwitch expr targets -> [CmmSwitch expr targets]
+ FinalReturn arguments ->
+ exit_function curr_format
+ (CmmLoad (CmmReg spReg) wordRep)
+ arguments
+ FinalJump target arguments ->
+ exit_function curr_format target arguments
+ -- TODO: do something about global saves
+ FinalCall next (CmmForeignCall target CmmCallConv)