[m-rev.] for review: reserve-tag flag in type_ctor_info structures

Zoltan Somogyi zs at cs.mu.OZ.AU
Tue Feb 11 16:40:51 AEDT 2003


The initialization macros for the builtin types assume that no builtin type
has a reserved tag. If any such types (e.g. for HAL) are different, we can
address that after this change has bootstrapped.

Zoltan.

Add a facility for recording boolean flags in the RTTI structures
of type constructors. At the moment, the only flag records whether
the type constructor has a tag value reserved for HAL variables.
The flag is not used yet.

runtime/mercury_type_info.h:
	Add the extra field if MR_TYPE_CTOR_INFO_HAS_FLAG is defined.
	(The #ifdef will be deleted once bootstrapping is complete.)

compiler/llds_out.m:
compiler/mlds_to_c.m:
	Define MR_TYPE_CTOR_INFO_HAS_FLAG for bootstrapping.

compiler/rtti.m:
	Add the field to the backend-independent RTTI description of
	type_ctor_infos, together with its encoding function.

compiler/type_ctor_info.m:
	Gather the information about the flags, for use when constructing
	the RTTI structure.

compiler/rtti_out.m:
	Add the flag field to the type_ctor_info structure for the LLDS backend.

compiler/rtti_to_mlds.m:
	Add the flag field to the type_ctor_info structure for the hlc backend.

compiler/mlds_to_gcc.m:
	Add the flag field to the type_ctor_info structure for the gcc backend.

library/rtti_implementation.m:
	Add the flag field to list of fields of the type_ctor_info structure.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.203
diff -u -b -r1.203 llds_out.m
--- compiler/llds_out.m	24 Nov 2002 03:57:23 -0000	1.203
+++ compiler/llds_out.m	4 Feb 2003 16:41:06 -0000
@@ -484,6 +484,8 @@
 		"**\n",
 		"** END_OF_C_GRADE_INFO\n",
 		"*/\n",
+		"\n",
+		"#define MR_TYPE_CTOR_INFO_HAS_FLAG 1\n",
 		"\n"
 	]).
 
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.142
diff -u -b -r1.142 mlds_to_c.m
--- compiler/mlds_to_c.m	11 Feb 2003 02:14:27 -0000	1.142
+++ compiler/mlds_to_c.m	11 Feb 2003 02:49:16 -0000
@@ -285,6 +285,7 @@
 	io__write_string(". */\n"),
 	mlds_indent(Indent),
 	io__write_string("/* :- interface. */\n"),
+	io__write_string("#define MR_TYPE_CTOR_INFO_HAS_FLAG 1\n"),
 	io__nl,
 	mlds_indent(Indent),
 	io__write_string("#ifndef MR_HEADER_GUARD_"),
@@ -326,6 +327,7 @@
 	io__write_string("/* :- module "),
 	prog_out__write_sym_name(ModuleName),
 	io__write_string(". */\n"),
+	io__write_string("#define MR_TYPE_CTOR_INFO_HAS_FLAG 1\n"),
 	mlds_indent(Indent),
 	io__write_string("/* :- implementation. */\n"),
 	mlds_output_src_bootstrap_defines, io__nl,
Index: compiler/mlds_to_gcc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_gcc.m,v
retrieving revision 1.79
diff -u -b -r1.79 mlds_to_gcc.m
--- compiler/mlds_to_gcc.m	10 Feb 2003 17:03:48 -0000	1.79
+++ compiler/mlds_to_gcc.m	11 Feb 2003 02:49:16 -0000
@@ -2068,6 +2068,7 @@
 	% MR_TypeFunctors     MR_type_ctor_functors;
 	% MR_TypeLayout       MR_type_ctor_layout;
 	% MR_int_least32_t    MR_type_ctor_num_functors;
