projects
/
ghc-hetmet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4a7fff2
)
implement the outOfLine primitive in MkZipCfg (proposed as mkBlock)
author
Norman Ramsey
<nr@eecs.harvard.edu>
Sat, 8 Sep 2007 15:51:41 +0000
(15:51 +0000)
committer
Norman Ramsey
<nr@eecs.harvard.edu>
Sat, 8 Sep 2007 15:51:41 +0000
(15:51 +0000)
compiler/cmm/MkZipCfg.hs
patch
|
blob
|
history
diff --git
a/compiler/cmm/MkZipCfg.hs
b/compiler/cmm/MkZipCfg.hs
index
10068b8
..
385b41d
100644
(file)
--- 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
module MkZipCfg
( AGraph, (<*>), emptyAGraph, withFreshLabel, withUnique
, mkMiddle, mkMiddles, mkLast, mkZTail, mkBranch, mkLabel, mkIfThenElse, mkWhileDo
- , mkBlock
+ , outOfLine
, emptyGraph, graphOfMiddles, graphOfZTail
, lgraphOfAGraph, graphOfAGraph, labelAGraph
)
, emptyGraph, graphOfMiddles, graphOfZTail
, lgraphOfAGraph, graphOfAGraph, labelAGraph
)
@@
-13,6
+13,7
@@
import ZipCfg
import Outputable
import Unique
import Outputable
import Unique
+import UniqFM
import UniqSupply
import Prelude hiding (zip, unzip, last)
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
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)
-- 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".
--
-- <*> 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
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 ->
mkIfThenElse cbranch tbranch fbranch =
withFreshLabel "end of if" $ \endif ->