Permalink
Browse files

Add optimisation level flag to `lcc`.

  • Loading branch information...
1 parent 80cffd6 commit c1bfa58d8dce2db4f1dc1a247cf694f8acabd0c8 @nominolo committed Sep 18, 2012
Showing with 11 additions and 4 deletions.
  1. +9 −3 compiler/Lambdachine/Options.hs
  2. +2 −1 compiler/Main.hs
@@ -10,7 +10,8 @@ data Options = Options
{ inputFile :: FilePath
, package_name :: String
, dumpCoreBinds :: Bool
- , dumpBytecode :: Bool }
+ , dumpBytecode :: Bool
+ , optLevel :: Int }
deriving (Show, Data, Typeable)
options = Options
@@ -19,9 +20,14 @@ options = Options
, dumpCoreBinds = def &= explicit &= name "dump-core-binds"
&= help "Dump GHC's Core."
, dumpBytecode = def &= explicit &= name "dump-bytecode"
- &= help "Dump generated bytecode" }
+ &= help "Dump generated bytecode"
+ , optLevel = def &= opt (0 :: Int) }
&= summary "The Lambdachine Compiler, v0.1"
&= program "lc"
getOptions :: IO Options
-getOptions = cmdArgs options
+getOptions = do
+ opts <- cmdArgs options
+ let level = max 0 (min 2 (optLevel opts))
+ return opts{ optLevel = level }
+
View
@@ -34,7 +34,8 @@ main = do
opts <- Cli.getOptions
runGhc (Just libdir) $ do
dflags0 <- getSessionDynFlags
- let dflags1 = dflags0{ ghcLink = NoLink }
+ let dflags1 = dflags0{ ghcLink = NoLink
+ , optLevel = Cli.optLevel opts }
dflags2 | Cli.package_name opts /= ""
= setPackageName (Cli.package_name opts) dflags1
| otherwise = dflags1

0 comments on commit c1bfa58

Please sign in to comment.