X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fcmm%2FCmm.hs;h=903853489f14972a0b16d31f1223f85047946455;hp=cae1633366894bbadc22d7a5f831c9e7f9629e14;hb=1f46671fe24c7155ee64091b71b77dd66909e7a0;hpb=207802589da0d23c3f16195f453b24a1e46e322d diff --git a/compiler/cmm/Cmm.hs b/compiler/cmm/Cmm.hs index cae1633..9038534 100644 --- a/compiler/cmm/Cmm.hs +++ b/compiler/cmm/Cmm.hs @@ -7,8 +7,9 @@ ----------------------------------------------------------------------------- module Cmm ( - GenCmm(..), Cmm, - GenCmmTop(..), CmmTop, + GenCmm(..), Cmm, RawCmm, + GenCmmTop(..), CmmTop, RawCmmTop, + CmmInfo(..), ClosureTypeInfo(..), ProfilingInfo(..), GenBasicBlock(..), CmmBasicBlock, blockId, blockStmts, CmmStmt(..), CmmActuals, CmmFormal, CmmFormals, CmmHintFormals, CmmCallTarget(..), @@ -16,7 +17,7 @@ module Cmm ( CmmExpr(..), cmmExprRep, CmmReg(..), cmmRegRep, CmmLit(..), cmmLitRep, - LocalReg(..), localRegRep, Kind(..), + LocalReg(..), localRegRep, localRegGCFollow, Kind(..), BlockId(..), BlockEnv, GlobalReg(..), globalRegRep, @@ -28,6 +29,8 @@ module Cmm ( import MachOp import CLabel import ForeignCall +import SMRep +import ClosureInfo import Unique import UniqFM import FastString @@ -48,15 +51,19 @@ import Data.Word -- (a) Plain C--, i.e. populated with CmmLit and CmmExpr respectively, -- (b) Native code, populated with instructions -- -newtype GenCmm d i = Cmm [GenCmmTop d i] +newtype GenCmm d h i = Cmm [GenCmmTop d h i] -type Cmm = GenCmm CmmStatic CmmStmt +-- | Cmm with the info table as a data type +type Cmm = GenCmm CmmStatic CmmInfo CmmStmt + +-- | Cmm with the info tables converted to a list of 'CmmStatic' +type RawCmm = GenCmm CmmStatic [CmmStatic] CmmStmt -- A top-level chunk, abstracted over the type of the contents of -- the basic blocks (Cmm or instructions are the likely instantiations). -data GenCmmTop d i +data GenCmmTop d h i = CmmProc - [d] -- Info table, may be empty + h -- Extra header such as the info table CLabel -- Used to generate both info & entry labels CmmFormals -- Argument locals live on entry (C-- procedure params) [GenBasicBlock i] -- Code, may be empty. The first block is @@ -71,7 +78,8 @@ data GenCmmTop d i -- some static data. | CmmData Section [d] -- constant values only -type CmmTop = GenCmmTop CmmStatic CmmStmt +type CmmTop = GenCmmTop CmmStatic CmmInfo CmmStmt +type RawCmmTop = GenCmmTop CmmStatic [CmmStatic] CmmStmt -- A basic block containing a single label, at the beginning. -- The list of basic blocks in a top-level code block may be re-ordered. @@ -95,6 +103,43 @@ blockId (BasicBlock blk_id _ ) = blk_id blockStmts :: GenBasicBlock i -> [i] blockStmts (BasicBlock _ stmts) = stmts +----------------------------------------------------------------------------- +-- Info Tables +----------------------------------------------------------------------------- + +-- Info table as a haskell data type +data CmmInfo + = CmmInfo + ProfilingInfo + (Maybe BlockId) -- GC target + ClosureTypeTag -- Int + ClosureTypeInfo + | CmmNonInfo -- Procedure doesn't need an info table + (Maybe BlockId) -- But we still need a GC target for it + +-- TODO: The GC target shouldn't really be part of CmmInfo +-- as it doesn't appear in the resulting info table. +-- It should be factored out. + +data ClosureTypeInfo + = ConstrInfo ClosureLayout ConstrTag ConstrDescription + | FunInfo ClosureLayout C_SRT FunType FunArity ArgDescr SlowEntry + | ThunkInfo ClosureLayout C_SRT + | ThunkSelectorInfo SelectorOffset C_SRT + | ContInfo + [Maybe LocalReg] -- Forced stack parameters + C_SRT + +-- TODO: These types may need refinement +data ProfilingInfo = ProfilingInfo CmmLit CmmLit -- closure_type, closure_desc +type ClosureTypeTag = StgHalfWord +type ClosureLayout = (StgHalfWord, StgHalfWord) -- pts, nptrs +type ConstrTag = StgHalfWord +type ConstrDescription = CmmLit +type FunType = StgHalfWord +type FunArity = StgHalfWord +type SlowEntry = CLabel +type SelectorOffset = StgWord ----------------------------------------------------------------------------- -- CmmStmt @@ -116,6 +161,7 @@ data CmmStmt CmmCallTarget CmmHintFormals -- zero or more results CmmActuals -- zero or more arguments + C_SRT -- SRT for the continuation of the call | CmmBranch BlockId -- branch to another BB in this fn