module SPARC.Stack (
spRel,
fpRel,
spillSlotToOffset,
maxSpillSlots
)
where
import SPARC.AddrMode
import SPARC.Regs
import SPARC.Base
import SPARC.Imm
import Outputable
spRel :: Int
-> AddrMode
spRel n = AddrRegImm sp (ImmInt (n * wordLength))
fpRel :: Int -> AddrMode
fpRel n
= AddrRegImm fp (ImmInt (n * wordLength))
spillSlotToOffset :: Int -> Int
spillSlotToOffset slot
| slot >= 0 && slot < maxSpillSlots
= 64 + spillSlotSize * slot
| otherwise
= pprPanic "spillSlotToOffset:"
( text "invalid spill location: " <> int slot
$$ text "maxSpillSlots: " <> int maxSpillSlots)
maxSpillSlots :: Int
maxSpillSlots
= ((spillAreaLength 64) `div` spillSlotSize) 1