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
import GHC.Utils.Panic
spRel :: Int
-> AddrMode
spRel :: Int -> AddrMode
spRel 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 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 :: NCGConfig -> Int -> Int
spillSlotToOffset :: NCGConfig -> Int -> Int
spillSlotToOffset NCGConfig
config Int
slot
| Int
slot Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
0 Bool -> Bool -> Bool
&& Int
slot Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< NCGConfig -> Int
maxSpillSlots NCGConfig
config
= Int
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 String
"spillSlotToOffset:"
( String -> SDoc
text String
"invalid spill location: " SDoc -> SDoc -> SDoc
<> Int -> SDoc
int Int
slot
SDoc -> SDoc -> SDoc
$$ String -> SDoc
text String
"maxSpillSlots: " SDoc -> SDoc -> SDoc
<> Int -> SDoc
int (NCGConfig -> Int
maxSpillSlots NCGConfig
config))
maxSpillSlots :: NCGConfig -> Int
maxSpillSlots :: NCGConfig -> Int
maxSpillSlots NCGConfig
config
= ((NCGConfig -> Int
ncgSpillPreallocSize NCGConfig
config Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
64) Int -> Int -> Int
forall a. Integral a => a -> a -> a
`div` Int
spillSlotSize) Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1