Fix todo in compiler/nativeGen: Rename Size to Format
[ghc.git] / compiler / nativeGen / X86 / RegInfo.hs
1 {-# LANGUAGE CPP #-}
2 module X86.RegInfo (
3 mkVirtualReg,
4 regDotColor
5 )
6
7 where
8
9 #include "nativeGen/NCG.h"
10 #include "HsVersions.h"
11
12 import Format
13 import Reg
14
15 import Outputable
16 import Platform
17 import Unique
18
19 import UniqFM
20 import X86.Regs
21
22
23 mkVirtualReg :: Unique -> Format -> VirtualReg
24 mkVirtualReg u format
25 = case format of
26 FF32 -> VirtualRegSSE u
27 FF64 -> VirtualRegSSE u
28 FF80 -> VirtualRegD u
29 _other -> VirtualRegI u
30
31 regDotColor :: Platform -> RealReg -> SDoc
32 regDotColor platform reg
33 = let Just str = lookupUFM (regColors platform) reg
34 in text str
35
36 regColors :: Platform -> UniqFM [Char]
37 regColors platform = listToUFM (normalRegColors platform ++ fpRegColors)
38
39 normalRegColors :: Platform -> [(Reg,String)]
40 normalRegColors platform
41 | target32Bit platform = [ (eax, "#00ff00")
42 , (ebx, "#0000ff")
43 , (ecx, "#00ffff")
44 , (edx, "#0080ff") ]
45 | otherwise = [ (rax, "#00ff00"), (eax, "#00ff00")
46 , (rbx, "#0000ff"), (ebx, "#0000ff")
47 , (rcx, "#00ffff"), (ecx, "#00ffff")
48 , (rdx, "#0080ff"), (edx, "#00ffff")
49 , (r8, "#00ff80")
50 , (r9, "#008080")
51 , (r10, "#0040ff")
52 , (r11, "#00ff40")
53 , (r12, "#008040")
54 , (r13, "#004080")
55 , (r14, "#004040")
56 , (r15, "#002080") ]
57
58 fpRegColors :: [(Reg,String)]
59 fpRegColors =
60 [ (fake0, "#ff00ff")
61 , (fake1, "#ff00aa")
62 , (fake2, "#aa00ff")
63 , (fake3, "#aa00aa")
64 , (fake4, "#ff0055")
65 , (fake5, "#5500ff") ]
66
67 ++ zip (map regSingle [24..39]) (repeat "red")