summaryrefslogtreecommitdiff
path: root/compiler/nativeGen/RegAlloc/Graph
diff options
context:
space:
mode:
authorKavon Farvardin <kavon@farvard.in>2018-09-23 15:29:37 -0500
committerKavon Farvardin <kavon@farvard.in>2018-09-23 15:29:37 -0500
commit84c2ad99582391005b5e873198b15e9e9eb4f78d (patch)
treecaa8c2f2ec7e97fbb4977263c6817c9af5025cf4 /compiler/nativeGen/RegAlloc/Graph
parent8ddb47cfcf5776e9a3c55fd37947c8a95e00fa12 (diff)
parente68b439fe5de61b9a2ca51af472185c62ccb8b46 (diff)
downloadhaskell-wip/T13904.tar.gz
update to current master againwip/T13904
Diffstat (limited to 'compiler/nativeGen/RegAlloc/Graph')
-rw-r--r--compiler/nativeGen/RegAlloc/Graph/ArchBase.hs2
-rw-r--r--compiler/nativeGen/RegAlloc/Graph/ArchX86.hs27
-rw-r--r--compiler/nativeGen/RegAlloc/Graph/Coalesce.hs6
-rw-r--r--compiler/nativeGen/RegAlloc/Graph/Main.hs3
-rw-r--r--compiler/nativeGen/RegAlloc/Graph/Spill.hs13
-rw-r--r--compiler/nativeGen/RegAlloc/Graph/SpillClean.hs2
-rw-r--r--compiler/nativeGen/RegAlloc/Graph/SpillCost.hs2
-rw-r--r--compiler/nativeGen/RegAlloc/Graph/Stats.hs17
-rw-r--r--compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs2
9 files changed, 49 insertions, 25 deletions
diff --git a/compiler/nativeGen/RegAlloc/Graph/ArchBase.hs b/compiler/nativeGen/RegAlloc/Graph/ArchBase.hs
index 6771e4ecb9..634e61cb13 100644
--- a/compiler/nativeGen/RegAlloc/Graph/ArchBase.hs
+++ b/compiler/nativeGen/RegAlloc/Graph/ArchBase.hs
@@ -21,6 +21,8 @@ module RegAlloc.Graph.ArchBase (
bound,
squeese
) where
+import GhcPrelude
+
import UniqSet
import UniqFM
import Unique
diff --git a/compiler/nativeGen/RegAlloc/Graph/ArchX86.hs b/compiler/nativeGen/RegAlloc/Graph/ArchX86.hs
index 439899071a..0472e4cf09 100644
--- a/compiler/nativeGen/RegAlloc/Graph/ArchX86.hs
+++ b/compiler/nativeGen/RegAlloc/Graph/ArchX86.hs
@@ -14,9 +14,14 @@ module RegAlloc.Graph.ArchX86 (
worst,
squeese,
) where
+
+import GhcPrelude
+
import RegAlloc.Graph.ArchBase (Reg(..), RegSub(..), RegClass(..))
import UniqSet
+import qualified Data.Array as A
+
-- | Determine the class of a register
classOfReg :: Reg -> RegClass
@@ -57,18 +62,28 @@ regName :: Reg -> Maybe String
regName reg
= case reg of
Reg ClassG32 i
- | i <= 7-> Just $ [ "eax", "ebx", "ecx", "edx"
- , "ebp", "esi", "edi", "esp" ] !! i
+ | i <= 7 ->
+ let names = A.listArray (0,8)
+ [ "eax", "ebx", "ecx", "edx"
+ , "ebp", "esi", "edi", "esp" ]
+ in Just $ names A.! i
RegSub SubL16 (Reg ClassG32 i)
- | i <= 7 -> Just $ [ "ax", "bx", "cx", "dx"
- , "bp", "si", "di", "sp"] !! i
+ | i <= 7 ->
+ let names = A.listArray (0,8)
+ [ "ax", "bx", "cx", "dx"
+ , "bp", "si", "di", "sp"]
+ in Just $ names A.! i
RegSub SubL8 (Reg ClassG32 i)
- | i <= 3 -> Just $ [ "al", "bl", "cl", "dl"] !! i
+ | i <= 3 ->
+ let names = A.listArray (0,4) [ "al", "bl", "cl", "dl"]
+ in Just $ names A.! i
RegSub SubL8H (Reg ClassG32 i)
- | i <= 3 -> Just $ [ "ah", "bh", "ch", "dh"] !! i
+ | i <= 3 ->
+ let names = A.listArray (0,4) [ "ah", "bh", "ch", "dh"]
+ in Just $ names A.! i
_ -> Nothing
diff --git a/compiler/nativeGen/RegAlloc/Graph/Coalesce.hs b/compiler/nativeGen/RegAlloc/Graph/Coalesce.hs
index 7e8047f29f..5ca2412c73 100644
--- a/compiler/nativeGen/RegAlloc/Graph/Coalesce.hs
+++ b/compiler/nativeGen/RegAlloc/Graph/Coalesce.hs
@@ -3,6 +3,8 @@ module RegAlloc.Graph.Coalesce (
regCoalesce,
slurpJoinMovs
) where
+import GhcPrelude
+
import RegAlloc.Liveness
import Instruction
import Reg
@@ -14,8 +16,6 @@ import UniqFM
import UniqSet
import UniqSupply
-import Data.List
-
-- | Do register coalescing on this top level thing
--
@@ -62,7 +62,7 @@ sinkReg fm r
-- | Slurp out mov instructions that only serve to join live ranges.
--
--- During a mov, if the source reg dies and the destiation reg is
+-- During a mov, if the source reg dies and the destination reg is
-- born then we can rename the two regs to the same thing and
-- eliminate the move.
slurpJoinMovs
diff --git a/compiler/nativeGen/RegAlloc/Graph/Main.hs b/compiler/nativeGen/RegAlloc/Graph/Main.hs
index 08538453f7..4c17d930ea 100644
--- a/compiler/nativeGen/RegAlloc/Graph/Main.hs
+++ b/compiler/nativeGen/RegAlloc/Graph/Main.hs
@@ -4,6 +4,8 @@
module RegAlloc.Graph.Main (
regAlloc
) where
+import GhcPrelude
+
import qualified GraphColor as Color
import RegAlloc.Liveness
import RegAlloc.Graph.Spill
@@ -25,7 +27,6 @@ import UniqSet
import UniqSupply
import Util (seqList)
-import Data.List
import Data.Maybe
import Control.Monad
diff --git a/compiler/nativeGen/RegAlloc/Graph/Spill.hs b/compiler/nativeGen/RegAlloc/Graph/Spill.hs
index 0014ab6fed..bce24bdd3c 100644
--- a/compiler/nativeGen/RegAlloc/Graph/Spill.hs
+++ b/compiler/nativeGen/RegAlloc/Graph/Spill.hs
@@ -7,6 +7,8 @@ module RegAlloc.Graph.Spill (
SpillStats(..),
accSpillSL
) where
+import GhcPrelude
+
import RegAlloc.Liveness
import Instruction
import Reg
@@ -34,7 +36,7 @@ import qualified Data.IntSet as IntSet
-- TODO: See if we can split some of the live ranges instead of just globally
-- spilling the virtual reg. This might make the spill cleaner's job easier.
--
--- TODO: On CISCy x86 and x86_64 we don't nessesarally have to add a mov instruction
+-- TODO: On CISCy x86 and x86_64 we don't necessarily have to add a mov instruction
-- when making spills. If an instr is using a spilled virtual we may be able to
-- address the spill slot directly.
--
@@ -111,8 +113,8 @@ regSpill_top platform regSlotMap cmm
-- after we've done a successful allocation.
let liveSlotsOnEntry' :: BlockMap IntSet
liveSlotsOnEntry'
- = mapFoldWithKey patchLiveSlot
- liveSlotsOnEntry liveVRegsOnEntry
+ = mapFoldlWithKey patchLiveSlot
+ liveSlotsOnEntry liveVRegsOnEntry
let info'
= LiveInfo static firstId
@@ -129,10 +131,9 @@ regSpill_top platform regSlotMap cmm
-- then record the fact that these slots are now live in those blocks
-- in the given slotmap.
patchLiveSlot
- :: BlockId -> RegSet
- -> BlockMap IntSet -> BlockMap IntSet
+ :: BlockMap IntSet -> BlockId -> RegSet -> BlockMap IntSet
- patchLiveSlot blockId regsLive slotMap
+ patchLiveSlot slotMap blockId regsLive
= let
-- Slots that are already recorded as being live.
curSlotsLive = fromMaybe IntSet.empty
diff --git a/compiler/nativeGen/RegAlloc/Graph/SpillClean.hs b/compiler/nativeGen/RegAlloc/Graph/SpillClean.hs
index faef4037c2..50001d7334 100644
--- a/compiler/nativeGen/RegAlloc/Graph/SpillClean.hs
+++ b/compiler/nativeGen/RegAlloc/Graph/SpillClean.hs
@@ -28,6 +28,8 @@
module RegAlloc.Graph.SpillClean (
cleanSpills
) where
+import GhcPrelude
+
import RegAlloc.Liveness
import Instruction
import Reg
diff --git a/compiler/nativeGen/RegAlloc/Graph/SpillCost.hs b/compiler/nativeGen/RegAlloc/Graph/SpillCost.hs
index 9811f1a64b..f603b609df 100644
--- a/compiler/nativeGen/RegAlloc/Graph/SpillCost.hs
+++ b/compiler/nativeGen/RegAlloc/Graph/SpillCost.hs
@@ -13,6 +13,8 @@ module RegAlloc.Graph.SpillCost (
lifeMapFromSpillCostInfo
) where
+import GhcPrelude
+
import RegAlloc.Liveness
import Instruction
import RegClass
diff --git a/compiler/nativeGen/RegAlloc/Graph/Stats.hs b/compiler/nativeGen/RegAlloc/Graph/Stats.hs
index 71956025b0..487e3ee03a 100644
--- a/compiler/nativeGen/RegAlloc/Graph/Stats.hs
+++ b/compiler/nativeGen/RegAlloc/Graph/Stats.hs
@@ -16,6 +16,8 @@ module RegAlloc.Graph.Stats (
#include "nativeGen/NCG.h"
+import GhcPrelude
+
import qualified GraphColor as Color
import RegAlloc.Liveness
import RegAlloc.Graph.Spill
@@ -32,9 +34,6 @@ import UniqFM
import UniqSet
import State
-import Data.List
-
-
-- | Holds interesting statistics from the register allocator.
data RegAllocStats statics instr
@@ -265,8 +264,8 @@ pprStatsConflict stats
$$ text "\n")
--- | For every vreg, dump it's how many conflicts it has and its lifetime
--- good for making a scatter plot.
+-- | For every vreg, dump how many conflicts it has, and its lifetime.
+-- Good for making a scatter plot.
pprStatsLifeConflict
:: [RegAllocStats statics instr]
-> Color.Graph VirtualReg RegClass RealReg -- ^ global register conflict graph
@@ -277,10 +276,10 @@ pprStatsLifeConflict stats graph
$ foldl' plusSpillCostInfo zeroSpillCostInfo
$ [ raSpillCosts s | s@RegAllocStatsStart{} <- stats ]
- scatter = map (\r -> let lifetime = case lookupUFM lifeMap r of
- Just (_, l) -> l
- Nothing -> 0
- Just node = Color.lookupNode graph r
+ scatter = map (\r -> let lifetime = case lookupUFM lifeMap r of
+ Just (_, l) -> l
+ Nothing -> 0
+ Just node = Color.lookupNode graph r
in parens $ hcat $ punctuate (text ", ")
[ doubleQuotes $ ppr $ Color.nodeId node
, ppr $ sizeUniqSet (Color.nodeConflicts node)
diff --git a/compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs b/compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs
index 204de846ae..7774985dce 100644
--- a/compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs
+++ b/compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs
@@ -8,6 +8,8 @@ where
#include "HsVersions.h"
+import GhcPrelude
+
import RegClass
import Reg