X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FnativeGen%2FX86%2FInstr.hs;h=26da90778c82dca0c37c0e2a5dde6aa14496d752;hb=72636a93a047af23461df5123edc2342b2dec48d;hp=b4b6fb5f4be684a9a93f2b360a52e65dca8028a1;hpb=b04a210e26ca57242fd052f2aa91011a80b76299;p=ghc-hetmet.git diff --git a/compiler/nativeGen/X86/Instr.hs b/compiler/nativeGen/X86/Instr.hs index b4b6fb5..26da907 100644 --- a/compiler/nativeGen/X86/Instr.hs +++ b/compiler/nativeGen/X86/Instr.hs @@ -23,6 +23,8 @@ import BlockId import Cmm import FastString import FastBool +import Outputable +import Constants (rESERVED_C_STACK_BYTES) import CLabel import Panic @@ -655,6 +657,23 @@ x86_mkLoadInstr _ _ _ = panic "X86.RegInfo.mkLoadInstr: not defined for this architecture." #endif +spillSlotSize :: Int +spillSlotSize = IF_ARCH_i386(12, 8) + +maxSpillSlots :: Int +maxSpillSlots = ((rESERVED_C_STACK_BYTES - 64) `div` spillSlotSize) - 1 + +-- convert a spill slot number to a *byte* offset, with no sign: +-- decide on a per arch basis whether you are spilling above or below +-- the C stack pointer. +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) --------------------------------------------------------------------------------