summaryrefslogtreecommitdiff
path: root/compiler/codeGen
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2012-09-14 15:24:30 +0100
committerIan Lynagh <ian@well-typed.com>2012-09-14 15:24:30 +0100
commitf203e63c6ff92bde63a206a58ea63ec082033b8a (patch)
tree0fdb84f953c6195727971d765a025c076fc5e07f /compiler/codeGen
parent6f3be2b6ea39ee28d6cf8da08effb5dd215c92f2 (diff)
downloadhaskell-f203e63c6ff92bde63a206a58ea63ec082033b8a.tar.gz
Move more constants into platformConstants
Diffstat (limited to 'compiler/codeGen')
-rw-r--r--compiler/codeGen/CgCallConv.hs60
-rw-r--r--compiler/codeGen/CgTailCall.lhs7
-rw-r--r--compiler/codeGen/CgUtils.hs8
3 files changed, 40 insertions, 35 deletions
diff --git a/compiler/codeGen/CgCallConv.hs b/compiler/codeGen/CgCallConv.hs
index 9b3fcecd36..2be57893dd 100644
--- a/compiler/codeGen/CgCallConv.hs
+++ b/compiler/codeGen/CgCallConv.hs
@@ -34,7 +34,6 @@ import SMRep
import OldCmm
import CLabel
-import Constants
import CgStackery
import ClosureInfo( CgRep(..), nonVoidArg, idCgRep, cgRepSizeW, isFollowableArg )
import OldCmmUtils
@@ -264,7 +263,7 @@ type AssignRegs a = [(CgRep,a)] -- Arg or result values to assign
[(CgRep,a)]) -- Leftover arg or result values
assignCallRegs :: DynFlags -> AssignRegs a
-assignPrimOpCallRegs :: AssignRegs a
+assignPrimOpCallRegs :: DynFlags -> AssignRegs a
assignReturnRegs :: DynFlags -> AssignRegs a
assignCallRegs dflags args
@@ -273,8 +272,8 @@ assignCallRegs dflags args
-- never uses Node for argument passing; instead
-- Node points to the function closure itself
-assignPrimOpCallRegs args
- = assign_regs args (mkRegTbl_allRegs [])
+assignPrimOpCallRegs dflags args
+ = assign_regs args (mkRegTbl_allRegs dflags [])
-- For primops, *all* arguments must be passed in registers
assignReturnRegs dflags args
@@ -334,19 +333,19 @@ assign_reg _ _ = Nothing
useVanillaRegs :: DynFlags -> Int
useVanillaRegs dflags
| platformUnregisterised (targetPlatform dflags) = 0
- | otherwise = mAX_Real_Vanilla_REG
+ | otherwise = mAX_Real_Vanilla_REG dflags
useFloatRegs :: DynFlags -> Int
useFloatRegs dflags
| platformUnregisterised (targetPlatform dflags) = 0
- | otherwise = mAX_Real_Float_REG
+ | otherwise = mAX_Real_Float_REG dflags
useDoubleRegs :: DynFlags -> Int
useDoubleRegs dflags
| platformUnregisterised (targetPlatform dflags) = 0
- | otherwise = mAX_Real_Double_REG
+ | otherwise = mAX_Real_Double_REG dflags
useLongRegs :: DynFlags -> Int
useLongRegs dflags
| platformUnregisterised (targetPlatform dflags) = 0
- | otherwise = mAX_Real_Long_REG
+ | otherwise = mAX_Real_Long_REG dflags
vanillaRegNos, floatRegNos, doubleRegNos, longRegNos :: DynFlags -> [Int]
vanillaRegNos dflags = regList $ useVanillaRegs dflags
@@ -354,11 +353,12 @@ floatRegNos dflags = regList $ useFloatRegs dflags
doubleRegNos dflags = regList $ useDoubleRegs dflags
longRegNos dflags = regList $ useLongRegs dflags
-allVanillaRegNos, allFloatRegNos, allDoubleRegNos, allLongRegNos :: [Int]
-allVanillaRegNos = regList mAX_Vanilla_REG
-allFloatRegNos = regList mAX_Float_REG
-allDoubleRegNos = regList mAX_Double_REG
-allLongRegNos = regList mAX_Long_REG
+allVanillaRegNos, allFloatRegNos, allDoubleRegNos, allLongRegNos
+ :: DynFlags -> [Int]
+allVanillaRegNos dflags = regList $ mAX_Vanilla_REG dflags
+allFloatRegNos dflags = regList $ mAX_Float_REG dflags
+allDoubleRegNos dflags = regList $ mAX_Double_REG dflags
+allLongRegNos dflags = regList $ mAX_Long_REG dflags
regList :: Int -> [Int]
regList n = [1 .. n]
@@ -371,25 +371,29 @@ type AvailRegs = ( [Int] -- available vanilla regs.
mkRegTbl :: DynFlags -> [GlobalReg] -> AvailRegs
mkRegTbl dflags regs_in_use
- = mkRegTbl' regs_in_use (vanillaRegNos dflags)
- (floatRegNos dflags)
- (doubleRegNos dflags)
- (longRegNos dflags)
-
-mkRegTbl_allRegs :: [GlobalReg] -> AvailRegs
-mkRegTbl_allRegs regs_in_use
- = mkRegTbl' regs_in_use allVanillaRegNos allFloatRegNos allDoubleRegNos allLongRegNos
-
-mkRegTbl' :: [GlobalReg] -> [Int] -> [Int] -> [Int] -> [Int]
+ = mkRegTbl' dflags regs_in_use
+ vanillaRegNos floatRegNos doubleRegNos longRegNos
+
+mkRegTbl_allRegs :: DynFlags -> [GlobalReg] -> AvailRegs
+mkRegTbl_allRegs dflags regs_in_use
+ = mkRegTbl' dflags regs_in_use
+ allVanillaRegNos allFloatRegNos allDoubleRegNos allLongRegNos
+
+mkRegTbl' :: DynFlags -> [GlobalReg]
+ -> (DynFlags -> [Int])
+ -> (DynFlags -> [Int])
+ -> (DynFlags -> [Int])
+ -> (DynFlags -> [Int])
-> ([Int], [Int], [Int], [Int])
-mkRegTbl' regs_in_use vanillas floats doubles longs
+mkRegTbl' dflags regs_in_use vanillas floats doubles longs
= (ok_vanilla, ok_float, ok_double, ok_long)
where
- ok_vanilla = mapCatMaybes (select (\i -> VanillaReg i VNonGcPtr)) vanillas
+ ok_vanilla = mapCatMaybes (select (\i -> VanillaReg i VNonGcPtr))
+ (vanillas dflags)
-- ptrhood isn't looked at, hence we can use any old rep.
- ok_float = mapCatMaybes (select FloatReg) floats
- ok_double = mapCatMaybes (select DoubleReg) doubles
- ok_long = mapCatMaybes (select LongReg) longs
+ ok_float = mapCatMaybes (select FloatReg) (floats dflags)
+ ok_double = mapCatMaybes (select DoubleReg) (doubles dflags)
+ ok_long = mapCatMaybes (select LongReg) (longs dflags)
select :: (Int -> GlobalReg) -> Int{-cand-} -> Maybe Int
-- one we've unboxed the Int, we make a GlobalReg
diff --git a/compiler/codeGen/CgTailCall.lhs b/compiler/codeGen/CgTailCall.lhs
index 5f5ff90e54..3e64e6007d 100644
--- a/compiler/codeGen/CgTailCall.lhs
+++ b/compiler/codeGen/CgTailCall.lhs
@@ -413,11 +413,12 @@ tailCallPrimCall primcall
tailCallPrim :: CLabel -> [StgArg] -> Code
tailCallPrim lbl args
- = do { -- We're going to perform a normal-looking tail call,
+ = do { dflags <- getDynFlags
+ -- We're going to perform a normal-looking tail call,
-- except that *all* the arguments will be in registers.
-- Hence the ASSERT( null leftovers )
- arg_amodes <- getArgAmodes args
- ; let (arg_regs, leftovers) = assignPrimOpCallRegs arg_amodes
+ ; arg_amodes <- getArgAmodes args
+ ; let (arg_regs, leftovers) = assignPrimOpCallRegs dflags arg_amodes
live_regs = Just $ map snd arg_regs
jump_to_primop = jumpToLbl lbl live_regs
diff --git a/compiler/codeGen/CgUtils.hs b/compiler/codeGen/CgUtils.hs
index 64b116dc60..228c5bd2c6 100644
--- a/compiler/codeGen/CgUtils.hs
+++ b/compiler/codeGen/CgUtils.hs
@@ -299,11 +299,11 @@ callerSaveVolatileRegs dflags vols = (caller_save, caller_load)
vol_list = case vols of Nothing -> all_of_em; Just regs -> regs
- all_of_em = [ VanillaReg n VNonGcPtr | n <- [0..mAX_Vanilla_REG] ]
+ all_of_em = [ VanillaReg n VNonGcPtr | n <- [0 .. mAX_Vanilla_REG dflags] ]
-- The VNonGcPtr is a lie, but I don't think it matters
- ++ [ FloatReg n | n <- [0..mAX_Float_REG] ]
- ++ [ DoubleReg n | n <- [0..mAX_Double_REG] ]
- ++ [ LongReg n | n <- [0..mAX_Long_REG] ]
+ ++ [ FloatReg n | n <- [0 .. mAX_Float_REG dflags] ]
+ ++ [ DoubleReg n | n <- [0 .. mAX_Double_REG dflags] ]
+ ++ [ LongReg n | n <- [0 .. mAX_Long_REG dflags] ]
callerSaveGlobalReg reg next
| callerSaves platform reg =