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