yhccore-0.9.1: Yhc's Internal Core language.

Yhc.Core.Simplify

Synopsis

Documentation

coreSimplifyExpr :: CoreExpr -> CoreExprSource

Simplify a single Core Expr.

Performs NO inlining, guaranteed to run in same or better space and time. May increase code size.

Bugs lurk here, with inadvertant free variable capture. Move to a proper free variable monad and a guarantee of uniqueness

coreSimplifyCaseCon :: CoreExpr -> CoreExprSource

Apply the Case (CoreCon ..) rule This rule has a serious sharing bug (doh!)

coreSimplifyCaseCase :: CoreExpr -> CoreExprSource

Apply the Case (Case ..) rule

coreSimplifyCaseLet :: CoreExpr -> CoreExprSource

Apply the Case (Let ..) rule

coreSimplifyExprUnique :: UniqueIdM m => CoreExpr -> m CoreExprSource

Precondition: All variables must be unique

The following patterns must not occur:

CoreApp _ [] CoreLet [] _ CoreLam [] _ CorePos _ _

CoreCase on _ => on notElem {CoreCon _, CoreApp (CoreCon _) _, CoreLet _ _, CoreCase _ _} CoreApp x _ => x notElem {CoreApp _ _, CoreLet _ _, CoreCase _ _, CoreLam _ _} CoreLet bind _ => all (map snd bind) notElem {CoreLet _ _, CoreVar _}

The following should be applied if possible (and not breaking sharing):

CoreLet bind x => replaceFreeVars bind x CoreLet (CoreCase x alts) => CoreCase x (CoreLet inside each alt)

coreSimplifyExprUniqueExt :: UniqueIdM m => ((CoreExpr -> m CoreExpr) -> CoreExpr -> m CoreExpr) -> CoreExpr -> m CoreExprSource

Sismplify in an extensible manner.

myfunc retransform

You should invoke retransform on all constructors you create.