never executed always true always false
    1 
    2 module GHC.CmmToAsm.SPARC.AddrMode (
    3         AddrMode(..),
    4         addrOffset
    5 )
    6 
    7 where
    8 
    9 import GHC.Prelude
   10 
   11 import GHC.CmmToAsm.SPARC.Imm
   12 import GHC.CmmToAsm.SPARC.Base
   13 import GHC.Platform.Reg
   14 
   15 -- addressing modes ------------------------------------------------------------
   16 
   17 -- | Represents a memory address in an instruction.
   18 --      Being a RISC machine, the SPARC addressing modes are very regular.
   19 --
   20 data AddrMode
   21         = AddrRegReg    Reg Reg         -- addr = r1 + r2
   22         | AddrRegImm    Reg Imm         -- addr = r1 + imm
   23 
   24 
   25 -- | Add an integer offset to the address in an AddrMode.
   26 --
   27 addrOffset :: AddrMode -> Int -> Maybe AddrMode
   28 addrOffset addr off
   29   = case addr of
   30       AddrRegImm r (ImmInt n)
   31        | fits13Bits n2 -> Just (AddrRegImm r (ImmInt n2))
   32        | otherwise     -> Nothing
   33        where n2 = n + off
   34 
   35       AddrRegImm r (ImmInteger n)
   36        | fits13Bits n2 -> Just (AddrRegImm r (ImmInt (fromInteger n2)))
   37        | otherwise     -> Nothing
   38        where n2 = n + toInteger off
   39 
   40       AddrRegReg r (RegReal (RealRegSingle 0))
   41        | fits13Bits off -> Just (AddrRegImm r (ImmInt off))
   42        | otherwise     -> Nothing
   43 
   44       _ -> Nothing