summaryrefslogtreecommitdiff
path: root/compiler/codeGen
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2012-08-28 20:52:44 +0100
committerIan Lynagh <ian@well-typed.com>2012-08-28 20:52:44 +0100
commitc0907ed27351e4160c0c8b2a5c9877899d87aae9 (patch)
treeae34750faa31e4c334ef9e3a5556093d30c11dea /compiler/codeGen
parent0e7d2906e706acdd716f121abb19c433986ae830 (diff)
downloadhaskell-c0907ed27351e4160c0c8b2a5c9877899d87aae9.tar.gz
Move more code into codeGen/CodeGen/Platform.hs
HaskellMachRegs.h is no longer included in anything under compiler/ Also, includes/CodeGen.Platform.hs now includes "stg/MachRegs.h" rather than <stg/MachRegs.h> which means that we always get the file from the tree, rather than from the bootstrapping compiler.
Diffstat (limited to 'compiler/codeGen')
-rw-r--r--compiler/codeGen/CodeGen/Platform.hs40
-rw-r--r--compiler/codeGen/CodeGen/Platform/ARM.hs2
-rw-r--r--compiler/codeGen/CodeGen/Platform/NoRegs.hs2
-rw-r--r--compiler/codeGen/CodeGen/Platform/PPC.hs2
-rw-r--r--compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs2
-rw-r--r--compiler/codeGen/CodeGen/Platform/SPARC.hs2
-rw-r--r--compiler/codeGen/CodeGen/Platform/X86.hs2
-rw-r--r--compiler/codeGen/CodeGen/Platform/X86_64.hs2
8 files changed, 39 insertions, 15 deletions
diff --git a/compiler/codeGen/CodeGen/Platform.hs b/compiler/codeGen/CodeGen/Platform.hs
index 78fba978ec..ca3bafb8de 100644
--- a/compiler/codeGen/CodeGen/Platform.hs
+++ b/compiler/codeGen/CodeGen/Platform.hs
@@ -1,8 +1,12 @@
-module CodeGen.Platform (callerSaves, activeStgRegs, haveRegBase) where
+module CodeGen.Platform
+ (callerSaves, activeStgRegs, haveRegBase, globalRegMaybe, freeReg)
+ where
import CmmExpr
+import FastBool
import Platform
+import Reg
import qualified CodeGen.Platform.ARM as ARM
import qualified CodeGen.Platform.PPC as PPC
@@ -71,3 +75,37 @@ haveRegBase platform
| otherwise -> NoRegs.haveRegBase
+globalRegMaybe :: Platform -> GlobalReg -> Maybe RealReg
+globalRegMaybe platform
+ | platformUnregisterised platform = NoRegs.globalRegMaybe
+ | otherwise
+ = case platformArch platform of
+ ArchX86 -> X86.globalRegMaybe
+ ArchX86_64 -> X86_64.globalRegMaybe
+ ArchSPARC -> SPARC.globalRegMaybe
+ ArchARM {} -> ARM.globalRegMaybe
+ arch
+ | arch `elem` [ArchPPC, ArchPPC_64] ->
+ case platformOS platform of
+ OSDarwin -> PPC_Darwin.globalRegMaybe
+ _ -> PPC.globalRegMaybe
+
+ | otherwise -> NoRegs.globalRegMaybe
+
+freeReg :: Platform -> RegNo -> FastBool
+freeReg platform
+ | platformUnregisterised platform = NoRegs.freeReg
+ | otherwise
+ = case platformArch platform of
+ ArchX86 -> X86.freeReg
+ ArchX86_64 -> X86_64.freeReg
+ ArchSPARC -> SPARC.freeReg
+ ArchARM {} -> ARM.freeReg
+ arch
+ | arch `elem` [ArchPPC, ArchPPC_64] ->
+ case platformOS platform of
+ OSDarwin -> PPC_Darwin.freeReg
+ _ -> PPC.freeReg
+
+ | otherwise -> NoRegs.freeReg
+
diff --git a/compiler/codeGen/CodeGen/Platform/ARM.hs b/compiler/codeGen/CodeGen/Platform/ARM.hs
index cad3eb7f50..727a43561f 100644
--- a/compiler/codeGen/CodeGen/Platform/ARM.hs
+++ b/compiler/codeGen/CodeGen/Platform/ARM.hs
@@ -1,8 +1,6 @@
module CodeGen.Platform.ARM where
-import CmmExpr
-
#define MACHREGS_NO_REGS 0
#define MACHREGS_arm 1
#include "../../../../includes/CodeGen.Platform.hs"
diff --git a/compiler/codeGen/CodeGen/Platform/NoRegs.hs b/compiler/codeGen/CodeGen/Platform/NoRegs.hs
index 6d7c3342d0..c4c63b7572 100644
--- a/compiler/codeGen/CodeGen/Platform/NoRegs.hs
+++ b/compiler/codeGen/CodeGen/Platform/NoRegs.hs
@@ -1,8 +1,6 @@
module CodeGen.Platform.NoRegs where
-import CmmExpr
-
#define MACHREGS_NO_REGS 1
#include "../../../../includes/CodeGen.Platform.hs"
diff --git a/compiler/codeGen/CodeGen/Platform/PPC.hs b/compiler/codeGen/CodeGen/Platform/PPC.hs
index 19d0609ae2..bcbdfe244b 100644
--- a/compiler/codeGen/CodeGen/Platform/PPC.hs
+++ b/compiler/codeGen/CodeGen/Platform/PPC.hs
@@ -1,8 +1,6 @@
module CodeGen.Platform.PPC where
-import CmmExpr
-
#define MACHREGS_NO_REGS 0
#define MACHREGS_powerpc 1
#include "../../../../includes/CodeGen.Platform.hs"
diff --git a/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs b/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs
index a53ee06cc2..42bf22f26c 100644
--- a/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs
+++ b/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs
@@ -1,8 +1,6 @@
module CodeGen.Platform.PPC_Darwin where
-import CmmExpr
-
#define MACHREGS_NO_REGS 0
#define MACHREGS_powerpc 1
#define MACHREGS_darwin 1
diff --git a/compiler/codeGen/CodeGen/Platform/SPARC.hs b/compiler/codeGen/CodeGen/Platform/SPARC.hs
index 391d6c8086..b49af14409 100644
--- a/compiler/codeGen/CodeGen/Platform/SPARC.hs
+++ b/compiler/codeGen/CodeGen/Platform/SPARC.hs
@@ -1,8 +1,6 @@
module CodeGen.Platform.SPARC where
-import CmmExpr
-
#define MACHREGS_NO_REGS 0
#define MACHREGS_sparc 1
#include "../../../../includes/CodeGen.Platform.hs"
diff --git a/compiler/codeGen/CodeGen/Platform/X86.hs b/compiler/codeGen/CodeGen/Platform/X86.hs
index c5ea94f68c..6dd74df130 100644
--- a/compiler/codeGen/CodeGen/Platform/X86.hs
+++ b/compiler/codeGen/CodeGen/Platform/X86.hs
@@ -1,8 +1,6 @@
module CodeGen.Platform.X86 where
-import CmmExpr
-
#define MACHREGS_NO_REGS 0
#define MACHREGS_i386 1
#include "../../../../includes/CodeGen.Platform.hs"
diff --git a/compiler/codeGen/CodeGen/Platform/X86_64.hs b/compiler/codeGen/CodeGen/Platform/X86_64.hs
index c5aa0808b6..190d642ea6 100644
--- a/compiler/codeGen/CodeGen/Platform/X86_64.hs
+++ b/compiler/codeGen/CodeGen/Platform/X86_64.hs
@@ -1,8 +1,6 @@
module CodeGen.Platform.X86_64 where
-import CmmExpr
-
#define MACHREGS_NO_REGS 0
#define MACHREGS_x86_64 1
#include "../../../../includes/CodeGen.Platform.hs"