%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
-% $Id: AbsCSyn.lhs,v 1.31 2000/07/06 14:08:31 simonmar Exp $
+% $Id: AbsCSyn.lhs,v 1.32 2000/08/02 14:13:26 rrt Exp $
%
\section[AbstractC]{Abstract C: the last stop before machine code}
| REGISTER_FOREIGN_EXPORT -- register a foreign exported fun
| REGISTER_IMPORT -- register an imported module
+ | REGISTER_DIMPORT -- register an imported module from
+ -- another DLL
| GRAN_FETCH -- for GrAnSim only -- HWL
| GRAN_RESCHEDULE -- for GrAnSim only -- HWL
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
-% $Id: CLabel.lhs,v 1.37 2000/07/03 14:59:25 simonmar Exp $
+% $Id: CLabel.lhs,v 1.38 2000/08/02 14:13:26 rrt Exp $
%
\section[CLabel]{@CLabel@: Information to make C Labels}
import CmdLineOpts ( opt_Static, opt_DoTickyProfiling )
import CStrings ( pp_cSEP )
import DataCon ( ConTag, DataCon )
-import Module ( ModuleName )
+import Module ( ModuleName, moduleName, Module, isLocalModule )
import Name ( Name, getName, isDllName, isExternallyVisibleName )
import TyCon ( TyCon )
import Unique ( pprUnique, Unique )
| AsmTempLabel Unique
- | ModuleInitLabel ModuleName
+ | ModuleInitLabel Module
| RtsLabel RtsLabelInfo
-- Some fixed runtime system labels
-mkErrorStdEntryLabel = RtsLabel RtsShouldNeverHappenCode
-
+mkErrorStdEntryLabel = RtsLabel RtsShouldNeverHappenCode
mkStgUpdatePAPLabel = RtsLabel (Rts_Code "stg_update_PAP")
mkSplitMarkerLabel = RtsLabel (Rts_Code "__stg_split_marker")
mkUpdInfoLabel = RtsLabel RtsUpdInfo
needsCDecl (IdLabel _ _) = True
needsCDecl (CaseLabel _ CaseReturnPt) = True
needsCDecl (DataConLabel _ _) = True
-needsCDecl (CaseLabel _ _) = False
needsCDecl (TyConLabel _) = True
+needsCDecl (ModuleInitLabel _) = True
+needsCDecl (CaseLabel _ _) = False
needsCDecl (AsmTempLabel _) = False
-needsCDecl (ModuleInitLabel _) = False
needsCDecl (RtsLabel _) = False
needsCDecl (ForeignLabel _ _) = False
needsCDecl (CC_Label _) = False
labelType (CaseLabel _ CaseReturnPt) = CodeType
labelType (CaseLabel _ CaseVecTbl) = VecTblType
labelType (TyConLabel _) = ClosureTblType
+labelType (ModuleInitLabel _ ) = CodeType
labelType (IdLabel _ info) =
case info of
labelDynamic :: CLabel -> Bool
labelDynamic lbl =
case lbl of
- RtsLabel _ -> not opt_Static -- i.e., is the RTS in a DLL or not?
- IdLabel n k -> isDllName n
- DataConLabel n k -> isDllName n
- TyConLabel tc -> isDllName (getName tc)
- ForeignLabel _ d -> d
- _ -> False
+ -- The special case for RtsShouldNeverHappenCode is because the associated address is
+ -- NULL, i.e. not a DLL entry point
+ RtsLabel RtsShouldNeverHappenCode -> False
+ RtsLabel _ -> not opt_Static -- i.e., is the RTS in a DLL or not?
+ IdLabel n k -> isDllName n
+ DataConLabel n k -> isDllName n
+ TyConLabel tc -> isDllName (getName tc)
+ ForeignLabel _ d -> d
+ ModuleInitLabel m -> (not opt_Static) && (not (isLocalModule m))
+ _ -> False
\end{code}
pprCLbl (CaseLabel u CaseBitmap)
= hcat [pprUnique u, pp_cSEP, ptext SLIT("btm")]
-pprCLbl (RtsLabel RtsShouldNeverHappenCode) = ptext SLIT("stg_error_entry")
+pprCLbl (RtsLabel RtsShouldNeverHappenCode) = ptext SLIT("NULL")
+-- used to be stg_error_entry but Windows can't have DLL entry points as static
+-- initialisers, and besides, this ShouldNeverHappen, right?
pprCLbl (RtsLabel RtsUpdInfo) = ptext SLIT("upd_frame_info")
pprCLbl (RtsLabel RtsSeqInfo) = ptext SLIT("seq_frame_info")
pprCLbl (CC_Label cc) = ppr cc
pprCLbl (CCS_Label ccs) = ppr ccs
-pprCLbl (ModuleInitLabel mod) = ptext SLIT("__init_") <> ptext mod
+pprCLbl (ModuleInitLabel mod) = ptext SLIT("__init_") <> ptext (moduleName mod)
ppIdFlavor :: IdLabelInfo -> SDoc
import Constants ( mIN_UPD_SIZE )
import CallConv ( callConvAttribute )
-import CLabel ( externallyVisibleCLabel, mkErrorStdEntryLabel,
+import CLabel ( externallyVisibleCLabel,
needsCDecl, pprCLabel,
mkReturnInfoLabel, mkReturnPtLabel, mkClosureTblLabel,
- mkClosureLabel,
+ mkClosureLabel, mkErrorStdEntryLabel,
CLabel, CLabelType(..), labelType, labelDynamic
)
cStmtMacroText SET_TAG = SLIT("SET_TAG")
cStmtMacroText REGISTER_FOREIGN_EXPORT = SLIT("REGISTER_FOREIGN_EXPORT")
cStmtMacroText REGISTER_IMPORT = SLIT("REGISTER_IMPORT")
+cStmtMacroText REGISTER_DIMPORT = SLIT("REGISTER_DIMPORT")
cStmtMacroText GRAN_FETCH = SLIT("GRAN_FETCH")
cStmtMacroText GRAN_RESCHEDULE = SLIT("GRAN_RESCHEDULE")
cStmtMacroText GRAN_FETCH_AND_RESCHEDULE= SLIT("GRAN_FETCH_AND_RESCHEDULE")
Nothing -> mkErrorStdEntryLabel
Just _ -> entryLabelFromCI cl_info
-ppr_decls_AbsC (CSRT lbl closure_lbls)
+ppr_decls_AbsC (CSRT _ closure_lbls)
= mapTE labelSeenTE closure_lbls `thenTE` \ seen ->
returnTE (Nothing,
if and seen then Nothing
isDllName nm = not opt_Static &&
not (isLocallyDefinedName nm) &&
not (isLocalModule (nameModule nm))
+-- Why is the isLocallyDefinedName test needed?
nameSrcLoc name = provSrcLoc (n_prov name)
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
-% $Id: CgCase.lhs,v 1.44 2000/07/14 08:14:53 simonpj Exp $
+% $Id: CgCase.lhs,v 1.45 2000/08/02 14:13:27 rrt Exp $
%
%********************************************************
%* *
deflt_lbl =
case nonemptyAbsC deflt_absC of
-- the simplifier might have eliminated a case
- Nothing -> CLbl mkErrorStdEntryLabel CodePtrRep
+ Nothing -> mkIntCLit 0 -- CLbl mkErrorStdEntryLabel CodePtrRep
Just absC@(CCodeBlock lbl _) -> CLbl lbl CodePtrRep
mk_vector_entry :: ConTag -> (CAddrMode, AbstractC)
import StgSyn
import CgMonad
import AbsCSyn
-import CLabel ( CLabel, mkSRTLabel, mkClosureLabel, mkModuleInitLabel )
+import CLabel ( CLabel, mkSRTLabel, mkClosureLabel,
+ mkModuleInitLabel, labelDynamic )
import PprAbsC ( dumpRealC )
import AbsCUtils ( mkAbstractCs, flattenAbsC )
codeGen :: Module -- Module name
- -> [ModuleName] -- Import names
+ -> [Module] -- Import names
-> ([CostCentre], -- Local cost-centres needing declaring/registering
[CostCentre], -- "extern" cost-centres needing declaring
[CostCentreStack]) -- Pre-defined "singleton" cost centre stacks
mkModuleInit
:: [Id] -- foreign exported functions
-> Module -- module name
- -> [ModuleName] -- import names
+ -> [Module] -- import names
-> ([CostCentre], -- cost centre info
[CostCentre],
[CostCentreStack])
(cc_decls, cc_regs) = mkCostCentreStuff cost_centre_info
- mk_import_register import_name
- = CMacroStmt REGISTER_IMPORT [
- CLbl (mkModuleInitLabel import_name) AddrRep
+ mk_import_register imp =
+ CMacroStmt REGISTER_IMPORT [
+ CLbl (mkModuleInitLabel imp) AddrRep
]
register_imports = map mk_import_register imps
in
mkAbstractCs [
cc_decls,
- CModuleInitBlock (mkModuleInitLabel (Module.moduleName mod))
+ CModuleInitBlock (mkModuleInitLabel mod)
(mkAbstractCs (register_fes ++
cc_regs :
register_imports))
, ParsedIface -- The new interface
, RnNameSupply -- Final env; for renaming derivings
, FixityEnv -- The fixity environment; for derivings
- , [ModuleName]) -- Imported modules; for profiling
+ , [Module]) -- Imported modules
renameModule :: UniqSupply -> RdrNameHsModule -> IO (Maybe RenameResult)
renameModule us this_mod@(HsModule mod_name vers exports imports local_decls _ loc)
mkImportExportInfo mod_name export_avails exports `thenRn` \ (my_exports, my_usages) ->
-- RETURN THE RENAMED MODULE
- getNameSupplyRn `thenRn` \ name_supply ->
+ getNameSupplyRn `thenRn` \ name_supply ->
+ getIfacesRn `thenRn` \ ifaces ->
let
+ direct_import_mods :: [Module]
+ direct_import_mods = [m | (_, _, Just (m, _, _, _, ImportByUser, _))
+ <- eltsFM (iImpModInfo ifaces)]
+ -- Pick just the non-back-edge imports
+ -- (Back edges are ImportByUserSource)
+
this_module = mkThisModule mod_name
- direct_import_mods = [mod | ImportDecl mod _ _ _ _ _ <- imports]
-- Export only those fixities that are for names that are
-- (a) defined in this module
%*********************************************************
\begin{code}
-reportUnusedNames :: ModuleName -> [ModuleName]
+reportUnusedNames :: ModuleName -> [Module]
-> GlobalRdrEnv -> AvailEnv
-> Avails -> NameSet -> [RenamedHsDecl]
-> RnMG ()
-- There's really no good way to detect this, so the error message
-- in RnEnv.warnUnusedModules is weakened instead
inst_mods = [m | InstD (InstDecl _ _ _ (Just dfun) _) <- imported_decls,
- let m = moduleName (nameModule dfun),
+ let m = nameModule dfun,
m `elem` direct_import_mods
]
- minimal_imports :: FiniteMap ModuleName AvailEnv
+ minimal_imports :: FiniteMap Module AvailEnv
minimal_imports0 = emptyFM
minimal_imports1 = foldNameSet add_name minimal_imports0 really_used_names
minimal_imports = foldr add_inst_mod minimal_imports1 inst_mods
add_name n acc = case maybeUserImportedFrom n of
Nothing -> acc
- Just m -> addToFM_C plusAvailEnv acc (moduleName m)
+ Just m -> addToFM_C plusAvailEnv acc m
(unitAvailEnv (mk_avail n))
add_inst_mod m acc
| m `elemFM` acc = acc -- We import something already
module_unused :: Name -> Bool
-- Name is imported from a module that's completely unused,
-- so don't report stuff about the name (the module covers it)
- module_unused n = moduleName (expectJust "module_unused" (maybeUserImportedFrom n))
+ module_unused n = expectJust "module_unused" (maybeUserImportedFrom n)
`elem` unused_imp_mods
-- module_unused is only called if it's user-imported
in
parens (fsep (punctuate comma (map ppr ies)))
to_ies (mod, avail_env) = mapRn to_ie (availEnvElts avail_env) `thenRn` \ ies ->
- returnRn (mod, ies)
+ returnRn (moduleName mod, ies)
to_ie :: AvailInfo -> RnMG (IE Name)
to_ie (Avail n) = returnRn (IEVar n)
\begin{code}
-warnUnusedModules :: [ModuleName] -> RnM d ()
+warnUnusedModules :: [Module] -> RnM d ()
warnUnusedModules mods
| not opt_WarnUnusedImports = returnRn ()
- | otherwise = mapRn_ (addWarnRn . unused_mod) mods
+ | otherwise = mapRn_ (addWarnRn . unused_mod . moduleName) mods
where
unused_mod m = vcat [ptext SLIT("Module") <+> quotes (pprModuleName m) <+>
text "is imported, but nothing from it is used",
# -----------------------------------------------------------------------------
-# $Id: Makefile,v 1.11 1998/12/02 13:21:15 simonm Exp $
+# $Id: Makefile,v 1.12 2000/08/02 14:13:27 rrt Exp $
#
TOP = ..
#
# All header files
#
-H_FILES = $(wildcard *.h)
+H_FILES = $(filter-out gmp.h,$(wildcard *.h)) gmp.h
#
# Header file built from the configure script's findings
all :: $(H_CONFIG) NativeDefs.h
+# gmp.h is copied from the GMP directory
+gmp.h : $(FPTOOLS_TOP)/ghc/rts/gmp/gmp.h
+ $(CP) $< $@
+
# The fptools configure script creates the configuration header file
# and puts it in fptools/mk/config.h. We copy it down to here, prepending
# some make variables specifying cpp platform variables.
/* -----------------------------------------------------------------------------
- * $Id: StgMacros.h,v 1.31 2000/07/21 09:48:47 rrt Exp $
+ * $Id: StgMacros.h,v 1.32 2000/08/02 14:13:27 rrt Exp $
*
* (c) The GHC Team, 1998-1999
*
#define EXTINFO_RTS extern DLL_IMPORT_RTS INFO_TBL_CONST StgInfoTable
#define ED_ extern
-#define EDD_ extern DLLIMPORT
+#define EDD_ extern DLLIMPORT
#define ED_RO_ extern const
#define ID_ static
#define ID_RO_ static const
We use a RET_DYN frame the same as for a dynamic heap check.
------------------------------------------------------------------------- */
-#if COMPILING_RTS
-EI_(stg_gen_chk_info);
-#else
-EDI_(stg_gen_chk_info);
-#endif
+EXTINFO_RTS(stg_gen_chk_info);
+
/* -----------------------------------------------------------------------------
Vectored Returns
STGCALL1(getStablePtr,reg_fe_binder)
#define REGISTER_IMPORT(reg_mod_name) \
- do { EXTFUN_RTS(reg_mod_name); \
- PUSH_INIT_STACK(reg_mod_name) ; \
- } while (0)
-
+ PUSH_INIT_STACK(reg_mod_name)
+
#define END_MOD_INIT() \
}}; \
JMP_(POP_INIT_STACK()); \
/* -----------------------------------------------------------------------------
- * $Id: StgMiscClosures.h,v 1.17 2000/07/21 09:31:46 rrt Exp $
+ * $Id: StgMiscClosures.h,v 1.18 2000/08/02 14:13:27 rrt Exp $
*
* (c) The GHC Team, 1998-1999
*
/* standard entry points */
-extern StgFun stg_error_entry;
+/* EXTFUN_RTS(stg_error_entry); No longer used */
/* (see also below -- KSW 1998-12) */
DLL_DESCRIPTION="GHC-compiled Haskell Prelude"
DLL_IMPLIB_NAME = libHSstd_imp.a
SRC_BLD_DLL_OPTS += --export-all --output-def=HSstd.def DllVersionInfo.o
-SRC_BLD_DLL_OPTS += -lwinmm -lHSrts_imp -lHSstd_cbits_imp -lgmp -L. -L../../rts/gmp -L../../rts -Lcbits
+SRC_BLD_DLL_OPTS += -lwinmm -lHSrts_imp -lHSstd_cbits_imp -lgmp_imp -L. -L../../rts/gmp -L../../rts -Lcbits
ifeq "$(way)" "dll"
HS_SRCS := $(filter-out PrelMain.lhs PrelHugs.lhs, $(HS_SRCS))
% -----------------------------------------------------------------------------
-% $Id: PrelBase.lhs,v 1.33 2000/07/07 11:03:57 simonmar Exp $
+% $Id: PrelBase.lhs,v 1.34 2000/08/02 14:13:27 rrt Exp $
%
% (c) The University of Glasgow, 1992-2000
%
module PrelBase
(
module PrelBase,
- module PrelGHC -- Re-export PrelGHC, to avoid lots of people
- -- having to import it explicitly
+ module PrelGHC, -- Re-export PrelGHC, PrelErr & PrelNum, to avoid lots
+ module PrelErr, -- of people having to import it explicitly
+ module PrelNum
)
where
import PrelGHC
+import {-# SOURCE #-} PrelErr
+import {-# SOURCE #-} PrelNum
infixr 9 .
infixr 5 ++, :
-- primitive operations and types that GHC knows about.
---------------------------------------------------------------------------
-__interface "std" PrelGHC 1 0 where
+__interface "rts" PrelGHC 1 0 where
__export PrelGHC
-- Export PrelErr.error, so that others don't have to import PrelErr
__export PrelErr error ;
---------------------------------------------------
--- These imports tell modules low down in the hierarchy that
--- PrelErr and PrelBase are in the same package and
--- should be read from their hi-boot files
-import PrelErr @ ;
-import PrelNum @ ;
-
--------------------------------------------------
instance {CCallable Charzh} = zdfCCallableCharzh;
/* -----------------------------------------------------------------------------
- * $Id: StgMiscClosures.hc,v 1.46 2000/07/17 15:15:40 rrt Exp $
+ * $Id: StgMiscClosures.hc,v 1.47 2000/08/02 14:13:28 rrt Exp $
*
* (c) The GHC Team, 1998-2000
*
This is used for filling in vector-table entries that can never happen,
for instance.
-------------------------------------------------------------------------- */
-
+/* No longer used; we use NULL, because a) it never happens, right? and b)
+ Windows doesn't like DLL entry points being used as static initialisers
STGFUN(stg_error_entry) \
{ \
FB_ \
return NULL; \
FE_ \
}
-
+*/
/* -----------------------------------------------------------------------------
Dummy return closure