[project @ 1999-05-26 14:12:07 by simonmar]
[ghc-hetmet.git] / ghc / tests / programs / jeff-bug / Utils.hs
1 module Utils where
2
3 import Hawk
4 import Trans
5 import DLX
6 import Maybe
7 import LazyST
8
9 --(f,g) >< (x,y) = (f x, g y)
10
11
12
13 unique x = x
14 {-
15 unique (Sig xs) = runST (
16   do { x <- newSTRef 0
17      ; l <- mapM (anno x) xs
18      ; return $ Sig l
19      }
20   )
21   where anno x xs = mapM (anno' x) xs 
22         anno' x y = do { v <- readSTRef x 
23                        ; writeSTRef x (v+1)
24                        ; return $ addInfo (Loc (Word v)) y
25                        }
26 -}
27
28 convert (Loc y) = Loc y
29 convert (Imm y)    = Imm y
30 convert (Reg r x) = Reg (Real r) x
31
32 convertBack (Loc y) = Loc y
33 convertBack (Imm y)    = Imm y
34 convertBack (Reg (Real r) x) = Reg r x
35 convertBack (Reg (Virtual _ (Just r)) x) = Reg r x
36 convertBack t@(Reg (Virtual r Nothing) x) = error "ConvertBack"
37
38 removeVirtuals t = Trans dest op src info
39       where src = map convertBack $ getSrc t
40             dest = map convertBack $ getDst t
41             info = map convertBack $ getInfo t
42             op = getOp t
43