[m-rev.] diff: improve mmake support for high level data on IL backend

Peter Ross peter.ross at miscrit.be
Wed Jul 18 19:29:46 AEST 2001


Hi,


===================================================================


Estimated hours taken: 2
Branches: main

Improve the mmake support in preperation for high level data on the IL
backend.

compiler/modules.m:
    Ensure that all the mercury modules a foreign code module might
    refer to are built before the foreign code module.
    Add .foreign_dlls to the main build target to ensure that all the
    foreign code dlls get built.

compiler/mlds_to_mcpp.m:
    Fix an XXX about high level data.

Index: compiler/mlds_to_mcpp.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_mcpp.m,v
retrieving revision 1.12
diff -u -r1.12 mlds_to_mcpp.m
--- compiler/mlds_to_mcpp.m	17 Jul 2001 15:40:35 -0000	1.12
+++ compiler/mlds_to_mcpp.m	18 Jul 2001 09:24:37 -0000
@@ -102,11 +102,7 @@
 		"#include ""mercury_mcpp.h""\n",
 		"#using ""mercury_mcpp.dll""\n",
 		"#using ""mercury_il.dll""\n",
-		% XXX This line will need to be re-enabled for high
-		% level data.  This will also require that the build
-		% rules be changed so that the mercury code dlls are
-		% always built first.
-		"// #using """, ModuleNameStr, ".dll""\n",
+		"#using """, ModuleNameStr, ".dll""\n",
 
 		% XXX We have to use the mercury namespace, as
 		% llds_out still generates some of the code used in the
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.173
diff -u -r1.173 modules.m
--- compiler/modules.m	17 Jul 2001 15:40:35 -0000	1.173
+++ compiler/modules.m	18 Jul 2001 09:24:41 -0000
@@ -2033,12 +2033,20 @@
 				SourceFileName, "\n\n"
 		]),
 
-		% If we are on the IL backend and the current module
-		% contains some foreign code, generate a dependency
-		% between the dll containing the mercury code and the
-		% dll containing the foreign code.  Also generate
-		% dependencies between the foreign code dll and how to
-		% it relates to the il file (dll -> cpp -> il).
+		% Generate the following dependency.  This dependency is
+		% needed because module__cpp_code.dll might refer to
+		% high level data in any of the mercury modules it
+		% imports plus itself.
+		%
+		% 	module__cpp_code.dll : module.dll imports.dll
+		% 
+		%
+		% Generate the following sequence of rules which state
+		% how to generate the module__cpp_code.dll.
+		%
+		%	module__cpp_code.dll : module__cpp_code.cpp
+		%	module__cpp_code.cpp : module.il
+		%
 		globals__io_get_target(Target),
 		(
 			{ Target = il },
@@ -2064,8 +2072,13 @@
 			module_name_to_file_name(ModuleName,
 					ForeignCodeExt ++ "dll",
 					no, ForeignDllFileName),
+
+			io__write_strings(DepStream, [
+				ForeignDllFileName, " : ", DllFileName]),
+			write_dll_dependencies_list(AllDeps, DepStream),
+			io__nl(DepStream),
+
 			io__write_strings(DepStream, [
-				DllFileName, " : ", ForeignDllFileName, "\n",
 				ForeignDllFileName, " : ", ForeignFileName,"\n",
 				ForeignFileName, " : ", IlFileName, "\n\n"])
 		;
@@ -3357,7 +3370,8 @@
 
 	{ If = ["ifeq ($(findstring il,$(GRADE)),il)\n"] },
 	{ ILMainRule = [ExeFileName, " : ", ExeFileName, ".exe ",
-			"$(", MakeVarName, ".dlls)\n"] },
+			"$(", MakeVarName, ".dlls) ",
+			"$(", MakeVarName, ".foreign_dlls)\n"] },
 	{ Else = ["else\n"] },
 	{ MainRule =
 		[ExeFileName, " : $(", MakeVarName, ".cs_or_ss) ",
@@ -3815,6 +3829,30 @@
 	io__write_string(DepStream, " \\\n\t"),
 	io__write_string(DepStream, FileName),
 	write_dependencies_list(Modules, Suffix, DepStream).
+
+:- pred write_dll_dependencies_list(list(module_name), io__output_stream,
+				io__state, io__state).
+:- mode write_dll_dependencies_list(in, in, di, uo) is det.
+
+write_dll_dependencies_list(Modules0, DepStream) -->
+	{ F = (func(M) =
+		( if M = unqualified(S), mercury_std_library_module(S) then
+			unqualified("mercury")
+		else
+			M
+		)
+	)},
+	{ Modules = list__remove_dups(list__map(F, Modules0)) },
+	list__foldl(write_dll_dependency(DepStream), Modules).
+
+:- pred write_dll_dependency(io__output_stream, module_name,
+				io__state, io__state).
+:- mode write_dll_dependency(in, in, di, uo) is det.
+
+write_dll_dependency(DepStream, Module) -->
+	module_name_to_file_name(Module, ".dll", no, FileName),
+	io__write_string(DepStream, " \\\n\t"),
+	io__write_string(DepStream, FileName).
 
 :- pred write_fact_table_dependencies_list(module_name, list(file_name),
 			string, io__output_stream, io__state, io__state).

--------------------------------------------------------------------------
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