[m-dev.] diff: GCC back-end fixes

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Feb 26 12:08:30 AEDT 2001


Estimated hours taken: 4

Various fixes for the GCC back-end.

library/array.m:
library/private_builtin.m:
library/sparse_bitset.m:
library/string.m:
library/table_builtin.m:
library/time.m:
	Add #includes for header files needed by these modules.

compiler/modules.m:
	Add the extra object files needed for the GCC back-end
	(and for fact tables) to the .pic_os list as well as to
	the .os list.

compiler/gcc.m:
	Delete the second copy of a duplicated paragraph in the comments.

compiler/mlds_to_gcc.m:
	Fix a bug that showed up after my recent change which added
	an MLDS->MLDS optimization that converted assignments into
	initializers.  The bug was that the code here didn't handle
	the case when an initializer for a local variable refers to
	another local variable declared earlier in the same block.

Workspace: /mnt/hg/home/hg/fjh/gcc-cvs/gcc/mercury
Index: compiler/gcc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/gcc.m,v
retrieving revision 1.21
diff -u -d -r1.21 gcc.m
--- compiler/gcc.m	2001/02/01 01:09:54	1.21
+++ compiler/gcc.m	2001/02/23 19:49:12
@@ -51,10 +51,6 @@
 % stuff defined by the gcc back-end are documented better
 % in the comments in the gcc source code.
 %
-% Many of the procedures here which are implemented using
-% stuff defined by the gcc back-end are documented better
-% in the comments in the gcc source code.
-%
 % QUOTES
 %
 %	``GCC is a software Vietnam.''
Index: compiler/mlds_to_gcc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_gcc.m,v
retrieving revision 1.31
diff -u -d -r1.31 mlds_to_gcc.m
--- compiler/mlds_to_gcc.m	2001/02/10 11:21:31	1.31
+++ compiler/mlds_to_gcc.m	2001/02/26 01:03:52
@@ -866,25 +866,24 @@
 	% Handle MLDS definitions that are nested inside a
 	% function definition (or inside a block within a function),
 	% and which are hence local to that function.
-:- pred build_local_defns(mlds__defns, defn_info, mlds_module_name, 
-		symbol_table, symbol_table, io__state, io__state).
-:- mode build_local_defns(in, in, in, in, out, di, uo) is det.
+:- pred build_local_defns(mlds__defns, mlds_module_name, defn_info, defn_info,
+		io__state, io__state).
+:- mode build_local_defns(in, in, in, out, di, uo) is det.
 
-build_local_defns([], _, _, SymbolTable, SymbolTable) --> [].
-build_local_defns([Defn|Defns], DefnInfo, ModuleName,
-		SymbolTable0, SymbolTable) -->
-	build_local_defn(Defn, DefnInfo, ModuleName, GCC_Defn),
+build_local_defns([], _, DefnInfo, DefnInfo) --> [].
+build_local_defns([Defn|Defns], ModuleName, DefnInfo0, DefnInfo) -->
+	build_local_defn(Defn, DefnInfo0, ModuleName, GCC_Defn),
 	% Insert the variable definition into our symbol table.
 	% The MLDS code that the MLDS code generator generates should
 	% not have any shadowing of parameters or local variables by
 	% nested local variables, so we use map__det_insert rather
 	% than map__set here.  (Actually nothing in this module depends
-	% on it, so this sanity here is perhaps a bit paranoid.)
+	% on it, so this sanity check here is perhaps a bit paranoid.)
 	{ Defn = mlds__defn(Name, _, _, _) },
-	{ SymbolTable1 = map__det_insert(SymbolTable0,
-		qual(ModuleName, Name), GCC_Defn) },
-	build_local_defns(Defns, DefnInfo, ModuleName,
-		SymbolTable1, SymbolTable).
+	{ DefnInfo1 = DefnInfo0 ^ local_vars :=
+		map__det_insert(DefnInfo0 ^ local_vars,
+			qual(ModuleName, Name), GCC_Defn) },
+	build_local_defns(Defns, ModuleName, DefnInfo1, DefnInfo).
 
 	% Handle MLDS definitions that are nested inside a type, 
 	% i.e. fields of that type.
@@ -2505,10 +2504,7 @@
 	gcc__start_block,
 	{ FuncName = DefnInfo0 ^ func_name },
 	{ FuncName = qual(ModuleName, _) },
