1 module Mate.RegisterAllocation where
8 type IEdge a = (Label a, Label a)
9 data IGraph a = IGraph [IEdge a] deriving (Show)
11 -- TODO: make IEdge eq
13 --data IArchitecture = Arch { regs :: Integer }
14 type IArchitecture = Int --number of regs
17 type Assignment a = (a, Int)
20 edgeEq (from,to) (from',to') = from == from' && to == to'
23 -- TODO: find combinator do match try semantics here
24 -- Solution: use list because list is MonadPlus instance
25 -- other solution add maybe monadplus implementation
26 conflicts (IGraph xs) (label,anotherLabel) =
27 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")]