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.
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.
10 -- TODO: We should also make arch specific versions of RegAlloc.Graph.TrivColorable
13 targetVirtualRegSqueeze,
24 #include "HsVersions.h"
30 import CmmType (wordWidth)
36 import qualified X86.Regs as X86
37 import qualified X86.RegInfo as X86
39 import qualified PPC.Regs as PPC
41 import qualified SPARC.Regs as SPARC
43 -- TODO: We shouldn't be using defaultTargetPlatform here.
44 -- We should be passing DynFlags in instead, and looking at
45 -- its targetPlatform.
47 targetVirtualRegSqueeze :: RegClass -> VirtualReg -> FastInt
48 targetVirtualRegSqueeze
49 = case platformArch defaultTargetPlatform of
50 ArchX86 -> X86.virtualRegSqueeze
51 ArchX86_64 -> X86.virtualRegSqueeze
52 ArchPPC -> PPC.virtualRegSqueeze
53 ArchSPARC -> SPARC.virtualRegSqueeze
54 ArchPPC_64 -> panic "targetVirtualRegSqueeze ArchPPC_64"
56 targetRealRegSqueeze :: RegClass -> RealReg -> FastInt
58 = case platformArch defaultTargetPlatform of
59 ArchX86 -> X86.realRegSqueeze
60 ArchX86_64 -> X86.realRegSqueeze
61 ArchPPC -> PPC.realRegSqueeze
62 ArchSPARC -> SPARC.realRegSqueeze
63 ArchPPC_64 -> panic "targetRealRegSqueeze ArchPPC_64"
65 targetClassOfRealReg :: RealReg -> RegClass
67 = case platformArch defaultTargetPlatform of
68 ArchX86 -> X86.classOfRealReg
69 ArchX86_64 -> X86.classOfRealReg
70 ArchPPC -> PPC.classOfRealReg
71 ArchSPARC -> SPARC.classOfRealReg
72 ArchPPC_64 -> panic "targetClassOfRealReg ArchPPC_64"
74 -- TODO: This should look at targetPlatform too
75 targetWordSize :: Size
76 targetWordSize = intSize wordWidth
78 targetMkVirtualReg :: Unique -> Size -> VirtualReg
80 = case platformArch defaultTargetPlatform of
81 ArchX86 -> X86.mkVirtualReg
82 ArchX86_64 -> X86.mkVirtualReg
83 ArchPPC -> PPC.mkVirtualReg
84 ArchSPARC -> SPARC.mkVirtualReg
85 ArchPPC_64 -> panic "targetMkVirtualReg ArchPPC_64"
87 targetRegDotColor :: RealReg -> SDoc
89 = case platformArch defaultTargetPlatform of
90 ArchX86 -> X86.regDotColor
91 ArchX86_64 -> X86.regDotColor
92 ArchPPC -> PPC.regDotColor
93 ArchSPARC -> SPARC.regDotColor
94 ArchPPC_64 -> panic "targetRegDotColor ArchPPC_64"
97 targetClassOfReg :: Reg -> RegClass
100 RegVirtual vr -> classOfVirtualReg vr
101 RegReal rr -> targetClassOfRealReg rr