[project @ 1999-04-29 11:53:12 by simonpj]
[ghc-hetmet.git] / ghc / tests / programs / jeff-bug / ROB.hs
1 module ROB(rob)  where
2 import LazyST
3
4 import Hawk
5 import Trans
6
7 import qualified RF 
8 import qualified AQ as Q
9 import qualified RAT 
10 import RF(RF)
11 import AQ(AQ)
12 import RAT(RAT)
13 import ROB_insert(insert)
14 import ROB_retire(retire)
15
16 import DLX
17
18
19 {-
20 type ROB s i r w =  Int ->                                         
21               (s [Trans i r w], s [VTrans r w]) ->
22               (s [Trans i r w], s [VTrans r w], s Int,s Bool)
23 -}
24  
25
26 --rob :: (Signal s,Register r,Word w) => ROB s StandardOp r w
27 rob n (fetched,computed)
28   = unbundle4 $ runST (
29     do { q <- Q.new n
30        ; rat <- RAT.new
31        ; regfile <- RF.new 
32        ; step2(fetched,computed)
33            { update q computed
34            ; instrs <- insert rat q regfile fetched
35            ; (retired,missed) <- retire rat q regfile
36            ; inCase missed $ do { Q.clear q
37                                 ; RAT.clear rat
38                                 }
39            ; capacity <- Q.space q
40            ; let ready = if missed then [] else instrs
41            ; return (retired,ready,capacity,missed)
42            }
43        }
44    )   
45     where 
46     inCase x y = if x then y else return ()
47
48
49 -- assumes single register dest ops (not a good assumption)
50 --update :: (Register r,Word w) => AQ s (VTrans r w) -> [VTrans r w] -> ST s ()
51 update q
52   = mapM_ $ \t ->
53     do { let [Reg (Virtual v (Just r)) val] = getDst t 
54        ; Q.insert q v t
55        }
56
57