summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Breitner <mail@joachim-breitner.de>2015-03-10 09:04:31 +0100
committerJoachim Breitner <mail@joachim-breitner.de>2015-03-10 09:04:31 +0100
commit8257cbe459ef40ec08338e622de2d82236305e08 (patch)
tree5d7ebaac5f4da8fbc1be7e9bb5fdce2812b7c815
parent0c8dd275e1dfd79d15ec7fadb2a34e66bc5815b6 (diff)
downloadhaskell-8257cbe459ef40ec08338e622de2d82236305e08.tar.gz
Add a overview comment to CmmCreateSwitchPlan
that explains its purpose and the division between CmmCreateSwitchPlan and CmmSwitch.
-rw-r--r--compiler/cmm/CmmCreateSwitchPlans.hs15
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/cmm/CmmCreateSwitchPlans.hs b/compiler/cmm/CmmCreateSwitchPlans.hs
index 570ed6efb2..1b3ecb4443 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)