~cypheon/rapid

6e9050bed735f874d06eb5ba37a367f34c2b871c — Johann Rudloff 11 months ago d1fcd00 cps-indexed
Switch to use CPSI for main compiler
1 files changed, 20 insertions(+), 5 deletions(-)

M src/Compiler/Codegen/LLVM.idr
M src/Compiler/Codegen/LLVM.idr => src/Compiler/Codegen/LLVM.idr +20 -5
@@ 15,11 15,15 @@ import Compiler.VMCode
import Libraries.Utils.Path

import Compiler.CPS
import Compiler.CPSI
import Compiler.CPSLift
import Compiler.CPSPrepare
import Data.Utils
import Rapid.Common
import Rapid.Driver

%hide Data.Utils.showSep

shell : List String -> String
shell args = showSep " " $ map shellQuote args
  where


@@ 94,12 98,23 @@ compile defs tmpDir outputDir term outfile = do

  cd <- getCompileData False Cases term
  coreLift_ $ fPutStrLn stderr $ "got compiledata"
  let mainExpr = forget (cd.mainExpr)
  let mainExpr = cd.mainExpr
  let mainName = MN "__mainExpression" 0
  let allFunctionsRaw = (mainName, emptyFC, MkNmFun [] mainExpr)::cd.namedDefs
  let allFunctions = map transformDef allFunctionsRaw

  cps <- for allFunctions (\(n, fc, d) => pure (n, fc, !(defToCPS d)))
  let allFunctionsRaw = (mainName, emptyFC, MkFun [] mainExpr)::cd.cseDefs
  let allFunctions = map prepareDef allFunctionsRaw
  coreLift_ $ fPutStrLn stderr $ "preparation complete"
  let funCount = length allFunctions
  cpsRaw <- for (enumerate allFunctions) (\(i, (n, fc, d)) => do
    coreLift_ $ fPutStrLn stderr $ "CPS transform def \{show i}/\{show funCount}: \{show n}"
    pure (n, fc, CPSI.defToCPS d))
  coreLift_ $ fPutStrLn stderr $ "cps transform complete"

  --let cps = cpsRaw <&> (\(n, fc, d) => (n, fc, (forgetDef d)))
  cps <- for (enumerate cpsRaw) (\(i, (n, fc, d)) => do
    coreLift_ $ fPutStrLn stderr $ "CPS forget def \{show i}/\{show funCount}: \{show n}"
    pure (n, fc, forgetDef d))
  coreLift_ $ fPutStrLn stderr $ "forget complete"
  --cps <- for allFunctions (\(n, fc, d) => pure (n, fc, !(defToCPS d)))
  liftedCps <- liftDefs cps

  coreLift_ $ fPutStrLn stderr $ "got lifted CPS defs"