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