X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FnativeGen%2FSPARC%2FInstr.hs;h=6c7af5b169d75f1a50d931fc3c653c29247f224b;hp=6dc6477f9c5bf7bb4c868a739178c6cda25c51b9;hb=547bf6827f1fc3f2fb31bc6323cc0d33b445f32a;hpb=8b94848bae9cabac968d9c86c36a28d3cc7b6a72 diff --git a/compiler/nativeGen/SPARC/Instr.hs b/compiler/nativeGen/SPARC/Instr.hs index 6dc6477..6c7af5b 100644 --- a/compiler/nativeGen/SPARC/Instr.hs +++ b/compiler/nativeGen/SPARC/Instr.hs @@ -11,14 +11,23 @@ module SPARC.Instr ( RI(..), + riZero, + + fpRelEA, + moveSp, + 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 +35,6 @@ import Size import BlockId import Cmm -import Outputable -import Constants (rESERVED_C_STACK_BYTES ) import FastString import FastBool @@ -39,6 +46,29 @@ 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 + -- | instance for sparc instruction set instance Instruction Instr where @@ -347,29 +377,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