2 module Mate.RegisterAllocation where
12 type IEdge a = (Label a, Label a)
13 data IGraph a = IGraph [IEdge a] deriving (Show)
15 -- TODO: make IEdge eq
17 --data IArchitecture = Arch { regs :: Integer }
18 type IArchitecture = Int --number of regs
21 type Assignment a = (a, Int)
24 edgeEq (from,to) (from',to') = from == from' && to == to'
27 -- TODO: find combinator do match try semantics here
28 -- Solution: use list because list is MonadPlus instance
29 -- other solution add maybe monadplus implementation
30 conflicts (IGraph xs) (label,anotherLabel) =
31 let comparison = edgeEq (label,anotherLabel)
32 comparison' = edgeEq (anotherLabel,label)
33 in isJust (find comparison xs) || isJust (find comparison' xs)
36 isParticipiant label (from,to) = from == label || to == label
38 count p = length . filter p
40 degree g@(IGraph xs) label = count (isParticipiant label) xs
43 doChaitin81 :: (Eq a) => IArchitecture -> IGraph a -> [Assignment a]
44 doChaitin81 numberOfRegisters graph = []
46 type IState a = ([a],IGraph a)
48 --chait81Simplification :: (Eq a) => IArchitecture -> SimplState
49 --chait81Simplification regs = do (
51 testGraph = IGraph [("a", "b"), ("a","c"), ("c", "b"), ("b","d"), ("d","c"),("b","e"),("d","e")]