1 -----------------------------------------------------------------------------
3 -- Machine-specific parts of the register allocator
5 -- (c) The University of Glasgow 1996-2004
7 -----------------------------------------------------------------------------
19 #include "nativeGen/NCG.h"
20 #include "HsVersions.h"
31 data JumpDest = DestBlockId BlockId | DestImm Imm
33 canShortcut :: Instr -> Maybe JumpDest
34 canShortcut _ = Nothing
36 shortcutJump :: (BlockId -> Maybe JumpDest) -> Instr -> Instr
37 shortcutJump _ other = other
40 -- Here because it knows about JumpDest
41 shortcutStatic :: (BlockId -> Maybe JumpDest) -> CmmStatic -> CmmStatic
43 shortcutStatic fn (CmmStaticLit (CmmLabel lab))
44 | Just uq <- maybeAsmTemp lab
45 = CmmStaticLit (CmmLabel (shortBlockId fn (BlockId uq)))
47 shortcutStatic fn (CmmStaticLit (CmmLabelDiffOff lbl1 lbl2 off))
48 | Just uq <- maybeAsmTemp lbl1
49 = CmmStaticLit (CmmLabelDiffOff (shortBlockId fn (BlockId uq)) lbl2 off)
50 -- slightly dodgy, we're ignoring the second label, but this
51 -- works with the way we use CmmLabelDiffOff for jump tables now.
53 shortcutStatic _ other_static
57 :: (BlockId -> Maybe JumpDest)
61 shortBlockId fn blockid@(BlockId uq) =
63 Nothing -> mkAsmTempLabel uq
64 Just (DestBlockId blockid') -> shortBlockId fn blockid'
65 Just (DestImm (ImmCLbl lbl)) -> lbl
66 _other -> panic "shortBlockId"