{-# LANGUAGE CPP #-}
module GHC.CmmToLlvm.Regs (
lmGlobalRegArg, lmGlobalRegVar, alwaysLive,
stgTBAA, baseN, stackN, heapN, rxN, topN, tbaa, getTBAA
) where
#include "HsVersions.h"
import GHC.Prelude
import GHC.Llvm
import GHC.Cmm.Expr
import GHC.Platform
import GHC.Data.FastString
import GHC.Utils.Panic ( panic )
import GHC.Types.Unique
lmGlobalRegVar :: Platform -> GlobalReg -> LlvmVar
lmGlobalRegVar :: Platform -> GlobalReg -> LlvmVar
lmGlobalRegVar Platform
platform = LlvmVar -> LlvmVar
pVarLift forall b c a. (b -> c) -> (a -> b) -> a -> c
. Platform -> String -> GlobalReg -> LlvmVar
lmGlobalReg Platform
platform String
"_Var"
lmGlobalRegArg :: Platform -> GlobalReg -> LlvmVar
lmGlobalRegArg :: Platform -> GlobalReg -> LlvmVar
lmGlobalRegArg Platform
platform = Platform -> String -> GlobalReg -> LlvmVar
lmGlobalReg Platform
platform String
"_Arg"
lmGlobalReg :: Platform -> String -> GlobalReg -> LlvmVar
lmGlobalReg :: Platform -> String -> GlobalReg -> LlvmVar
lmGlobalReg Platform
platform String
suf GlobalReg
reg
= case GlobalReg
reg of
GlobalReg
BaseReg -> String -> LlvmVar
ptrGlobal forall a b. (a -> b) -> a -> b
$ String
"Base" forall a. [a] -> [a] -> [a]
++ String
suf
GlobalReg
Sp -> String -> LlvmVar
ptrGlobal forall a b. (a -> b) -> a -> b
$ String
"Sp" forall a. [a] -> [a] -> [a]
++ String
suf
GlobalReg
Hp -> String -> LlvmVar
ptrGlobal forall a b. (a -> b) -> a -> b
$ String
"Hp" forall a. [a] -> [a] -> [a]
++ String
suf
VanillaReg Int
1 VGcPtr
_ -> String -> LlvmVar
wordGlobal forall a b. (a -> b) -> a -> b
$ String
"R1" forall a. [a] -> [a] -> [a]
++ String
suf
VanillaReg Int
2 VGcPtr
_ -> String -> LlvmVar
wordGlobal forall a b. (a -> b) -> a -> b
$ String
"R2" forall a. [a] -> [a] -> [a]
++ String
suf
VanillaReg Int
3 VGcPtr
_ -> String -> LlvmVar
wordGlobal forall a b. (a -> b) -> a -> b
$ String
"R3" forall a. [a] -> [a] -> [a]
++ String
suf
VanillaReg Int
4 VGcPtr
_ -> String -> LlvmVar
wordGlobal forall a b. (a -> b) -> a -> b
$ String
"R4" forall a. [a] -> [a] -> [a]
++ String
suf
VanillaReg Int
5 VGcPtr
_ -> String -> LlvmVar
wordGlobal forall a b. (a -> b) -> a -> b
$ String
"R5" forall a. [a] -> [a] -> [a]
++ String
suf
VanillaReg Int
6 VGcPtr
_ -> String -> LlvmVar
wordGlobal forall a b. (a -> b) -> a -> b
$ String
"R6" forall a. [a] -> [a] -> [a]
++ String
suf
VanillaReg Int
7 VGcPtr
_ -> String -> LlvmVar
wordGlobal forall a b. (a -> b) -> a -> b
$ String
"R7" forall a. [a] -> [a] -> [a]
++ String
suf
VanillaReg Int
8 VGcPtr
_ -> String -> LlvmVar
wordGlobal forall a b. (a -> b) -> a -> b
$ String
"R8" forall a. [a] -> [a] -> [a]
++ String
suf
VanillaReg Int
9 VGcPtr
_ -> String -> LlvmVar
wordGlobal forall a b. (a -> b) -> a -> b
$ String
"R9" forall a. [a] -> [a] -> [a]
++ String
suf
VanillaReg Int
10 VGcPtr
_ -> String -> LlvmVar
wordGlobal forall a b. (a -> b) -> a -> b
$ String
"R10" forall a. [a] -> [a] -> [a]
++ String
suf
GlobalReg
SpLim -> String -> LlvmVar
wordGlobal forall a b. (a -> b) -> a -> b
$ String
"SpLim" forall a. [a] -> [a] -> [a]
++ String
suf
FloatReg Int
1 -> String -> LlvmVar
floatGlobal forall a b. (a -> b) -> a -> b
$ String
"F1" forall a. [a] -> [a] -> [a]
++ String
suf
FloatReg Int
2 -> String -> LlvmVar
floatGlobal forall a b. (a -> b) -> a -> b
$ String
"F2" forall a. [a] -> [a] -> [a]
++ String
suf
FloatReg Int
3 -> String -> LlvmVar
floatGlobal forall a b. (a -> b) -> a -> b
$ String
"F3" forall a. [a] -> [a] -> [a]
++ String
suf
FloatReg Int
4 -> String -> LlvmVar
floatGlobal forall a b. (a -> b) -> a -> b
$ String
"F4" forall a. [a] -> [a] -> [a]
++ String
suf
FloatReg Int
5 -> String -> LlvmVar
floatGlobal forall a b. (a -> b) -> a -> b
$ String
"F5" forall a. [a] -> [a] -> [a]
++ String
suf
FloatReg Int
6 -> String -> LlvmVar
floatGlobal forall a b. (a -> b) -> a -> b
$ String
"F6" forall a. [a] -> [a] -> [a]
++ String
suf
DoubleReg Int
1 -> String -> LlvmVar
doubleGlobal forall a b. (a -> b) -> a -> b
$ String
"D1" forall a. [a] -> [a] -> [a]
++ String
suf
DoubleReg Int
2 -> String -> LlvmVar
doubleGlobal forall a b. (a -> b) -> a -> b
$ String
"D2" forall a. [a] -> [a] -> [a]
++ String
suf
DoubleReg Int
3 -> String -> LlvmVar
doubleGlobal forall a b. (a -> b) -> a -> b
$ String
"D3" forall a. [a] -> [a] -> [a]
++ String
suf
DoubleReg Int
4 -> String -> LlvmVar
doubleGlobal forall a b. (a -> b) -> a -> b
$ String
"D4" forall a. [a] -> [a] -> [a]
++ String
suf
DoubleReg Int
5 -> String -> LlvmVar
doubleGlobal forall a b. (a -> b) -> a -> b
$ String
"D5" forall a. [a] -> [a] -> [a]
++ String
suf
DoubleReg Int
6 -> String -> LlvmVar
doubleGlobal forall a b. (a -> b) -> a -> b
$ String
"D6" forall a. [a] -> [a] -> [a]
++ String
suf
XmmReg Int
1 -> String -> LlvmVar
xmmGlobal forall a b. (a -> b) -> a -> b
$ String
"XMM1" forall a. [a] -> [a] -> [a]
++ String
suf
XmmReg Int
2 -> String -> LlvmVar
xmmGlobal forall a b. (a -> b) -> a -> b
$ String
"XMM2" forall a. [a] -> [a] -> [a]
++ String
suf
XmmReg Int
3 -> String -> LlvmVar
xmmGlobal forall a b. (a -> b) -> a -> b
$ String
"XMM3" forall a. [a] -> [a] -> [a]
++ String
suf
XmmReg Int
4 -> String -> LlvmVar
xmmGlobal forall a b. (a -> b) -> a -> b
$ String
"XMM4" forall a. [a] -> [a] -> [a]
++ String
suf
XmmReg Int
5 -> String -> LlvmVar
xmmGlobal forall a b. (a -> b) -> a -> b
$ String
"XMM5" forall a. [a] -> [a] -> [a]
++ String
suf
XmmReg Int
6 -> String -> LlvmVar
xmmGlobal forall a b. (a -> b) -> a -> b
$ String
"XMM6" forall a. [a] -> [a] -> [a]
++ String
suf
YmmReg Int
1 -> String -> LlvmVar
ymmGlobal forall a b. (a -> b) -> a -> b
$ String
"YMM1" forall a. [a] -> [a] -> [a]
++ String
suf
YmmReg Int
2 -> String -> LlvmVar
ymmGlobal forall a b. (a -> b) -> a -> b
$ String
"YMM2" forall a. [a] -> [a] -> [a]
++ String
suf
YmmReg Int
3 -> String -> LlvmVar
ymmGlobal forall a b. (a -> b) -> a -> b
$ String
"YMM3" forall a. [a] -> [a] -> [a]
++ String
suf
YmmReg Int
4 -> String -> LlvmVar
ymmGlobal forall a b. (a -> b) -> a -> b
$ String
"YMM4" forall a. [a] -> [a] -> [a]
++ String
suf
YmmReg Int
5 -> String -> LlvmVar
ymmGlobal forall a b. (a -> b) -> a -> b
$ String
"YMM5" forall a. [a] -> [a] -> [a]
++ String
suf
YmmReg Int
6 -> String -> LlvmVar
ymmGlobal forall a b. (a -> b) -> a -> b
$ String
"YMM6" forall a. [a] -> [a] -> [a]
++ String
suf
ZmmReg Int
1 -> String -> LlvmVar
zmmGlobal forall a b. (a -> b) -> a -> b
$ String
"ZMM1" forall a. [a] -> [a] -> [a]
++ String
suf
ZmmReg Int
2 -> String -> LlvmVar
zmmGlobal forall a b. (a -> b) -> a -> b
$ String
"ZMM2" forall a. [a] -> [a] -> [a]
++ String
suf
ZmmReg Int
3 -> String -> LlvmVar
zmmGlobal forall a b. (a -> b) -> a -> b
$ String
"ZMM3" forall a. [a] -> [a] -> [a]
++ String
suf
ZmmReg Int
4 -> String -> LlvmVar
zmmGlobal forall a b. (a -> b) -> a -> b
$ String
"ZMM4" forall a. [a] -> [a] -> [a]
++ String
suf
ZmmReg Int
5 -> String -> LlvmVar
zmmGlobal forall a b. (a -> b) -> a -> b
$ String
"ZMM5" forall a. [a] -> [a] -> [a]
++ String
suf
ZmmReg Int
6 -> String -> LlvmVar
zmmGlobal forall a b. (a -> b) -> a -> b
$ String
"ZMM6" forall a. [a] -> [a] -> [a]
++ String
suf
GlobalReg
MachSp -> String -> LlvmVar
wordGlobal forall a b. (a -> b) -> a -> b
$ String
"MachSp" forall a. [a] -> [a] -> [a]
++ String
suf
GlobalReg
_other -> forall a. String -> a
panic forall a b. (a -> b) -> a -> b
$ String
"GHC.CmmToLlvm.Reg: GlobalReg (" forall a. [a] -> [a] -> [a]
++ (forall a. Show a => a -> String
show GlobalReg
reg)
forall a. [a] -> [a] -> [a]
++ String
") not supported!"
where
wordGlobal :: String -> LlvmVar
wordGlobal String
name = FastString -> LlvmType -> LlvmVar
LMNLocalVar (String -> FastString
fsLit String
name) (Platform -> LlvmType
llvmWord Platform
platform)
ptrGlobal :: String -> LlvmVar
ptrGlobal String
name = FastString -> LlvmType -> LlvmVar
LMNLocalVar (String -> FastString
fsLit String
name) (Platform -> LlvmType
llvmWordPtr Platform
platform)
floatGlobal :: String -> LlvmVar
floatGlobal String
name = FastString -> LlvmType -> LlvmVar
LMNLocalVar (String -> FastString
fsLit String
name) LlvmType
LMFloat
doubleGlobal :: String -> LlvmVar
doubleGlobal String
name = FastString -> LlvmType -> LlvmVar
LMNLocalVar (String -> FastString
fsLit String
name) LlvmType
LMDouble
xmmGlobal :: String -> LlvmVar
xmmGlobal String
name = FastString -> LlvmType -> LlvmVar
LMNLocalVar (String -> FastString
fsLit String
name) (Int -> LlvmType -> LlvmType
LMVector Int
4 (Int -> LlvmType
LMInt Int
32))
ymmGlobal :: String -> LlvmVar
ymmGlobal String
name = FastString -> LlvmType -> LlvmVar
LMNLocalVar (String -> FastString
fsLit String
name) (Int -> LlvmType -> LlvmType
LMVector Int
8 (Int -> LlvmType
LMInt Int
32))
zmmGlobal :: String -> LlvmVar
zmmGlobal String
name = FastString -> LlvmType -> LlvmVar
LMNLocalVar (String -> FastString
fsLit String
name) (Int -> LlvmType -> LlvmType
LMVector Int
16 (Int -> LlvmType
LMInt Int
32))
alwaysLive :: [GlobalReg]
alwaysLive :: [GlobalReg]
alwaysLive = [GlobalReg
BaseReg, GlobalReg
Sp, GlobalReg
Hp, GlobalReg
SpLim, GlobalReg
HpLim, GlobalReg
node]
stgTBAA :: [(Unique, LMString, Maybe Unique)]
stgTBAA :: [(Unique, FastString, Maybe Unique)]
stgTBAA
= [ (Unique
rootN, String -> FastString
fsLit String
"root", forall a. Maybe a
Nothing)
, (Unique
topN, String -> FastString
fsLit String
"top", forall a. a -> Maybe a
Just Unique
rootN)
, (Unique
stackN, String -> FastString
fsLit String
"stack", forall a. a -> Maybe a
Just Unique
topN)
, (Unique
heapN, String -> FastString
fsLit String
"heap", forall a. a -> Maybe a
Just Unique
topN)
, (Unique
rxN, String -> FastString
fsLit String
"rx", forall a. a -> Maybe a
Just Unique
heapN)
, (Unique
baseN, String -> FastString
fsLit String
"base", forall a. a -> Maybe a
Just Unique
topN)
]
rootN, topN, stackN, heapN, rxN, baseN :: Unique
rootN :: Unique
rootN = forall a. Uniquable a => a -> Unique
getUnique (String -> FastString
fsLit String
"GHC.CmmToLlvm.Regs.rootN")
topN :: Unique
topN = forall a. Uniquable a => a -> Unique
getUnique (String -> FastString
fsLit String
"GHC.CmmToLlvm.Regs.topN")
stackN :: Unique
stackN = forall a. Uniquable a => a -> Unique
getUnique (String -> FastString
fsLit String
"GHC.CmmToLlvm.Regs.stackN")
heapN :: Unique
heapN = forall a. Uniquable a => a -> Unique
getUnique (String -> FastString
fsLit String
"GHC.CmmToLlvm.Regs.heapN")
rxN :: Unique
rxN = forall a. Uniquable a => a -> Unique
getUnique (String -> FastString
fsLit String
"GHC.CmmToLlvm.Regs.rxN")
baseN :: Unique
baseN = forall a. Uniquable a => a -> Unique
getUnique (String -> FastString
fsLit String
"GHC.CmmToLlvm.Regs.baseN")
tbaa :: LMString
tbaa :: FastString
tbaa = String -> FastString
fsLit String
"tbaa"
getTBAA :: GlobalReg -> Unique
getTBAA :: GlobalReg -> Unique
getTBAA GlobalReg
BaseReg = Unique
baseN
getTBAA GlobalReg
Sp = Unique
stackN
getTBAA GlobalReg
Hp = Unique
heapN
getTBAA (VanillaReg Int
_ VGcPtr
_) = Unique
rxN
getTBAA GlobalReg
_ = Unique
topN