Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
295d2a00
Commit
295d2a00
authored
Sep 11, 2007
by
Ben.Lippmeier@anu.edu.au
Browse files
Try and allocate vregs spilled/reloaded from some slot to the same hreg
parent
a12bf21a
Changes
2
Hide whitespace changes
Inline
Side-by-side
compiler/nativeGen/RegAllocColor.hs
View file @
295d2a00
...
...
@@ -119,7 +119,7 @@ regAlloc_spin dflags (spinCount :: Int) triv regsFree slotsFree debug_codeGraphs
-- rewrite regs in the code that have been coalesced
let
patchF
reg
=
case
lookupUFM
rmCoalesce
reg
of
Just
reg'
->
reg'
Just
reg'
->
patchF
reg'
Nothing
->
reg
let
code_coalesced
=
map
(
patchEraseLive
patchF
)
code
...
...
@@ -246,16 +246,18 @@ buildGraph code
let
(
conflictList
,
moveList
)
=
unzip
$
map
slurpConflicts
code
let
conflictBag
=
unionManyBags
conflictList
let
move
Bag
=
unionManyBags
moveList
-- Slurp out the spill/reload coalesces
let
move
List2
=
map
slurpReloadCoalesce
code
-- Add the reg-reg conflicts to the graph
let
conflictBag
=
unionManyBags
conflictList
let
graph_conflict
=
foldrBag
graphAddConflictSet
Color
.
initGraph
conflictBag
-- Add the coalescences edges to the graph.
let
moveBag
=
unionBags
(
unionManyBags
moveList2
)
(
unionManyBags
moveList
)
let
graph_coalesce
=
foldrBag
graphAddCoalesce
graph_conflict
moveBag
return
graph_coalesce
return
$
Color
.
validateGraph
(
text
"urk"
)
graph_coalesce
-- | Add some conflict edges to the graph.
...
...
@@ -326,7 +328,7 @@ patchRegsFromGraph graph code
(
text
"There is no node in the graph for register "
<>
ppr
reg
$$
ppr
code
$$
Color
.
dotGraph
(
\
_
->
text
"white"
)
trivColorable
graph
)
in
patchEraseLive
patchF
code
...
...
compiler/nativeGen/RegLiveness.hs
View file @
295d2a00
...
...
@@ -22,6 +22,7 @@ module RegLiveness (
stripLive
,
spillNatBlock
,
slurpConflicts
,
slurpReloadCoalesce
,
lifetimeCount
,
eraseDeltasLive
,
patchEraseLive
,
...
...
@@ -244,6 +245,51 @@ slurpConflicts live
,
moves
)
lis
-- | For spill/reloads
--
-- SPILL v1, slot1
-- ...
-- RELOAD slot1, v2
--
-- If we can arrange that v1 and v2 are allocated to the same hreg it's more likely
-- the spill/reload instrs can be cleaned and replaced by a nop reg-reg move.
--
-- TODO: This only works intra-block at the momement. It's be nice to join up the mappings
-- across blocks also.
--
slurpReloadCoalesce
::
LiveCmmTop
->
Bag
(
Reg
,
Reg
)
slurpReloadCoalesce
live
=
slurpCmm
emptyBag
live
where
slurpCmm
cs
CmmData
{}
=
cs
slurpCmm
cs
(
CmmProc
_
_
_
(
ListGraph
blocks
))
=
foldl'
slurpComp
cs
blocks
slurpComp
cs
(
BasicBlock
_
blocks
)
=
foldl'
slurpBlock
cs
blocks
slurpBlock
cs
(
BasicBlock
_
instrs
)
=
let
(
_
,
mMoves
)
=
mapAccumL
slurpLI
emptyUFM
instrs
in
unionBags
cs
(
listToBag
$
catMaybes
mMoves
)
slurpLI
::
UniqFM
Reg
->
LiveInstr
->
(
UniqFM
Reg
,
Maybe
(
Reg
,
Reg
))
slurpLI
slotMap
(
Instr
instr
_
)
-- remember what reg was stored into the slot
|
SPILL
reg
slot
<-
instr
,
slotMap'
<-
addToUFM
slotMap
slot
reg
=
(
slotMap'
,
Nothing
)
-- add an edge betwen the this reg and the last one stored into the slot
|
RELOAD
slot
reg
<-
instr
=
case
lookupUFM
slotMap
slot
of
Just
reg2
->
(
slotMap
,
Just
(
reg
,
reg2
))
Nothing
->
(
slotMap
,
Nothing
)
|
otherwise
=
(
slotMap
,
Nothing
)
-- | Strip away liveness information, yielding NatCmmTop
stripLive
::
LiveCmmTop
->
NatCmmTop
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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