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
bd510644
Commit
bd510644
authored
Aug 06, 2016
by
Ömer Sinan Ağacan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RegAlloc: Use IntSet/IntMaps instead of generic Set/Maps
parent
3bfe6a52
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
29 deletions
+29
-29
compiler/cmm/BlockId.hs
compiler/cmm/BlockId.hs
+7
-1
compiler/nativeGen/RegAlloc/Graph/Spill.hs
compiler/nativeGen/RegAlloc/Graph/Spill.hs
+9
-11
compiler/nativeGen/RegAlloc/Graph/SpillClean.hs
compiler/nativeGen/RegAlloc/Graph/SpillClean.hs
+8
-10
compiler/nativeGen/RegAlloc/Liveness.hs
compiler/nativeGen/RegAlloc/Liveness.hs
+5
-7
No files found.
compiler/cmm/BlockId.hs
View file @
bd510644
...
...
@@ -7,7 +7,7 @@ module BlockId
,
BlockSet
,
BlockEnv
,
IsSet
(
..
),
setInsertList
,
setDeleteList
,
setUnions
,
IsMap
(
..
),
mapInsertList
,
mapDeleteList
,
mapUnions
,
emptyBlockSet
,
emptyBlockMap
,
emptyBlockSet
,
emptyBlockMap
,
lookupBlockMap
,
insertBlockMap
,
blockLbl
,
infoTblLbl
,
retPtLbl
)
where
...
...
@@ -61,6 +61,12 @@ instance Outputable a => Outputable (BlockEnv a) where
emptyBlockMap
::
BlockEnv
a
emptyBlockMap
=
mapEmpty
lookupBlockMap
::
BlockId
->
BlockEnv
a
->
Maybe
a
lookupBlockMap
=
mapLookup
insertBlockMap
::
BlockId
->
a
->
BlockEnv
a
->
BlockEnv
a
insertBlockMap
=
mapInsert
-- Block sets
type
BlockSet
=
Hoopl
.
LabelSet
...
...
compiler/nativeGen/RegAlloc/Graph/Spill.hs
View file @
bd510644
...
...
@@ -24,10 +24,8 @@ import Platform
import
Data.List
import
Data.Maybe
import
Data.Map
(
Map
)
import
Data.Set
(
Set
)
import
qualified
Data.Map
as
Map
import
qualified
Data.Set
as
Set
import
Data.IntSet
(
IntSet
)
import
qualified
Data.IntSet
as
IntSet
-- | Spill all these virtual regs to stack slots.
...
...
@@ -110,7 +108,7 @@ regSpill_top platform regSlotMap cmm
-- number to the liveSlotsOnEntry set. The spill cleaner needs
-- this information to erase unneeded spill and reload instructions
-- after we've done a successful allocation.
let
liveSlotsOnEntry'
::
Map
BlockId
(
Set
Int
)
let
liveSlotsOnEntry'
::
BlockMap
IntSet
liveSlotsOnEntry'
=
mapFoldWithKey
patchLiveSlot
liveSlotsOnEntry
liveVRegsOnEntry
...
...
@@ -131,23 +129,23 @@ regSpill_top platform regSlotMap cmm
-- in the given slotmap.
patchLiveSlot
::
BlockId
->
RegSet
->
Map
BlockId
(
Set
Int
)
->
Map
BlockId
(
Set
Int
)
->
BlockMap
IntSet
->
BlockMap
IntSet
patchLiveSlot
blockId
regsLive
slotMap
=
let
-- Slots that are already recorded as being live.
curSlotsLive
=
fromMaybe
Set
.
empty
$
Map
.
looku
p
blockId
slotMap
curSlotsLive
=
fromMaybe
Int
Set
.
empty
$
lookupBlockMa
p
blockId
slotMap
moreSlotsLive
=
Set
.
fromList
moreSlotsLive
=
Int
Set
.
fromList
$
catMaybes
$
map
(
lookupUFM
regSlotMap
)
$
nonDetEltsUFM
regsLive
-- See Note [Unique Determinism and code generation]
slotMap'
=
Map
.
insert
blockId
(
Set
.
union
curSlotsLive
moreSlotsLive
)
slotMap
=
insertBlockMap
blockId
(
Int
Set
.
union
curSlotsLive
moreSlotsLive
)
slotMap
in
slotMap'
...
...
compiler/nativeGen/RegAlloc/Graph/SpillClean.hs
View file @
bd510644
...
...
@@ -43,10 +43,8 @@ import Platform
import
Data.List
import
Data.Maybe
import
Data.Map
(
Map
)
import
Data.Set
(
Set
)
import
qualified
Data.Map
as
Map
import
qualified
Data.Set
as
Set
import
Data.IntSet
(
IntSet
)
import
qualified
Data.IntSet
as
IntSet
-- | The identification number of a spill slot.
...
...
@@ -309,7 +307,7 @@ cleanTopBackward cmm
cleanBlockBackward
::
Instruction
instr
=>
Map
BlockId
(
Set
Int
)
=>
BlockMap
IntSet
->
LiveBasicBlock
instr
->
CleanM
(
LiveBasicBlock
instr
)
...
...
@@ -321,7 +319,7 @@ cleanBlockBackward liveSlotsOnEntry (BasicBlock blockId instrs)
cleanBackward
::
Instruction
instr
=>
Map
BlockId
(
Set
Int
)
-- ^ Slots live on entry to each block
=>
BlockMap
IntSet
-- ^ Slots live on entry to each block
->
UniqSet
Int
-- ^ Slots that have been spilled, but not reloaded from
->
[
LiveInstr
instr
]
-- ^ acc
->
[
LiveInstr
instr
]
-- ^ Instrs to clean (in forwards order)
...
...
@@ -334,7 +332,7 @@ cleanBackward liveSlotsOnEntry noReloads acc lis
cleanBackward'
::
Instruction
instr
=>
Map
BlockId
(
Set
Int
)
=>
BlockMap
IntSet
->
UniqFM
[
BlockId
]
->
UniqSet
Int
->
[
LiveInstr
instr
]
...
...
@@ -381,14 +379,14 @@ cleanBackward' liveSlotsOnEntry reloadedBy noReloads acc (li : instrs)
,
targets
<-
jumpDestsOfInstr
instr
=
do
let
slotsReloadedByTargets
=
Set
.
unions
=
Int
Set
.
unions
$
catMaybes
$
map
(
flip
Map
.
looku
p
liveSlotsOnEntry
)
$
map
(
flip
lookupBlockMa
p
liveSlotsOnEntry
)
$
targets
let
noReloads'
=
foldl'
delOneFromUniqSet
noReloads
$
Set
.
toList
slotsReloadedByTargets
$
Int
Set
.
toList
slotsReloadedByTargets
cleanBackward
liveSlotsOnEntry
noReloads'
(
li
:
acc
)
instrs
...
...
compiler/nativeGen/RegAlloc/Liveness.hs
View file @
bd510644
...
...
@@ -55,9 +55,7 @@ import State
import
Data.List
import
Data.Maybe
import
Data.Map
(
Map
)
import
Data.Set
(
Set
)
import
qualified
Data.Map
as
Map
import
Data.IntSet
(
IntSet
)
-----------------------------------------------------------------------------
type
RegSet
=
UniqSet
Reg
...
...
@@ -173,7 +171,7 @@ data LiveInfo
[
BlockId
]
-- entry points (first one is the
-- entry point for the proc).
(
Maybe
(
BlockMap
RegSet
))
-- argument locals live on entry to this block
(
Map
BlockId
(
Set
Int
))
-- stack slots live on entry to this block
(
BlockMap
IntSet
)
-- stack slots live on entry to this block
-- | A basic block with liveness information.
...
...
@@ -648,7 +646,7 @@ natCmmTopToLive (CmmData i d)
=
CmmData
i
d
natCmmTopToLive
(
CmmProc
info
lbl
live
(
ListGraph
[]
))
=
CmmProc
(
LiveInfo
info
[]
Nothing
Map
.
empty
)
lbl
live
[]
=
CmmProc
(
LiveInfo
info
[]
Nothing
emptyBlockMap
)
lbl
live
[]
natCmmTopToLive
proc
@
(
CmmProc
info
lbl
live
(
ListGraph
blocks
@
(
first
:
_
)))
=
let
first_id
=
blockId
first
...
...
@@ -659,7 +657,7 @@ natCmmTopToLive proc@(CmmProc info lbl live (ListGraph blocks@(first : _)))
BasicBlock
l
(
map
(
\
i
->
LiveInstr
(
Instr
i
)
Nothing
)
instrs
)))
$
sccs
in
CmmProc
(
LiveInfo
info
(
first_id
:
entry_ids
)
Nothing
Map
.
empty
)
in
CmmProc
(
LiveInfo
info
(
first_id
:
entry_ids
)
Nothing
emptyBlockMap
)
lbl
live
sccsLive
...
...
@@ -725,7 +723,7 @@ regLiveness _ (CmmData i d)
regLiveness
_
(
CmmProc
info
lbl
live
[]
)
|
LiveInfo
static
mFirst
_
_
<-
info
=
return
$
CmmProc
(
LiveInfo
static
mFirst
(
Just
mapEmpty
)
Map
.
empty
)
(
LiveInfo
static
mFirst
(
Just
mapEmpty
)
emptyBlockMap
)
lbl
live
[]
regLiveness
platform
(
CmmProc
info
lbl
live
sccs
)
...
...
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