never executed always true always false
1 module GHC.CmmToAsm.SPARC.Stack (
2 spRel,
3 fpRel,
4 spillSlotToOffset,
5 maxSpillSlots
6 )
7
8 where
9
10 import GHC.Prelude
11
12 import GHC.CmmToAsm.SPARC.AddrMode
13 import GHC.CmmToAsm.SPARC.Regs
14 import GHC.CmmToAsm.SPARC.Base
15 import GHC.CmmToAsm.SPARC.Imm
16 import GHC.CmmToAsm.Config
17
18 import GHC.Utils.Outputable
19 import GHC.Utils.Panic
20
21 -- | Get an AddrMode relative to the address in sp.
22 -- This gives us a stack relative addressing mode for volatile
23 -- temporaries and for excess call arguments.
24 --
25 spRel :: Int -- ^ stack offset in words, positive or negative
26 -> AddrMode
27
28 spRel n = AddrRegImm sp (ImmInt (n * wordLength))
29
30
31 -- | Get an address relative to the frame pointer.
32 -- This doesn't work work for offsets greater than 13 bits; we just hope for the best
33 --
34 fpRel :: Int -> AddrMode
35 fpRel n
36 = AddrRegImm fp (ImmInt (n * wordLength))
37
38
39 -- | Convert a spill slot number to a *byte* offset, with no sign.
40 --
41 spillSlotToOffset :: NCGConfig -> Int -> Int
42 spillSlotToOffset config slot
43 | slot >= 0 && slot < maxSpillSlots config
44 = 64 + spillSlotSize * slot
45
46 | otherwise
47 = pprPanic "spillSlotToOffset:"
48 ( text "invalid spill location: " <> int slot
49 $$ text "maxSpillSlots: " <> int (maxSpillSlots config))
50
51
52 -- | The maximum number of spill slots available on the C stack.
53 -- If we use up all of the slots, then we're screwed.
54 --
55 -- Why do we reserve 64 bytes, instead of using the whole thing??
56 -- -- BL 2009/02/15
57 --
58 maxSpillSlots :: NCGConfig -> Int
59 maxSpillSlots config
60 = ((ncgSpillPreallocSize config - 64) `div` spillSlotSize) - 1