blob: ed495623f13738df0838f9f3ba5877676b7009f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
module GHC.Cmm.LRegSet (
LRegSet,
LRegKey,
emptyLRegSet,
nullLRegSet,
insertLRegSet,
elemLRegSet,
deleteFromLRegSet,
sizeLRegSet,
plusLRegSet,
elemsLRegSet
) where
import GHC.Prelude
import GHC.Types.Unique
import GHC.Cmm.Expr
import Data.IntSet as IntSet
-- Compact sets for membership tests of local variables.
type LRegSet = IntSet.IntSet
type LRegKey = Int
emptyLRegSet :: LRegSet
emptyLRegSet = IntSet.empty
nullLRegSet :: LRegSet -> Bool
nullLRegSet = IntSet.null
insertLRegSet :: LocalReg -> LRegSet -> LRegSet
insertLRegSet l = IntSet.insert (getKey (getUnique l))
elemLRegSet :: LocalReg -> LRegSet -> Bool
elemLRegSet l = IntSet.member (getKey (getUnique l))
deleteFromLRegSet :: LRegSet -> LocalReg -> LRegSet
deleteFromLRegSet set reg = IntSet.delete (getKey . getUnique $ reg) set
sizeLRegSet :: IntSet -> Int
sizeLRegSet = IntSet.size
plusLRegSet :: IntSet -> IntSet -> IntSet
plusLRegSet = IntSet.union
elemsLRegSet :: IntSet -> [Int]
elemsLRegSet = IntSet.toList
|