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