From 62db9295ba79d5229585fb08530fff944179c609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Mon, 11 Mar 2019 14:44:28 +0300 Subject: Remove duplicate functions in StgCmmUtils, use functions from CgUtils Also remove unused arg from get_Regtable_addr_from_offset --- 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 6a2840294a..0ff9bd8b56 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 64af5c579c..766584e2c9 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) ------------------------------------------------------------------------- -- -- cgit v1.2.1