diff options
Diffstat (limited to 'compiler/nativeGen/RegAlloc/Graph')
-rw-r--r-- | compiler/nativeGen/RegAlloc/Graph/Spill.hs | 20 | ||||
-rw-r--r-- | compiler/nativeGen/RegAlloc/Graph/SpillClean.hs | 18 |
2 files changed, 17 insertions, 21 deletions
diff --git a/compiler/nativeGen/RegAlloc/Graph/Spill.hs b/compiler/nativeGen/RegAlloc/Graph/Spill.hs index a1d46cbc1b..a9ea6e5728 100644 --- a/compiler/nativeGen/RegAlloc/Graph/Spill.hs +++ b/compiler/nativeGen/RegAlloc/Graph/Spill.hs @@ -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.lookup blockId slotMap + curSlotsLive = fromMaybe IntSet.empty + $ lookupBlockMap blockId slotMap - moreSlotsLive = Set.fromList + moreSlotsLive = IntSet.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 (IntSet.union curSlotsLive moreSlotsLive) + slotMap in slotMap' diff --git a/compiler/nativeGen/RegAlloc/Graph/SpillClean.hs b/compiler/nativeGen/RegAlloc/Graph/SpillClean.hs index 25d0ff4e80..1df4b2570a 100644 --- a/compiler/nativeGen/RegAlloc/Graph/SpillClean.hs +++ b/compiler/nativeGen/RegAlloc/Graph/SpillClean.hs @@ -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 + = IntSet.unions $ catMaybes - $ map (flip Map.lookup liveSlotsOnEntry) + $ map (flip lookupBlockMap liveSlotsOnEntry) $ targets let noReloads' = foldl' delOneFromUniqSet noReloads - $ Set.toList slotsReloadedByTargets + $ IntSet.toList slotsReloadedByTargets cleanBackward liveSlotsOnEntry noReloads' (li : acc) instrs |