2 module SPARC.ShortcutJump (
28 canShortcut :: Instr -> Maybe JumpDest
29 canShortcut _ = Nothing
32 shortcutJump :: (BlockId -> Maybe JumpDest) -> Instr -> Instr
33 shortcutJump _ other = other
36 shortcutStatic :: (BlockId -> Maybe JumpDest) -> CmmStatic -> CmmStatic
38 shortcutStatic fn (CmmStaticLit (CmmLabel lab))
39 | Just uq <- maybeAsmTemp lab
40 = CmmStaticLit (CmmLabel (shortBlockId fn (BlockId uq)))
42 shortcutStatic fn (CmmStaticLit (CmmLabelDiffOff lbl1 lbl2 off))
43 | Just uq <- maybeAsmTemp lbl1
44 = CmmStaticLit (CmmLabelDiffOff (shortBlockId fn (BlockId uq)) lbl2 off)
46 -- slightly dodgy, we're ignoring the second label, but this
47 -- works with the way we use CmmLabelDiffOff for jump tables now.
48 shortcutStatic _ other_static
52 shortBlockId :: (BlockId -> Maybe JumpDest) -> BlockId -> CLabel
53 shortBlockId fn blockid@(BlockId uq) =
55 Nothing -> mkAsmTempLabel uq
56 Just (DestBlockId blockid') -> shortBlockId fn blockid'
57 Just (DestImm (ImmCLbl lbl)) -> lbl
58 _other -> panic "shortBlockId"