[project @ 2001-05-28 17:34:24 by qrczak]
[ghc-hetmet.git] / ghc / tests / programs / jeff-bug / DLX_Op.hs
1 module DLX_Op (DLX_Op(..)) where
2
3 import Arithmetic
4 import Memory
5 import Instruction
6 import Probe
7
8 data DLX_Op = ExecOp AluOp |
9           CondExecOp AluOp AluOp |      -- If first source == zero, then the
10                                         --  first AluOp is performed on rest
11                                         --  of source arguments, otherwise the
12                                         --  second AluOp is performed on them.
13           ParExecOp AluOp AluOp |       -- The first destination cell is the
14                                         --  result of the first AluOp; the
15                                         --  second destination cell is the
16                                         --  result of the second AluOp.
17           MemOp LoadStoreOp |
18           NoOp String                   -- Null operation. The string argument
19                                         --  can be used as a comment indicating
20                                         --  which phase generated a stall.
21           deriving (Eq,Show)
22
23 -- Begin Signature ---------------------------------------------------------
24 -- End Signature ---------------------------------------------------------
25
26 instance Instruction DLX_Op where
27    isNoOp t = case t of
28                 NoOp _ -> True
29                 _      -> False   
30
31    isAddOp t = case t of
32                 ExecOp (Add _) -> True
33                 _ -> False 
34
35    isSubOp t = case t of
36                 ExecOp (Sub _) -> True   
37                 _ -> False
38
39    isMultOp t = case t of
40                 ExecOp (Mult _) -> True
41                 _ -> False
42                      
43    isDivOp t = case t of
44                 ExecOp (Div _) -> True
45                 _ -> False
46
47    isJumpOp t = case t of
48                 CondExecOp _ _ -> True
49                 _ -> False           
50
51    isMemOp t = case t of
52                 MemOp _ -> True
53                 _ -> False
54  
55    isLoadOp t = case t of
56                 MemOp (Load _ _) -> True
57                 _ -> False
58
59    isStoreOp t = case t of
60                 MemOp (Store _) -> True
61                 _ -> False
62
63    noOp = NoOp ""
64    isAluOp t = case t of
65                 ExecOp _ -> True
66                 _ -> False
67
68    isCmpOp t = case t of
69                 ExecOp (S _) -> True
70                 _ -> False
71
72    isBoolOp t = case t of
73                 ExecOp Xor -> True
74                 ExecOp Or -> True
75                 ExecOp And -> True
76                 ExecOp Not -> True
77                 _ -> False
78
79    isMoveOp t = case t of
80                 ExecOp Input1 -> True
81                 _ -> False
82  
83    aluOp (ExecOp f) = f
84
85    isCond = isJumpOp
86
87    isPar (ParExecOp _ _) = True
88    isPar _ = False
89
90    fstOp (ParExecOp f _) = f
91    fstOp (CondExecOp f _) = f
92
93    sndOp (ParExecOp f g) = g
94    sndOp (CondExecOp f g) = g
95
96    memOp (MemOp f) = f
97
98
99