summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Seipp <austin@well-typed.com>2014-04-21 19:53:59 -0500
committerAustin Seipp <austin@well-typed.com>2014-04-28 04:17:48 -0500
commit41ddcd7d7909224ac891c7b1ced8f2c59cb07dfc (patch)
tree075b59e814869d27144e960196a55bd14b9da0c0
parent6e9a99743cce3195e2f1dafa90068651752a3161 (diff)
downloadhaskell-41ddcd7d7909224ac891c7b1ced8f2c59cb07dfc.tar.gz
ghc: add -march/-mcpu to DynFlags
Currently these are still unused, but now recognized by the command line. Signed-off-by: Austin Seipp <austin@well-typed.com>
-rw-r--r--compiler/main/DynFlags.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 72ebb38fc2..ee84bf587c 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -794,6 +794,9 @@ data DynFlags = DynFlags {
avx512f :: Bool, -- Enable AVX-512 instructions.
avx512pf :: Bool, -- Enable AVX-512 PreFetch Instructions.
+ march :: CPUDesc,
+ mcpu :: CPUDesc,
+
-- | Run-time linker information (what options we need, etc.)
rtldInfo :: IORef (Maybe LinkerInfo),
@@ -1459,6 +1462,8 @@ defaultDynFlags mySettings =
avx512er = False,
avx512f = False,
avx512pf = False,
+ march = Generic,
+ mcpu = Generic,
rtldInfo = panic "defaultDynFlags: no rtldInfo",
rtccInfo = panic "defaultDynFlags: no rtccInfo",
@@ -2388,6 +2393,9 @@ dynamic_flags = [
, Flag "mavx512f" (noArg (\d -> d{ avx512f = True }))
, Flag "mavx512pf" (noArg (\d -> d{ avx512pf = True }))
+ , Flag "march" (HasArg hasMarch)
+ , Flag "mcpu" (HasArg hasMcpu)
+
------ Warning opts -------------------------------------------------
, Flag "W" (NoArg (mapM_ setWarningFlag minusWOpts))
, Flag "Werror" (NoArg (setGeneralFlag Opt_WarnIsError))
@@ -3704,6 +3712,20 @@ setUnsafeGlobalDynFlags :: DynFlags -> IO ()
setUnsafeGlobalDynFlags = writeIORef v_unsafeGlobalDynFlags
-- -----------------------------------------------------------------------------
+-- march/mcpu handling
+
+hasMarch :: String -> DynP ()
+hasMarch s = case descToCPU s of
+ Nothing -> addWarn ("Invalid argument for -march, '"++s++"'")
+ Just x -> do
+ upd (\d -> d { march = x })
+
+hasMcpu :: String -> DynP ()
+hasMcpu s = case descToCPU s of
+ Nothing -> addWarn ("Invalid argument for -mcpu, '"++s++"'")
+ Just x -> upd (\d -> d { mcpu = x })
+
+-- -----------------------------------------------------------------------------
-- SSE and AVX
-- TODO: Instead of using a separate predicate (i.e. isSse2Enabled) to