Follow vreg/hreg patch in PPC NCG
[ghc-hetmet.git] / compiler / nativeGen / X86 / RegInfo.hs
1
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 Size
13 import Reg
14
15 import Outputable
16 import Unique
17
18 #if i386_TARGET_ARCH || x86_64_TARGET_ARCH
19 import UniqFM
20 import X86.Regs
21 #endif
22
23
24 mkVirtualReg :: Unique -> Size -> VirtualReg
25 mkVirtualReg u size
26    | not (isFloatSize size) = VirtualRegI u
27    | otherwise
28    = case size of
29         FF32    -> VirtualRegD u
30         FF64    -> VirtualRegD u
31         _       -> panic "mkVirtualReg"
32
33
34 -- reg colors for x86
35 #if i386_TARGET_ARCH
36 regDotColor :: RealReg -> SDoc
37 regDotColor reg
38  = let  Just    str     = lookupUFM regColors reg
39    in   text str
40
41 regColors :: UniqFM [Char]
42 regColors
43  = listToUFM
44  $      [ (eax, "#00ff00")
45         , (ebx, "#0000ff")
46         , (ecx, "#00ffff")
47         , (edx, "#0080ff")
48
49         , (fake0, "#ff00ff")
50         , (fake1, "#ff00aa")
51         , (fake2, "#aa00ff")
52         , (fake3, "#aa00aa")
53         , (fake4, "#ff0055")
54         , (fake5, "#5500ff") ]
55
56
57 -- reg colors for x86_64
58 #elif x86_64_TARGET_ARCH
59 regDotColor :: RealReg -> SDoc
60 regDotColor reg
61  = let  Just    str     = lookupUFM regColors reg
62    in   text str
63
64 regColors :: UniqFM [Char]
65 regColors
66  = listToUFM
67  $      [ (rax, "#00ff00"), (eax, "#00ff00")
68         , (rbx, "#0000ff"), (ebx, "#0000ff")
69         , (rcx, "#00ffff"), (ecx, "#00ffff")
70         , (rdx, "#0080ff"), (edx, "#00ffff")
71         , (r8,  "#00ff80")
72         , (r9,  "#008080")
73         , (r10, "#0040ff")
74         , (r11, "#00ff40")
75         , (r12, "#008040")
76         , (r13, "#004080")
77         , (r14, "#004040")
78         , (r15, "#002080") ]
79
80         ++ zip (map RealReg [16..31]) (repeat "red")
81 #else
82 regDotColor :: Reg -> SDoc
83 regDotColor     = panic "not defined"
84 #endif