1 -----------------------------------------------------------------------------
3 -- Machine-specific parts of the register allocator
5 -- (c) The University of Glasgow 1996-2004
7 -----------------------------------------------------------------------------
22 #include "nativeGen/NCG.h"
23 #include "HsVersions.h"
38 mkVReg :: Unique -> Size -> Reg
40 | not (isFloatSize size) = VirtualRegI u
50 data JumpDest = DestBlockId BlockId | DestImm Imm
52 canShortcut :: Instr -> Maybe JumpDest
53 canShortcut _ = Nothing
55 shortcutJump :: (BlockId -> Maybe JumpDest) -> Instr -> Instr
56 shortcutJump _ other = other
59 -- Here because it knows about JumpDest
60 shortcutStatic :: (BlockId -> Maybe JumpDest) -> CmmStatic -> CmmStatic
62 shortcutStatic fn (CmmStaticLit (CmmLabel lab))
63 | Just uq <- maybeAsmTemp lab
64 = CmmStaticLit (CmmLabel (shortBlockId fn (BlockId uq)))
66 shortcutStatic fn (CmmStaticLit (CmmLabelDiffOff lbl1 lbl2 off))
67 | Just uq <- maybeAsmTemp lbl1
68 = CmmStaticLit (CmmLabelDiffOff (shortBlockId fn (BlockId uq)) lbl2 off)
69 -- slightly dodgy, we're ignoring the second label, but this
70 -- works with the way we use CmmLabelDiffOff for jump tables now.
72 shortcutStatic _ other_static
76 :: (BlockId -> Maybe JumpDest)
80 shortBlockId fn blockid@(BlockId uq) =
82 Nothing -> mkAsmTempLabel uq
83 Just (DestBlockId blockid') -> shortBlockId fn blockid'
84 Just (DestImm (ImmCLbl lbl)) -> lbl
85 _other -> panic "shortBlockId"
89 regDotColor :: Reg -> SDoc
91 = case regClass reg of
92 RcInteger -> text "blue"
94 RcDouble -> text "green"