module GHC.CmmToAsm.SPARC.Imm (
Imm(..),
strImmLit,
litToImm
)
where
import GHC.Prelude
import GHC.Cmm
import GHC.Cmm.CLabel
import GHC.Utils.Outputable
import GHC.Utils.Panic
data Imm
= ImmInt Int
| ImmInteger Integer
| ImmCLbl CLabel
| ImmLit SDoc
| ImmIndex CLabel Int
| ImmFloat Rational
| ImmDouble Rational
| ImmConstantSum Imm Imm
| ImmConstantDiff Imm Imm
| LO Imm
| HI Imm
strImmLit :: String -> Imm
strImmLit s = ImmLit (text s)
litToImm :: CmmLit -> Imm
litToImm lit
= case lit of
CmmInt i w -> ImmInteger (narrowS w i)
CmmFloat f W32 -> ImmFloat f
CmmFloat f W64 -> ImmDouble f
CmmLabel l -> ImmCLbl l
CmmLabelOff l off -> ImmIndex l off
CmmLabelDiffOff l1 l2 off _
-> ImmConstantSum
(ImmConstantDiff (ImmCLbl l1) (ImmCLbl l2))
(ImmInt off)
_ -> panic "SPARC.Regs.litToImm: no match"