X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FnativeGen%2FSPARC%2FInstr.hs;h=b21f9476ac3c6554ad12f09f809f6cce982c9966;hb=42222f95a101fb3647f8728302bbf1098b74e59e;hp=6dc6477f9c5bf7bb4c868a739178c6cda25c51b9;hpb=b04a210e26ca57242fd052f2aa91011a80b76299;p=ghc-hetmet.git diff --git a/compiler/nativeGen/SPARC/Instr.hs b/compiler/nativeGen/SPARC/Instr.hs index 6dc6477..b21f947 100644 --- a/compiler/nativeGen/SPARC/Instr.hs +++ b/compiler/nativeGen/SPARC/Instr.hs @@ -11,14 +11,25 @@ module SPARC.Instr ( RI(..), + riZero, + + fpRelEA, + moveSp, + + isUnconditionalJump, + Instr(..), maxSpillSlots ) where -import SPARC.Regs +import SPARC.Stack +import SPARC.Imm +import SPARC.AddrMode import SPARC.Cond +import SPARC.Regs +import SPARC.Base import Instruction import RegClass import Reg @@ -26,8 +37,6 @@ import Size import BlockId import Cmm -import Outputable -import Constants (rESERVED_C_STACK_BYTES ) import FastString import FastBool @@ -39,6 +48,40 @@ data RI = RIReg Reg | RIImm Imm +-- | Check if a RI represents a zero value. +-- - a literal zero +-- - register %g0, which is always zero. +-- +riZero :: RI -> Bool +riZero (RIImm (ImmInt 0)) = True +riZero (RIImm (ImmInteger 0)) = True +riZero (RIReg (RealReg 0)) = True +riZero _ = False + + +-- | Calculate the effective address which would be used by the +-- corresponding fpRel sequence. +fpRelEA :: Int -> Reg -> Instr +fpRelEA n dst + = ADD False False fp (RIImm (ImmInt (n * wordLength))) dst + + +-- | Code to shift the stack pointer by n words. +moveSp :: Int -> Instr +moveSp n + = ADD False False sp (RIImm (ImmInt (n * wordLength))) sp + +-- | An instruction that will cause the one after it never to be exectuted +isUnconditionalJump :: Instr -> Bool +isUnconditionalJump ii + = case ii of + CALL{} -> True + JMP{} -> True + JMP_TBL{} -> True + BI ALWAYS _ _ -> True + BF ALWAYS _ _ -> True + _ -> False + -- | instance for sparc instruction set instance Instruction Instr where @@ -347,29 +390,6 @@ sparc_mkLoadInstr reg _ slot in LD sz (fpRel (- off_w)) reg --- | Convert a spill slot number to a *byte* offset, with no sign. --- -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) - - --- | We need 8 bytes because our largest registers are 64 bit. -spillSlotSize :: Int -spillSlotSize = 8 - - --- | The maximum number of spill slots available on the C stack. --- If we use up all of the slots, then we're screwed. -maxSpillSlots :: Int -maxSpillSlots = ((rESERVED_C_STACK_BYTES - 64) `div` spillSlotSize) - 1 - -------------------------------------------------------------------------------- -- | See if this instruction is telling us the current C stack delta