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