1 --------------------------------------------------------------------------------
2 -- | Deal with Cmm registers
5 module LlvmCodeGen.Regs (
6 lmGlobalRegArg, lmGlobalRegVar
9 #include "HsVersions.h"
14 import Outputable ( panic )
17 -- | Get the LlvmVar function variable storing the real register
18 lmGlobalRegVar :: GlobalReg -> LlvmVar
19 lmGlobalRegVar = (pVarLift . lmGlobalReg "_Var")
21 -- | Get the LlvmVar function argument storing the real register
22 lmGlobalRegArg :: GlobalReg -> LlvmVar
23 lmGlobalRegArg = lmGlobalReg "_Arg"
25 {- Need to make sure the names here can't conflict with the unique generated
26 names. Uniques generated names containing only base62 chars. So using say
27 the '_' char guarantees this.
29 lmGlobalReg :: String -> GlobalReg -> LlvmVar
32 BaseReg -> ptrGlobal $ "Base" ++ suf
33 Sp -> ptrGlobal $ "Sp" ++ suf
34 Hp -> ptrGlobal $ "Hp" ++ suf
35 VanillaReg 1 _ -> wordGlobal $ "R1" ++ suf
36 VanillaReg 2 _ -> wordGlobal $ "R2" ++ suf
37 VanillaReg 3 _ -> wordGlobal $ "R3" ++ suf
38 VanillaReg 4 _ -> wordGlobal $ "R4" ++ suf
39 VanillaReg 5 _ -> wordGlobal $ "R5" ++ suf
40 VanillaReg 6 _ -> wordGlobal $ "R6" ++ suf
41 SpLim -> wordGlobal $ "SpLim" ++ suf
42 FloatReg 1 -> floatGlobal $"F1" ++ suf
43 FloatReg 2 -> floatGlobal $"F2" ++ suf
44 FloatReg 3 -> floatGlobal $"F3" ++ suf
45 FloatReg 4 -> floatGlobal $"F4" ++ suf
46 DoubleReg 1 -> doubleGlobal $ "D1" ++ suf
47 DoubleReg 2 -> doubleGlobal $ "D2" ++ suf
48 _other -> panic $ "LlvmCodeGen.Reg: GlobalReg (" ++ (show reg)
51 wordGlobal name = LMNLocalVar (fsLit name) llvmWord
52 ptrGlobal name = LMNLocalVar (fsLit name) llvmWordPtr
53 floatGlobal name = LMNLocalVar (fsLit name) LMFloat
54 doubleGlobal name = LMNLocalVar (fsLit name) LMDouble