15 #include "nativeGen/NCG.h"
16 #include "HsVersions.h"
30 #if i386_TARGET_ARCH || x86_64_TARGET_ARCH
35 mkVReg :: Unique -> Size -> Reg
37 | not (isFloatSize size) = VirtualRegI u
45 data JumpDest = DestBlockId BlockId | DestImm Imm
48 canShortcut :: Instr -> Maybe JumpDest
49 canShortcut (JXX ALWAYS id) = Just (DestBlockId id)
50 canShortcut (JMP (OpImm imm)) = Just (DestImm imm)
51 canShortcut _ = Nothing
54 shortcutJump :: (BlockId -> Maybe JumpDest) -> Instr -> Instr
55 shortcutJump fn insn@(JXX cc id) =
58 Just (DestBlockId id') -> shortcutJump fn (JXX cc id')
59 Just (DestImm imm) -> shortcutJump fn (JXX_GBL cc imm)
61 shortcutJump _ other = other
64 -- Here because it knows about JumpDest
65 shortcutStatic :: (BlockId -> Maybe JumpDest) -> CmmStatic -> CmmStatic
66 shortcutStatic fn (CmmStaticLit (CmmLabel lab))
67 | Just uq <- maybeAsmTemp lab
68 = CmmStaticLit (CmmLabel (shortBlockId fn (BlockId uq)))
69 shortcutStatic fn (CmmStaticLit (CmmLabelDiffOff lbl1 lbl2 off))
70 | Just uq <- maybeAsmTemp lbl1
71 = CmmStaticLit (CmmLabelDiffOff (shortBlockId fn (BlockId uq)) lbl2 off)
72 -- slightly dodgy, we're ignoring the second label, but this
73 -- works with the way we use CmmLabelDiffOff for jump tables now.
75 shortcutStatic _ other_static
79 :: (BlockId -> Maybe JumpDest)
83 shortBlockId fn blockid@(BlockId uq) =
85 Nothing -> mkAsmTempLabel uq
86 Just (DestBlockId blockid') -> shortBlockId fn blockid'
87 Just (DestImm (ImmCLbl lbl)) -> lbl
88 _other -> panic "shortBlockId"
94 regDotColor :: Reg -> SDoc
96 = let Just str = lookupUFM regColors reg
99 regColors :: UniqFM [Char]
112 , (fake5, "#5500ff") ]
115 -- reg colors for x86_64
116 #elif x86_64_TARGET_ARCH
117 regDotColor :: Reg -> SDoc
119 = let Just str = lookupUFM regColors reg
122 regColors :: UniqFM [Char]
125 $ [ (rax, "#00ff00"), (eax, "#00ff00")
126 , (rbx, "#0000ff"), (ebx, "#0000ff")
127 , (rcx, "#00ffff"), (ecx, "#00ffff")
128 , (rdx, "#0080ff"), (edx, "#00ffff")
138 ++ zip (map RealReg [16..31]) (repeat "red")
140 regDotColor :: Reg -> SDoc
141 regDotColor = panic "not defined"