From: Norman Ramsey Date: Sat, 8 Sep 2007 15:51:41 +0000 (+0000) Subject: implement the outOfLine primitive in MkZipCfg (proposed as mkBlock) X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=0967b989b62abe69e0cd74ac563dbde200f7f3c5 implement the outOfLine primitive in MkZipCfg (proposed as mkBlock) --- diff --git a/compiler/cmm/MkZipCfg.hs b/compiler/cmm/MkZipCfg.hs index 10068b8..385b41d 100644 --- a/compiler/cmm/MkZipCfg.hs +++ b/compiler/cmm/MkZipCfg.hs @@ -3,7 +3,7 @@ module MkZipCfg ( AGraph, (<*>), emptyAGraph, withFreshLabel, withUnique , mkMiddle, mkMiddles, mkLast, mkZTail, mkBranch, mkLabel, mkIfThenElse, mkWhileDo - , mkBlock + , outOfLine , emptyGraph, graphOfMiddles, graphOfZTail , lgraphOfAGraph, graphOfAGraph, labelAGraph ) @@ -13,6 +13,7 @@ import ZipCfg import Outputable import Unique +import UniqFM import UniqSupply import Prelude hiding (zip, unzip, last) @@ -171,21 +172,21 @@ withFreshLabel :: String -> (BlockId -> AGraph m l) -> AGraph m l withUnique :: (Unique -> AGraph m l) -> AGraph m l -mkBlock :: AGraph m l -> AGraph m l --- ^ --- The argument is an AGraph that has an +outOfLine :: (LastNode l, Outputable m, Outputable l) + => AGraph m l -> AGraph m l +-- ^ The argument is an AGraph that has an -- empty entry sequence and no exit sequence. -- The result is a new AGraph that has an empty entry sequence -- connected to an empty exit sequence, with the original graph -- sitting to the side out-of-line. -- -- Example: mkMiddle (x = 3) --- <*> mkBlock (mkLabel L <*> ...stuff...) +-- <*> outOfLine (mkLabel L <*> ...stuff...) -- <*> mkMiddle (y = x) -- Control will flow directly from x=3 to y=x; -- the block starting with L is "on the side". -- --- N.B. algebraically for any g, g' g <*> mkBlock g' == mkBlock g' <*> g +-- N.B. algebraically forall g g' : g <*> outOfLine g' == outOfLine g' <*> g @@ -291,7 +292,12 @@ withUnique ofU = AGraph f let AGraph f' = ofU u f' g -mkBlock = undefined +outOfLine (AGraph f) = AGraph f' + where f' (Graph tail' blocks') = + do Graph emptyEntrance blocks <- f emptyGraph + note_this_code_becomes_unreachable emptyEntrance + return $ Graph tail' (blocks `plusUFM` blocks') + mkIfThenElse cbranch tbranch fbranch = withFreshLabel "end of if" $ \endif ->