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