[commit: ghc] master, wip/test-ci-images-commit: Remove duplicate functions in StgCmmUtils, use functions from CgUtils (62db929)

git at git.haskell.org git at git.haskell.org
Tue Mar 12 14:59:32 UTC 2019


Repository : ssh://git@git.haskell.org/ghc

On branches: master,wip/test-ci-images-commit
Link       : http://ghc.haskell.org/trac/ghc/changeset/62db9295ba79d5229585fb08530fff944179c609/ghc

>---------------------------------------------------------------

commit 62db9295ba79d5229585fb08530fff944179c609
Author: Ömer Sinan Ağacan <omeragacan at gmail.com>
Date:   Mon Mar 11 14:44:28 2019 +0300

    Remove duplicate functions in StgCmmUtils, use functions from CgUtils
    
    Also remove unused arg from get_Regtable_addr_from_offset


>---------------------------------------------------------------

62db9295ba79d5229585fb08530fff944179c609
 compiler/codeGen/CgUtils.hs     | 16 ++++++++------
 compiler/codeGen/StgCmmUtils.hs | 46 +----------------------------------------
 2 files changed, 11 insertions(+), 51 deletions(-)

diff --git a/compiler/codeGen/CgUtils.hs b/compiler/codeGen/CgUtils.hs
index 6a28402..0ff9bd8 100644
--- a/compiler/codeGen/CgUtils.hs
+++ b/compiler/codeGen/CgUtils.hs
@@ -8,7 +8,13 @@
 --
 -----------------------------------------------------------------------------
 
-module CgUtils ( fixStgRegisters ) where
+module CgUtils (
+        fixStgRegisters,
+        baseRegOffset,
+        get_Regtable_addr_from_offset,
+        regTableOffset,
+        get_GlobalReg_addr,
+  ) where
 
 import GhcPrelude
 
@@ -104,8 +110,7 @@ baseRegOffset _      UnwindReturnReg     = panic "CgUtils.baseRegOffset:UnwindRe
 get_GlobalReg_addr :: DynFlags -> GlobalReg -> CmmExpr
 get_GlobalReg_addr dflags BaseReg = regTableOffset dflags 0
 get_GlobalReg_addr dflags mid
-    = get_Regtable_addr_from_offset dflags
-                                    (globalRegType dflags mid) (baseRegOffset dflags mid)
+    = get_Regtable_addr_from_offset dflags (baseRegOffset dflags mid)
 
 -- Calculate a literal representing an offset into the register table.
 -- Used when we don't have an actual BaseReg to offset from.
@@ -113,8 +118,8 @@ regTableOffset :: DynFlags -> Int -> CmmExpr
 regTableOffset dflags n =
   CmmLit (CmmLabelOff mkMainCapabilityLabel (oFFSET_Capability_r dflags + n))
 
-get_Regtable_addr_from_offset :: DynFlags -> CmmType -> Int -> CmmExpr
-get_Regtable_addr_from_offset dflags _ offset =
+get_Regtable_addr_from_offset :: DynFlags -> Int -> CmmExpr
+get_Regtable_addr_from_offset dflags offset =
     if haveRegBase (targetPlatform dflags)
     then CmmRegOff baseReg offset
     else regTableOffset dflags offset
@@ -179,4 +184,3 @@ fixStgRegStmt dflags stmt = fixAssign $ mapExpDeep fixExpr stmt
                                                    (wordWidth dflags))]
 
         other_expr -> other_expr
-
diff --git a/compiler/codeGen/StgCmmUtils.hs b/compiler/codeGen/StgCmmUtils.hs
index 64af5c5..766584e 100644
--- a/compiler/codeGen/StgCmmUtils.hs
+++ b/compiler/codeGen/StgCmmUtils.hs
@@ -54,6 +54,7 @@ import CodeGen.Platform
 import CLabel
 import CmmUtils
 import CmmSwitch
+import CgUtils
 
 import ForeignCall
 import IdInfo
@@ -257,51 +258,6 @@ callerSaveVolatileRegs dflags = (caller_save, caller_load)
         = mkAssign (CmmGlobal reg)
                    (CmmLoad (get_GlobalReg_addr dflags reg) (globalRegType dflags reg))
 
--- -----------------------------------------------------------------------------
--- Global registers
-
--- We map STG registers onto appropriate CmmExprs.  Either they map
--- to real machine registers or stored as offsets from BaseReg.  Given
--- a GlobalReg, get_GlobalReg_addr always produces the
--- register table address for it.
--- (See also get_GlobalReg_reg_or_addr in MachRegs)
-
-get_GlobalReg_addr :: DynFlags -> GlobalReg -> CmmExpr
-get_GlobalReg_addr dflags BaseReg = regTableOffset dflags 0
-get_GlobalReg_addr dflags mid
-    = get_Regtable_addr_from_offset dflags
-                                    (globalRegType dflags mid) (baseRegOffset dflags mid)
-
--- Calculate a literal representing an offset into the register table.
--- Used when we don't have an actual BaseReg to offset from.
-regTableOffset :: DynFlags -> Int -> CmmExpr
-regTableOffset dflags n =
-  CmmLit (CmmLabelOff mkMainCapabilityLabel (oFFSET_Capability_r dflags + n))
-
-get_Regtable_addr_from_offset :: DynFlags -> CmmType -> Int -> CmmExpr
-get_Regtable_addr_from_offset dflags _rep offset =
-    if haveRegBase (targetPlatform dflags)
-    then CmmRegOff baseReg offset
-    else regTableOffset dflags offset
-
-
--- -----------------------------------------------------------------------------
--- Information about global registers
-
-baseRegOffset :: DynFlags -> GlobalReg -> Int
-
-baseRegOffset dflags Sp             = oFFSET_StgRegTable_rSp dflags
-baseRegOffset dflags SpLim          = oFFSET_StgRegTable_rSpLim dflags
-baseRegOffset dflags (LongReg 1)    = oFFSET_StgRegTable_rL1 dflags
-baseRegOffset dflags Hp             = oFFSET_StgRegTable_rHp dflags
-baseRegOffset dflags HpLim          = oFFSET_StgRegTable_rHpLim dflags
-baseRegOffset dflags CCCS           = oFFSET_StgRegTable_rCCCS dflags
-baseRegOffset dflags CurrentTSO     = oFFSET_StgRegTable_rCurrentTSO dflags
-baseRegOffset dflags CurrentNursery = oFFSET_StgRegTable_rCurrentNursery dflags
-baseRegOffset dflags HpAlloc        = oFFSET_StgRegTable_rHpAlloc dflags
-baseRegOffset dflags GCEnter1       = oFFSET_stgGCEnter1 dflags
-baseRegOffset dflags GCFun          = oFFSET_stgGCFun dflags
-baseRegOffset _      reg            = pprPanic "StgCmmUtils.baseRegOffset:" (ppr reg)
 
 -------------------------------------------------------------------------
 --



More information about the ghc-commits mailing list