Skip to content

Commit

Permalink
[ treeless ] don't generate code for functions that are always inlined
Browse files Browse the repository at this point in the history
  • Loading branch information
UlfNorell committed Nov 6, 2015
1 parent 9f30efb commit 966c296
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/full/Agda/Compiler/MAlonzo/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ definition kit Defn{defName = q, defType = ty, defCompiledRep = compiled, theDef
return ([tsig,def] ++ ccls)

functionViaTreeless :: QName -> CompiledClauses -> TCM [HS.Decl]
functionViaTreeless q cc = do
treeless <- ccToTreeless q cc
functionViaTreeless q cc = caseMaybeM (ccToTreeless q cc) (pure []) $ \ treeless -> do
e <- closedTerm treeless
let (ps, b) =
case stripTopCoerce e of
Expand Down
4 changes: 2 additions & 2 deletions src/full/Agda/Compiler/ToTreeless.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ prettyPure :: P.Pretty a => a -> TCM Doc
prettyPure = return . P.pretty

-- | Converts compiled clauses to treeless syntax.
ccToTreeless :: QName -> CC.CompiledClauses -> TCM C.TTerm
ccToTreeless q cc = ifM (alwaysInline q) (pure C.TErased) $ do
ccToTreeless :: QName -> CC.CompiledClauses -> TCM (Maybe C.TTerm)
ccToTreeless q cc = ifM (alwaysInline q) (pure Nothing) $ Just <$> do
reportSDoc "treeless.opt" 20 $ text "-- compiling" <+> prettyTCM q
reportSDoc "treeless.convert" 30 $ text "-- compiled clauses:" $$ nest 2 (prettyPure cc)
body <- casetreeTop cc
Expand Down
14 changes: 8 additions & 6 deletions src/full/Agda/Compiler/UHC/FromAgda.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import Agda.Compiler.UHC.MagicTypes

import Agda.Compiler.UHC.Bridge as CA

import Agda.Utils.Maybe
import Agda.Utils.Except ( MonadError (catchError) )

#include "undefined.h"
Expand Down Expand Up @@ -117,13 +118,14 @@ translateDefn (n, defini) = do
lift $ reportSDoc "uhc.fromagda" 15 $ text "type:" <+> (text . show) ty
let cc = fromMaybe __IMPOSSIBLE__ $ funCompiled f

funBody <- convertGuards <$> lift (ccToTreeless n cc)
lift $ reportSDoc "uhc.fromagda" 30 $ text " compiled treeless fun:" <+> (text . show) funBody
funBody' <- runTT $ compileTerm funBody
lift $ reportSDoc "uhc.fromagda" 30 $ text " compiled UHC Core fun:" <+> (text . show) funBody'
caseMaybeM (lift $ ccToTreeless n cc) (pure []) $ \ treeless -> do
let funBody = convertGuards treeless
lift $ reportSDoc "uhc.fromagda" 30 $ text " compiled treeless fun:" <+> (text . show) funBody
funBody' <- runTT $ compileTerm funBody
lift $ reportSDoc "uhc.fromagda" 30 $ text " compiled UHC Core fun:" <+> (text . show) funBody'

addExports [crName]
return [mkBind1 crName funBody']
addExports [crName]
return [mkBind1 crName funBody']

Constructor{} | Just n == (nameOfSharp <$> kit) -> do
addExports [crName]
Expand Down

0 comments on commit 966c296

Please sign in to comment.