Commit 0dc9f1c7 authored by ian@well-typed.com's avatar ian@well-typed.com
Browse files

Merge branch 'master' of darcs.haskell.org:/srv/darcs//ghc

parents 3f90064f 571ecdd8
......@@ -53,6 +53,8 @@ data OptKind m -- Suppose the flag is -f
| AnySuffix (String -> EwM m ()) -- -f or -farg; pass entire "-farg" to fn
| PrefixPred (String -> Bool) (String -> EwM m ())
| AnySuffixPred (String -> Bool) (String -> EwM m ())
| VersionSuffix (Int -> Int -> EwM m ())
-- -f or -f=maj.min; pass major and minor version to fn
--------------------------------------------------------
......@@ -196,6 +198,13 @@ processOneArg opt_kind rest arg args
AnySuffix f -> Right (f dash_arg, args)
AnySuffixPred _ f -> Right (f dash_arg, args)
VersionSuffix f | [maj_s, min_s] <- split '.' rest_no_eq,
Just maj <- parseInt maj_s,
Just min <- parseInt min_s -> Right (f maj min, args)
| [maj_s] <- split '.' rest_no_eq,
Just maj <- parseInt maj_s -> Right (f maj 0, args)
| otherwise -> Left ("malformed version argument in " ++ dash_arg)
findArg :: [Flag m] -> String -> Maybe (String, OptKind m)
findArg spec arg =
......@@ -222,6 +231,7 @@ arg_ok (OptPrefix _) _ _ = True
arg_ok (PassFlag _) rest _ = null rest
arg_ok (AnySuffix _) _ _ = True
arg_ok (AnySuffixPred p _) _ arg = p arg
arg_ok (VersionSuffix _) _ _ = True
-- | Parse an Int
--
......
......@@ -1436,7 +1436,8 @@ runPhase LlvmLlc input_fn dflags
++ map SysTools.Option lc_opts
++ [SysTools.Option tbaa]
++ map SysTools.Option fpOpts
++ map SysTools.Option abiOpts)
++ map SysTools.Option abiOpts
++ map SysTools.Option sseOpts)
return (next_phase, output_fn)
where
......@@ -1462,6 +1463,10 @@ runPhase LlvmLlc input_fn dflags
ArchARM ARMv7 _ _ -> []
_ -> []
sseOpts | isSse4_2Enabled dflags = ["-mattr=+sse42"]
| isSse2Enabled dflags = ["-mattr=+sse2"]
| otherwise = []
-----------------------------------------------------------------------------
-- LlvmMangle phase
......
......@@ -322,8 +322,6 @@ data GeneralFlag
| Opt_EmitExternalCore
| Opt_SharedImplib
| Opt_BuildingCabalPackage
| Opt_SSE2
| Opt_SSE4_2
| Opt_IgnoreDotGhci
| Opt_GhciSandbox
| Opt_GhciHistory
......@@ -711,7 +709,10 @@ data DynFlags = DynFlags {
llvmVersion :: IORef Int,
nextWrapperNum :: IORef Int
nextWrapperNum :: IORef Int,
-- | Machine dependant flags (-m<blah> stuff)
sseVersion :: Maybe (Int, Int) -- (major, minor)
}
class HasDynFlags m where
......@@ -1305,7 +1306,8 @@ defaultDynFlags mySettings =
profAuto = NoProfAuto,
llvmVersion = panic "defaultDynFlags: No llvmVersion",
interactivePrint = Nothing,
nextWrapperNum = panic "defaultDynFlags: No nextWrapperNum"
nextWrapperNum = panic "defaultDynFlags: No nextWrapperNum",
sseVersion = Nothing
}
defaultWays :: Settings -> [Way]
......@@ -2181,13 +2183,7 @@ dynamic_flags = [
, Flag "monly-2-regs" (NoArg (addWarn "The -monly-2-regs flag does nothing; it will be removed in a future GHC release"))
, Flag "monly-3-regs" (NoArg (addWarn "The -monly-3-regs flag does nothing; it will be removed in a future GHC release"))
, Flag "monly-4-regs" (NoArg (addWarn "The -monly-4-regs flag does nothing; it will be removed in a future GHC release"))
, Flag "msse2" (NoArg (setGeneralFlag Opt_SSE2))
, Flag "msse4.2" (NoArg (setGeneralFlag Opt_SSE4_2))
-- at some point we should probably have a single SSE flag that
-- contains the SSE version, instead of having a different flag
-- per version. That would make it easier to e.g. check if SSE2 is
-- enabled as you wouldn't have to check if either Opt_SSE2 or
-- Opt_SSE4_2 is set (as the latter implies the former).
, Flag "msse" (versionSuffix (\maj min d -> d{ sseVersion = Just (maj, min) }))
------ Warning opts -------------------------------------------------
, Flag "W" (NoArg (mapM_ setWarningFlag minusWOpts))
......@@ -2944,6 +2940,9 @@ optIntSuffixM :: (Maybe Int -> DynFlags -> DynP DynFlags)
-> OptKind (CmdLineP DynFlags)
optIntSuffixM fn = OptIntSuffix (\mi -> updM (fn mi))
versionSuffix :: (Int -> Int -> DynFlags -> DynFlags) -> OptKind (CmdLineP DynFlags)
versionSuffix fn = VersionSuffix (\maj min -> upd (fn maj min))
setDumpFlag :: DumpFlag -> OptKind (CmdLineP DynFlags)
setDumpFlag dump_flag = NoArg (setDumpFlag' dump_flag)
......@@ -3411,18 +3410,20 @@ makeDynFlagsConsistent dflags
-- -----------------------------------------------------------------------------
-- SSE
-- TODO: Instead of using a separate predicate (i.e. isSse2Enabled) to
-- check if SSE is enabled, we might have x86-64 imply the -msse2
-- flag.
isSse2Enabled :: DynFlags -> Bool
isSse2Enabled dflags = isSse4_2Enabled dflags || isSse2Enabled'
where
isSse2Enabled' = case platformArch (targetPlatform dflags) of
ArchX86_64 -> -- SSE2 is fixed on for x86_64. It would be
-- possible to make it optional, but we'd need to
-- fix at least the foreign call code where the
-- calling convention specifies the use of xmm regs,
-- and possibly other places.
True
ArchX86 -> gopt Opt_SSE2 dflags
_ -> False
isSse2Enabled dflags = case platformArch (targetPlatform dflags) of
ArchX86_64 -> -- SSE2 is fixed on for x86_64. It would be
-- possible to make it optional, but we'd need to
-- fix at least the foreign call code where the
-- calling convention specifies the use of xmm regs,
-- and possibly other places.
True
ArchX86 -> sseVersion dflags >= Just (2,0)
_ -> False
isSse4_2Enabled :: DynFlags -> Bool
isSse4_2Enabled dflags = gopt Opt_SSE4_2 dflags
isSse4_2Enabled dflags = sseVersion dflags >= Just (4,2)
......@@ -54,9 +54,6 @@ __thread Task *my_task;
# else
ThreadLocalKey currentTaskKey;
# endif
#ifdef llvm_CC_FLAVOR
ThreadLocalKey gctKey;
#endif
#else
Task *my_task;
#endif
......@@ -77,9 +74,6 @@ initTaskManager (void)
#if defined(THREADED_RTS)
#if !defined(MYTASK_USE_TLV)
newThreadLocalKey(&currentTaskKey);
#endif
#if defined(llvm_CC_FLAVOR)
newThreadLocalKey(&gctKey);
#endif
initMutex(&all_tasks_mutex);
#endif
......@@ -115,9 +109,6 @@ freeTaskManager (void)
#if !defined(MYTASK_USE_TLV)
freeThreadLocalKey(&currentTaskKey);
#endif
#if defined(llvm_CC_FLAVOR)
freeThreadLocalKey(&gctKey);
#endif
#endif
tasksInitialized = 0;
......
......@@ -238,12 +238,6 @@ extern __thread Task *my_task;
#else
extern ThreadLocalKey currentTaskKey;
#endif
// LLVM-based compilers do not upport the __thread attribute, so we need
// to store the gct variable as a pthread local storage. We declare the
// key here to keep thread local storage initialization in the same place.
#if defined(llvm_CC_FLAVOR)
extern ThreadLocalKey gctKey;
#endif
#else
extern Task *my_task;
#endif
......
......@@ -52,7 +52,7 @@ extern __thread gc_thread* gct;
// with a C compiler that uses an LLVM back end (clang or llvm-gcc) then we
// use pthread_getspecific() to handle the thread local storage for gct.
#define gct ((gc_thread *)(pthread_getspecific(gctKey)))
#define DECLARE_GCT /* nothing */
#define DECLARE_GCT ThreadLocalKey gctKey;
#elif defined(sparc_HOST_ARCH)
// On SPARC we can't pin gct to a register. Names like %l1 are just offsets
......
......@@ -204,6 +204,10 @@ extern nat n_gc_threads;
extern gc_thread **gc_threads;
#if defined(THREADED_RTS) && defined(llvm_CC_FLAVOR)
extern ThreadLocalKey gctKey;
#endif
#include "EndPrivate.h"
#endif // SM_GCTHREAD_H
......
......@@ -229,6 +229,10 @@ void storageAddCapabilities (nat from, nat to)
}
}
#if defined(THREADED_RTS) && defined(llvm_CC_FLAVOR)
newThreadLocalKey(&gctKey);
#endif
initGcThreads(from, to);
}
......@@ -249,6 +253,9 @@ freeStorage (rtsBool free_heap)
closeMutex(&sm_mutex);
#endif
stgFree(nurseries);
#if defined(THREADED_RTS) && defined(llvm_CC_FLAVOR)
freeThreadLocalKey(&gctKey);
#endif
freeGcThreads();
}
......
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