From 75700644a7430612b40ba94476a5749594010671 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Tue, 21 Aug 2012 17:44:38 +0100 Subject: Move activeStgRegs into CodeGen.Platform --- compiler/codeGen/CodeGen/CallerSaves.hs | 32 --------------- compiler/codeGen/CodeGen/Platform.hs | 52 +++++++++++++++++++++++++ compiler/codeGen/CodeGen/Platform/ARM.hs | 4 +- compiler/codeGen/CodeGen/Platform/NoRegs.hs | 4 +- compiler/codeGen/CodeGen/Platform/PPC.hs | 4 +- compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs | 4 +- compiler/codeGen/CodeGen/Platform/SPARC.hs | 4 +- compiler/codeGen/CodeGen/Platform/X86.hs | 4 +- compiler/codeGen/CodeGen/Platform/X86_64.hs | 4 +- 9 files changed, 66 insertions(+), 46 deletions(-) delete mode 100644 compiler/codeGen/CodeGen/CallerSaves.hs create mode 100644 compiler/codeGen/CodeGen/Platform.hs (limited to 'compiler/codeGen/CodeGen') diff --git a/compiler/codeGen/CodeGen/CallerSaves.hs b/compiler/codeGen/CodeGen/CallerSaves.hs deleted file mode 100644 index b6c709df8c..0000000000 --- a/compiler/codeGen/CodeGen/CallerSaves.hs +++ /dev/null @@ -1,32 +0,0 @@ - -module CodeGen.CallerSaves (callerSaves) 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 - 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 + diff --git a/compiler/codeGen/CodeGen/Platform/ARM.hs b/compiler/codeGen/CodeGen/Platform/ARM.hs index 0116139313..cad3eb7f50 100644 --- a/compiler/codeGen/CodeGen/Platform/ARM.hs +++ b/compiler/codeGen/CodeGen/Platform/ARM.hs @@ -1,9 +1,9 @@ -module CodeGen.Platform.ARM (callerSaves) where +module CodeGen.Platform.ARM where import CmmExpr #define MACHREGS_NO_REGS 0 #define MACHREGS_arm 1 -#include "../../../../includes/CallerSaves.part.hs" +#include "../../../../includes/CodeGen.Platform.hs" diff --git a/compiler/codeGen/CodeGen/Platform/NoRegs.hs b/compiler/codeGen/CodeGen/Platform/NoRegs.hs index ff39dd90ae..6d7c3342d0 100644 --- a/compiler/codeGen/CodeGen/Platform/NoRegs.hs +++ b/compiler/codeGen/CodeGen/Platform/NoRegs.hs @@ -1,8 +1,8 @@ -module CodeGen.Platform.NoRegs (callerSaves) where +module CodeGen.Platform.NoRegs where import CmmExpr #define MACHREGS_NO_REGS 1 -#include "../../../../includes/CallerSaves.part.hs" +#include "../../../../includes/CodeGen.Platform.hs" diff --git a/compiler/codeGen/CodeGen/Platform/PPC.hs b/compiler/codeGen/CodeGen/Platform/PPC.hs index c4c975a58f..19d0609ae2 100644 --- a/compiler/codeGen/CodeGen/Platform/PPC.hs +++ b/compiler/codeGen/CodeGen/Platform/PPC.hs @@ -1,9 +1,9 @@ -module CodeGen.Platform.PPC (callerSaves) where +module CodeGen.Platform.PPC where import CmmExpr #define MACHREGS_NO_REGS 0 #define MACHREGS_powerpc 1 -#include "../../../../includes/CallerSaves.part.hs" +#include "../../../../includes/CodeGen.Platform.hs" diff --git a/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs b/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs index a0cbe7e433..a53ee06cc2 100644 --- a/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs +++ b/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs @@ -1,10 +1,10 @@ -module CodeGen.Platform.PPC_Darwin (callerSaves) where +module CodeGen.Platform.PPC_Darwin where import CmmExpr #define MACHREGS_NO_REGS 0 #define MACHREGS_powerpc 1 #define MACHREGS_darwin 1 -#include "../../../../includes/CallerSaves.part.hs" +#include "../../../../includes/CodeGen.Platform.hs" diff --git a/compiler/codeGen/CodeGen/Platform/SPARC.hs b/compiler/codeGen/CodeGen/Platform/SPARC.hs index 86b949469e..391d6c8086 100644 --- a/compiler/codeGen/CodeGen/Platform/SPARC.hs +++ b/compiler/codeGen/CodeGen/Platform/SPARC.hs @@ -1,9 +1,9 @@ -module CodeGen.Platform.SPARC (callerSaves) where +module CodeGen.Platform.SPARC where import CmmExpr #define MACHREGS_NO_REGS 0 #define MACHREGS_sparc 1 -#include "../../../../includes/CallerSaves.part.hs" +#include "../../../../includes/CodeGen.Platform.hs" diff --git a/compiler/codeGen/CodeGen/Platform/X86.hs b/compiler/codeGen/CodeGen/Platform/X86.hs index c19bf9dcfb..c5ea94f68c 100644 --- a/compiler/codeGen/CodeGen/Platform/X86.hs +++ b/compiler/codeGen/CodeGen/Platform/X86.hs @@ -1,9 +1,9 @@ -module CodeGen.Platform.X86 (callerSaves) where +module CodeGen.Platform.X86 where import CmmExpr #define MACHREGS_NO_REGS 0 #define MACHREGS_i386 1 -#include "../../../../includes/CallerSaves.part.hs" +#include "../../../../includes/CodeGen.Platform.hs" diff --git a/compiler/codeGen/CodeGen/Platform/X86_64.hs b/compiler/codeGen/CodeGen/Platform/X86_64.hs index 59cf788e43..c5aa0808b6 100644 --- a/compiler/codeGen/CodeGen/Platform/X86_64.hs +++ b/compiler/codeGen/CodeGen/Platform/X86_64.hs @@ -1,9 +1,9 @@ -module CodeGen.Platform.X86_64 (callerSaves) where +module CodeGen.Platform.X86_64 where import CmmExpr #define MACHREGS_NO_REGS 0 #define MACHREGS_x86_64 1 -#include "../../../../includes/CallerSaves.part.hs" +#include "../../../../includes/CodeGen.Platform.hs" -- cgit v1.2.1