+	% MR_int_least16_t    MR_type_ctor_flags;
 
 	{ MR_ProcAddr = gcc__ptr_type_node },
 	build_struct_type("MR_TypeFunctors",
@@ -2088,7 +2089,8 @@
 		 'MR_ConstString'	- "MR_type_ctor_name",
 		 MR_TypeFunctors	- "MR_type_ctor_functors",
 		 MR_TypeLayout		- "MR_type_ctor_layout",
-		 'MR_int_least32_t'	- "MR_type_ctor_num_functors"],
+		 'MR_int_least32_t'	- "MR_type_ctor_num_functors",
+		 'MR_int_least16_t'	- "MR_type_ctor_flags"],
 		GCC_Type).
 build_rtti_type(base_typeclass_info(_, _, _), Size, GCC_Type) -->
 	{ MR_BaseTypeclassInfo = gcc__ptr_type_node },
Index: compiler/rtti.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti.m,v
retrieving revision 1.22
diff -u -b -r1.22 rtti.m
--- compiler/rtti.m	1 Nov 2002 09:56:54 -0000	1.22
+++ compiler/rtti.m	4 Feb 2003 03:02:18 -0000
@@ -28,7 +28,7 @@
 :- import_module hlds__hlds_module, hlds__hlds_pred, hlds__hlds_data.
 :- import_module backend_libs__code_model.
 
-:- import_module assoc_list, bool, list, map, std_util.
+:- import_module assoc_list, bool, list, set, map, std_util.
 
 %-----------------------------------------------------------------------------%
 %
@@ -104,9 +104,13 @@
 			tcr_arity		:: int,
 			tcr_unify_pred		:: univ,
 			tcr_compare_pred	:: univ,
+			tcr_flags		:: set(type_ctor_flag),
 			tcr_rep_details		:: type_ctor_details
 		).
 
+:- type type_ctor_flag
+	--->	reserve_tag_flag.
+
 	% A type_ctor_details structure contains all the information that the
 	% runtime system needs to know about the data representation scheme
 	% used by a type constructor.
@@ -501,6 +505,8 @@
 %
 % The functions operating on RTTI data.
 
+:- func encode_type_ctor_flags(set(type_ctor_flag)) = int.
+
 	% Return the id of the type constructor.
 :- func tcd_get_rtti_type_ctor(type_ctor_data) = rtti_type_ctor.
 
@@ -623,6 +629,15 @@
 :- import_module ll_backend__llds_out.	% for name_mangle and sym_name_mangle
 
 :- import_module int, string, require, varset.
+
+encode_type_ctor_flags(FlagSet) =
+		list__foldl(encode_type_ctor_flag, FlagList, 0) :-
+	set__to_sorted_list(FlagSet, FlagList).
+
+:- func encode_type_ctor_flag(type_ctor_flag, int) = int.
+
+	% The encoding here must match the one in runtime/mercury_type_info.h.
+encode_type_ctor_flag(reserve_tag_flag, N) = N + 1.
 
 rtti_data_to_name(type_ctor_info(TypeCtorData), RttiTypeCtor,
 		type_ctor_info) :-
Index: compiler/rtti_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti_out.m,v
retrieving revision 1.31
diff -u -b -r1.31 rtti_out.m
--- compiler/rtti_out.m	8 Aug 2002 08:15:46 -0000	1.31
+++ compiler/rtti_out.m	5 Feb 2003 01:58:54 -0000
@@ -285,7 +285,7 @@
 output_type_ctor_data_defn(TypeCtorData, DeclSet0, DeclSet) -->
 	{ RttiTypeCtor = tcd_get_rtti_type_ctor(TypeCtorData) },
 	{ TypeCtorData = type_ctor_data(Version, Module, TypeName, TypeArity,
-		UnifyUniv, CompareUniv, TypeCtorDetails) },
+		UnifyUniv, CompareUniv, Flags, TypeCtorDetails) },
 	output_type_ctor_details_defn(RttiTypeCtor, TypeCtorDetails,
 		MaybeFunctorsName, MaybeLayoutName, DeclSet0, DeclSet1),
 	{ det_univ_to_type(UnifyUniv, UnifyProcLabel) },
