X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fcmm%2FMkZipCfg.hs;h=067e74956c8e08750f451dd51ea3323583014192;hb=e4db45612e3efa59251239e1e0b8a0440783b966;hp=7df775fa90974f6d6d43b55012766048a1e7d226;hpb=0f4cdf0261a0dcdade830ea89664ab58efd61ab3;p=ghc-hetmet.git diff --git a/compiler/cmm/MkZipCfg.hs b/compiler/cmm/MkZipCfg.hs index 7df775f..067e749 100644 --- a/compiler/cmm/MkZipCfg.hs +++ b/compiler/cmm/MkZipCfg.hs @@ -1,6 +1,7 @@ {-# LANGUAGE ScopedTypeVariables #-} module MkZipCfg - ( AGraph, (<*>), emptyAGraph, withFreshLabel, withUnique + ( AGraph, (<*>), catAGraphs + , emptyAGraph, withFreshLabel, withUnique , mkMiddle, mkMiddles, mkLast, mkZTail, mkBranch, mkLabel, mkIfThenElse, mkWhileDo , outOfLine , emptyGraph, graphOfMiddles, graphOfZTail @@ -14,6 +15,7 @@ import Outputable import Unique import UniqFM import UniqSupply +import Util import Prelude hiding (zip, unzip, last) @@ -153,6 +155,8 @@ representation is agnostic on this point.) infixr 3 <*> (<*>) :: AGraph m l -> AGraph m l -> AGraph m l +catAGraphs :: [AGraph m l] -> AGraph m l + -- | A graph is built up by splicing together graphs each containing a -- single node (where a label is considered a 'first' node. The empty -- graph is a left and right unit for splicing. All of the AGraph @@ -247,6 +251,8 @@ newtype AGraph m l = AGraph (Graph m l -> UniqSM (Graph m l)) AGraph f1 <*> AGraph f2 = AGraph f where f g = f2 g >>= f1 -- note right associativity +catAGraphs = foldr (<*>) emptyAGraph + emptyAGraph = AGraph return graphOfAGraph (AGraph f) = f emptyGraph @@ -345,5 +351,12 @@ Emitting a Branch at this point is fine: goto L1; L2: ...stuff... -} -_unused :: FS.FastString -_unused = undefined + +-- | The string argument to 'freshBlockId' was originally helpful in debugging +-- the Quick C-- compiler, so I have kept it here even though at present it is +-- thrown away at this spot---there's no reason a BlockId couldn't one day carry +-- a string. + +freshBlockId :: String -> UniqSM BlockId +freshBlockId _ = do { u <- getUniqueUs; return $ BlockId u } +