Implement SSE2 floating-point support in the x86 native code generator (#594)
[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    = case size of
27         FF32    -> VirtualRegSSE u
28         FF64    -> VirtualRegSSE u
29         FF80    -> VirtualRegD   u
30         _other  -> VirtualRegI   u
31
32
33 -- reg colors for x86
34 #if i386_TARGET_ARCH
35 regDotColor :: RealReg -> SDoc
36 regDotColor reg
37  = let  Just    str     = lookupUFM regColors reg
38    in   text str
39
40 regColors :: UniqFM [Char]
41 regColors
42  = listToUFM
43  $      [ (eax, "#00ff00")
44         , (ebx, "#0000ff")
45         , (ecx, "#00ffff")
46         , (edx, "#0080ff") ]
47         ++ fpRegColors
48
49 -- reg colors for x86_64
50 #elif x86_64_TARGET_ARCH
51 regDotColor :: RealReg -> SDoc
52 regDotColor reg
53  = let  Just    str     = lookupUFM regColors reg
54    in   text str
55
56 regColors :: UniqFM [Char]
57 regColors
58  = listToUFM
59  $      [ (rax, "#00ff00"), (eax, "#00ff00")
60         , (rbx, "#0000ff"), (ebx, "#0000ff")
61         , (rcx, "#00ffff"), (ecx, "#00ffff")
62         , (rdx, "#0080ff"), (edx, "#00ffff")
63         , (r8,  "#00ff80")
64         , (r9,  "#008080")
65         , (r10, "#0040ff")
66         , (r11, "#00ff40")
67         , (r12, "#008040")
68         , (r13, "#004080")
69         , (r14, "#004040")
70         , (r15, "#002080") ]
71         ++ fpRegColors
72 #else
73 regDotColor :: Reg -> SDoc
74 regDotColor     = panic "not defined"
75 #endif
76
77 fpRegColors :: [(Reg,String)]
78 fpRegColors =
79         [ (fake0, "#ff00ff")
80         , (fake1, "#ff00aa")
81         , (fake2, "#aa00ff")
82         , (fake3, "#aa00aa")
83         , (fake4, "#ff0055")
84         , (fake5, "#5500ff") ]
85
86         ++ zip (map regSingle [24..39]) (repeat "red")