@@ -335,6 +335,8 @@
 	),
 	io__write_string(",\n\t"),
 	io__write_int(type_ctor_details_num_functors(TypeCtorDetails)),
+	io__write_string(",\n\t"),
+	io__write_int(encode_type_ctor_flags(Flags)),
 % This code is commented out while the corresponding fields of the
 % MR_TypeCtorInfo_Struct type are commented out.
 %
Index: compiler/rtti_to_mlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti_to_mlds.m,v
retrieving revision 1.36
diff -u -b -r1.36 rtti_to_mlds.m
--- compiler/rtti_to_mlds.m	27 Oct 2002 08:05:08 -0000	1.36
+++ compiler/rtti_to_mlds.m	5 Feb 2003 01:58:22 -0000
@@ -178,7 +178,7 @@
 gen_init_rtti_data_defn(RttiData, ModuleInfo, Init, SubDefns) :-
 	RttiData = type_ctor_info(TypeCtorData), 
 	TypeCtorData = type_ctor_data(Version, TypeModule, TypeName,
-		TypeArity, UnifyUniv, CompareUniv, TypeCtorDetails),
+		TypeArity, UnifyUniv, CompareUniv, Flags, TypeCtorDetails),
 	RttiTypeCtor = rtti_type_ctor(TypeModule, TypeName, TypeArity),
 	prog_out__sym_name_to_string(TypeModule, TypeModuleName),
 	NumPtags = type_ctor_details_num_ptags(TypeCtorDetails),
@@ -203,7 +203,8 @@
 		init_struct([
 			LayoutInfo
 		]),
-		gen_init_int(NumFunctors)
+		gen_init_int(NumFunctors),
+		gen_init_int(encode_type_ctor_flags(Flags))
 			% These two are commented out while the corresponding
 			% fields of the MR_TypeCtorInfo_Struct type are
 			% commented out.
Index: compiler/type_ctor_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/type_ctor_info.m,v
retrieving revision 1.32
diff -u -b -r1.32 type_ctor_info.m
--- compiler/type_ctor_info.m	14 Jan 2003 16:42:30 -0000	1.32
+++ compiler/type_ctor_info.m	5 Feb 2003 02:02:32 -0000
@@ -67,7 +67,7 @@
 :- import_module backend_libs__builtin_ops, hlds__error_util.
 
 :- import_module bool, string, int, map, std_util, assoc_list, require.
-:- import_module term.
+:- import_module set, term.
 
 %---------------------------------------------------------------------------%
 
@@ -260,8 +260,14 @@
 			)
 		)
 	),
