diff options
Diffstat (limited to 'compiler/codeGen')
-rw-r--r-- | compiler/codeGen/CallerSaves.hs | 51 | ||||
-rw-r--r-- | compiler/codeGen/CgUtils.hs | 2 | ||||
-rw-r--r-- | compiler/codeGen/CodeGen/CallerSaves.hs | 32 | ||||
-rw-r--r-- | compiler/codeGen/CodeGen/Platform/ARM.hs | 9 | ||||
-rw-r--r-- | compiler/codeGen/CodeGen/Platform/NoRegs.hs | 8 | ||||
-rw-r--r-- | compiler/codeGen/CodeGen/Platform/PPC.hs | 9 | ||||
-rw-r--r-- | compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs | 10 | ||||
-rw-r--r-- | compiler/codeGen/CodeGen/Platform/SPARC.hs | 9 | ||||
-rw-r--r-- | compiler/codeGen/CodeGen/Platform/X86.hs | 9 | ||||
-rw-r--r-- | compiler/codeGen/CodeGen/Platform/X86_64.hs | 9 | ||||
-rw-r--r-- | compiler/codeGen/StgCmmUtils.hs | 2 |
11 files changed, 97 insertions, 53 deletions
diff --git a/compiler/codeGen/CallerSaves.hs b/compiler/codeGen/CallerSaves.hs deleted file mode 100644 index babee9e36e..0000000000 --- a/compiler/codeGen/CallerSaves.hs +++ /dev/null @@ -1,51 +0,0 @@ - -module CallerSaves (callerSaves) where - -import CmmExpr -import Platform - --- | Returns 'True' if this global register is stored in a caller-saves --- machine register. - -callerSaves :: Platform -> GlobalReg -> Bool -#define MACHREGS_NO_REGS 0 -callerSaves (Platform { platformArch = ArchX86 }) = platformCallerSaves - where -#define MACHREGS_i386 1 -#include "../../includes/CallerSaves.part.hs" -#undef MACHREGS_i386 -callerSaves (Platform { platformArch = ArchX86_64 }) = platformCallerSaves - where -#define MACHREGS_x86_64 1 -#include "../../includes/CallerSaves.part.hs" -#undef MACHREGS_x86_64 -callerSaves (Platform { platformArch = ppcArch, platformOS = OSDarwin }) - | ppcArch `elem` [ArchPPC, ArchPPC_64] = platformCallerSaves - where -#define MACHREGS_powerpc 1 -#define MACHREGS_darwin 1 -#include "../../includes/CallerSaves.part.hs" -#undef MACHREGS_powerpc -#undef MACHREGS_darwin -callerSaves (Platform { platformArch = ppcArch }) - | ppcArch `elem` [ArchPPC, ArchPPC_64] = platformCallerSaves - where -#define MACHREGS_powerpc 1 -#include "../../includes/CallerSaves.part.hs" -#undef MACHREGS_powerpc -callerSaves (Platform { platformArch = ArchSPARC }) = platformCallerSaves - where -#define MACHREGS_sparc 1 -#include "../../includes/CallerSaves.part.hs" -#undef MACHREGS_sparc -callerSaves (Platform { platformArch = ArchARM {} }) = platformCallerSaves - where -#define MACHREGS_arm 1 -#include "../../includes/CallerSaves.part.hs" -#undef MACHREGS_arm -callerSaves _ = platformCallerSaves - where -#undef MACHREGS_NO_REGS -#define MACHREGS_NO_REGS 1 -#include "../../includes/CallerSaves.part.hs" - diff --git a/compiler/codeGen/CgUtils.hs b/compiler/codeGen/CgUtils.hs index d64aaa87e3..b488f16299 100644 --- a/compiler/codeGen/CgUtils.hs +++ b/compiler/codeGen/CgUtils.hs @@ -48,7 +48,7 @@ module CgUtils ( #include "../includes/stg/HaskellMachRegs.h" import BlockId -import CallerSaves +import CodeGen.CallerSaves import CgMonad import TyCon import DataCon diff --git a/compiler/codeGen/CodeGen/CallerSaves.hs b/compiler/codeGen/CodeGen/CallerSaves.hs new file mode 100644 index 0000000000..b6c709df8c --- /dev/null +++ b/compiler/codeGen/CodeGen/CallerSaves.hs @@ -0,0 +1,32 @@ + +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/ARM.hs b/compiler/codeGen/CodeGen/Platform/ARM.hs new file mode 100644 index 0000000000..0116139313 --- /dev/null +++ b/compiler/codeGen/CodeGen/Platform/ARM.hs @@ -0,0 +1,9 @@ + +module CodeGen.Platform.ARM (callerSaves) where + +import CmmExpr + +#define MACHREGS_NO_REGS 0 +#define MACHREGS_arm 1 +#include "../../../../includes/CallerSaves.part.hs" + diff --git a/compiler/codeGen/CodeGen/Platform/NoRegs.hs b/compiler/codeGen/CodeGen/Platform/NoRegs.hs new file mode 100644 index 0000000000..ff39dd90ae --- /dev/null +++ b/compiler/codeGen/CodeGen/Platform/NoRegs.hs @@ -0,0 +1,8 @@ + +module CodeGen.Platform.NoRegs (callerSaves) where + +import CmmExpr + +#define MACHREGS_NO_REGS 1 +#include "../../../../includes/CallerSaves.part.hs" + diff --git a/compiler/codeGen/CodeGen/Platform/PPC.hs b/compiler/codeGen/CodeGen/Platform/PPC.hs new file mode 100644 index 0000000000..c4c975a58f --- /dev/null +++ b/compiler/codeGen/CodeGen/Platform/PPC.hs @@ -0,0 +1,9 @@ + +module CodeGen.Platform.PPC (callerSaves) where + +import CmmExpr + +#define MACHREGS_NO_REGS 0 +#define MACHREGS_powerpc 1 +#include "../../../../includes/CallerSaves.part.hs" + diff --git a/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs b/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs new file mode 100644 index 0000000000..a0cbe7e433 --- /dev/null +++ b/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs @@ -0,0 +1,10 @@ + +module CodeGen.Platform.PPC_Darwin (callerSaves) where + +import CmmExpr + +#define MACHREGS_NO_REGS 0 +#define MACHREGS_powerpc 1 +#define MACHREGS_darwin 1 +#include "../../../../includes/CallerSaves.part.hs" + diff --git a/compiler/codeGen/CodeGen/Platform/SPARC.hs b/compiler/codeGen/CodeGen/Platform/SPARC.hs new file mode 100644 index 0000000000..86b949469e --- /dev/null +++ b/compiler/codeGen/CodeGen/Platform/SPARC.hs @@ -0,0 +1,9 @@ + +module CodeGen.Platform.SPARC (callerSaves) where + +import CmmExpr + +#define MACHREGS_NO_REGS 0 +#define MACHREGS_sparc 1 +#include "../../../../includes/CallerSaves.part.hs" + diff --git a/compiler/codeGen/CodeGen/Platform/X86.hs b/compiler/codeGen/CodeGen/Platform/X86.hs new file mode 100644 index 0000000000..c19bf9dcfb --- /dev/null +++ b/compiler/codeGen/CodeGen/Platform/X86.hs @@ -0,0 +1,9 @@ + +module CodeGen.Platform.X86 (callerSaves) where + +import CmmExpr + +#define MACHREGS_NO_REGS 0 +#define MACHREGS_i386 1 +#include "../../../../includes/CallerSaves.part.hs" + diff --git a/compiler/codeGen/CodeGen/Platform/X86_64.hs b/compiler/codeGen/CodeGen/Platform/X86_64.hs new file mode 100644 index 0000000000..59cf788e43 --- /dev/null +++ b/compiler/codeGen/CodeGen/Platform/X86_64.hs @@ -0,0 +1,9 @@ + +module CodeGen.Platform.X86_64 (callerSaves) where + +import CmmExpr + +#define MACHREGS_NO_REGS 0 +#define MACHREGS_x86_64 1 +#include "../../../../includes/CallerSaves.part.hs" + diff --git a/compiler/codeGen/StgCmmUtils.hs b/compiler/codeGen/StgCmmUtils.hs index 13c8eccb9a..ad435c740e 100644 --- a/compiler/codeGen/StgCmmUtils.hs +++ b/compiler/codeGen/StgCmmUtils.hs @@ -57,7 +57,7 @@ import StgCmmClosure import Cmm import BlockId import MkGraph -import CallerSaves +import CodeGen.CallerSaves import CLabel import CmmUtils |