Commit d1c1b7d0 authored by simonmar's avatar simonmar
Browse files

[project @ 2005-03-18 13:37:27 by simonmar]

Flags cleanup.

Basically the purpose of this commit is to move more of the compiler's
global state into DynFlags, which is moving in the direction we need
to go for the GHC API which can have multiple active sessions
supported by a single GHC instance.

Before:

$ grep 'global_var' */*hs | wc -l
     78

After:

$ grep 'global_var' */*hs | wc -l
     27

Well, it's an improvement.  Most of what's left won't really affect
our ability to host multiple sessions.

Lots of static flags have become dynamic flags (yay!).  Notably lots
of flags that we used to think of as "driver" flags, like -I and -L,
are now dynamic.  The most notable static flags left behind are the
"way" flags, eg. -prof.  It would be nice to fix this, but it isn't
urgent.

On the way, lots of cleanup has happened.  Everything related to
static and dynamic flags lives in StaticFlags and DynFlags
respectively, and they share a common command-line parser library in
CmdLineParser.  The flags related to modes (--makde, --interactive
etc.) are now private to the front end: in fact private to Main
itself, for now.
parent 6a51f7df
......@@ -112,7 +112,7 @@ import Maybes ( orElse )
import SrcLoc ( SrcLoc )
import Outputable
import Unique ( Unique, mkBuiltinUnique )
import CmdLineOpts ( opt_NoStateHack )
import StaticFlags ( opt_NoStateHack )
-- infixl so you can say (id `set` a `set` b)
infixl 1 `setIdUnfolding`,
......
......@@ -24,7 +24,7 @@ module NewDemand(
#include "HsVersions.h"
import CmdLineOpts ( opt_CprOff )
import StaticFlags ( opt_CprOff )
import BasicTypes ( Arity )
import VarEnv ( VarEnv, emptyVarEnv, isEmptyVarEnv )
import UniqFM ( ufmToList )
......
......@@ -41,7 +41,7 @@ import UniqFM
import Unique ( Unique, deriveUnique, getUnique )
import Util ( zipEqual, foldl2 )
import Maybes ( orElse, isJust )
import CmdLineOpts ( opt_PprStyle_Debug )
import StaticFlags( opt_PprStyle_Debug )
import Outputable
import FastTypes
\end{code}
......
......@@ -99,7 +99,8 @@ module CLabel (
#include "HsVersions.h"
import CmdLineOpts ( DynFlags, opt_Static, opt_DoTickyProfiling )
import DynFlags ( DynFlags )
import StaticFlags ( opt_Static, opt_DoTickyProfiling )
import Packages ( isHomeModule, isDllName )
import DataCon ( ConTag )
import Module ( moduleFS, Module )
......
......@@ -37,7 +37,8 @@ import Literal ( mkMachInt )
import Unique
import UniqFM
import SrcLoc
import CmdLineOpts ( DynFlags, DynFlag(..), opt_SccProfilingOn )
import DynFlags ( DynFlags, DynFlag(..) )
import StaticFlags ( opt_SccProfilingOn )
import ErrUtils ( printError, dumpIfSet_dyn, showPass )
import StringBuffer ( hGetStringBuffer )
import FastString
......
......@@ -37,7 +37,7 @@ import UniqFM ( eltsUFM )
import FastString
import Outputable
import Constants
import CmdLineOpts ( opt_EnsureSplittableC )
import StaticFlags ( opt_SplitObjs )
-- The rest
import Data.List ( intersperse, groupBy )
......@@ -67,8 +67,8 @@ writeCs handle cmms = printForUser handle alwaysQualify (pprCs cmms)
-- ToDo: should be printForC
split_marker
| opt_EnsureSplittableC = ptext SLIT("__STG_SPLIT_MARKER")
| otherwise = empty
| opt_SplitObjs = ptext SLIT("__STG_SPLIT_MARKER")
| otherwise = empty
-- --------------------------------------------------------------------------
-- Now do some real work
......
......@@ -58,7 +58,7 @@ import TyCon ( TyCon, tyConFamilySize )
import Bitmap ( Bitmap, mAX_SMALL_BITMAP_SIZE,
mkBitmap, intsToReverseBitmap )
import Util ( isn'tIn, sortLe )
import CmdLineOpts ( opt_Unregisterised )
import StaticFlags ( opt_Unregisterised )
import FastString ( LitString )
import Outputable
import DATA_BITS
......
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
% $Id: CgCase.lhs,v 1.72 2004/11/26 16:19:59 simonmar Exp $
% $Id: CgCase.lhs,v 1.73 2005/03/18 13:37:38 simonmar Exp $
%
%********************************************************
%* *
......@@ -48,7 +48,7 @@ import CmmUtils ( CmmStmts, noStmts, oneStmt, plusStmts )
import Cmm
import MachOp ( wordRep )
import ClosureInfo ( mkLFArgument )
import CmdLineOpts ( opt_SccProfilingOn )
import StaticFlags ( opt_SccProfilingOn )
import Id ( Id, idName, isDeadBinder, idType )
import ForeignCall ( ForeignCall(..), CCallSpec(..), playSafe )
import VarSet ( varSetElems )
......
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
% $Id: CgClosure.lhs,v 1.66 2004/12/08 14:32:29 simonpj Exp $
% $Id: CgClosure.lhs,v 1.67 2005/03/18 13:37:40 simonmar Exp $
%
\section[CgClosure]{Code generation for closures}
......@@ -42,7 +42,7 @@ import CmmUtils ( CmmStmts, mkStmts, oneStmt, plusStmts, noStmts,
mkLblExpr )
import CLabel
import StgSyn
import CmdLineOpts ( opt_DoTickyProfiling )
import StaticFlags ( opt_DoTickyProfiling )
import CostCentre
import Id ( Id, idName, idType )
import Name ( Name )
......
......@@ -32,7 +32,7 @@ import MachOp
import SMRep
import ForeignCall
import Constants
import CmdLineOpts ( opt_SccProfilingOn )
import StaticFlags ( opt_SccProfilingOn )
import Outputable
import Monad ( when )
......
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
% $Id: CgHeapery.lhs,v 1.43 2005/02/10 13:01:53 simonmar Exp $
% $Id: CgHeapery.lhs,v 1.44 2005/03/18 13:37:42 simonmar Exp $
%
\section[CgHeapery]{Heap management functions}
......@@ -53,7 +53,7 @@ import TyCon ( tyConPrimRep )
import CostCentre ( CostCentreStack )
import Util ( mapAccumL, filterOut )
import Constants ( wORD_SIZE )
import CmdLineOpts ( DynFlags )
import DynFlags ( DynFlags )
import Outputable
import GLAEXTS
......
......@@ -57,7 +57,8 @@ import StgSyn ( SRT(..) )
import Name ( Name )
import DataCon ( DataCon, dataConTag, fIRST_TAG )
import Unique ( Uniquable(..) )
import CmdLineOpts ( opt_SccProfilingOn, DynFlags(..), HscTarget(..) )
import DynFlags ( DynFlags(..), HscTarget(..) )
import StaticFlags ( opt_SccProfilingOn )
import ListSetOps ( assocDefault )
import Maybes ( isJust )
import Constants ( wORD_SIZE, sIZEOF_StgFunInfoExtraRev )
......
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
% $Id: CgMonad.lhs,v 1.43 2004/12/08 14:32:31 simonpj Exp $
% $Id: CgMonad.lhs,v 1.44 2005/03/18 13:37:44 simonmar Exp $
%
\section[CgMonad]{The code generation monad}
......@@ -61,7 +61,7 @@ module CgMonad (
import {-# SOURCE #-} CgBindery ( CgBindings, nukeVolatileBinds )
import CmdLineOpts ( DynFlags )
import DynFlags ( DynFlags )
import Cmm
import CmmUtils ( CmmStmts, isNopStmt )
import CLabel
......
......@@ -12,7 +12,7 @@ import CgMonad
import CgCallConv ( mkRegLiveness )
import Id ( Id )
import Cmm ( CmmLit, GlobalReg(..), node, CmmExpr )
import CmdLineOpts ( opt_GranMacros )
import StaticFlags ( opt_GranMacros )
import Outputable
staticParHdr :: [CmmLit]
......
......@@ -47,7 +47,7 @@ import Module ( moduleUserString )
import Id ( Id )
import CostCentre
import StgSyn ( GenStgExpr(..), StgExpr )
import CmdLineOpts ( opt_SccProfilingOn )
import StaticFlags ( opt_SccProfilingOn )
import FastString ( FastString, mkFastString, LitString )
import Constants -- Lots of field offsets
import Outputable
......
......@@ -53,7 +53,7 @@ import CLabel ( CLabel, mkRtsDataLabel, mkRednCountsLabel )
import Name ( isInternalName )
import Id ( Id, idType )
import CmdLineOpts ( opt_DoTickyProfiling )
import StaticFlags ( opt_DoTickyProfiling )
import BasicTypes ( Arity )
import FastString ( FastString, mkFastString, LitString )
import Constants -- Lots of field offsets
......
......@@ -52,7 +52,7 @@ import CLabel ( CLabel, mkStringLitLabel )
import Digraph ( SCC(..), stronglyConnComp )
import ListSetOps ( assocDefault )
import Util ( filterOut, sortLe )
import CmdLineOpts ( DynFlags(..), HscTarget(..) )
import DynFlags ( DynFlags(..), HscTarget(..) )
import FastString ( LitString, FastString, unpackFS )
import Outputable
......
......@@ -63,7 +63,8 @@ import CLabel
import Constants ( mIN_UPD_SIZE, mIN_SIZE_NonUpdHeapObject )
import Packages ( isDllName )
import CmdLineOpts ( DynFlags, opt_SccProfilingOn, opt_OmitBlackHoling,
import DynFlags ( DynFlags )
import StaticFlags ( opt_SccProfilingOn, opt_OmitBlackHoling,
opt_Parallel, opt_DoTickyProfiling,
opt_SMP )
import Id ( Id, idType, idArity, idName )
......
......@@ -19,8 +19,6 @@ module CodeGen ( codeGen ) where
#include "HsVersions.h"
import DriverState ( v_Build_tag, v_MainModIs )
-- Kludge (??) so that CgExpr is reached via at least one non-SOURCE
-- import. Before, that wasn't the case, and CM therefore didn't
-- bother to compile it.
......@@ -41,8 +39,8 @@ import MachOp ( wordRep, MachHint(..) )
import StgSyn
import PrelNames ( gHC_PRIM, rOOT_MAIN, mAIN, pREL_TOP_HANDLER )
import CmdLineOpts ( DynFlags, DynFlag(..), opt_EnsureSplittableC,
opt_SccProfilingOn )
import DynFlags ( DynFlags(..), DynFlag(..) )
import StaticFlags ( opt_SplitObjs, opt_SccProfilingOn )
import HscTypes ( ForeignStubs(..), TypeEnv, typeEnvTyCons )
import CostCentre ( CollectedCCs )
......@@ -75,8 +73,8 @@ codeGen dflags this_mod type_env foreign_stubs imported_mods
cost_centre_info stg_binds
= do
{ showPass dflags "CodeGen"
; way <- readIORef v_Build_tag
; mb_main_mod <- readIORef v_MainModIs
; let way = buildTag dflags
mb_main_mod = mainModIs dflags
; let tycons = typeEnvTyCons type_env
data_tycons = filter isDataTyCon tycons
......@@ -346,7 +344,7 @@ which refers to this name).
\begin{code}
maybeExternaliseId :: Id -> FCode Id
maybeExternaliseId id
| opt_EnsureSplittableC, -- Externalise the name for -split-objs
| opt_SplitObjs, -- Externalise the name for -split-objs
isInternalName name = do { mod <- moduleName
; returnFC (setIdName id (externalise mod)) }
| otherwise = returnFC id
......
......@@ -42,7 +42,8 @@ import Id ( Id, idType )
import Type ( Type, typePrimRep, PrimRep(..) )
import TyCon ( TyCon, tyConPrimRep )
import MachOp-- ( MachRep(..), MachHint(..), wordRep )
import CmdLineOpts ( opt_SccProfilingOn, opt_GranMacros, opt_Unregisterised )
import StaticFlags ( opt_SccProfilingOn, opt_GranMacros,
opt_Unregisterised )
import Constants
import Outputable
......
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