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