diff options
author | Ian Lynagh <ian@well-typed.com> | 2012-08-21 18:44:31 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2012-08-21 18:44:31 +0100 |
commit | 15856e97d3107f75be40588ec2dc8e6d670463fe (patch) | |
tree | 71c1e827241d150298c0b7dea412506a5c2f22ae | |
parent | 75700644a7430612b40ba94476a5749594010671 (diff) | |
download | haskell-15856e97d3107f75be40588ec2dc8e6d670463fe.tar.gz |
Add haveRegBase to CodeGen.Platform
-rw-r--r-- | compiler/codeGen/CgUtils.hs | 30 | ||||
-rw-r--r-- | compiler/codeGen/CodeGen/Platform.hs | 17 | ||||
-rw-r--r-- | includes/CodeGen.Platform.hs | 7 |
3 files changed, 38 insertions, 16 deletions
diff --git a/compiler/codeGen/CgUtils.hs b/compiler/codeGen/CgUtils.hs index 4661450fe5..64e3a2f5e7 100644 --- a/compiler/codeGen/CgUtils.hs +++ b/compiler/codeGen/CgUtils.hs @@ -308,14 +308,15 @@ callerSaveVolatileRegs dflags vols = (caller_save, caller_load) callerSaveGlobalReg reg next | callerSaves platform reg = - CmmStore (get_GlobalReg_addr reg) + CmmStore (get_GlobalReg_addr platform reg) (CmmReg (CmmGlobal reg)) : next | otherwise = next callerRestoreGlobalReg reg next | callerSaves platform reg = CmmAssign (CmmGlobal reg) - (CmmLoad (get_GlobalReg_addr reg) (globalRegType reg)) + (CmmLoad (get_GlobalReg_addr platform reg) + (globalRegType reg)) : next | otherwise = next @@ -810,10 +811,11 @@ srt_escape = -1 -- to real machine registers or stored as offsets from BaseReg. Given -- a GlobalReg, get_GlobalReg_addr always produces the -- register table address for it. -get_GlobalReg_addr :: GlobalReg -> CmmExpr -get_GlobalReg_addr BaseReg = regTableOffset 0 -get_GlobalReg_addr mid = get_Regtable_addr_from_offset - (globalRegType mid) (baseRegOffset mid) +get_GlobalReg_addr :: Platform -> GlobalReg -> CmmExpr +get_GlobalReg_addr _ BaseReg = regTableOffset 0 +get_GlobalReg_addr platform mid + = get_Regtable_addr_from_offset platform + (globalRegType mid) (baseRegOffset mid) -- Calculate a literal representing an offset into the register table. -- Used when we don't have an actual BaseReg to offset from. @@ -821,13 +823,11 @@ regTableOffset :: Int -> CmmExpr regTableOffset n = CmmLit (CmmLabelOff mkMainCapabilityLabel (oFFSET_Capability_r + n)) -get_Regtable_addr_from_offset :: CmmType -> Int -> CmmExpr -get_Regtable_addr_from_offset _ offset = -#ifdef REG_Base - CmmRegOff (CmmGlobal BaseReg) offset -#else - regTableOffset offset -#endif +get_Regtable_addr_from_offset :: Platform -> CmmType -> Int -> CmmExpr +get_Regtable_addr_from_offset platform _ offset = + if haveRegBase platform + then CmmRegOff (CmmGlobal BaseReg) offset + else regTableOffset offset -- | Fixup global registers so that they assign to locations within the -- RegTable if they aren't pinned for the current target. @@ -848,7 +848,7 @@ fixStgRegStmt platform stmt = case stmt of CmmAssign (CmmGlobal reg) src -> let src' = fixStgRegExpr platform src - baseAddr = get_GlobalReg_addr reg + baseAddr = get_GlobalReg_addr platform reg in case reg `elem` activeStgRegs platform of True -> CmmAssign (CmmGlobal reg) src' False -> CmmStore baseAddr src' @@ -896,7 +896,7 @@ fixStgRegExpr platform expr case reg `elem` activeStgRegs platform of True -> expr False -> - let baseAddr = get_GlobalReg_addr reg + let baseAddr = get_GlobalReg_addr platform reg in case reg of BaseReg -> fixStgRegExpr platform baseAddr _other -> fixStgRegExpr platform diff --git a/compiler/codeGen/CodeGen/Platform.hs b/compiler/codeGen/CodeGen/Platform.hs index 66e8f85aff..2ed99833a9 100644 --- a/compiler/codeGen/CodeGen/Platform.hs +++ b/compiler/codeGen/CodeGen/Platform.hs @@ -1,5 +1,5 @@ -module CodeGen.Platform (callerSaves, activeStgRegs) where +module CodeGen.Platform (callerSaves, activeStgRegs, haveRegBase) where import CmmExpr import Platform @@ -50,3 +50,18 @@ activeStgRegs platform | otherwise -> NoRegs.activeStgRegs +haveRegBase :: Platform -> Bool +haveRegBase platform + = case platformArch platform of + ArchX86 -> X86.haveRegBase + ArchX86_64 -> X86_64.haveRegBase + ArchSPARC -> SPARC.haveRegBase + ArchARM {} -> ARM.haveRegBase + arch + | arch `elem` [ArchPPC, ArchPPC_64] -> + case platformOS platform of + OSDarwin -> PPC_Darwin.haveRegBase + _ -> PPC.haveRegBase + + | otherwise -> NoRegs.haveRegBase + diff --git a/includes/CodeGen.Platform.hs b/includes/CodeGen.Platform.hs index 5ab3642e75..7b29edea0c 100644 --- a/includes/CodeGen.Platform.hs +++ b/includes/CodeGen.Platform.hs @@ -143,3 +143,10 @@ activeStgRegs = [ #endif ] +haveRegBase :: Bool +#ifdef REG_Base +haveRegBase = True +#else +haveRegBase = False +#endif + |