+-- LlvmOpt phase
+
+runPhase LlvmOpt _stop hsc_env _basename _suff input_fn get_output_fn maybe_loc
+ = liftIO $ do
+ let dflags = hsc_dflags hsc_env
+ let lo_opts = getOpts dflags opt_lo
+ let opt_lvl = max 0 (min 2 $ optLevel dflags)
+
+ output_fn <- get_output_fn dflags LlvmLlc maybe_loc
+
+ SysTools.runLlvmOpt dflags
+ (map SysTools.Option lo_opts
+ ++ [ SysTools.FileOption "" input_fn,
+ SysTools.Option (llvmOpts !! opt_lvl),
+ SysTools.Option "-o",
+ SysTools.FileOption "" output_fn])
+
+ return (LlvmLlc, dflags, maybe_loc, output_fn)
+ where
+ -- we always run Opt since we rely on it to fix up some pretty
+ -- big deficiencies in the code we generate
+ llvmOpts = ["-mem2reg", "-O1", "-O2"]
+
+
+-----------------------------------------------------------------------------
+-- LlvmLlc phase
+
+runPhase LlvmLlc _stop hsc_env _basename _suff input_fn get_output_fn maybe_loc
+ = liftIO $ do
+ let dflags = hsc_dflags hsc_env
+ let lc_opts = getOpts dflags opt_lc
+ let opt_lvl = max 0 (min 2 $ optLevel dflags)
+
+ output_fn <- get_output_fn dflags As maybe_loc
+
+ SysTools.runLlvmLlc dflags
+ (map SysTools.Option lc_opts
+ ++ [ -- SysTools.Option "-tailcallopt",
+ SysTools.Option (llvmOpts !! opt_lvl),
+ SysTools.FileOption "" input_fn,
+ SysTools.Option "-o", SysTools.FileOption "" output_fn])
+
+ return (As, dflags, maybe_loc, output_fn)
+ where
+ llvmOpts = ["-O1", "-O2", "-O3"]
+
+
+-- warning suppression
+runPhase other _stop _dflags _basename _suff _input_fn _get_output_fn _maybe_loc =
+ panic ("runPhase: don't know how to run phase " ++ show other)
+-----------------------------------------------------------------------------