summaryrefslogtreecommitdiff
path: root/compiler/codeGen/CodeGen/Platform.hs
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2012-08-21 17:44:38 +0100
committerIan Lynagh <ian@well-typed.com>2012-08-21 17:44:38 +0100
commit75700644a7430612b40ba94476a5749594010671 (patch)
tree4f1717e39ef576a35cbd65706582067b56d14487 /compiler/codeGen/CodeGen/Platform.hs
parent07295e96981b29cc6fb88b334d8ebd4b1b807516 (diff)
downloadhaskell-75700644a7430612b40ba94476a5749594010671.tar.gz
Move activeStgRegs into CodeGen.Platform
Diffstat (limited to 'compiler/codeGen/CodeGen/Platform.hs')
-rw-r--r--compiler/codeGen/CodeGen/Platform.hs52
1 files changed, 52 insertions, 0 deletions
diff --git a/compiler/codeGen/CodeGen/Platform.hs b/compiler/codeGen/CodeGen/Platform.hs
new file mode 100644
index 0000000000..66e8f85aff
--- /dev/null
+++ b/compiler/codeGen/CodeGen/Platform.hs
@@ -0,0 +1,52 @@
+
+module CodeGen.Platform (callerSaves, activeStgRegs) where
+
+import CmmExpr
+import Platform
+
+import qualified CodeGen.Platform.ARM as ARM
+import qualified CodeGen.Platform.PPC as PPC
+import qualified CodeGen.Platform.PPC_Darwin as PPC_Darwin
+import qualified CodeGen.Platform.SPARC as SPARC
+import qualified CodeGen.Platform.X86 as X86
+import qualified CodeGen.Platform.X86_64 as X86_64
+import qualified CodeGen.Platform.NoRegs as NoRegs
+
+-- | Returns 'True' if this global register is stored in a caller-saves
+-- machine register.
+
+callerSaves :: Platform -> GlobalReg -> Bool
+callerSaves platform
+ = case platformArch platform of
+ ArchX86 -> X86.callerSaves
+ ArchX86_64 -> X86_64.callerSaves
+ ArchSPARC -> SPARC.callerSaves
+ ArchARM {} -> ARM.callerSaves
+ arch
+ | arch `elem` [ArchPPC, ArchPPC_64] ->
+ case platformOS platform of
+ OSDarwin -> PPC_Darwin.callerSaves
+ _ -> PPC.callerSaves
+
+ | otherwise -> NoRegs.callerSaves
+
+-- | Here is where the STG register map is defined for each target arch.
+-- The order matters (for the llvm backend anyway)! We must make sure to
+-- maintain the order here with the order used in the LLVM calling conventions.
+-- Note that also, this isn't all registers, just the ones that are currently
+-- possbily mapped to real registers.
+activeStgRegs :: Platform -> [GlobalReg]
+activeStgRegs platform
+ = case platformArch platform of
+ ArchX86 -> X86.activeStgRegs
+ ArchX86_64 -> X86_64.activeStgRegs
+ ArchSPARC -> SPARC.activeStgRegs
+ ArchARM {} -> ARM.activeStgRegs
+ arch
+ | arch `elem` [ArchPPC, ArchPPC_64] ->
+ case platformOS platform of
+ OSDarwin -> PPC_Darwin.activeStgRegs
+ _ -> PPC.activeStgRegs
+
+ | otherwise -> NoRegs.activeStgRegs
+