-	{ SymbolTable0 = DefnInfo0 ^ local_vars },
-	build_local_defns(Defns, DefnInfo0, ModuleName,
-		SymbolTable0, SymbolTable),
-	{ DefnInfo = DefnInfo0 ^ local_vars := SymbolTable },
+	build_local_defns(Defns, ModuleName, DefnInfo0, DefnInfo),
 	gen_statements(DefnInfo, Statements),
 	gcc__end_block.
 
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.151
diff -u -d -r1.151 modules.m
--- compiler/modules.m	2001/02/12 11:39:58	1.151
+++ compiler/modules.m	2001/02/25 23:51:22
@@ -2705,6 +2705,8 @@
 	write_compact_dependencies_list(Modules, "$(os_subdir)",
 					".$(EXT_FOR_PIC_OBJECTS)",
 					Basis, DepStream),
+	write_extra_link_dependencies_list(ExtraLinkObjs,
+					".$(EXT_FOR_PIC_OBJECTS)", DepStream),
 	io__write_string(DepStream, "\n"),
 
 	io__write_string(DepStream, MakeVarName),
@@ -3207,6 +3209,7 @@
 	]).
 
 %-----------------------------------------------------------------------------%
+
 	% get_extra_link_objects(Modules, DepsMap, Target, ExtraLinkObjs) },
 	% Find any extra .$O files that should be linked into the executable.
 	% These include fact table object files and object files for foreign
Index: library/array.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/array.m,v
retrieving revision 1.84
diff -u -d -r1.84 array.m
--- library/array.m	2001/02/08 17:20:47	1.84
+++ library/array.m	2001/02/26 00:08:43
@@ -608,6 +608,7 @@
 %-----------------------------------------------------------------------------%
 
 :- pragma foreign_decl("C", "
+#include ""mercury_heap.h""		/* for MR_maybe_record_allocation() */
 #include ""mercury_library_types.h""	/* for MR_ArrayType */
 #include ""mercury_misc.h""		/* for MR_fatal_error() */
 ").
Index: library/private_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/private_builtin.m,v
retrieving revision 1.68
diff -u -d -r1.68 private_builtin.m
--- library/private_builtin.m	2001/02/04 04:10:34	1.68
+++ library/private_builtin.m	2001/02/26 00:10:53
@@ -120,6 +120,10 @@
 :- pragma inline(builtin_compare_string/3).
 :- pragma inline(builtin_compare_float/3).
 
+:- pragma foreign_decl("C", "
+	#include ""mercury_heap.h""	/* for MR_free_heap() */
+").
+
 :- pragma foreign_code("C", free_heap(Val::di),
 	[will_not_call_mercury, thread_safe],
 	"MR_free_heap((void *) Val);").
Index: library/sparse_bitset.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/sparse_bitset.m,v
retrieving revision 1.5
diff -u -d -r1.5 sparse_bitset.m
--- library/sparse_bitset.m	2001/02/11 11:45:13	1.5
+++ library/sparse_bitset.m	2001/02/26 00:14:00
@@ -759,6 +759,10 @@
 
 %make_bitset_elem(A, B) = bitset_elem(A, B).
 
+:- pragma foreign_decl("C", "
+	#include ""mercury_heap.h""	/* for MR_incr_hp_atomic_msg() */
+").
+
 	% The bit pattern will often look like a pointer,
 	% so allocate the pairs using GC_malloc_atomic()
 	% to avoid unnecessary memory retention.
Index: library/string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.142
diff -u -d -r1.142 string.m
--- library/string.m	2001/02/12 04:31:07	1.142
+++ library/string.m	2001/02/26 00:16:08
@@ -1476,6 +1476,9 @@
 :- pragma c_header_code("
 #include <string.h>
 #include <stdio.h>
+
+#include ""mercury_string.h""	/* for MR_allocate_aligned_string*() etc. */
+#include ""mercury_tags.h""	/* for MR_list_cons*() */
 ").
 
 %-----------------------------------------------------------------------------%
Index: library/table_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/table_builtin.m,v
retrieving revision 1.6
diff -u -d -r1.6 table_builtin.m
--- library/table_builtin.m	2001/01/01 04:03:55	1.6
+++ library/table_builtin.m	2001/02/26 00:39:59
@@ -457,6 +457,10 @@
 % since the I/O actions executed during such times do not belong to the user
 % program.
 
+:- pragma foreign_decl("C", "
+	#include ""mercury_trace_base.h""	/* for MR_io_tabling_* */
+").
+
 :- pragma foreign_code("C",
 	table_io_in_range(T::out, Counter::out, Start::out),
 	[will_not_call_mercury],
Index: library/time.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/time.m,v
retrieving revision 1.18
diff -u -d -r1.18 time.m
--- library/time.m	2001/01/01 04:03:55	1.18
+++ library/time.m	2001/02/26 00:17:35
@@ -161,6 +161,8 @@
 	#endif
 
 	#define update_io(r_src, r_dest)	((r_dest) = (r_src))
+
+	#include ""mercury_string.h"" /* for MR_make_aligned_string_copy() */
 ").
 
 %-----------------------------------------------------------------------------%

-- 
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-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list