From 3599ea7af038d843eb693618f4801366907a55a2 Mon Sep 17 00:00:00 2001 From: simonpj Date: Wed, 8 Dec 2004 15:03:50 +0000 Subject: [PATCH] [project @ 2004-12-08 15:03:50 by simonpj] First commit for new Cmm code generation (branch) --- ghc/compiler/cmm/Cmm.hs | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/ghc/compiler/cmm/Cmm.hs b/ghc/compiler/cmm/Cmm.hs index 9fcc96e..048cb5e 100644 --- a/ghc/compiler/cmm/Cmm.hs +++ b/ghc/compiler/cmm/Cmm.hs @@ -65,6 +65,8 @@ data GenCmmTop d i -- to a label. To jump to the first block in a Proc, -- use the appropriate CLabel. + [GenCmmCont i] -- Continuations declared in this proc + -- some static data. | CmmData Section [d] -- constant values only @@ -93,6 +95,15 @@ blockStmts :: GenBasicBlock i -> [i] blockStmts (BasicBlock _ stmts) = stmts +data GenCmmCont i + = CmmCont + [LocalReg] -- The formal params of the ccntinuation + (GenBasicBlock i) + +type ContId = BlockId -- Continuation is named (in eg + -- also-unwinds-to annotations) via the + -- block-id of its GenBasicBlock + ----------------------------------------------------------------------------- -- CmmStmt -- A "statement". Note that all branches are explicit: there are no @@ -113,10 +124,7 @@ data CmmStmt CmmCallTarget [(CmmReg,MachHint)] -- zero or more results [(CmmExpr,MachHint)] -- zero or more arguments - (Maybe [GlobalReg]) -- Global regs that may need to be saved - -- if they will be clobbered by the call. - -- Nothing <=> save *all* globals that - -- might be clobbered. + Flow | CmmBranch BlockId -- branch to another BB in this fn @@ -131,6 +139,14 @@ data CmmStmt | CmmJump CmmExpr [LocalReg] -- Jump to another function, with these -- parameters. + | CmmSpan CmmSpan [CmmStmt] + +----------------------------------------------------------------------------- +-- CmmSpan +----------------------------------------------------------------------------- + +data CmmSpan = UpdateFrame | CatchFrame -- Etc. + ----------------------------------------------------------------------------- -- CmmCallTarget -- @@ -138,7 +154,9 @@ data CmmStmt ----------------------------------------------------------------------------- data CmmCallTarget - = CmmForeignCall -- Call to a foreign function + = CmmVanillaCall CmmExpr -- Ordinarly call to a Cmm procedure + + | CmmForeignCall -- Call to a foreign function CmmExpr -- literal label <=> static call -- other expression <=> dynamic call CCallConv -- The calling convention @@ -148,6 +166,24 @@ data CmmCallTarget -- code by the backend. ----------------------------------------------------------------------------- +-- Flow +-- +----------------------------------------------------------------------------- + +data Flow + = Flow { normal_live :: FlowEdge () + , also_unwinds :: [FlowEdge ContId] + } + +data FlowEdge a + = FlowEdge { edge_target :: a + , live_locals :: [LocalReg] -- Live across the call + , save_globals :: Maybe [GlobalReg] -- Global regs that may need to be saved + } -- if they will be clobbered by the call. + -- Nothing <=> save *all* globals that + -- might be clobbered + +----------------------------------------------------------------------------- -- CmmExpr -- An expression. Expressions have no side effects. ----------------------------------------------------------------------------- -- 1.7.10.4