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