{-# LANGUAGE CPP #-}

-- | Flags à la GHC
module Gibbon.DynFlags
  ( DynFlags(..), GeneralFlag(..), DebugFlag(..)
  , defaultDynFlags, dynflagsParser
  , gopt, gopt_set, dopt, dopt_set
  ) where

#if !MIN_VERSION_base(4,11,0)
import Data.Monoid
#endif
import Data.Set as S
import Options.Applicative

data GeneralFlag
  = Opt_Gibbon1            -- ^ Set Opt_No_RemoveCopies & Opt_BigInfiniteRegions
  | Opt_Gibbon2            -- ^ Set Opt_RemoveCopies & Opt_InfiniteRegions
  | Opt_RemoveCopies       -- ^ Calls to copy functions are converted to indirections
  | Opt_No_RemoveCopies    -- ^ Unset Opt_RemoveCopies
  | Opt_InfiniteRegions    -- ^ Use infinite regions
  | Opt_BigInfiniteRegions -- ^ Use big infinite regions
  | Opt_BenchPrint         -- ^ Should the benchamrked function have its output printed?
  | Opt_Packed             -- ^ Use packed representation
  | Opt_Pointer            -- ^ Use pointer representation
  | Opt_BumpAlloc          -- ^ Use bump-pointer allocation if using the non-packed backend
  | Opt_Warnc              -- ^ Show warnings from the C compiler
  | Opt_DisableGC          -- ^ Don't run the the garbage collector (used by Codegen).
  | Opt_No_PureAnnot       -- ^ Don't use 'pure' annotations (a GCC optimization)
  | Opt_Fusion             -- ^ Enable fusion.
  | Opt_Parallel           -- ^ Fork/join parallelism.
  | Opt_RegionOnSpawn      -- ^ Allocate into fresh regions for every spawn, not steal.
  | Opt_GhcTc              -- ^ Typecheck with GHC before compiling with Gibbon.
  | Opt_RelativeOffsets    -- ^ Enable relative offsets.
  | Opt_CountParRegions    -- ^ Count and print the number of regions allocated for parallelism.
  | Opt_CountAllRegions    -- ^ Count and print the number of all the regions allocated.
  | Opt_RtsDebug           -- ^ Compile the RTS in debugging mode.
  | Opt_PrintGcStats       -- ^ Record and print GC statistics.
  | Opt_GenGc              -- ^ Use the new generational GC.
  | Opt_NoEagerPromote     -- ^ Disable eager promotion.
  | Opt_SimpleWriteBarrier -- ^ Disables eliminate-indirection-chains optimization.
  deriving (Int -> GeneralFlag -> ShowS
[GeneralFlag] -> ShowS
GeneralFlag -> String
(Int -> GeneralFlag -> ShowS)
-> (GeneralFlag -> String)
-> ([GeneralFlag] -> ShowS)
-> Show GeneralFlag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GeneralFlag -> ShowS
showsPrec :: Int -> GeneralFlag -> ShowS
$cshow :: GeneralFlag -> String
show :: GeneralFlag -> String
$cshowList :: [GeneralFlag] -> ShowS
showList :: [GeneralFlag] -> ShowS
Show,ReadPrec [GeneralFlag]
ReadPrec GeneralFlag
Int -> ReadS GeneralFlag
ReadS [GeneralFlag]
(Int -> ReadS GeneralFlag)
-> ReadS [GeneralFlag]
-> ReadPrec GeneralFlag
-> ReadPrec [GeneralFlag]
-> Read GeneralFlag
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS GeneralFlag
readsPrec :: Int -> ReadS GeneralFlag
$creadList :: ReadS [GeneralFlag]
readList :: ReadS [GeneralFlag]
$creadPrec :: ReadPrec GeneralFlag
readPrec :: ReadPrec GeneralFlag
$creadListPrec :: ReadPrec [GeneralFlag]
readListPrec :: ReadPrec [GeneralFlag]
Read,GeneralFlag -> GeneralFlag -> Bool
(GeneralFlag -> GeneralFlag -> Bool)
-> (GeneralFlag -> GeneralFlag -> Bool) -> Eq GeneralFlag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GeneralFlag -> GeneralFlag -> Bool
== :: GeneralFlag -> GeneralFlag -> Bool
$c/= :: GeneralFlag -> GeneralFlag -> Bool
/= :: GeneralFlag -> GeneralFlag -> Bool
Eq,Eq GeneralFlag
Eq GeneralFlag
-> (GeneralFlag -> GeneralFlag -> Ordering)
-> (GeneralFlag -> GeneralFlag -> Bool)
-> (GeneralFlag -> GeneralFlag -> Bool)
-> (GeneralFlag -> GeneralFlag -> Bool)
-> (GeneralFlag -> GeneralFlag -> Bool)
-> (GeneralFlag -> GeneralFlag -> GeneralFlag)
-> (GeneralFlag -> GeneralFlag -> GeneralFlag)
-> Ord GeneralFlag
GeneralFlag -> GeneralFlag -> Bool
GeneralFlag -> GeneralFlag -> Ordering
GeneralFlag -> GeneralFlag -> GeneralFlag
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: GeneralFlag -> GeneralFlag -> Ordering
compare :: GeneralFlag -> GeneralFlag -> Ordering
$c< :: GeneralFlag -> GeneralFlag -> Bool
< :: GeneralFlag -> GeneralFlag -> Bool
$c<= :: GeneralFlag -> GeneralFlag -> Bool
<= :: GeneralFlag -> GeneralFlag -> Bool
$c> :: GeneralFlag -> GeneralFlag -> Bool
> :: GeneralFlag -> GeneralFlag -> Bool
$c>= :: GeneralFlag -> GeneralFlag -> Bool
>= :: GeneralFlag -> GeneralFlag -> Bool
$cmax :: GeneralFlag -> GeneralFlag -> GeneralFlag
max :: GeneralFlag -> GeneralFlag -> GeneralFlag
$cmin :: GeneralFlag -> GeneralFlag -> GeneralFlag
min :: GeneralFlag -> GeneralFlag -> GeneralFlag
Ord)

-- | Exactly like GHC's ddump flags.
data DebugFlag
  = Opt_D_Dump_Repair
  | Opt_D_Dump_ParAlloc
  | Opt_D_DumpToFile
  | Opt_D_Dump_Hs
  deriving (Int -> DebugFlag -> ShowS
[DebugFlag] -> ShowS
DebugFlag -> String
(Int -> DebugFlag -> ShowS)
-> (DebugFlag -> String)
-> ([DebugFlag] -> ShowS)
-> Show DebugFlag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DebugFlag -> ShowS
showsPrec :: Int -> DebugFlag -> ShowS
$cshow :: DebugFlag -> String
show :: DebugFlag -> String
$cshowList :: [DebugFlag] -> ShowS
showList :: [DebugFlag] -> ShowS
Show, ReadPrec [DebugFlag]
ReadPrec DebugFlag
Int -> ReadS DebugFlag
ReadS [DebugFlag]
(Int -> ReadS DebugFlag)
-> ReadS [DebugFlag]
-> ReadPrec DebugFlag
-> ReadPrec [DebugFlag]
-> Read DebugFlag
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS DebugFlag
readsPrec :: Int -> ReadS DebugFlag
$creadList :: ReadS [DebugFlag]
readList :: ReadS [DebugFlag]
$creadPrec :: ReadPrec DebugFlag
readPrec :: ReadPrec DebugFlag
$creadListPrec :: ReadPrec [DebugFlag]
readListPrec :: ReadPrec [DebugFlag]
Read, DebugFlag -> DebugFlag -> Bool
(DebugFlag -> DebugFlag -> Bool)
-> (DebugFlag -> DebugFlag -> Bool) -> Eq DebugFlag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DebugFlag -> DebugFlag -> Bool
== :: DebugFlag -> DebugFlag -> Bool
$c/= :: DebugFlag -> DebugFlag -> Bool
/= :: DebugFlag -> DebugFlag -> Bool
Eq, Eq DebugFlag
Eq DebugFlag
-> (DebugFlag -> DebugFlag -> Ordering)
-> (DebugFlag -> DebugFlag -> Bool)
-> (DebugFlag -> DebugFlag -> Bool)
-> (DebugFlag -> DebugFlag -> Bool)
-> (DebugFlag -> DebugFlag -> Bool)
-> (DebugFlag -> DebugFlag -> DebugFlag)
-> (DebugFlag -> DebugFlag -> DebugFlag)
-> Ord DebugFlag
DebugFlag -> DebugFlag -> Bool
DebugFlag -> DebugFlag -> Ordering
DebugFlag -> DebugFlag -> DebugFlag
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: DebugFlag -> DebugFlag -> Ordering
compare :: DebugFlag -> DebugFlag -> Ordering
$c< :: DebugFlag -> DebugFlag -> Bool
< :: DebugFlag -> DebugFlag -> Bool
$c<= :: DebugFlag -> DebugFlag -> Bool
<= :: DebugFlag -> DebugFlag -> Bool
$c> :: DebugFlag -> DebugFlag -> Bool
> :: DebugFlag -> DebugFlag -> Bool
$c>= :: DebugFlag -> DebugFlag -> Bool
>= :: DebugFlag -> DebugFlag -> Bool
$cmax :: DebugFlag -> DebugFlag -> DebugFlag
max :: DebugFlag -> DebugFlag -> DebugFlag
$cmin :: DebugFlag -> DebugFlag -> DebugFlag
min :: DebugFlag -> DebugFlag -> DebugFlag
Ord)

-- Coming soon ...
-- data WarningFlag

data DynFlags = DynFlags { DynFlags -> Set GeneralFlag
generalFlags :: Set GeneralFlag
                         , DynFlags -> Set DebugFlag
debugFlags :: Set DebugFlag }
  deriving (Int -> DynFlags -> ShowS
[DynFlags] -> ShowS
DynFlags -> String
(Int -> DynFlags -> ShowS)
-> (DynFlags -> String) -> ([DynFlags] -> ShowS) -> Show DynFlags
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DynFlags -> ShowS
showsPrec :: Int -> DynFlags -> ShowS
$cshow :: DynFlags -> String
show :: DynFlags -> String
$cshowList :: [DynFlags] -> ShowS
showList :: [DynFlags] -> ShowS
Show,ReadPrec [DynFlags]
ReadPrec DynFlags
Int -> ReadS DynFlags
ReadS [DynFlags]
(Int -> ReadS DynFlags)
-> ReadS [DynFlags]
-> ReadPrec DynFlags
-> ReadPrec [DynFlags]
-> Read DynFlags
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS DynFlags
readsPrec :: Int -> ReadS DynFlags
$creadList :: ReadS [DynFlags]
readList :: ReadS [DynFlags]
$creadPrec :: ReadPrec DynFlags
readPrec :: ReadPrec DynFlags
$creadListPrec :: ReadPrec [DynFlags]
readListPrec :: ReadPrec [DynFlags]
Read,DynFlags -> DynFlags -> Bool
(DynFlags -> DynFlags -> Bool)
-> (DynFlags -> DynFlags -> Bool) -> Eq DynFlags
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DynFlags -> DynFlags -> Bool
== :: DynFlags -> DynFlags -> Bool
$c/= :: DynFlags -> DynFlags -> Bool
/= :: DynFlags -> DynFlags -> Bool
Eq,Eq DynFlags
Eq DynFlags
-> (DynFlags -> DynFlags -> Ordering)
-> (DynFlags -> DynFlags -> Bool)
-> (DynFlags -> DynFlags -> Bool)
-> (DynFlags -> DynFlags -> Bool)
-> (DynFlags -> DynFlags -> Bool)
-> (DynFlags -> DynFlags -> DynFlags)
-> (DynFlags -> DynFlags -> DynFlags)
-> Ord DynFlags
DynFlags -> DynFlags -> Bool
DynFlags -> DynFlags -> Ordering
DynFlags -> DynFlags -> DynFlags
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: DynFlags -> DynFlags -> Ordering
compare :: DynFlags -> DynFlags -> Ordering
$c< :: DynFlags -> DynFlags -> Bool
< :: DynFlags -> DynFlags -> Bool
$c<= :: DynFlags -> DynFlags -> Bool
<= :: DynFlags -> DynFlags -> Bool
$c> :: DynFlags -> DynFlags -> Bool
> :: DynFlags -> DynFlags -> Bool
$c>= :: DynFlags -> DynFlags -> Bool
>= :: DynFlags -> DynFlags -> Bool
$cmax :: DynFlags -> DynFlags -> DynFlags
max :: DynFlags -> DynFlags -> DynFlags
$cmin :: DynFlags -> DynFlags -> DynFlags
min :: DynFlags -> DynFlags -> DynFlags
Ord)

defaultDynFlags :: DynFlags
defaultDynFlags :: DynFlags
defaultDynFlags = DynFlags { generalFlags :: Set GeneralFlag
generalFlags = Set GeneralFlag
forall a. Set a
S.empty
                           , debugFlags :: Set DebugFlag
debugFlags = Set DebugFlag
forall a. Set a
S.empty }

-- | Test whether a 'GeneralFlag' is set
gopt :: GeneralFlag -> DynFlags -> Bool
gopt :: GeneralFlag -> DynFlags -> Bool
gopt GeneralFlag
f DynFlags
dflags  = GeneralFlag
f GeneralFlag -> Set GeneralFlag -> Bool
forall a. Ord a => a -> Set a -> Bool
`S.member` DynFlags -> Set GeneralFlag
generalFlags DynFlags
dflags

gopt_set :: GeneralFlag -> DynFlags -> DynFlags
gopt_set :: GeneralFlag -> DynFlags -> DynFlags
gopt_set GeneralFlag
f DynFlags
dflags = DynFlags
dflags { generalFlags :: Set GeneralFlag
generalFlags = GeneralFlag -> Set GeneralFlag -> Set GeneralFlag
forall a. Ord a => a -> Set a -> Set a
S.insert GeneralFlag
f (DynFlags -> Set GeneralFlag
generalFlags DynFlags
dflags) }

dopt :: DebugFlag -> DynFlags -> Bool
dopt :: DebugFlag -> DynFlags -> Bool
dopt DebugFlag
f DynFlags
dflags = DebugFlag
f DebugFlag -> Set DebugFlag -> Bool
forall a. Ord a => a -> Set a -> Bool
`S.member` DynFlags -> Set DebugFlag
debugFlags DynFlags
dflags

dopt_set :: DebugFlag -> DynFlags -> DynFlags
dopt_set :: DebugFlag -> DynFlags -> DynFlags
dopt_set DebugFlag
f DynFlags
dflags = DynFlags
dflags { debugFlags :: Set DebugFlag
debugFlags = DebugFlag -> Set DebugFlag -> Set DebugFlag
forall a. Ord a => a -> Set a -> Set a
S.insert DebugFlag
f (DynFlags -> Set DebugFlag
debugFlags DynFlags
dflags) }

dynflagsParser :: Parser DynFlags
dynflagsParser :: Parser DynFlags
dynflagsParser = Set GeneralFlag -> Set DebugFlag -> DynFlags
DynFlags (Set GeneralFlag -> Set DebugFlag -> DynFlags)
-> Parser (Set GeneralFlag) -> Parser (Set DebugFlag -> DynFlags)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ([GeneralFlag] -> Set GeneralFlag
forall a. Ord a => [a] -> Set a
S.fromList ([GeneralFlag] -> Set GeneralFlag)
-> Parser [GeneralFlag] -> Parser (Set GeneralFlag)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser GeneralFlag -> Parser [GeneralFlag]
forall a. Parser a -> Parser [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many Parser GeneralFlag
gflagsParser) Parser (Set DebugFlag -> DynFlags)
-> Parser (Set DebugFlag) -> Parser DynFlags
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ([DebugFlag] -> Set DebugFlag
forall a. Ord a => [a] -> Set a
S.fromList ([DebugFlag] -> Set DebugFlag)
-> Parser [DebugFlag] -> Parser (Set DebugFlag)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser DebugFlag -> Parser [DebugFlag]
forall a. Parser a -> Parser [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many Parser DebugFlag
dflagsParser)
  where
    gflagsParser :: Parser GeneralFlag
    gflagsParser :: Parser GeneralFlag
gflagsParser = -- Default Opt_Gibbon2
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_Gibbon1 (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"gibbon1" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<>
                                      String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Gibbon1 mode") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   -- Default Opt_RemoveCopies
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_No_RemoveCopies (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"no-rcopies" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<>
                                              String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Calls to copy functions are *not* converted to indirections") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   -- Default Opt_InfiniteRegions
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_BigInfiniteRegions (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"biginf" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<>
                                                 String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Use big infinite regions") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_BenchPrint (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"bench-print" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<>
                                         String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Print the output of the benchmarked function, rather than #t") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_Packed (Char -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'p' Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<>
                                     String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"packed" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<>
                                     String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Enable packed tree representation in C backend") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_Pointer (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"pointer" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<>
                                      String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Enable pointer-based trees in C backend (default)") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_BumpAlloc (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"bumpalloc" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<>
                                        String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Use BUMPALLOC mode in generated C code.  Only affects --pointer") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_Warnc (Char -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'w' Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<>
                                    String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"warnc" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<>
                                    String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Show warnings from C compiler, normally suppressed") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_DisableGC (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"no-gc" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<>
                                        String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Disable the garbage collector (don't use -g when using this flag).") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_No_PureAnnot (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"no-pure-annot" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<>
                                           String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Don't use 'pure' annotations (a GCC optimization).") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_Fusion (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"fusion" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<>
                                     String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Enable fusion.") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_Parallel (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"parallel" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Enable parallelism") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_RegionOnSpawn (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"region-on-spawn" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Allocate into fresh regions for every spawn, not steal.") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_GhcTc (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"ghc-tc" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Typecheck with GHC before compiling with Gibbon. Output shown with -v3.") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_RelativeOffsets (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"reloffsets" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Enable relative offsets.") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_CountParRegions (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"count-par-regions" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Count and print the number of regions allocated for parallelism.") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_CountAllRegions (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"count-all-regions" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Count and print the number of all the regions allocated.") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_RtsDebug (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"debug-rts" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Compile the RTS in debugging mode.") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_PrintGcStats (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"print-gc-stats" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<> Char -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'S' Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Record and print GC statistics.") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_GenGc (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"gen-gc" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Use the new generational GC.") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_NoEagerPromote (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"no-eager-promote" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Disable eager promotion.") Parser GeneralFlag -> Parser GeneralFlag -> Parser GeneralFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   GeneralFlag -> Mod FlagFields GeneralFlag -> Parser GeneralFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' GeneralFlag
Opt_SimpleWriteBarrier (String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"simple-write-barrier" Mod FlagFields GeneralFlag
-> Mod FlagFields GeneralFlag -> Mod FlagFields GeneralFlag
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields GeneralFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Disables eliminate-indirection-chains optimization.")


    dflagsParser :: Parser DebugFlag
    dflagsParser :: Parser DebugFlag
dflagsParser = DebugFlag -> Mod FlagFields DebugFlag -> Parser DebugFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' DebugFlag
Opt_D_Dump_Repair (String -> Mod FlagFields DebugFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"ddump-repair" Mod FlagFields DebugFlag
-> Mod FlagFields DebugFlag -> Mod FlagFields DebugFlag
forall a. Semigroup a => a -> a -> a
<>
                                            String -> Mod FlagFields DebugFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Dump some information while running RepairProgram") Parser DebugFlag -> Parser DebugFlag -> Parser DebugFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   DebugFlag -> Mod FlagFields DebugFlag -> Parser DebugFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' DebugFlag
Opt_D_Dump_ParAlloc (String -> Mod FlagFields DebugFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"ddump-paralloc" Mod FlagFields DebugFlag
-> Mod FlagFields DebugFlag -> Mod FlagFields DebugFlag
forall a. Semigroup a => a -> a -> a
<>
                                             String -> Mod FlagFields DebugFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Dump the AST after ParAlloc") Parser DebugFlag -> Parser DebugFlag -> Parser DebugFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   DebugFlag -> Mod FlagFields DebugFlag -> Parser DebugFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' DebugFlag
Opt_D_DumpToFile (String -> Mod FlagFields DebugFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"ddump-to-file" Mod FlagFields DebugFlag
-> Mod FlagFields DebugFlag -> Mod FlagFields DebugFlag
forall a. Semigroup a => a -> a -> a
<>
                                           String -> Mod FlagFields DebugFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Dump output to files instead of stdout.") Parser DebugFlag -> Parser DebugFlag -> Parser DebugFlag
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                   DebugFlag -> Mod FlagFields DebugFlag -> Parser DebugFlag
forall a. a -> Mod FlagFields a -> Parser a
flag' DebugFlag
Opt_D_Dump_Hs (String -> Mod FlagFields DebugFlag
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"ddump-hs" Mod FlagFields DebugFlag
-> Mod FlagFields DebugFlag -> Mod FlagFields DebugFlag
forall a. Semigroup a => a -> a -> a
<>
                                        String -> Mod FlagFields DebugFlag
forall (f :: * -> *) a. String -> Mod f a
help String
"Dump GHC compliant source code after all the L1 passes are done.")