Fix a build failure on non-{x86,amd64}
[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 Platform
17 import Unique
18
19 import UniqFM
20 import X86.Regs
21
22
23 mkVirtualReg :: Unique -> Size -> VirtualReg
24 mkVirtualReg u size
25    = case size of
26         FF32    -> VirtualRegSSE u
27         FF64    -> VirtualRegSSE u
28         FF80    -> VirtualRegD   u
29         _other  -> VirtualRegI   u
30
31 regDotColor :: RealReg -> SDoc
32 regDotColor reg
33  = let  Just    str     = lookupUFM regColors reg
34    in   text str
35
36 regColors :: UniqFM [Char]
37 regColors = listToUFM (normalRegColors ++ fpRegColors)
38
39 -- TODO: We shouldn't be using defaultTargetPlatform here.
40 --       We should be passing DynFlags in instead, and looking at
41 --       its targetPlatform.
42
43 normalRegColors :: [(Reg,String)]
44 normalRegColors = case platformArch defaultTargetPlatform of
45                   ArchX86 -> [ (eax, "#00ff00")
46                              , (ebx, "#0000ff")
47                              , (ecx, "#00ffff")
48                              , (edx, "#0080ff") ]
49                   ArchX86_64 -> [ (rax, "#00ff00"), (eax, "#00ff00")
50                                 , (rbx, "#0000ff"), (ebx, "#0000ff")
51                                 , (rcx, "#00ffff"), (ecx, "#00ffff")
52                                 , (rdx, "#0080ff"), (edx, "#00ffff")
53                                 , (r8,  "#00ff80")
54                                 , (r9,  "#008080")
55                                 , (r10, "#0040ff")
56                                 , (r11, "#00ff40")
57                                 , (r12, "#008040")
58                                 , (r13, "#004080")
59                                 , (r14, "#004040")
60                                 , (r15, "#002080") ]
61                   ArchPPC     -> panic "X86 normalRegColors ArchPPC"
62                   ArchPPC_64  -> panic "X86 normalRegColors ArchPPC_64"
63                   ArchSPARC   -> panic "X86 normalRegColors ArchSPARC"
64                   ArchUnknown -> panic "X86 normalRegColors ArchUnknown"
65
66 fpRegColors :: [(Reg,String)]
67 fpRegColors =
68         [ (fake0, "#ff00ff")
69         , (fake1, "#ff00aa")
70         , (fake2, "#aa00ff")
71         , (fake3, "#aa00aa")
72         , (fake4, "#ff0055")
73         , (fake5, "#5500ff") ]
74
75         ++ zip (map regSingle [24..39]) (repeat "red")
76