1 -- -----------------------------------------------------------------------------
3 -- (c) The University of Glasgow 1994-2004
5 -- Alpha support is rotted and incomplete.
6 -- -----------------------------------------------------------------------------
15 gp, pv, ra, sp, t9, t10, t11, t12, v0, f0, zeroh
22 #include "nativeGen/NCG.h"
23 #include "HsVersions.h"
24 #include "../includes/MachRegs.h"
30 import CgUtils ( get_GlobalReg_addr )
31 import CLabel ( CLabel, mkMainCapabilityLabel )
33 import Outputable ( Outputable(..), pprPanic, panic )
34 import qualified Outputable
46 -- | W -- word (2 bytes): UNUSED
48 | L -- longword (4 bytes)
49 | Q -- quadword (8 bytes)
50 -- | FF -- VAX F-style floating pt: UNUSED
51 -- | GF -- VAX G-style floating pt: UNUSED
52 -- | DF -- VAX D-style floating pt: UNUSED
53 -- | SF -- IEEE single-precision floating pt: UNUSED
54 | TF -- IEEE double-precision floating pt
64 addrOffset :: AddrMode -> Int -> Maybe AddrMode
67 _ -> panic "MachMisc.addrOffset not defined for Alpha"
69 fits8Bits :: Integer -> Bool
70 fits8Bits i = i >= -256 && i < 256
73 -- The Alpha has 64 registers of interest; 32 integer registers and 32 floating
74 -- point registers. The mapping of STG registers to alpha machine registers
75 -- is defined in StgRegs.h. We are, of course, prepared for any eventuality.
80 v0, f0, ra, pv, gp, sp, zeroh :: Reg
83 ra = FixedReg ILIT(26)
85 gp = FixedReg ILIT(29)
86 sp = FixedReg ILIT(30)
87 zeroh = FixedReg ILIT(31) -- "zero" is used in 1.3 (MonadZero method)
89 t9, t10, t11, t12 :: Reg
130 -- allMachRegs is the complete set of machine regs.
131 allMachRegNos :: [RegNo]
132 allMachRegNos = [0..63]
135 -- these are the regs which we cannot assume stay alive over a
137 callClobberedRegs :: [Reg]
139 = [0, 1, 2, 3, 4, 5, 6, 7, 8,
140 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
141 fReg 0, fReg 1, fReg 10, fReg 11, fReg 12, fReg 13, fReg 14, fReg 15,
142 fReg 16, fReg 17, fReg 18, fReg 19, fReg 20, fReg 21, fReg 22, fReg 23,
143 fReg 24, fReg 25, fReg 26, fReg 27, fReg 28, fReg 29, fReg 30]
146 -- argRegs is the set of regs which are read for an n-argument call to C.
147 -- For archs which pass all args on the stack (x86), is empty.
148 -- Sparc passes up to the first 6 args in regs.
149 -- Dunno about Alpha.
150 argRegs :: RegNo -> [Reg]
153 argRegs 1 = freeMappedRegs [16, fReg 16]
154 argRegs 2 = freeMappedRegs [16, 17, fReg 16, fReg 17]
155 argRegs 3 = freeMappedRegs [16, 17, 18, fReg 16, fReg 17, fReg 18]
156 argRegs 4 = freeMappedRegs [16, 17, 18, 19, fReg 16, fReg 17, fReg 18, fReg 19]
157 argRegs 5 = freeMappedRegs [16, 17, 18, 19, 20, fReg 16, fReg 17, fReg 18, fReg 19, fReg 20]
158 argRegs 6 = freeMappedRegs [16, 17, 18, 19, 20, 21, fReg 16, fReg 17, fReg 18, fReg 19, fReg 20, fReg 21]
159 argRegs _ = panic "MachRegs.argRegs(alpha): don't know about >6 arguments!"
162 -- all of the arg regs ??
163 allArgRegs :: [(Reg, Reg)]
164 allArgRegs = [(realReg i, realReg (fReg i)) | i <- [16..21]]
167 -- horror show -----------------------------------------------------------------
169 freeReg :: RegNo -> FastBool
171 freeReg 26 = fastBool False -- return address (ra)
172 freeReg 28 = fastBool False -- reserved for the assembler (at)
173 freeReg 29 = fastBool False -- global pointer (gp)
174 freeReg 30 = fastBool False -- stack pointer (sp)
175 freeReg 31 = fastBool False -- always zero (zeroh)
176 freeReg 63 = fastBool False -- always zero (f31)
179 freeReg REG_Base = fastBool False
182 freeReg REG_R1 = fastBool False
185 freeReg REG_R2 = fastBool False
188 freeReg REG_R3 = fastBool False
191 freeReg REG_R4 = fastBool False
194 freeReg REG_R5 = fastBool False
197 freeReg REG_R6 = fastBool False
200 freeReg REG_R7 = fastBool False
203 freeReg REG_R8 = fastBool False
206 freeReg REG_F1 = fastBool False
209 freeReg REG_F2 = fastBool False
212 freeReg REG_F3 = fastBool False
215 freeReg REG_F4 = fastBool False
218 freeReg REG_D1 = fastBool False
221 freeReg REG_D2 = fastBool False
224 freeReg REG_Sp = fastBool False
227 freeReg REG_Su = fastBool False
230 freeReg REG_SpLim = fastBool False
233 freeReg REG_Hp = fastBool False
236 freeReg REG_HpLim = fastBool False
238 freeReg n = fastBool True
241 -- | Returns 'Nothing' if this global register is not stored
242 -- in a real machine register, otherwise returns @'Just' reg@, where
243 -- reg is the machine register it is stored in.
245 globalRegMaybe :: GlobalReg -> Maybe Reg
248 globalRegMaybe BaseReg = Just (RealReg REG_Base)
251 globalRegMaybe (VanillaReg 1 _) = Just (RealReg REG_R1)
254 globalRegMaybe (VanillaReg 2 _) = Just (RealReg REG_R2)
257 globalRegMaybe (VanillaReg 3 _) = Just (RealReg REG_R3)
260 globalRegMaybe (VanillaReg 4 _) = Just (RealReg REG_R4)
263 globalRegMaybe (VanillaReg 5 _) = Just (RealReg REG_R5)
266 globalRegMaybe (VanillaReg 6 _) = Just (RealReg REG_R6)
269 globalRegMaybe (VanillaReg 7 _) = Just (RealReg REG_R7)
272 globalRegMaybe (VanillaReg 8 _) = Just (RealReg REG_R8)
275 globalRegMaybe (VanillaReg 9 _) = Just (RealReg REG_R9)
278 globalRegMaybe (VanillaReg 10 _) = Just (RealReg REG_R10)
281 globalRegMaybe (FloatReg 1) = Just (RealReg REG_F1)
284 globalRegMaybe (FloatReg 2) = Just (RealReg REG_F2)
287 globalRegMaybe (FloatReg 3) = Just (RealReg REG_F3)
290 globalRegMaybe (FloatReg 4) = Just (RealReg REG_F4)
293 globalRegMaybe (DoubleReg 1) = Just (RealReg REG_D1)
296 globalRegMaybe (DoubleReg 2) = Just (RealReg REG_D2)
299 globalRegMaybe Sp = Just (RealReg REG_Sp)
302 globalRegMaybe (LongReg 1) = Just (RealReg REG_Lng1)
305 globalRegMaybe (LongReg 2) = Just (RealReg REG_Lng2)
308 globalRegMaybe SpLim = Just (RealReg REG_SpLim)
311 globalRegMaybe Hp = Just (RealReg REG_Hp)
314 globalRegMaybe HpLim = Just (RealReg REG_HpLim)
316 #ifdef REG_CurrentTSO
317 globalRegMaybe CurrentTSO = Just (RealReg REG_CurrentTSO)
319 #ifdef REG_CurrentNursery
320 globalRegMaybe CurrentNursery = Just (RealReg REG_CurrentNursery)
322 globalRegMaybe _ = Nothing