diff options
author | Ian Lynagh <ian@well-typed.com> | 2012-08-07 02:37:46 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2012-08-07 02:37:46 +0100 |
commit | 46b5c197f9f2c8ed012251289400fbc7189b1acb (patch) | |
tree | 2c7dff6a0683de10b48bbb11e9eda60ec6c1e227 /compiler/codeGen/StgCmmUtils.hs | |
parent | f917eeb824cfb7143dde9b12e501d4ddb0049b65 (diff) | |
download | haskell-46b5c197f9f2c8ed012251289400fbc7189b1acb.tar.gz |
Define callerSaves for all platforms
This means that we now generate the same code whatever platform we are
on, which should help avoid changes on one platform breaking the build
on another.
It's also another step towards full cross-compilation.
Diffstat (limited to 'compiler/codeGen/StgCmmUtils.hs')
-rw-r--r-- | compiler/codeGen/StgCmmUtils.hs | 97 |
1 files changed, 9 insertions, 88 deletions
diff --git a/compiler/codeGen/StgCmmUtils.hs b/compiler/codeGen/StgCmmUtils.hs index caecff923b..af2b0203ec 100644 --- a/compiler/codeGen/StgCmmUtils.hs +++ b/compiler/codeGen/StgCmmUtils.hs @@ -57,6 +57,7 @@ import StgCmmClosure import Cmm import BlockId import MkGraph +import CallerSaves import CLabel import CmmUtils @@ -200,7 +201,9 @@ emitRtsCallGen -> Bool -- True <=> CmmSafe call -> FCode () emitRtsCallGen res pkg fun args _vols safe - = do { updfr_off <- getUpdFrameOff + = do { dflags <- getDynFlags + ; updfr_off <- getUpdFrameOff + ; let (caller_save, caller_load) = callerSaveVolatileRegs dflags ; emit caller_save ; call updfr_off ; emit caller_load } @@ -213,7 +216,6 @@ emitRtsCallGen res pkg fun args _vols safe (ForeignConvention CCallConv arg_hints res_hints)) res' args' (args', arg_hints) = unzip args (res', res_hints) = unzip res - (caller_save, caller_load) = callerSaveVolatileRegs fun_expr = mkLblExpr (mkCmmCodeLabel pkg fun) @@ -247,9 +249,11 @@ emitRtsCallGen res pkg fun args _vols safe -- cmm/CmmNode.hs. Right now the workaround is to avoid inlining across -- unsafe foreign calls in rewriteAssignments, but this is strictly -- temporary. -callerSaveVolatileRegs :: (CmmAGraph, CmmAGraph) -callerSaveVolatileRegs = (caller_save, caller_load) +callerSaveVolatileRegs :: DynFlags -> (CmmAGraph, CmmAGraph) +callerSaveVolatileRegs dflags = (caller_save, caller_load) where + platform = targetPlatform dflags + caller_save = catAGraphs (map callerSaveGlobalReg regs_to_save) caller_load = catAGraphs (map callerRestoreGlobalReg regs_to_save) @@ -257,7 +261,7 @@ callerSaveVolatileRegs = (caller_save, caller_load) {- ,SparkHd,SparkTl,SparkBase,SparkLim -} , BaseReg ] - regs_to_save = filter callerSaves system_regs + regs_to_save = filter (callerSaves platform) system_regs callerSaveGlobalReg reg = mkStore (get_GlobalReg_addr reg) (CmmReg (CmmGlobal reg)) @@ -295,89 +299,6 @@ get_Regtable_addr_from_offset _rep offset = #endif --- | Returns 'True' if this global register is stored in a caller-saves --- machine register. - -callerSaves :: GlobalReg -> Bool - -#ifdef CALLER_SAVES_Base -callerSaves BaseReg = True -#endif -#ifdef CALLER_SAVES_R1 -callerSaves (VanillaReg 1 _) = True -#endif -#ifdef CALLER_SAVES_R2 -callerSaves (VanillaReg 2 _) = True -#endif -#ifdef CALLER_SAVES_R3 -callerSaves (VanillaReg 3 _) = True -#endif -#ifdef CALLER_SAVES_R4 -callerSaves (VanillaReg 4 _) = True -#endif -#ifdef CALLER_SAVES_R5 -callerSaves (VanillaReg 5 _) = True -#endif -#ifdef CALLER_SAVES_R6 -callerSaves (VanillaReg 6 _) = True -#endif -#ifdef CALLER_SAVES_R7 -callerSaves (VanillaReg 7 _) = True -#endif -#ifdef CALLER_SAVES_R8 -callerSaves (VanillaReg 8 _) = True -#endif -#ifdef CALLER_SAVES_R9 -callerSaves (VanillaReg 9 _) = True -#endif -#ifdef CALLER_SAVES_R10 -callerSaves (VanillaReg 10 _) = True -#endif -#ifdef CALLER_SAVES_F1 -callerSaves (FloatReg 1) = True -#endif -#ifdef CALLER_SAVES_F2 -callerSaves (FloatReg 2) = True -#endif -#ifdef CALLER_SAVES_F3 -callerSaves (FloatReg 3) = True -#endif -#ifdef CALLER_SAVES_F4 -callerSaves (FloatReg 4) = True -#endif -#ifdef CALLER_SAVES_D1 -callerSaves (DoubleReg 1) = True -#endif -#ifdef CALLER_SAVES_D2 -callerSaves (DoubleReg 2) = True -#endif -#ifdef CALLER_SAVES_L1 -callerSaves (LongReg 1) = True -#endif -#ifdef CALLER_SAVES_Sp -callerSaves Sp = True -#endif -#ifdef CALLER_SAVES_SpLim -callerSaves SpLim = True -#endif -#ifdef CALLER_SAVES_Hp -callerSaves Hp = True -#endif -#ifdef CALLER_SAVES_HpLim -callerSaves HpLim = True -#endif -#ifdef CALLER_SAVES_CCCS -callerSaves CCCS = True -#endif -#ifdef CALLER_SAVES_CurrentTSO -callerSaves CurrentTSO = True -#endif -#ifdef CALLER_SAVES_CurrentNursery -callerSaves CurrentNursery = True -#endif -callerSaves _ = False - - -- ----------------------------------------------------------------------------- -- Information about global registers |