module SPARC.Imm (
Imm(..),
strImmLit,
litToImm
)
where
import OldCmm
import CLabel
import BlockId
import Pretty
import Panic
data Imm
= ImmInt Int
| ImmInteger Integer
| ImmCLbl CLabel
| ImmLit Doc
| 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)
CmmBlock id -> ImmCLbl (infoTblLbl id)
_ -> panic "SPARC.Regs.litToImm: no match"