summaryrefslogtreecommitdiff
path: root/compiler/cmm/CmmCPSData.hs
diff options
context:
space:
mode:
authorMichael D. Adams <t-madams@microsoft.com>2007-05-23 11:27:29 +0000
committerMichael D. Adams <t-madams@microsoft.com>2007-05-23 11:27:29 +0000
commita50f11ebc0667355e5669c922adf70f926c1763a (patch)
tree090364f8563a5e9c6533f3f663ad727daf2a9443 /compiler/cmm/CmmCPSData.hs
parent9a740fb96076fe9e02a62e391a905c6ca6d3a571 (diff)
downloadhaskell-a50f11ebc0667355e5669c922adf70f926c1763a.tar.gz
Factored proc-point analysis into separate file (compiler/cmm/CmmProcPoint)
Diffstat (limited to 'compiler/cmm/CmmCPSData.hs')
-rw-r--r--compiler/cmm/CmmCPSData.hs74
1 files changed, 74 insertions, 0 deletions
diff --git a/compiler/cmm/CmmCPSData.hs b/compiler/cmm/CmmCPSData.hs
new file mode 100644
index 0000000000..7ea1d40b5e
--- /dev/null
+++ b/compiler/cmm/CmmCPSData.hs
@@ -0,0 +1,74 @@
+module CmmCPSData (
+ blocksToBlockEnv,
+ BrokenBlock(..),
+ BlockEntryInfo(..),
+ FinalStmt(..)
+ ) where
+
+#include "HsVersions.h"
+
+import Cmm
+import CLabel
+
+import UniqFM
+
+-- A minor helper (TODO document)
+blocksToBlockEnv :: [BrokenBlock] -> BlockEnv BrokenBlock
+blocksToBlockEnv blocks = listToUFM $ map (\b -> (brokenBlockId b, b)) blocks
+
+data BrokenBlock
+ = BrokenBlock {
+ brokenBlockId :: BlockId, -- Like a CmmBasicBlock
+ brokenBlockEntry :: BlockEntryInfo,
+ -- How this block can be entered
+
+ brokenBlockStmts :: [CmmStmt],
+ -- Like a CmmBasicBlock
+ -- (but without the last statement)
+
+ brokenBlockTargets :: [BlockId],
+ -- Blocks that this block could
+ -- branch to one either by conditional
+ -- branches or via the last statement
+
+ brokenBlockExit :: FinalStmt
+ -- How the block can be left
+ }
+
+data BlockEntryInfo
+ = FunctionEntry -- Beginning of a function
+ CLabel -- The function name
+ CmmFormals -- Aguments to function
+
+ | ContinuationEntry -- Return point of a call
+ CmmFormals -- return values (argument to continuation)
+ -- TODO:
+ -- | ProcPointEntry -- no return values, but some live might end up as params or possibly in the frame
+
+ | ControlEntry -- A label in the input
+
+-- Final statement in a BlokenBlock
+-- Constructors and arguments match those in Cmm,
+-- but are restricted to branches, returns, jumps, calls and switches
+data FinalStmt
+ = FinalBranch
+ BlockId -- next block (must be a ControlEntry)
+
+ | FinalReturn
+ CmmActuals -- return values
+
+ | FinalJump
+ CmmExpr -- the function to call
+ CmmActuals -- arguments to call
+
+ | FinalCall
+ BlockId -- next block after call (must be a ContinuationEntry)
+ CmmCallTarget -- the function to call
+ CmmFormals -- results from call (redundant with ContinuationEntry)
+ CmmActuals -- arguments to call
+ (Maybe [GlobalReg]) -- registers that must be saved (TODO)
+
+ | FinalSwitch
+ CmmExpr [Maybe BlockId] -- Table branch
+
+ -- TODO: | ProcPointExit (needed?)