+	Flags0 = set__init,
+	( TypeBody ^ du_type_reserved_tag = yes ->
+		Flags = set__insert(Flags0, reserve_tag_flag)
+	;
+		Flags = Flags0
+	),
 	TypeCtorData = type_ctor_data(Version, ModuleName, TypeName, TypeArity,
-		UnifyUniv, CompareUniv, Details),
+		UnifyUniv, CompareUniv, Flags, Details),
 	RttiData = type_ctor_info(TypeCtorData).
 
 :- pred type_ctor_info__make_proc_label(pred_proc_id::in, module_info::in,
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
Index: library/rtti_implementation.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/rtti_implementation.m,v
retrieving revision 1.40
diff -u -b -r1.40 rtti_implementation.m
--- library/rtti_implementation.m	4 Feb 2003 07:37:22 -0000	1.40
+++ library/rtti_implementation.m	11 Feb 2003 05:29:41 -0000
@@ -1578,7 +1578,8 @@
 		type_ctor_name		= 7,
 		type_functors		= 8,
 		type_layout		= 9,
-		type_ctor_num_functors	= 10
+		type_ctor_num_functors	= 10,
+		type_ctor_flags		= 11
 	}
 
 	enum ptag_layout_field_nums {
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_type_info.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_type_info.h,v
retrieving revision 1.98
diff -u -b -r1.98 mercury_type_info.h
--- runtime/mercury_type_info.h	10 Feb 2003 17:03:57 -0000	1.98
+++ runtime/mercury_type_info.h	11 Feb 2003 05:15:14 -0000
@@ -25,6 +25,7 @@
 **      compiler/type_ctor_info.m
 **      compiler/rtti.m
 **      compiler/rtti_out.m
+**      compiler/rtti_to_mlds.m
 **      compiler/mlds_to_gcc.m
 **          (for updating the compiler-generated RTTI
 **          structures)
@@ -74,13 +75,14 @@
 ** compiler/type_ctor_info.m and with MR_RTTI_VERSION in mercury_mcpp.h.
 */
 
-#define MR_RTTI_VERSION                 MR_RTTI_VERSION__REP
+#define MR_RTTI_VERSION                 MR_RTTI_VERSION__FLAG
 #define MR_RTTI_VERSION__INITIAL        2
 #define MR_RTTI_VERSION__USEREQ         3
 #define MR_RTTI_VERSION__CLEAN_LAYOUT   4
 #define MR_RTTI_VERSION__VERSION_NO     5
 #define MR_RTTI_VERSION__COMPACT        6
 #define MR_RTTI_VERSION__REP            7
+#define MR_RTTI_VERSION__FLAG           8
 
 /*
 ** Check that the RTTI version is in a sensible range.
@@ -91,7 +93,8 @@
 */
 
 #define MR_TYPE_CTOR_INFO_CHECK_RTTI_VERSION_RANGE(typector)    \
-    assert(typector->MR_type_ctor_version == MR_RTTI_VERSION__REP)
+    assert(typector->MR_type_ctor_version == MR_RTTI_VERSION__REP \
+        || typector->MR_type_ctor_version == MR_RTTI_VERSION__FLAG)
 
 /*---------------------------------------------------------------------------*/
 
@@ -1057,6 +1060,9 @@
     MR_TypeFunctors     MR_type_ctor_functors;
     MR_TypeLayout       MR_type_ctor_layout;
     MR_int_least32_t    MR_type_ctor_num_functors;
+#ifdef  MR_TYPE_CTOR_INFO_HAS_FLAG
+    MR_int_least16_t    MR_type_ctor_flags;
+#endif
 
 /*
 ** The following fields will be added later, once we can exploit them:
@@ -1086,6 +1092,14 @@
 #define MR_type_ctor_num_functors(tci)                                      \
     ((tci)->MR_type_ctor_num_functors)
 
+/*
+** The flag bits here must agree with the ones in encode_type_ctor_flag
+** in compiler/rtti.m.
+*/
+
+#define MR_type_ctor_has_reserve_tag(tci)                                   \
+    ((tci)->MR_type_ctor_flags & 0x1)
+
 /*---------------------------------------------------------------------------*/
 
 #ifdef MR_HIGHLEVEL_CODE
@@ -1134,6 +1148,12 @@
 ** structures for builtin and special types.
 */
 
+#ifdef  MR_TYPE_CTOR_INFO_HAS_FLAG
+  #define MR_INIT_TYPE_CTOR_FLAG    , 0
+#else
+  #define MR_INIT_TYPE_CTOR_FLAG
+#endif
+
 #ifdef MR_HIGHLEVEL_CODE
 
   #define MR_DEFINE_TYPE_CTOR_INFO_TYPE                                 \
@@ -1186,6 +1206,7 @@
         { 0 },                                                          \
         { 0 },                                                          \
         -1                                                              \
+        MR_INIT_TYPE_CTOR_FLAG                                          \
     }
 
   #define MR_DEFINE_TYPE_CTOR_INFO_FULL(m, n, a, cr, u, c)              \
@@ -1240,6 +1261,7 @@
         { 0 },                                                          \
         { 0 },                                                          \
         -1                                                              \
+        MR_INIT_TYPE_CTOR_FLAG                                          \
     }
 
   #define MR_DEFINE_TYPE_CTOR_INFO_FULL(m, n, a, cr, u, c)              \
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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