[m-rev.] diff: GCC back-end: add Mmake support for nested modules
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri May 11 00:44:32 AEST 2001
With this change (which turned out to be easier than I thought it would be),
the GCC back-end should now pass all the tests in our test suite.
----------
Estimated hours taken: 2
Branches: main
Add Mmake support for using nested modules with the GCC back-end.
compiler/modules.m:
Change the way we compute the set of object files that
need to be linked into the program when --target asm is
enabled. In particular, only include object files for
top-level modules and separate sub-modules, not for
nested sub-modules.
Workspace: /mnt/hg/home/hg/fjh/gcc-cvs/gcc/mercury
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.162
diff -u -d -r1.162 modules.m
--- compiler/modules.m 2001/05/08 15:13:09 1.162
+++ compiler/modules.m 2001/05/10 13:27:48
@@ -2589,6 +2589,31 @@
relation__add_element(Relation0, Dep, DepRelKey, Relation1),
relation__add(Relation1, ModuleRelKey, DepRelKey, Relation).
+% check if a module is a top-level module, a nested sub-module,
+% or a separate sub-module.
+%
+:- type submodule_kind
+ ---> toplevel
+ ; nested_submodule
+ ; separate_submodule.
+
+:- func get_submodule_kind(module_name, deps_map) = submodule_kind.
+get_submodule_kind(ModuleName, DepsMap) = Kind :-
+ get_ancestors(ModuleName, Ancestors),
+ ( list__last(Ancestors, Parent) ->
+ map__lookup(DepsMap, ModuleName, deps(_, ModuleImports)),
+ map__lookup(DepsMap, Parent, deps(_, ParentImports)),
+ ModuleFileName = ModuleImports ^ source_file_name,
+ ParentFileName = ParentImports ^ source_file_name,
+ ( ModuleFileName = ParentFileName ->
+ Kind = nested_submodule
+ ;
+ Kind = separate_submodule
+ )
+ ;
+ Kind = toplevel
+ ).
+
%-----------------------------------------------------------------------------%
% Write out the `.dv' file, using the information collected in the
@@ -2711,8 +2736,21 @@
io__write_string(DepStream, MakeVarName),
io__write_string(DepStream, ".os = "),
- write_compact_dependencies_list(Modules, "$(os_subdir)", ".$O",
- Basis, DepStream),
+ % for --target asm, we only generate separate object files
+ % for top-level modules and separate sub-modules, not for
+ % nested sub-modules.
+ { IsNested = (pred(Mod::in) is semidet :-
+ get_submodule_kind(Mod, DepsMap) = nested_submodule) },
+ (
+ { Target = asm },
+ { list__filter(IsNested, Modules, NestedModules, MainModules) },
+ { NestedModules \= [] }
+ ->
+ write_dependencies_list(MainModules, ".$O", DepStream)
+ ;
+ write_compact_dependencies_list(Modules, "$(os_subdir)",
+ ".$O", Basis, DepStream)
+ ),
write_extra_link_dependencies_list(ExtraLinkObjs, ".$O", DepStream),
io__write_string(DepStream, "\n"),
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list