[commit: ghc] wip/T10137: Add a overview comment to CmmCreateSwitchPlan (8257cbe)

git at git.haskell.org git at git.haskell.org
Tue Mar 10 08:05:07 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/T10137
Link       : http://ghc.haskell.org/trac/ghc/changeset/8257cbe459ef40ec08338e622de2d82236305e08/ghc

>---------------------------------------------------------------

commit 8257cbe459ef40ec08338e622de2d82236305e08
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Tue Mar 10 09:04:31 2015 +0100

    Add a overview comment to CmmCreateSwitchPlan
    
    that explains its purpose and the division between CmmCreateSwitchPlan
    and CmmSwitch.


>---------------------------------------------------------------

8257cbe459ef40ec08338e622de2d82236305e08
 compiler/cmm/CmmCreateSwitchPlans.hs | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/compiler/cmm/CmmCreateSwitchPlans.hs b/compiler/cmm/CmmCreateSwitchPlans.hs
index 570ed6e..1b3ecb4 100644
--- a/compiler/cmm/CmmCreateSwitchPlans.hs
+++ b/compiler/cmm/CmmCreateSwitchPlans.hs
@@ -14,6 +14,21 @@ import CmmSwitch
 import UniqSupply
 import DynFlags
 
+
+--
+-- This module replaces Switch statements as generated by the Stg -> Cmm
+-- transformation, which might be huge and sparse and hence unsuitable for
+-- assembly code, by proper constructs (if-then-else trees, dense jump tables).
+--
+-- The actual, abstract strategy is determined by createSwitchPlan in
+-- CmmSwitch and returned as a SwitchPlan; here is just the implementation in
+-- terms of Cmm code. See Note [Cmm Switches, the general plan] in CmmSwitch.
+--
+-- This division into different modules is both to clearly separte concerns, 
+-- but also because createSwitchPlan needs access to the constructors of
+-- SwitchTargets, a data type exported abstractly by CmmSwitch.
+--
+
 cmmCreateSwitchPlans :: DynFlags -> CmmGraph -> UniqSM CmmGraph
 cmmCreateSwitchPlans dflags g = do
     blocks' <- concat <$> mapM (visitSwitches dflags) (toBlockList g)



More information about the ghc-commits mailing list