Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Glasgow Haskell Compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shayne Fletcher
Glasgow Haskell Compiler
Commits
ca7a31ac
Commit
ca7a31ac
authored
Mar 07, 2012
by
Simon Marlow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring only
parent
93e42a68
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
33 deletions
+69
-33
compiler/cmm/CmmLayoutStack.hs
compiler/cmm/CmmLayoutStack.hs
+69
-33
No files found.
compiler/cmm/CmmLayoutStack.hs
View file @
ca7a31ac
...
...
@@ -141,13 +141,6 @@ layout :: BlockSet -- proc points
layout
procpoints
liveness
entry
entry_args
final_stackmaps
final_hwm
blocks
=
go
blocks
init_stackmap
entry_args
[]
where
sp_high
=
final_hwm
-
entry_args
-- The stack check value is adjusted by the Sp offset on
-- entry to the proc, which is entry_args. We are
-- assuming that we only do a stack check at the
-- beginning of a proc, and we don't modify Sp before the
-- check.
(
updfr
,
cont_info
)
=
collectContInfo
blocks
init_stackmap
=
mapSingleton
entry
StackMap
{
sm_sp
=
entry_args
...
...
@@ -195,42 +188,80 @@ layout procpoints liveness entry entry_args final_stackmaps final_hwm blocks
-- middle3 -- some more middle nodes from handleLastNode
-- last1 -- the last node
--
-- The next step is to manifest Sp: turn all the CmmStackSlots
-- into CmmLoads from Sp. The adjustment for middle1/middle2
-- will be different from that for middle3/last1, because the
-- Sp adjustment intervenes.
--
let
area_off
=
getAreaOff
final_stackmaps
let
middle_pre
=
blockToList
$
foldl
blockSnoc
middle1
middle2
adj_pre_sp
,
adj_post_sp
::
CmmNode
e
x
->
CmmNode
e
x
adj_pre_sp
=
mapExpDeep
(
areaToSp
sp0
sp_high
area_off
)
adj_post_sp
=
mapExpDeep
(
areaToSp
(
sp0
-
sp_off
)
sp_high
area_off
)
sp_high
=
final_hwm
-
entry_args
-- The stack check value is adjusted by the Sp offset on
-- entry to the proc, which is entry_args. We are
-- assuming that we only do a stack check at the
-- beginning of a proc, and we don't modify Sp before the
-- check.
middle_pre
=
maybeAddSpAdj
sp_off
$
blockFromList
$
map
adj_pre_sp
$
elimStackStores
stack0
final_stackmaps
area_off
$
blockToList
$
foldl
blockSnoc
middle1
middle2
final_blocks
=
manifestSp
final_stackmaps
stack0
sp0
sp_high
entry0
middle_pre
sp_off
middle3
last1
fixup_blocks
middle_post
=
map
adj_post_sp
middle3
stackmaps'
=
mapUnion
acc_stackmaps
out
final_middle
=
foldl
blockSnoc
middle_pre
middle_post
final_last
=
optStackCheck
(
adj_post_sp
last1
)
hwm'
=
maximum
(
acc_hwm
:
(
sp0
-
sp_off
)
:
map
sm_sp
(
mapElems
out
))
newblock
=
blockJoin
entry0
final_middle
final_last
pprTrace
"layout(wibble)"
(
ppr
out
)
$
return
()
fixup_blocks'
=
map
(
blockMapNodes3
(
id
,
adj_post_sp
,
id
))
fixup_blocks
go
bs
stackmaps'
hwm'
(
final_blocks
++
acc_blocks
)
stackmaps'
=
mapUnion
acc_stackmaps
out
hwm'
=
maximum
(
acc_hwm
:
map
sm_sp
(
mapElems
out
))
-- -----------------------------------------------------------------------------
pprTrace
"layout(out)"
(
ppr
out
)
$
return
()
go
bs
stackmaps'
hwm'
(
newblock
:
fixup_blocks'
++
acc_blocks
)
-- | Manifest Sp: turn all the CmmStackSlots into CmmLoads from Sp. The
-- block looks like this:
--
-- middle_pre -- some middle nodes
-- Sp = Sp + sp_off -- Sp adjustment goes here
-- middle_post -- some more middle nodes, after the Sp adjustment
-- last -- the last node
--
-- And we have some extra blocks too (that don't contain Sp adjustments)
--
-- The adjustment for middle_pre will be different from that for
-- middle_post, because the Sp adjustment intervenes.
--
manifestSp
::
BlockEnv
StackMap
-- StackMaps for other blocks
->
StackMap
-- StackMap for this block
->
ByteOff
-- Sp on entry to the block
->
ByteOff
-- SpHigh
->
CmmNode
C
O
-- first node
->
[
CmmNode
O
O
]
-- middle_pre
->
ByteOff
-- sp_off
->
[
CmmNode
O
O
]
-- middle_post
->
CmmNode
O
C
-- last node
->
[
CmmBlock
]
-- new blocks
->
[
CmmBlock
]
-- final blocks with Sp manifest
manifestSp
stackmaps
stack0
sp0
sp_high
first
middle_pre
sp_off
middle_post
last
fixup_blocks
=
blockJoin
first
final_middle
final_last
:
fixup_blocks'
where
area_off
=
getAreaOff
stackmaps
adj_pre_sp
,
adj_post_sp
::
CmmNode
e
x
->
CmmNode
e
x
adj_pre_sp
=
mapExpDeep
(
areaToSp
sp0
sp_high
area_off
)
adj_post_sp
=
mapExpDeep
(
areaToSp
(
sp0
-
sp_off
)
sp_high
area_off
)
middle_pre'
=
maybeAddSpAdj
sp_off
$
blockFromList
$
map
adj_pre_sp
$
elimStackStores
stack0
stackmaps
area_off
$
middle_pre
middle_post'
=
map
adj_post_sp
middle_post
final_middle
=
foldl
blockSnoc
middle_pre'
middle_post'
final_last
=
optStackCheck
(
adj_post_sp
last
)
fixup_blocks'
=
map
(
blockMapNodes3
(
id
,
adj_post_sp
,
id
))
fixup_blocks
-- -----------------------------------------------------------------------------
-- | Eliminate stores of the form
--
...
...
@@ -445,6 +476,11 @@ handleLastNode procpoints liveness cont_info stackmaps
,
[
CmmBlock
]
,
BlockEnv
StackMap
)
-- handleProcPoints
-- | Just l <- future_continuation
-- , nub $ filter (`setMember` procpoints) $ successors last == [l]
-- =
handleProcPoints
=
do
pps
<-
mapM
handleProcPoint
(
successors
last
)
let
lbl_map
::
LabelMap
Label
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment