+
+-----------------------------------------------------------------------------
+-- LlvmAs phase
+
+runPhase LlvmAs _stop hsc_env _basename _suff input_fn get_output_fn maybe_loc
+ = liftIO $ do
+ let dflags = hsc_dflags hsc_env
+ let la_opts = getOpts dflags opt_la
+
+ output_fn <- get_output_fn dflags LlvmOpt maybe_loc
+
+ SysTools.runLlvmAs dflags
+ (map SysTools.Option la_opts
+ ++ [ SysTools.FileOption "" input_fn,
+ SysTools.Option "-o", SysTools.FileOption "" output_fn])
+
+ return (LlvmOpt, dflags, maybe_loc, output_fn)
+
+
+-----------------------------------------------------------------------------
+-- 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)
+
+ -- only run if > 0 OR opt options given by user
+ if opt_lvl /= 0 || lo_opts /= []
+ then do
+ 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)
+
+ else
+ return (LlvmLlc, dflags, maybe_loc, input_fn)
+ where
+ llvmOpts = ["-O1", "-O2", "-O3"]
+
+
+-----------------------------------------------------------------------------
+-- 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 = ["", "-O2", "-O3"]
+
+