Commit c150d2f6 authored by Michael D. Adams's avatar Michael D. Adams
Browse files

Fixed CPS converter to preserve function names

parent 7d43eb05
...@@ -81,8 +81,9 @@ data Continuation = ...@@ -81,8 +81,9 @@ data Continuation =
-- use the appropriate CLabel. -- use the appropriate CLabel.
data BlockEntryInfo data BlockEntryInfo
= FunctionEntry -- Beginning of function = FunctionEntry -- Beginning of a function
CmmFormals -- aguments to function CLabel -- The function name
CmmFormals -- Aguments to function
| ContinuationEntry -- Return point of a call | ContinuationEntry -- Return point of a call
CmmFormals -- return values (argument to continuation) CmmFormals -- return values (argument to continuation)
...@@ -167,7 +168,7 @@ calculateProcPoints blocks = calculateProcPoints' init_proc_points blocks ...@@ -167,7 +168,7 @@ calculateProcPoints blocks = calculateProcPoints' init_proc_points blocks
map brokenBlockId $ map brokenBlockId $
filter always_proc_point blocks filter always_proc_point blocks
always_proc_point BrokenBlock { always_proc_point BrokenBlock {
brokenBlockEntry = FunctionEntry _ } = True brokenBlockEntry = FunctionEntry _ _ } = True
always_proc_point BrokenBlock { always_proc_point BrokenBlock {
brokenBlockEntry = ContinuationEntry _ } = True brokenBlockEntry = ContinuationEntry _ } = True
always_proc_point _ = False always_proc_point _ = False
...@@ -230,14 +231,17 @@ buildContinuation proc_points blocks start = ...@@ -230,14 +231,17 @@ buildContinuation proc_points blocks start =
children_blocks = map (lookupWithDefaultUFM blocks (panic "TODO")) (uniqSetToList children) children_blocks = map (lookupWithDefaultUFM blocks (panic "TODO")) (uniqSetToList children)
body = start_block : children_blocks body = start_block : children_blocks
info_table = [] -- TODO info_table = [] -- TODO
is_entry = case start_block of start_block_entry = brokenBlockEntry start_block
BrokenBlock { brokenBlockEntry = FunctionEntry _ } -> True is_entry = case start_block_entry of
FunctionEntry _ _ -> True
_ -> False _ -> False
clabel = mkReturnPtLabel $ getUnique start clabel = case start_block_entry of
params = case start_block of FunctionEntry label _ -> label
BrokenBlock { brokenBlockEntry = FunctionEntry args } -> args _ -> mkReturnPtLabel $ getUnique start
BrokenBlock { brokenBlockEntry = ContinuationEntry args } -> args params = case start_block_entry of
BrokenBlock { brokenBlockEntry = ControlEntry } -> [] -- TODO: it's a proc-point, we could pass lives in parameter registers FunctionEntry _ args -> args
ContinuationEntry args -> args
ControlEntry -> [] -- TODO: it's a proc-point, we could pass lives in parameter registers
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- For now just select the continuation orders in the order they are in the set with no gaps -- For now just select the continuation orders in the order they are in the set with no gaps
...@@ -270,7 +274,7 @@ selectStackFormat live blocks = ...@@ -270,7 +274,7 @@ selectStackFormat live blocks =
formats unknown_block formats unknown_block
cause_name cause_name
-- Do initial calculates for function blocks -- Do initial calculates for function blocks
(Nothing, FunctionEntry _) -> (Nothing, FunctionEntry _ _) ->
Just $ Just $
addToUFM formats ident $ addToUFM formats ident $
StackFormat ident 0 [] StackFormat ident 0 []
...@@ -363,7 +367,7 @@ constructContinuation2' curr_ident formats (BrokenBlock ident entry stmts _ exit ...@@ -363,7 +367,7 @@ constructContinuation2' curr_ident formats (BrokenBlock ident entry stmts _ exit
unknown_block = panic "unknown BlockId in constructContinuation" unknown_block = panic "unknown BlockId in constructContinuation"
prefix = case entry of prefix = case entry of
ControlEntry -> [] ControlEntry -> []
FunctionEntry _ -> [] FunctionEntry _ _ -> []
ContinuationEntry formals -> ContinuationEntry formals ->
unpack_continuation curr_format unpack_continuation curr_format
postfix = case exit of postfix = case exit of
...@@ -567,7 +571,7 @@ cpsProc uniqSupply x@(CmmProc info_table ident params blocks) = ...@@ -567,7 +571,7 @@ cpsProc uniqSupply x@(CmmProc info_table ident params blocks) =
-- Break the block at each function call -- Break the block at each function call
broken_blocks :: [BrokenBlock] broken_blocks :: [BrokenBlock]
broken_blocks = concat $ zipWith3 breakBlock uniqes blocks broken_blocks = concat $ zipWith3 breakBlock uniqes blocks
(FunctionEntry params:repeat ControlEntry) (FunctionEntry ident params:repeat ControlEntry)
-- Calculate live variables for each broken block -- Calculate live variables for each broken block
live :: BlockEntryLiveness live :: BlockEntryLiveness
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment