X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fcmm%2FCmmLive.hs;h=ed659776a8e7bbff11e6a75a48514124f2029867;hp=3797220a225571ffd09d20d1d90fd128a74240e0;hb=edc0bafd3fcd01b85a2e8894e5dfe149eb0e0857;hpb=ad94d40948668032189ad22a0ad741ac1f645f50 diff --git a/compiler/cmm/CmmLive.hs b/compiler/cmm/CmmLive.hs index 3797220..ed65977 100644 --- a/compiler/cmm/CmmLive.hs +++ b/compiler/cmm/CmmLive.hs @@ -1,25 +1,18 @@ -{-# OPTIONS -w #-} --- The above warning supression flag is a temporary kludge. --- While working on this module you are encouraged to remove it and fix --- any warnings in the module. See --- http://hackage.haskell.org/trac/ghc/wiki/CodingStyle#Warnings --- for details - module CmmLive ( CmmLive, BlockEntryLiveness, cmmLiveness, - cmmHintFormalsToLiveLocals, + cmmFormalsToLiveLocals, ) where #include "HsVersions.h" +import BlockId import Cmm import Dataflow import Maybes import Panic -import UniqFM import UniqSet ----------------------------------------------------------------------------- @@ -46,13 +39,13 @@ cmmLiveness blocks = fixedpoint (cmmBlockDependants sources) (cmmBlockUpdate blocks') (map blockId blocks) - (listToUFM [(blockId b, emptyUniqSet) | b <- blocks]) + (mkBlockEnv [(blockId b, emptyUniqSet) | b <- blocks]) where sources :: BlockSources sources = cmmBlockSources blocks blocks' :: BlockStmts - blocks' = listToUFM $ map block_name blocks + blocks' = mkBlockEnv $ map block_name blocks block_name :: CmmBasicBlock -> (BlockId, [CmmStmt]) block_name b = (blockId b, blockStmts b) @@ -74,7 +67,7 @@ cmmLivenessComment live (BasicBlock ident stmts) = -- need updating after a given block is updated in the liveness analysis ----------------------------------------------------------------------------- cmmBlockSources :: [CmmBasicBlock] -> BlockSources -cmmBlockSources blocks = foldr aux emptyUFM blocks +cmmBlockSources blocks = foldr aux emptyBlockEnv blocks where aux :: CmmBasicBlock -> BlockSources @@ -88,7 +81,7 @@ cmmBlockSources blocks = foldr aux emptyUFM blocks -> BlockSources -> BlockSources add_source_edges source target ufm = - addToUFM_Acc (flip addOneToUniqSet) unitUniqSet ufm target source + addToBEnv_Acc (flip addOneToUniqSet) unitUniqSet ufm target source branch_targets :: [CmmStmt] -> UniqSet BlockId branch_targets stmts = @@ -106,7 +99,7 @@ cmmBlockSources blocks = foldr aux emptyUFM blocks ----------------------------------------------------------------------------- cmmBlockDependants :: BlockSources -> BlockId -> [BlockId] cmmBlockDependants sources ident = - uniqSetToList $ lookupWithDefaultUFM sources emptyUniqSet ident + uniqSetToList $ lookupWithDefaultBEnv sources emptyUniqSet ident ----------------------------------------------------------------------------- -- | Given the table of type 'BlockStmts' and a block that was updated, @@ -121,14 +114,14 @@ cmmBlockUpdate :: cmmBlockUpdate blocks node _ state = if (sizeUniqSet old_live) == (sizeUniqSet new_live) then Nothing - else Just $ addToUFM state node new_live + else Just $ extendBlockEnv state node new_live where new_live, old_live :: CmmLive new_live = cmmStmtListLive state block_stmts - old_live = lookupWithDefaultUFM state missing_live node + old_live = lookupWithDefaultBEnv state missing_live node block_stmts :: [CmmStmt] - block_stmts = lookupWithDefaultUFM blocks missing_block node + block_stmts = lookupWithDefaultBEnv blocks missing_block node missing_live = panic "unknown block id during liveness analysis" missing_block = panic "unknown block id during liveness analysis" @@ -163,8 +156,8 @@ addKilled new_killed live = live `minusUniqSet` new_killed -------------------------------- -- Liveness of a CmmStmt -------------------------------- -cmmHintFormalsToLiveLocals :: CmmHintFormals -> [LocalReg] -cmmHintFormalsToLiveLocals formals = map fst formals +cmmFormalsToLiveLocals :: HintedCmmFormals -> [LocalReg] +cmmFormalsToLiveLocals formals = map hintlessCmm formals cmmStmtLive :: BlockEntryLiveness -> CmmStmt -> CmmLivenessTransformer cmmStmtLive _ (CmmNop) = id @@ -179,27 +172,27 @@ cmmStmtLive _ (CmmStore expr1 expr2) = cmmExprLive expr2 . cmmExprLive expr1 cmmStmtLive _ (CmmCall target results arguments _ _) = target_liveness . - foldr ((.) . cmmExprLive) id (map fst arguments) . - addKilled (mkUniqSet $ cmmHintFormalsToLiveLocals results) where + foldr ((.) . cmmExprLive) id (map hintlessCmm arguments) . + addKilled (mkUniqSet $ cmmFormalsToLiveLocals results) where target_liveness = case target of (CmmCallee target _) -> cmmExprLive target (CmmPrim _) -> id cmmStmtLive other_live (CmmBranch target) = - addLive (lookupWithDefaultUFM other_live emptyUniqSet target) + addLive (lookupWithDefaultBEnv other_live emptyUniqSet target) cmmStmtLive other_live (CmmCondBranch expr target) = cmmExprLive expr . - addLive (lookupWithDefaultUFM other_live emptyUniqSet target) + addLive (lookupWithDefaultBEnv other_live emptyUniqSet target) cmmStmtLive other_live (CmmSwitch expr targets) = cmmExprLive expr . (foldr ((.) . (addLive . - lookupWithDefaultUFM other_live emptyUniqSet)) + lookupWithDefaultBEnv other_live emptyUniqSet)) id (mapCatMaybes id targets)) cmmStmtLive _ (CmmJump expr params) = - const (cmmExprLive expr $ foldr ((.) . cmmExprLive) id (map fst params) $ emptyUniqSet) + const (cmmExprLive expr $ foldr ((.) . cmmExprLive) id (map hintlessCmm params) $ emptyUniqSet) cmmStmtLive _ (CmmReturn params) = - const (foldr ((.) . cmmExprLive) id (map fst params) $ emptyUniqSet) + const (foldr ((.) . cmmExprLive) id (map hintlessCmm params) $ emptyUniqSet) -------------------------------- -- Liveness of a CmmExpr @@ -212,6 +205,7 @@ cmmExprLive expr = addLive (mkUniqSet $ expr_liveness expr) where expr_liveness (CmmReg reg) = reg_liveness reg expr_liveness (CmmMachOp _ exprs) = concatMap expr_liveness exprs expr_liveness (CmmRegOff reg _) = reg_liveness reg + expr_liveness (CmmStackSlot _ _) = panic "cmmExprLive CmmStackSlot" reg_liveness :: CmmReg -> [LocalReg] reg_liveness (CmmLocal reg) = [reg]