X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FcodeGen%2FCgInfoTbls.hs;h=14004ceef88ee21532bcc9892ab4512d7da4cac3;hb=4c6a3f787abcaed009a574196d82237d9ae64fc8;hp=4e38485455089b7eed2d00f3df406744d2943555;hpb=48fb2b521898998a17873ad6cf30610aa5ab6db3;p=ghc-hetmet.git diff --git a/compiler/codeGen/CgInfoTbls.hs b/compiler/codeGen/CgInfoTbls.hs index 4e384854..14004ce 100644 --- a/compiler/codeGen/CgInfoTbls.hs +++ b/compiler/codeGen/CgInfoTbls.hs @@ -1,3 +1,10 @@ +{-# OPTIONS -w #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings +-- for details + ----------------------------------------------------------------------------- -- -- Building info tables. @@ -15,6 +22,7 @@ module CgInfoTbls ( stdInfoTableSizeB, entryCode, closureInfoPtr, getConstrTag, + cmmGetClosureType, infoTable, infoTableClosureType, infoTablePtrs, infoTableNonPtrs, funInfoTable, makeRelativeRefTo @@ -56,7 +64,7 @@ import Outputable -- representation as a list of 'CmmAddr' is handled later -- in the pipeline by 'cmmToRawCmm'. -emitClosureCodeAndInfoTable :: ClosureInfo -> CmmFormals -> CgStmts -> Code +emitClosureCodeAndInfoTable :: ClosureInfo -> CmmFormalsWithoutKinds -> CgStmts -> Code emitClosureCodeAndInfoTable cl_info args body = do { blks <- cgStmtsToBlocks body ; info <- mkCmmInfo cl_info @@ -73,13 +81,11 @@ dataConTagZ con = dataConTag con - fIRST_TAG -- Not used for return points. (The 'smRepClosureTypeInt' call would panic.) mkCmmInfo :: ClosureInfo -> FCode CmmInfo mkCmmInfo cl_info = do - prof <- - if opt_SccProfilingOn + prof <- + if opt_SccProfilingOn then do ty_descr_lit <- mkStringCLit (closureTypeDescr cl_info) cl_descr_lit <- mkStringCLit (closureValDescr cl_info) - return $ ProfilingInfo - (makeRelativeRefTo info_lbl ty_descr_lit) - (makeRelativeRefTo info_lbl cl_descr_lit) + return $ ProfilingInfo ty_descr_lit cl_descr_lit else return $ ProfilingInfo (mkIntCLit 0) (mkIntCLit 0) case cl_info of @@ -233,8 +239,8 @@ stack_layout ((off, bind):binds) sizeW | off == sizeW - 1 = unique = getUnique (cgIdInfoId bind) machRep = argMachRep (cgIdInfoArgRep bind) kind = if isFollowableArg (cgIdInfoArgRep bind) - then KindPtr - else KindNonPtr + then GCKindPtr + else GCKindNonPtr stack_layout binds@((off, _):_) sizeW | otherwise = Nothing : (stack_layout binds (sizeW - 1)) @@ -260,8 +266,8 @@ stack_layout offsets sizeW = result unique = getUnique (cgIdInfoId x) machRep = argMachrep (cgIdInfoArgRep bind) kind = if isFollowableArg (cgIdInfoArgRep bind) - then KindPtr - else KindNonPtr + then GCKindPtr + else GCKindNonPtr -} emitAlgReturnTarget @@ -273,14 +279,24 @@ emitAlgReturnTarget emitAlgReturnTarget name branches mb_deflt fam_sz = do { blks <- getCgStmts $ - emitSwitch tag_expr branches mb_deflt 0 (fam_sz - 1) - -- NB: tag_expr is zero-based + -- is the constructor tag in the node reg? + if isSmallFamily fam_sz + then do -- yes, node has constr. tag + let tag_expr = cmmConstrTag1 (CmmReg nodeReg) + branches' = [(tag+1,branch)|(tag,branch)<-branches] + emitSwitch tag_expr branches' mb_deflt 1 fam_sz + else do -- no, get tag from info table + let -- Note that ptr _always_ has tag 1 + -- when the family size is big enough + untagged_ptr = cmmRegOffB nodeReg (-1) + tag_expr = getConstrTag (untagged_ptr) + emitSwitch tag_expr branches mb_deflt 0 (fam_sz - 1) ; lbl <- emitReturnTarget name blks ; return (lbl, Nothing) } -- Nothing: the internal branches in the switch don't have -- global labels, so we can't use them at the 'call site' where - tag_expr = getConstrTag (CmmReg nodeReg) + uniq = getUnique name -------------------------------- emitReturnInstr :: Code @@ -346,6 +362,14 @@ getConstrTag closure_ptr where info_table = infoTable (closureInfoPtr closure_ptr) +cmmGetClosureType :: CmmExpr -> CmmExpr +-- Takes a closure pointer, and return the closure type +-- obtained from the info table +cmmGetClosureType closure_ptr + = CmmMachOp (MO_U_Conv halfWordRep wordRep) [infoTableClosureType info_table] + where + info_table = infoTable (closureInfoPtr closure_ptr) + infoTable :: CmmExpr -> CmmExpr -- Takes an info pointer (the first word of a closure) -- and returns a pointer to the first word of the standard-form @@ -403,7 +427,7 @@ funInfoTable info_ptr emitInfoTableAndCode :: CLabel -- Label of entry or ret -> CmmInfo -- ...the info table - -> CmmFormals -- ...args + -> CmmFormalsWithoutKinds -- ...args -> [CmmBasicBlock] -- ...and body -> Code