X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FstgSyn%2FCoreToStg.lhs;h=94b0dd3f8e17baf4175afe964b9b7ac913f38260;hp=bdb3a6622d7edfcafb47cd9dca5d3649cd50d6ce;hb=ad94d40948668032189ad22a0ad741ac1f645f50;hpb=d5934bbb856aa0aa620c9b2e0fa51c90a1a5a048 diff --git a/compiler/stgSyn/CoreToStg.lhs b/compiler/stgSyn/CoreToStg.lhs index bdb3a66..94b0dd3 100644 --- a/compiler/stgSyn/CoreToStg.lhs +++ b/compiler/stgSyn/CoreToStg.lhs @@ -7,6 +7,13 @@ And, as we have the info in hand, we may convert some lets to let-no-escapes. \begin{code} +{-# 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/CodingStyle#Warnings +-- for details + module CoreToStg ( coreToStg, coreExprToStg ) where #include "HsVersions.h" @@ -16,11 +23,9 @@ import CoreUtils ( rhsIsStatic, manifestArity, exprType, findDefault ) import StgSyn import Type -import Coercion ( mkUnsafeCoercion ) -import TyCon ( isAlgTyCon ) +import TyCon import Id import Var ( Var, globalIdDetails, idType ) -import TyCon ( isUnboxedTupleTyCon, isPrimTyCon, isFunTyCon, isHiBootTyCon ) import IdInfo import DataCon import CostCentre ( noCCS ) @@ -318,15 +323,11 @@ coreToStgExpr (Note (SCC cc) expr) = coreToStgExpr expr `thenLne` ( \ (expr2, fvs, escs) -> returnLne (StgSCC cc expr2, fvs, escs) ) -coreToStgExpr (Note (TickBox m n) expr) +coreToStgExpr (Case (Var id) _bndr ty [(DEFAULT,[],expr)]) + | Just (TickBox m n) <- isTickBoxOp_maybe id = coreToStgExpr expr `thenLne` ( \ (expr2, fvs, escs) -> returnLne (StgTick m n expr2, fvs, escs) ) --- BinaryTickBox'es are are removed by the CorePrep pass. - -coreToStgExpr expr@(Note (BinaryTickBox m t e) _) - = pprPanic "coreToStgExpr: " (ppr expr) - coreToStgExpr (Note other_note expr) = coreToStgExpr expr @@ -415,10 +416,11 @@ coreToStgExpr (Let bind body) mkStgAltType scrut_ty alts = case splitTyConApp_maybe (repType scrut_ty) of Just (tc,_) | isUnboxedTupleTyCon tc -> UbxTupAlt tc - | isPrimTyCon tc -> PrimAlt tc + | isUnLiftedTyCon tc -> PrimAlt tc | isHiBootTyCon tc -> look_for_better_tycon | isAlgTyCon tc -> AlgAlt tc | isFunTyCon tc -> PolyAlt + | isPrimTyCon tc -> PolyAlt -- for "Any" | otherwise -> pprPanic "mkStgAlts" (ppr tc) Nothing -> PolyAlt @@ -452,6 +454,7 @@ coreToStgApp -> [CoreArg] -- Arguments -> LneM (StgExpr, FreeVarsInfo, EscVarsSet) + coreToStgApp maybe_thunk_body f args = coreToStgArgs args `thenLne` \ (args', args_fvs) -> lookupVarLne f `thenLne` \ how_bound -> @@ -505,10 +508,11 @@ coreToStgApp maybe_thunk_body f args res_ty = exprType (mkApps (Var f) args) app = case globalIdDetails f of DataConWorkId dc | saturated -> StgConApp dc args' - PrimOpId op -> ASSERT( saturated ) - StgOpApp (StgPrimOp op) args' res_ty + PrimOpId op -> ASSERT( saturated ) + StgOpApp (StgPrimOp op) args' res_ty FCallId call -> ASSERT( saturated ) StgOpApp (StgFCallOp call (idUnique f)) args' res_ty + TickBoxOpId {} -> pprPanic "coreToStg TickBox" $ ppr (f,args') _other -> StgApp f args' in @@ -549,6 +553,21 @@ coreToStgArgs (arg : args) -- Non-type argument StgLit lit -> StgLitArg lit _ -> pprPanic "coreToStgArgs" (ppr arg) in + -- WARNING: what if we have an argument like (v `cast` co) + -- where 'co' changes the representation type? + -- (This really only happens if co is unsafe.) + -- Then all the getArgAmode stuff in CgBindery will set the + -- cg_rep of the CgIdInfo based on the type of v, rather + -- than the type of 'co'. + -- This matters particularly when the function is a primop + -- or foreign call. + -- Wanted: a better solution than this hacky warning + let + arg_ty = exprType arg + stg_arg_ty = stgArgType stg_arg + in + WARN( isUnLiftedType arg_ty /= isUnLiftedType stg_arg_ty, + ptext SLIT("Dangerous-looking argument. Probable cause: bad unsafeCoerce#") $$ ppr arg) returnLne (stg_arg : stg_args, fvs) @@ -1084,8 +1103,6 @@ myCollectBinders expr where go bs (Lam b e) = go (b:bs) e go bs e@(Note (SCC _) _) = (reverse bs, e) - go bs e@(Note (TickBox {}) _) = (reverse bs, e) - go bs e@(Note (BinaryTickBox {}) _) = (reverse bs, e) go bs (Cast e co) = go bs e go bs (Note _ e) = go bs e go bs e = (reverse bs, e) @@ -1099,8 +1116,6 @@ myCollectArgs expr go (Var v) as = (v, as) go (App f a) as = go f (a:as) go (Note (SCC _) e) as = pprPanic "CoreToStg.myCollectArgs" (ppr expr) - go (Note (TickBox {}) e) as = pprPanic "CoreToStg.myCollectArgs" (ppr expr) - go (Note (BinaryTickBox {}) e) as = pprPanic "CoreToStg.myCollectArgs" (ppr expr) go (Cast e co) as = go e as go (Note n e) as = go e as go _ as = pprPanic "CoreToStg.myCollectArgs" (ppr expr)