NCG: Split up the native code generator into arch specific modules
[ghc-hetmet.git] / compiler / nativeGen / TargetReg.hs
1
2 -- | Hard wired things related to registers.
3 --      This is module is preventing the native code generator being able to 
4 --      emit code for non-host architectures.
5 --
6 --      TODO: Do a better job of the overloading, and eliminate this module.
7 --      We'd probably do better with a Register type class, and hook this to 
8 --      Instruction somehow.
9 --
10 --      TODO: We should also make arch specific versions of RegAlloc.Graph.TrivColorable
11
12 module TargetReg (
13         targetRegClass,
14         targetMkVReg,
15         targetWordSize,
16         targetRegDotColor
17 )
18
19 where
20
21 #include "HsVersions.h"
22
23 import Reg
24 import RegClass
25 import Size
26
27 import CmmExpr  (wordWidth)
28 import Outputable
29 import Unique
30
31
32 #if i386_TARGET_ARCH || x86_64_TARGET_ARCH
33 import qualified X86.Regs       as X86
34 import qualified X86.RegInfo    as X86
35
36 #elif powerpc_TARGET_ARCH
37 import qualified PPC.Regs       as PPC
38 import qualified PPC.RegInfo    as PPC
39
40 #elif sparc_TARGET_ARCH 
41 import qualified SPARC.Regs     as SPARC
42 import qualified SPARC.RegInfo  as SPARC
43
44
45 #else
46 #error "RegAlloc.Graph.TargetReg: not defined"
47 #endif
48
49 -- x86 -------------------------------------------------------------------------
50 #if i386_TARGET_ARCH || x86_64_TARGET_ARCH
51 targetRegClass :: Reg -> RegClass
52 targetRegClass  = X86.regClass
53
54 targetWordSize :: Size
55 targetWordSize = intSize wordWidth
56
57 targetMkVReg :: Unique -> Size -> Reg
58 targetMkVReg    = X86.mkVReg
59
60 targetRegDotColor :: Reg -> SDoc
61 targetRegDotColor = X86.regDotColor
62
63
64 -- ppc -------------------------------------------------------------------------
65 #elif powerpc_TARGET_ARCH
66 targetRegClass :: Reg -> RegClass
67 targetRegClass  = PPC.regClass
68
69 targetWordSize :: Size
70 targetWordSize = intSize wordWidth
71
72 targetMkVReg :: Unique -> Size -> Reg
73 targetMkVReg    = PPC.mkVReg
74
75 targetRegDotColor :: Reg -> SDoc
76 targetRegDotColor = PPC.regDotColor
77
78
79 -- sparc -----------------------------------------------------------------------
80 #elif sparc_TARGET_ARCH
81 targetRegClass :: Reg -> RegClass
82 targetRegClass  = SPARC.regClass
83
84 -- | Size of a machine word. 
85 --      This is big enough to hold a pointer.
86 targetWordSize :: Size
87 targetWordSize = intSize wordWidth
88
89 targetMkVReg :: Unique -> Size -> Reg
90 targetMkVReg    = SPARC.mkVReg
91
92 targetRegDotColor :: Reg -> SDoc
93 targetRegDotColor = SPARC.regDotColor
94
95 --------------------------------------------------------------------------------
96 #else
97 #error "RegAlloc.Graph.TargetReg: not defined"
98 #endif
99
100
101