Make SDoc an abstract type.
[ghc-hetmet.git] / compiler / nativeGen / Alpha / Instr.hs
1 -----------------------------------------------------------------------------
2 --
3 -- Machine-dependent assembly language
4 --
5 -- (c) The University of Glasgow 1993-2004
6 --
7 -----------------------------------------------------------------------------
8
9 #include "HsVersions.h"
10 #include "nativeGen/NCG.h"
11
12 module Alpha.Instr (
13 --      Cond(..),
14 --      Instr(..),
15 --      RI(..)
16 )
17
18 where
19
20 {-
21 import BlockId
22 import Regs
23 import Cmm
24 import FastString
25 import CLabel
26
27 data Cond
28         = ALWAYS        -- For BI (same as BR)
29         | EQQ           -- For CMP and BI (NB: "EQ" is a 1.3 Prelude name)
30         | GE            -- For BI only
31         | GTT           -- For BI only (NB: "GT" is a 1.3 Prelude name)
32         | LE            -- For CMP and BI
33         | LTT           -- For CMP and BI (NB: "LT" is a 1.3 Prelude name)
34         | NE            -- For BI only
35         | NEVER         -- For BI (null instruction)
36         | ULE           -- For CMP only
37         | ULT           -- For CMP only
38         deriving Eq
39         
40
41 -- -----------------------------------------------------------------------------
42 -- Machine's assembly language
43
44 -- We have a few common "instructions" (nearly all the pseudo-ops) but
45 -- mostly all of 'Instr' is machine-specific.
46
47 -- Register or immediate
48 data RI 
49         = RIReg Reg
50         | RIImm Imm
51
52 data Instr
53         -- comment pseudo-op
54         = COMMENT FastString            
55
56         -- some static data spat out during code
57         -- generation.  Will be extracted before
58         -- pretty-printing.
59         | LDATA   Section [CmmStatic]   
60
61         -- start a new basic block.  Useful during
62         -- codegen, removed later.  Preceding 
63         -- instruction should be a jump, as per the
64         -- invariants for a BasicBlock (see Cmm).
65         | NEWBLOCK BlockId              
66
67         -- specify current stack offset for
68         -- benefit of subsequent passes
69         | DELTA   Int
70
71         -- | spill this reg to a stack slot
72         | SPILL   Reg Int
73
74         -- | reload this reg from a stack slot
75         | RELOAD  Int Reg
76
77         -- Loads and stores.
78         | LD          Size Reg AddrMode         -- size, dst, src
79         | LDA         Reg AddrMode              -- dst, src
80         | LDAH        Reg AddrMode              -- dst, src
81         | LDGP        Reg AddrMode              -- dst, src
82         | LDI         Size Reg Imm              -- size, dst, src
83         | ST          Size Reg AddrMode         -- size, src, dst
84
85         -- Int Arithmetic.
86         | CLR         Reg                       -- dst
87         | ABS         Size RI Reg               -- size, src, dst
88         | NEG         Size Bool RI Reg          -- size, overflow, src, dst
89         | ADD         Size Bool Reg RI Reg      -- size, overflow, src, src, dst
90         | SADD        Size Size Reg RI Reg      -- size, scale, src, src, dst
91         | SUB         Size Bool Reg RI Reg      -- size, overflow, src, src, dst
92         | SSUB        Size Size Reg RI Reg      -- size, scale, src, src, dst
93         | MUL         Size Bool Reg RI Reg      -- size, overflow, src, src, dst
94         | DIV         Size Bool Reg RI Reg      -- size, unsigned, src, src, dst
95         | REM         Size Bool Reg RI Reg      -- size, unsigned, src, src, dst
96
97         -- Simple bit-twiddling.
98         | NOT         RI Reg
99         | AND         Reg RI Reg
100         | ANDNOT      Reg RI Reg
101         | OR          Reg RI Reg
102         | ORNOT       Reg RI Reg
103         | XOR         Reg RI Reg
104         | XORNOT      Reg RI Reg
105         | SLL         Reg RI Reg
106         | SRL         Reg RI Reg
107         | SRA         Reg RI Reg
108
109         | ZAP         Reg RI Reg
110         | ZAPNOT      Reg RI Reg
111
112         | NOP
113
114         -- Comparison
115         | CMP         Cond Reg RI Reg
116
117         -- Float Arithmetic.
118         | FCLR        Reg
119         | FABS        Reg Reg
120         | FNEG        Size Reg Reg
121         | FADD        Size Reg Reg Reg
122         | FDIV        Size Reg Reg Reg
123         | FMUL        Size Reg Reg Reg
124         | FSUB        Size Reg Reg Reg
125         | CVTxy       Size Size Reg Reg
126         | FCMP        Size Cond Reg Reg Reg
127         | FMOV        Reg Reg
128
129         -- Jumping around.
130         | BI          Cond Reg Imm
131         | BF          Cond Reg Imm
132         | BR          Imm
133         | JMP         Reg AddrMode Int
134         | BSR         Imm Int
135         | JSR         Reg AddrMode Int
136
137         -- Alpha-specific pseudo-ops.
138         | FUNBEGIN CLabel
139         | FUNEND CLabel
140
141
142 -}