18 -- | Get an AddrMode relative to the address in sp.
19 -- This gives us a stack relative addressing mode for volatile
20 -- temporaries and for excess call arguments.
22 spRel :: Int -- ^ stack offset in words, positive or negative
25 spRel n = AddrRegImm sp (ImmInt (n * wordLength))
28 -- | Get an address relative to the frame pointer.
29 -- This doesn't work work for offsets greater than 13 bits; we just hope for the best
31 fpRel :: Int -> AddrMode
33 = AddrRegImm fp (ImmInt (n * wordLength))
36 -- | Convert a spill slot number to a *byte* offset, with no sign.
38 spillSlotToOffset :: Int -> Int
39 spillSlotToOffset slot
40 | slot >= 0 && slot < maxSpillSlots
41 = 64 + spillSlotSize * slot
44 = pprPanic "spillSlotToOffset:"
45 ( text "invalid spill location: " <> int slot
46 $$ text "maxSpillSlots: " <> int maxSpillSlots)
49 -- | The maximum number of spill slots available on the C stack.
50 -- If we use up all of the slots, then we're screwed.
52 -- Why do we reserve 64 bytes, instead of using the whole thing??
57 = ((spillAreaLength - 64) `div` spillSlotSize) - 1