never executed always true always false
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 module GHC.CmmToAsm.Reg.Target (
12 targetVirtualRegSqueeze,
13 targetRealRegSqueeze,
14 targetClassOfRealReg,
15 targetMkVirtualReg,
16 targetRegDotColor,
17 targetClassOfReg
18 )
19
20 where
21
22 import GHC.Prelude
23
24 import GHC.Platform.Reg
25 import GHC.Platform.Reg.Class
26 import GHC.CmmToAsm.Format
27
28 import GHC.Utils.Outputable
29 import GHC.Utils.Panic
30 import GHC.Types.Unique
31 import GHC.Platform
32
33 import qualified GHC.CmmToAsm.X86.Regs as X86
34 import qualified GHC.CmmToAsm.X86.RegInfo as X86
35 import qualified GHC.CmmToAsm.PPC.Regs as PPC
36 import qualified GHC.CmmToAsm.SPARC.Regs as SPARC
37 import qualified GHC.CmmToAsm.AArch64.Regs as AArch64
38
39
40 targetVirtualRegSqueeze :: Platform -> RegClass -> VirtualReg -> Int
41 targetVirtualRegSqueeze platform
42 = case platformArch platform of
43 ArchX86 -> X86.virtualRegSqueeze
44 ArchX86_64 -> X86.virtualRegSqueeze
45 ArchPPC -> PPC.virtualRegSqueeze
46 ArchS390X -> panic "targetVirtualRegSqueeze ArchS390X"
47 ArchSPARC -> SPARC.virtualRegSqueeze
48 ArchSPARC64 -> panic "targetVirtualRegSqueeze ArchSPARC64"
49 ArchPPC_64 _ -> PPC.virtualRegSqueeze
50 ArchARM _ _ _ -> panic "targetVirtualRegSqueeze ArchARM"
51 ArchAArch64 -> AArch64.virtualRegSqueeze
52 ArchAlpha -> panic "targetVirtualRegSqueeze ArchAlpha"
53 ArchMipseb -> panic "targetVirtualRegSqueeze ArchMipseb"
54 ArchMipsel -> panic "targetVirtualRegSqueeze ArchMipsel"
55 ArchRISCV64 -> panic "targetVirtualRegSqueeze ArchRISCV64"
56 ArchJavaScript-> panic "targetVirtualRegSqueeze ArchJavaScript"
57 ArchUnknown -> panic "targetVirtualRegSqueeze ArchUnknown"
58
59
60 targetRealRegSqueeze :: Platform -> RegClass -> RealReg -> Int
61 targetRealRegSqueeze platform
62 = case platformArch platform of
63 ArchX86 -> X86.realRegSqueeze
64 ArchX86_64 -> X86.realRegSqueeze
65 ArchPPC -> PPC.realRegSqueeze
66 ArchS390X -> panic "targetRealRegSqueeze ArchS390X"
67 ArchSPARC -> SPARC.realRegSqueeze
68 ArchSPARC64 -> panic "targetRealRegSqueeze ArchSPARC64"
69 ArchPPC_64 _ -> PPC.realRegSqueeze
70 ArchARM _ _ _ -> panic "targetRealRegSqueeze ArchARM"
71 ArchAArch64 -> AArch64.realRegSqueeze
72 ArchAlpha -> panic "targetRealRegSqueeze ArchAlpha"
73 ArchMipseb -> panic "targetRealRegSqueeze ArchMipseb"
74 ArchMipsel -> panic "targetRealRegSqueeze ArchMipsel"
75 ArchRISCV64 -> panic "targetRealRegSqueeze ArchRISCV64"
76 ArchJavaScript-> panic "targetRealRegSqueeze ArchJavaScript"
77 ArchUnknown -> panic "targetRealRegSqueeze ArchUnknown"
78
79 targetClassOfRealReg :: Platform -> RealReg -> RegClass
80 targetClassOfRealReg platform
81 = case platformArch platform of
82 ArchX86 -> X86.classOfRealReg platform
83 ArchX86_64 -> X86.classOfRealReg platform
84 ArchPPC -> PPC.classOfRealReg
85 ArchS390X -> panic "targetClassOfRealReg ArchS390X"
86 ArchSPARC -> SPARC.classOfRealReg
87 ArchSPARC64 -> panic "targetClassOfRealReg ArchSPARC64"
88 ArchPPC_64 _ -> PPC.classOfRealReg
89 ArchARM _ _ _ -> panic "targetClassOfRealReg ArchARM"
90 ArchAArch64 -> AArch64.classOfRealReg
91 ArchAlpha -> panic "targetClassOfRealReg ArchAlpha"
92 ArchMipseb -> panic "targetClassOfRealReg ArchMipseb"
93 ArchMipsel -> panic "targetClassOfRealReg ArchMipsel"
94 ArchRISCV64 -> panic "targetClassOfRealReg ArchRISCV64"
95 ArchJavaScript-> panic "targetClassOfRealReg ArchJavaScript"
96 ArchUnknown -> panic "targetClassOfRealReg ArchUnknown"
97
98 targetMkVirtualReg :: Platform -> Unique -> Format -> VirtualReg
99 targetMkVirtualReg platform
100 = case platformArch platform of
101 ArchX86 -> X86.mkVirtualReg
102 ArchX86_64 -> X86.mkVirtualReg
103 ArchPPC -> PPC.mkVirtualReg
104 ArchS390X -> panic "targetMkVirtualReg ArchS390X"
105 ArchSPARC -> SPARC.mkVirtualReg
106 ArchSPARC64 -> panic "targetMkVirtualReg ArchSPARC64"
107 ArchPPC_64 _ -> PPC.mkVirtualReg
108 ArchARM _ _ _ -> panic "targetMkVirtualReg ArchARM"
109 ArchAArch64 -> AArch64.mkVirtualReg
110 ArchAlpha -> panic "targetMkVirtualReg ArchAlpha"
111 ArchMipseb -> panic "targetMkVirtualReg ArchMipseb"
112 ArchMipsel -> panic "targetMkVirtualReg ArchMipsel"
113 ArchRISCV64 -> panic "targetMkVirtualReg ArchRISCV64"
114 ArchJavaScript-> panic "targetMkVirtualReg ArchJavaScript"
115 ArchUnknown -> panic "targetMkVirtualReg ArchUnknown"
116
117 targetRegDotColor :: Platform -> RealReg -> SDoc
118 targetRegDotColor platform
119 = case platformArch platform of
120 ArchX86 -> X86.regDotColor platform
121 ArchX86_64 -> X86.regDotColor platform
122 ArchPPC -> PPC.regDotColor
123 ArchS390X -> panic "targetRegDotColor ArchS390X"
124 ArchSPARC -> SPARC.regDotColor
125 ArchSPARC64 -> panic "targetRegDotColor ArchSPARC64"
126 ArchPPC_64 _ -> PPC.regDotColor
127 ArchARM _ _ _ -> panic "targetRegDotColor ArchARM"
128 ArchAArch64 -> AArch64.regDotColor
129 ArchAlpha -> panic "targetRegDotColor ArchAlpha"
130 ArchMipseb -> panic "targetRegDotColor ArchMipseb"
131 ArchMipsel -> panic "targetRegDotColor ArchMipsel"
132 ArchRISCV64 -> panic "targetRegDotColor ArchRISCV64"
133 ArchJavaScript-> panic "targetRegDotColor ArchJavaScript"
134 ArchUnknown -> panic "targetRegDotColor ArchUnknown"
135
136
137 targetClassOfReg :: Platform -> Reg -> RegClass
138 targetClassOfReg platform reg
139 = case reg of
140 RegVirtual vr -> classOfVirtualReg vr
141 RegReal rr -> targetClassOfRealReg platform rr