Commit f1a72b29 authored by dterei's avatar dterei

Remove LlvmAs phase as the llvm opt tool now handles this phase

This phase originally invoked the llvm-as tool that turns a textual
llvm assembly file into a bit code file for the rest of llvm to deal
with. Now the llvm opt tool can do this itself, so we don't need to
use llvm-as anymore.
parent ab1845f0
......@@ -80,9 +80,8 @@ data Phase
| SplitMangle -- after mangler if splitting
| SplitAs
| As
| LlvmAs -- LLVM assembly to bitcode file
| LlvmOpt -- Run LLVM opt tool over llvm assembly
| LlvmLlc -- LLVM bitcode to native assembly
| LlvmOpt -- Run LLVM opt tool over llvm assembly
| LlvmLlc -- LLVM bitcode to native assembly
| CmmCpp -- pre-process Cmm source
| Cmm -- parse & compile Cmm code
......@@ -112,7 +111,6 @@ eqPhase Mangle Mangle = True
eqPhase SplitMangle SplitMangle = True
eqPhase SplitAs SplitAs = True
eqPhase As As = True
eqPhase LlvmAs LlvmAs = True
eqPhase LlvmOpt LlvmOpt = True
eqPhase LlvmLlc LlvmLlc = True
eqPhase CmmCpp CmmCpp = True
......@@ -139,9 +137,8 @@ nextPhase HCc = Mangle
nextPhase Mangle = SplitMangle
nextPhase SplitMangle = As
nextPhase As = SplitAs
nextPhase LlvmAs = LlvmOpt
nextPhase LlvmOpt = LlvmLlc
nextPhase LlvmLlc = As
nextPhase LlvmOpt = LlvmLlc
nextPhase LlvmLlc = As
nextPhase SplitAs = StopLn
nextPhase Ccpp = As
nextPhase Cc = As
......@@ -169,9 +166,8 @@ startPhase "raw_s" = Mangle
startPhase "split_s" = SplitMangle
startPhase "s" = As
startPhase "S" = As
startPhase "ll" = LlvmAs
startPhase "bc" = LlvmOpt
startPhase "opt_bc" = LlvmLlc
startPhase "ll" = LlvmOpt
startPhase "bc" = LlvmLlc
startPhase "o" = StopLn
startPhase "cmm" = CmmCpp
startPhase "cmmcpp" = Cmm
......@@ -196,9 +192,8 @@ phaseInputExt Cc = "c"
phaseInputExt Mangle = "raw_s"
phaseInputExt SplitMangle = "split_s" -- not really generated
phaseInputExt As = "s"
phaseInputExt LlvmAs = "ll"
phaseInputExt LlvmOpt = "bc"
phaseInputExt LlvmLlc = "opt_bc"
phaseInputExt LlvmOpt = "ll"
phaseInputExt LlvmLlc = "bc"
phaseInputExt SplitAs = "split_s" -- not really generated
phaseInputExt CmmCpp = "cmm"
phaseInputExt Cmm = "cmmcpp"
......@@ -210,7 +205,7 @@ haskellish_src_suffixes, haskellish_suffixes, cish_suffixes,
haskellish_src_suffixes = haskellish_user_src_suffixes ++
[ "hspp", "hscpp", "hcr", "cmm" ]
haskellish_suffixes = haskellish_src_suffixes ++ ["hc", "raw_s"]
cish_suffixes = [ "c", "cpp", "C", "cc", "cxx", "s", "S", "ll", "bc", "opt_bc" ]
cish_suffixes = [ "c", "cpp", "C", "cc", "cxx", "s", "S", "ll", "bc" ]
extcoreish_suffixes = [ "hcr" ]
-- Will not be deleted as temp files:
haskellish_user_src_suffixes = [ "hs", "lhs", "hs-boot", "lhs-boot" ]
......
......@@ -605,7 +605,7 @@ getOutputFilename stop_phase output basename
keep_hc = dopt Opt_KeepHcFiles dflags
keep_raw_s = dopt Opt_KeepRawSFiles dflags
keep_s = dopt Opt_KeepSFiles dflags
keep_bc = dopt Opt_KeepLlvmFiles dflags
keep_bc = dopt Opt_KeepLlvmFiles dflags
myPhaseInputExt HCc = hcsuf
myPhaseInputExt StopLn = osuf
......@@ -619,8 +619,7 @@ getOutputFilename stop_phase output basename
StopLn -> True
Mangle | keep_raw_s -> True
As | keep_s -> True
LlvmAs | keep_bc -> True
LlvmOpt | keep_bc -> True
LlvmOpt | keep_bc -> True
HCc | keep_hc -> True
_other -> False
......@@ -1237,50 +1236,28 @@ runPhase SplitAs _stop hsc_env _basename _suff _input_fn get_output_fn maybe_loc
-----------------------------------------------------------------------------
-- LlvmAs phase
-- LlvmOpt phase
runPhase LlvmAs _stop hsc_env _basename _suff input_fn get_output_fn maybe_loc
runPhase LlvmOpt _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)
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
-----------------------------------------------------------------------------
-- LlvmOpt phase
SysTools.runLlvmOpt dflags
(map SysTools.Option lo_opts
++ [ SysTools.FileOption "" input_fn,
SysTools.Option (llvmOpts !! opt_lvl),
SysTools.Option "-o",
SysTools.FileOption "" output_fn])
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)
return (LlvmLlc, dflags, maybe_loc, output_fn)
where
llvmOpts = ["-O1", "-O2", "-O3"]
-- 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"]
-----------------------------------------------------------------------------
......@@ -1288,22 +1265,22 @@ runPhase LlvmOpt _stop hsc_env _basename _suff input_fn get_output_fn maybe_loc
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)
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
output_fn <- get_output_fn dflags As maybe_loc
SysTools.runLlvmLlc dflags
(map SysTools.Option lc_opts
++ [ -- SysTools.Option "-tailcallopt",
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])
SysTools.Option "-o", SysTools.FileOption "" output_fn])
return (As, dflags, maybe_loc, output_fn)
return (As, dflags, maybe_loc, output_fn)
where
llvmOpts = ["", "-O2", "-O3"]
llvmOpts = ["-O1", "-O2", "-O3"]
-- warning suppression
......@@ -1906,7 +1883,7 @@ hscNextPhase dflags _ hsc_lang =
HscC -> HCc
HscAsm | dopt Opt_SplitObjs dflags -> SplitMangle
| otherwise -> As
HscLlvm -> LlvmAs
HscLlvm -> LlvmOpt
HscNothing -> StopLn
HscInterpreted -> StopLn
_other -> StopLn
......
......@@ -423,7 +423,6 @@ data DynFlags = DynFlags {
opt_a :: [String],
opt_l :: [String],
opt_windres :: [String],
opt_la :: [String], -- LLVM: llvm-as assembler
opt_lo :: [String], -- LLVM: llvm optimiser
opt_lc :: [String], -- LLVM: llc static compiler
......@@ -440,7 +439,6 @@ data DynFlags = DynFlags {
pgm_T :: String,
pgm_sysman :: String,
pgm_windres :: String,
pgm_la :: (String,[Option]), -- LLVM: llvm-as assembler
pgm_lo :: (String,[Option]), -- LLVM: opt llvm optimiser
pgm_lc :: (String,[Option]), -- LLVM: llc static compiler
......@@ -667,7 +665,6 @@ defaultDynFlags =
opt_m = [],
opt_l = [],
opt_windres = [],
opt_la = [],
opt_lo = [],
opt_lc = [],
......@@ -696,7 +693,6 @@ defaultDynFlags =
pgm_T = panic "defaultDynFlags: No pgm_T",
pgm_sysman = panic "defaultDynFlags: No pgm_sysman",
pgm_windres = panic "defaultDynFlags: No pgm_windres",
pgm_la = panic "defaultDynFlags: No pgm_la",
pgm_lo = panic "defaultDynFlags: No pgm_lo",
pgm_lc = panic "defaultDynFlags: No pgm_lc",
-- end of initSysTools values
......@@ -787,9 +783,9 @@ getVerbFlag dflags
setObjectDir, setHiDir, setStubDir, setOutputDir, setDylibInstallName,
setObjectSuf, setHiSuf, setHcSuf, parseDynLibLoaderMode,
setPgmP, setPgmL, setPgmF, setPgmc, setPgmm, setPgms, setPgma, setPgml, setPgmdll, setPgmwindres,
setPgmla, setPgmlo, setPgmlc,
addOptL, addOptP, addOptF, addOptc, addOptm, addOpta, addOptl, addOptwindres, addOptla, addOptlo,
addOptlc, addCmdlineFramework, addHaddockOpts
setPgmlo, setPgmlc,
addOptL, addOptP, addOptF, addOptc, addOptm, addOpta, addOptl, addOptwindres, addOptlo, addOptlc,
addCmdlineFramework, addHaddockOpts
:: String -> DynFlags -> DynFlags
setOutputFile, setOutputHi, setDumpPrefixForce
:: Maybe String -> DynFlags -> DynFlags
......@@ -833,7 +829,6 @@ setPgma f d = d{ pgm_a = (f,[])}
setPgml f d = d{ pgm_l = (f,[])}
setPgmdll f d = d{ pgm_dll = (f,[])}
setPgmwindres f d = d{ pgm_windres = f}
setPgmla f d = d{ pgm_la = (f,[])}
setPgmlo f d = d{ pgm_lo = (f,[])}
setPgmlc f d = d{ pgm_lc = (f,[])}
......@@ -845,7 +840,6 @@ addOptm f d = d{ opt_m = f : opt_m d}
addOpta f d = d{ opt_a = f : opt_a d}
addOptl f d = d{ opt_l = f : opt_l d}
addOptwindres f d = d{ opt_windres = f : opt_windres d}
addOptla f d = d{ opt_la = f : opt_la d}
addOptlo f d = d{ opt_lo = f : opt_lo d}
addOptlc f d = d{ opt_lc = f : opt_lc d}
......@@ -1043,7 +1037,6 @@ dynamic_flags = [
------- Specific phases --------------------------------------------
-- need to appear before -pgmL to be parsed as LLVM flags.
, Flag "pgmla" (HasArg (upd . setPgmla)) Supported
, Flag "pgmlo" (HasArg (upd . setPgmlo)) Supported
, Flag "pgmlc" (HasArg (upd . setPgmlc)) Supported
......@@ -1059,7 +1052,6 @@ dynamic_flags = [
, Flag "pgmwindres" (HasArg (upd . setPgmwindres)) Supported
-- need to appear before -optl/-opta to be parsed as LLVM flags.
, Flag "optla" (HasArg (upd . addOptla)) Supported
, Flag "optlo" (HasArg (upd . addOptlo)) Supported
, Flag "optlc" (HasArg (upd . addOptlc)) Supported
......
......@@ -18,7 +18,6 @@ module SysTools (
runAs, runLink, -- [Option] -> IO ()
runMkDLL,
runWindres,
runLlvmAs,
runLlvmOpt,
runLlvmLlc,
......@@ -223,8 +222,7 @@ initSysTools mbMinusB dflags0
ld_prog = gcc_prog
-- figure out llvm location. (TODO: Acutally implement).
; let la_prog = "llvm-as"
lc_prog = "llc"
; let lc_prog = "llc"
lo_prog = "opt"
; return dflags1{
......@@ -244,7 +242,6 @@ initSysTools mbMinusB dflags0
pgm_T = touch_path,
pgm_sysman = top_dir ++ "/ghc/rts/parallel/SysMan",
pgm_windres = windres_path,
pgm_la = (la_prog,[]),
pgm_lo = (lo_prog,[]),
pgm_lc = (lc_prog,[])
-- Hans: this isn't right in general, but you can
......@@ -392,11 +389,6 @@ runAs dflags args = do
mb_env <- getGccEnv args1
runSomethingFiltered dflags id "Assembler" p args1 mb_env
runLlvmAs :: DynFlags -> [Option] -> IO ()
runLlvmAs dflags args = do
let (p,args0) = pgm_la dflags
runSomething dflags "LLVM Assembler" p (args0++args)
runLlvmOpt :: DynFlags -> [Option] -> IO ()
runLlvmOpt dflags args = do
let (p,args0) = pgm_lo dflags
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment