[m-dev.] for review: compressing RTTI using non-word creates (part 2)

Zoltan Somogyi zs at cs.mu.OZ.AU
Tue Apr 27 18:47:05 AEST 1999


Here is the relative diff with the stuff Fergus asked for.
I did not remember to back up runtime/mercury_conf.h.in,
but the change to that is obvious.

Zoltan.

diff --recursive -u backup/compiler/llds.m mercury/compiler/llds.m
--- backup/compiler/llds.m	Tue Apr 27 12:19:03 1999
+++ mercury/compiler/llds.m	Tue Apr 27 12:56:37 1999
@@ -621,7 +621,7 @@
 		% Or it may say that this cell can be allocated either way,
 		% subject to other constraints (e.g. a cell cannot be allocated
 		% statically unless all of its components are statically
-		% allocated as well.
+		% allocated as well).
 		%
 		% The label number is needed for the case when
 		% we can construct the term at compile-time
@@ -632,7 +632,7 @@
 		% in memory profiling.
 		%
 		% For the time being, you must leave the argument types
-		% implicit if you the cell is to be unique. This is because
+		% implicit if the cell is to be unique. This is because
 		% (a) the code generator assumes that each argument of a cell
 		% it creates on the heap is the same size as a Word; (b)
 		% this assumption may be incorrect with explicitly defined
@@ -661,8 +661,8 @@
 	%
 	% If the type is given as yes(LldsType), then the type is the C type
 	% corresponding to LldsType. If the type is given as no, then the
-	% type is implicit; it is llds_out__rval_type_as_arg says when given
-	% the actual argument.
+	% type is implicit; it is what llds_out__rval_type_as_arg says
+	% when given the actual argument.
 :- type create_arg_types
 	--->	uniform(maybe(llds_type))	% All the arguments have
 						% the given C type.
@@ -840,30 +840,30 @@
 :- type llds_type
 	--->	bool		% A boolean value
 				% represented using the C type `Integer'.
-	;	int8		% A signed value that fits that contains
+	;	int_least8	% A signed value that fits that contains
 				% at least eight bits, represented using the
 				% C type int_least8_t. Intended for use in
 				% static data declarations, not for data
 				% that gets stored in registers, stack slots
 				% etc.
-	;	uint8		% An unsigned version of int8, represented
-				% using the C type uint_least8_t.
-	;	int16		% A signed value that fits that contains
+	;	uint_least8	% An unsigned version of int_least8,
+				% represented using the C type uint_least8_t.
+	;	int_least16	% A signed value that fits that contains
 				% at least sixteen bits, represented using the
 				% C type int_least16_t. Intended for use in
 				% static data declarations, not for data
 				% that gets stored in registers, stack slots
 				% etc.
-	;	uint16		% An unsigned version of int16, represented
-				% using the C type uint_least16_t.
-	;	int32		% A signed value that fits that contains
+	;	uint_least16	% An unsigned version of int_least16,
+				% represented using the C type uint_least16_t.
+	;	int_least32	% A signed value that fits that contains
 				% at least 32 bits, represented using the
 				% C type int_least32_t. Intended for use in
 				% static data declarations, not for data
 				% that gets stored in registers, stack slots
 				% etc.
-	;	uint32		% An unsigned version of int32, represented
-				% using the C type uint_least32_t.
+	;	uint_least32	% An unsigned version of intleast_32,
+				% represented using the C type uint_least32_t.
 	;	integer		% A Mercury `int', represented in C as a
 				% value of type `Integer' (which is
 				% a signed integral type of the same
@@ -874,8 +874,8 @@
 				% value of type `Float' (which may be either
 				% `float' or `double', but is usually
 				% `double').
-	;	string		% A string; represented in C as a value of
-				% type `String'.
+	;	string		% A Mercury string; represented in C as a
+				% value of type `String'.
 	;	data_ptr	% A pointer to data; represented in C
 				% as a value of C type `Word *'.
 	;	code_ptr	% A pointer to code; represented in C
@@ -1049,17 +1049,17 @@
 llds__maybe_type_is_word_size(yes(Type), IsWordSize) :-
 	llds__type_is_word_size_as_arg(Type, IsWordSize).
 
-llds__type_is_word_size_as_arg(int8,     no).
-llds__type_is_word_size_as_arg(uint8,    no).
-llds__type_is_word_size_as_arg(int16,    no).
-llds__type_is_word_size_as_arg(uint16,   no).
-llds__type_is_word_size_as_arg(int32,    no).
-llds__type_is_word_size_as_arg(uint32,   no).
-llds__type_is_word_size_as_arg(bool,     yes).
-llds__type_is_word_size_as_arg(integer,  yes).
-llds__type_is_word_size_as_arg(unsigned, yes).
-llds__type_is_word_size_as_arg(float,    yes).
-llds__type_is_word_size_as_arg(string,   yes).
-llds__type_is_word_size_as_arg(data_ptr, yes).
-llds__type_is_word_size_as_arg(code_ptr, yes).
-llds__type_is_word_size_as_arg(word,     yes).
+llds__type_is_word_size_as_arg(int_least8,   no).
+llds__type_is_word_size_as_arg(uint_least8,  no).
+llds__type_is_word_size_as_arg(int_least16,  no).
+llds__type_is_word_size_as_arg(uint_least16, no).
+llds__type_is_word_size_as_arg(int_least32,  no).
+llds__type_is_word_size_as_arg(uint_least32, no).
+llds__type_is_word_size_as_arg(bool,         yes).
+llds__type_is_word_size_as_arg(integer,      yes).
+llds__type_is_word_size_as_arg(unsigned,     yes).
+llds__type_is_word_size_as_arg(float,        yes).
+llds__type_is_word_size_as_arg(string,       yes).
+llds__type_is_word_size_as_arg(data_ptr,     yes).
+llds__type_is_word_size_as_arg(code_ptr,     yes).
+llds__type_is_word_size_as_arg(word,         yes).
diff --recursive -u backup/compiler/llds_out.m mercury/compiler/llds_out.m
--- backup/compiler/llds_out.m	Tue Apr 27 12:19:03 1999
+++ mercury/compiler/llds_out.m	Tue Apr 27 20:06:43 1999
@@ -2322,20 +2322,20 @@
 
 :- pred output_llds_type(llds_type::in, io__state::di, io__state::uo) is det.
 
-output_llds_type(int8)     --> io__write_string("int_least8_t").
-output_llds_type(uint8)    --> io__write_string("uint_least8_t").
-output_llds_type(int16)    --> io__write_string("int_least16_t").
-output_llds_type(uint16)   --> io__write_string("uint_least16_t").
-output_llds_type(int32)    --> io__write_string("int_least32_t").
-output_llds_type(uint32)   --> io__write_string("uint_least32_t").
-output_llds_type(bool)     --> io__write_string("Integer").
-output_llds_type(integer)  --> io__write_string("Integer").
-output_llds_type(unsigned) --> io__write_string("Unsigned").
-output_llds_type(float)    --> io__write_string("Float").
-output_llds_type(word)     --> io__write_string("Word").
-output_llds_type(string)   --> io__write_string("String").
-output_llds_type(data_ptr) --> io__write_string("Word *").
-output_llds_type(code_ptr) --> io__write_string("Code *").
+output_llds_type(int_least8)   --> io__write_string("int_least8_t").
+output_llds_type(uint_least8)  --> io__write_string("uint_least8_t").
+output_llds_type(int_least16)  --> io__write_string("int_least16_t").
+output_llds_type(uint_least16) --> io__write_string("uint_least16_t").
+output_llds_type(int_least32)  --> io__write_string("int_least32_t").
+output_llds_type(uint_least32) --> io__write_string("uint_least32_t").
+output_llds_type(bool)         --> io__write_string("Integer").
+output_llds_type(integer)      --> io__write_string("Integer").
+output_llds_type(unsigned)     --> io__write_string("Unsigned").
+output_llds_type(float)        --> io__write_string("Float").
+output_llds_type(word)         --> io__write_string("Word").
+output_llds_type(string)       --> io__write_string("String").
+output_llds_type(data_ptr)     --> io__write_string("Word *").
+output_llds_type(code_ptr)     --> io__write_string("Code *").
 
 :- pred output_cons_arg_decls(list(maybe(rval))::in, string::in, string::in,
 	int::in, int::out, decl_set::in, decl_set::out,
@@ -2374,8 +2374,12 @@
 output_uniform_cons_args([Arg | Args], MaybeType, Indent) -->
 	( { Arg = yes(Rval) } ->
 		io__write_string(Indent),
-		llds_arg_type(Rval, MaybeType, Type),
-		output_rval_as_type(Rval, Type),
+		( { MaybeType = yes(_) } ->
+			output_static_rval(Rval)
+		;
+			llds_out__rval_type_as_arg(Rval, Type),
+			output_rval_as_type(Rval, Type)
+		),
 		( { Args \= [] } ->
 			io__write_string(",\n"),
 			output_uniform_cons_args(Args, MaybeType, Indent)
@@ -2413,8 +2417,12 @@
 		( { Arg = yes(Rval) } ->
 			{ N1 is N - 1 },
 			io__write_string(Indent),
-			llds_arg_type(Rval, MaybeType, Type),
-			output_rval_as_type(Rval, Type),
+			( { MaybeType = yes(_) } ->
+				output_static_rval(Rval)
+			;
+				llds_out__rval_type_as_arg(Rval, Type),
+				output_rval_as_type(Rval, Type)
+			),
 			( { Args \= [] } ->
 				io__write_string(",\n"),
 				output_initial_cons_args_2(Args, N1, MaybeType,
@@ -2893,8 +2901,7 @@
 llds_out__make_stack_layout_name(Label, Name) :-
 	llds_out__get_label(Label, yes, LabelName),
 	string__append_list([
-		"mercury_data_",
-		"_layout__",
+		"mercury_data__layout__",
 		LabelName
 	], Name).
 
@@ -3241,7 +3248,6 @@
 			output_rval(Rval)
 		)
 	).
-
 	
 	% types_match(DesiredType, ActualType) is true iff
 	% a value of type ActualType can be used as a value of
@@ -3553,6 +3559,70 @@
 	io__write_string("(Word *) &"),
 	output_data_addr(ModuleName, VarName).
 output_rval_const(label_entry(Label)) -->
+	io__write_string("ENTRY("),
+	output_label(Label),
+	io__write_string(")").
+
+	% Output an rval as an initializer in a static struct.
+	% Make sure it has the C type the corresponding field would have.
+	% This is the "really" natural type of the rval, free of the
+	% Mercury abstract engine's need to shoehorn things into Words.
+
+:- pred output_static_rval(rval, io__state, io__state).
+:- mode output_static_rval(in, di, uo) is det.
+
+output_static_rval(const(Const)) -->
+	output_rval_static_const(Const).
+output_static_rval(unop(_, _)) -->
+	{ error("Cannot output a unop(_, _) in a static initializer") }.
+output_static_rval(binop(_, _, _)) -->
+	{ error("Cannot output a binop(_, _, _) in a static initializer") }.
+output_static_rval(mkword(Tag, Exprn)) -->
+	io__write_string("mkword("),
+	output_tag(Tag),
+	io__write_string(", "),
+	output_rval_as_type(Exprn, data_ptr),
+	io__write_string(")").
+output_static_rval(lval(_)) -->
+	{ error("Cannot output an lval(_) in a static initializer") }.
+output_static_rval(create(Tag, _Args, _ArgTypes, _StatDyn, CellNum, _Msg)) -->
+		% emit a reference to the static constant which we
+		% declared in output_rval_decls.
+	io__write_string("mkword(mktag("),
+	io__write_int(Tag),
+	io__write_string("), "),
+	io__write_string("&mercury_const_"),
+	io__write_int(CellNum),
+	io__write_string(")").
+output_static_rval(var(_)) -->
+	{ error("Cannot output a var(_) in a static initializer") }.
+output_static_rval(mem_addr(_)) -->
+	{ error("Cannot output a mem_ref(_) in a static initializer") }.
+
+:- pred output_rval_static_const(rval_const, io__state, io__state).
+:- mode output_rval_static_const(in, di, uo) is det.
+
+output_rval_static_const(int_const(N)) -->
+	io__write_int(N).
+output_rval_static_const(float_const(FloatVal)) -->
+	io__write_float(FloatVal).
+output_rval_static_const(string_const(String)) -->
+	io__write_string("(String) string_const("""),
+	output_c_quoted_string(String),
+	{ string__length(String, StringLength) },
+	io__write_string(""", "),
+	io__write_int(StringLength),
+	io__write_string(")").
+output_rval_static_const(true) -->
+	io__write_string("TRUE").
+output_rval_static_const(false) -->
+	io__write_string("FALSE").
+output_rval_static_const(code_addr_const(CodeAddress)) -->
+	output_code_addr(CodeAddress).
+output_rval_static_const(data_addr_const(data_addr(ModuleName, VarName))) -->
+	io__write_string("(Word *) &"),
+	output_data_addr(ModuleName, VarName).
+output_rval_static_const(label_entry(Label)) -->
 	io__write_string("ENTRY("),
 	output_label(Label),
 	io__write_string(")").
diff --recursive -u backup/compiler/options.m mercury/compiler/options.m
--- backup/compiler/options.m	Tue Apr 27 12:19:07 1999
+++ mercury/compiler/options.m	Tue Apr 27 16:10:42 1999
@@ -2031,6 +2031,9 @@
 		"--no-static-ground-terms",
 		"\tDisable the optimization of constructing constant ground terms",
 		"\tat compile time and storing them as static constants.",
+		"\tNote that auxiliarity data structures created by the compiler",
+		"\tfor purposes such as debugging will still be created as",
+		"\tstatic constants.",
 		"--no-middle-rec",
 		"\tDisable the middle recursion optimization.",
 		"--no-simple-neg",
diff --recursive -u backup/compiler/stack_layout.m mercury/compiler/stack_layout.m
--- backup/compiler/stack_layout.m	Tue Apr 27 12:19:14 1999
+++ mercury/compiler/stack_layout.m	Tue Apr 27 20:40:20 1999
@@ -337,8 +337,8 @@
 	{ stack_layout__represent_determinism(Detism, DetismRval) },
 	{ TraversalRvals = [yes(CodeAddrRval), yes(SuccipRval),
 		yes(StackSlotsRval), yes(DetismRval)] },
-	{ TraversalArgTypes = [1 - yes(code_ptr), 1 - yes(uint32), 
-		2 - yes(uint16)] },
+	{ TraversalArgTypes = [1 - yes(code_ptr), 1 - yes(uint_least32), 
+		2 - yes(uint_least16)] },
 
 	stack_layout__get_procid_stack_layout(ProcIdLayout0),
 	{ bool__or(ProcIdLayout0, ForceProcIdLayout, ProcIdLayout) },
@@ -356,7 +356,7 @@
 	;
 		% Indicate the absence of the proc id and exec trace fields.
 		{ IdTraceRvals = [yes(const(int_const(-1)))] },
-		{ IdTraceArgTypes = initial([1 - yes(word)], none) }
+		{ IdTraceArgTypes = initial([1 - yes(integer)], none) }
 	),
 
 	{ Exported = no },	% XXX With the new profiler, we will need to
@@ -402,7 +402,7 @@
 			DeclRval = yes(const(int_const(-1)))
 		),
 		Rvals = [CallRval, FromFullRval, DeclRval],
-		ArgTypes = initial([1 - yes(data_ptr), 2 - yes(int16)],
+		ArgTypes = initial([1 - yes(data_ptr), 2 - yes(int_least16)],
 			none)
 	;
 		% Indicate the absence of the trace layout fields.
@@ -588,7 +588,7 @@
 	list__length(TypeParamLocs, TypeParamsLength),
 	LengthRval = const(int_const(TypeParamsLength)),
 	Vector = [yes(LengthRval) | TypeParamLocs],
-	VectorTypes = uniform(yes(uint32)).
+	VectorTypes = uniform(yes(uint_least32)).
 
 %---------------------------------------------------------------------------%
 
@@ -711,16 +711,17 @@
 
 stack_layout__construct_liveval_arrays(VarInfos, LengthRval,
 		TypeLocnVector, NameVector) -->
+	{ int__pow(2, stack_layout__byte_bits, BytesLimit) },
 	stack_layout__construct_liveval_array_infos(VarInfos,
-		IntArrayInfo, ByteArrayInfo),
+		0, BytesLimit, IntArrayInfo, ByteArrayInfo),
 
 	{ list__length(IntArrayInfo, IntArrayLength) },
 	{ list__length(ByteArrayInfo, ByteArrayLength) },
 	{ list__append(IntArrayInfo, ByteArrayInfo, AllArrayInfo) },
 	{ AllArrayLength is IntArrayLength + ByteArrayLength },
 
-	{ stack_layout__byte_bits(ByteBits) },
-	{ EncodedLength is IntArrayLength << ByteBits + ByteArrayLength },
+	{ EncodedLength is IntArrayLength << stack_layout__byte_bits
+		+ ByteArrayLength },
 	{ LengthRval = const(int_const(EncodedLength)) },
 
 	{ SelectLocns = lambda([ArrayInfo::in, MaybeLocnRval::out] is det, (
@@ -741,9 +742,9 @@
 	{ list__map(SelectLocns, ByteArrayInfo, ByteLocns) },
 	{ list__append(IntLocns, ByteLocns, AllLocns) },
 	{ list__append(AllTypes, AllLocns, TypeLocnVectorRvals) },
-	{ ArgTypes = initial([AllArrayLength - yes(word),
-			IntArrayLength - yes(uint32),
-			ByteArrayLength - yes(uint8)], none) },
+	{ ArgTypes = initial([AllArrayLength - yes(data_ptr),
+			IntArrayLength - yes(uint_least32),
+			ByteArrayLength - yes(uint_least8)], none) },
 	stack_layout__get_next_cell_number(CNum1),
 	{ TypeLocnVector = create(0, TypeLocnVectorRvals, ArgTypes,
 		must_be_static, CNum1, "stack_layout_locn_vector") },
@@ -754,27 +755,31 @@
 		must_be_static, CNum2, "stack_layout_name_vector") }.
 
 :- pred stack_layout__construct_liveval_array_infos(list(var_info)::in,
+	int::in, int::in,
 	list(liveval_array_info)::out, list(liveval_array_info)::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
-stack_layout__construct_liveval_array_infos([], [], []) --> [].
+stack_layout__construct_liveval_array_infos([], _, _, [], []) --> [].
 stack_layout__construct_liveval_array_infos([VarInfo | VarInfos],
-		IntVars, ByteVars) -->
-	stack_layout__construct_liveval_array_infos(VarInfos,
-		IntVars0, ByteVars0),
+		BytesSoFar, BytesLimit, IntVars, ByteVars) -->
 	{ VarInfo = var_info(Locn, LiveValueType) },
 	stack_layout__represent_live_value_type(LiveValueType, TypeRval),
 	{ stack_layout__construct_liveval_name(VarInfo, NameRval) },
-	{ stack_layout__represent_locn_as_byte(Locn, LocnByteRval) ->
-		Var = live_array_info(LocnByteRval, TypeRval, NameRval),
-		IntVars = IntVars0,
-		ByteVars = [Var | ByteVars0]
-	;
-		stack_layout__represent_locn_as_int(Locn, LocnRval),
-		Var = live_array_info(LocnRval, TypeRval, NameRval),
-		IntVars = [Var | IntVars0],
-		ByteVars = ByteVars0
-	}.
+	(
+		{ BytesSoFar < BytesLimit },
+		{ stack_layout__represent_locn_as_byte(Locn, LocnByteRval) }
+	->
+		{ Var = live_array_info(LocnByteRval, TypeRval, NameRval) },
+		stack_layout__construct_liveval_array_infos(VarInfos,
+			BytesSoFar + 1, BytesLimit, IntVars, ByteVars0),
+		{ ByteVars = [Var | ByteVars0] }
+	;
+		{ stack_layout__represent_locn_as_int(Locn, LocnRval) },
+		{ Var = live_array_info(LocnRval, TypeRval, NameRval) },
+		stack_layout__construct_liveval_array_infos(VarInfos,
+			BytesSoFar, BytesLimit, IntVars0, ByteVars),
+		{ IntVars = [Var | IntVars0] }
+	).
 
 :- pred stack_layout__construct_liveval_name(var_info::in, rval::out)
 	is det.
@@ -924,10 +929,10 @@
 	Rval = const(int_const(Word)).
 stack_layout__represent_locn_as_int(indirect(Lval, Offset), Rval) :-
 	stack_layout__represent_lval(Lval, BaseWord),
-	stack_layout__offset_bits(OffsetBits),
-	require((1 << OffsetBits) > Offset,
+	require((1 << stack_layout__long_lval_offset_bits) > Offset,
 	"stack_layout__represent_locn: offset too large to be represented"),
-	BaseAndOffset is (BaseWord << OffsetBits) + Offset,
+	BaseAndOffset is (BaseWord << stack_layout__long_lval_offset_bits)
+		+ Offset,
 	stack_layout__make_tagged_word(lval_indirect, BaseAndOffset, Word),
 	Rval = const(int_const(Word)).
 
@@ -989,8 +994,7 @@
 
 stack_layout__make_tagged_word(Locn, Value, TaggedValue) :-
 	stack_layout__locn_type_code(Locn, Tag),
-	stack_layout__tag_bits(TagBits),
-	TaggedValue is (Value << TagBits) + Tag.
+	TaggedValue is (Value << stack_layout__long_lval_tag_bits) + Tag.
 
 :- type locn_type
 	--->	lval_r_reg
@@ -1017,19 +1021,19 @@
 stack_layout__locn_type_code(lval_sp,       8).
 stack_layout__locn_type_code(lval_indirect, 9).
 
-:- pred stack_layout__tag_bits(int::out) is det.
+:- func stack_layout__long_lval_tag_bits = int.
 
 % This number of tag bits must be able to encode all values of
 % stack_layout__locn_type_code.
 
-stack_layout__tag_bits(4).
+stack_layout__long_lval_tag_bits = 4.
 
 % This number of tag bits must be able to encode the largest offset
 % of a type_info within a typeclass_info.
 
-:- pred stack_layout__offset_bits(int::out) is det.
+:- func stack_layout__long_lval_offset_bits = int.
 
-stack_layout__offset_bits(6).
+stack_layout__long_lval_offset_bits = 6.
 
 %---------------------------------------------------------------------------%
 
@@ -1075,14 +1079,19 @@
 :- pred stack_layout__make_tagged_byte(int::in, int::in, int::out) is semidet.
 
 stack_layout__make_tagged_byte(Tag, Value, TaggedValue) :-
-	stack_layout__byte_bits(ByteBits),
-	int__pow(2, ByteBits - 2, Limit),
+	int__pow(2, stack_layout__byte_bits
+		- stack_layout__short_lval_tag_bigs, Limit),
 	Value < Limit,
-	TaggedValue is unchecked_left_shift(Value, 2) + Tag.
+	TaggedValue is unchecked_left_shift(Value,
+		stack_layout__short_lval_tag_bigs) + Tag.
+
+:- func stack_layout__short_lval_tag_bigs = int.
+
+stack_layout__short_lval_tag_bigs = 2.
 
-:- pred stack_layout__byte_bits(int::out) is det.
+:- func stack_layout__byte_bits = int.
 
-stack_layout__byte_bits(8).
+stack_layout__byte_bits = 8.
 
 %---------------------------------------------------------------------------%
 
diff --recursive -u backup/configure.in mercury/configure.in
--- backup/configure.in	Tue Apr 27 12:17:42 1999
+++ mercury/configure.in	Tue Apr 27 19:21:45 1999
@@ -722,14 +722,15 @@
 		[mercury_cv_word_type=unknown])
 	fi
 	AC_MSG_RESULT($mercury_cv_word_type)
-	AC_DEFINE_UNQUOTED(WORD_TYPE, $mercury_cv_word_type)
-	WORD_TYPE=$mercury_cv_word_type
-	AC_SUBST(WORD_TYPE)
+	AC_DEFINE_UNQUOTED(MR_WORD_TYPE, $mercury_cv_word_type)
+	MR_WORD_TYPE=$mercury_cv_word_type
+	AC_SUBST(MR_WORD_TYPE)
 #-----------------------------------------------------------------------------#
-	AC_MSG_CHECKING(for a 32-bit integer type)
-	AC_CACHE_VAL(mercury_cv_int32_type,
+	AC_MSG_CHECKING(for an integer type of at least 32 bits)
+	AC_CACHE_VAL(mercury_cv_int_least32_type,
 		AC_TRY_RUN([
 		#include <stdio.h>
+		#include <limits.h>
 		int main() {
 			FILE *fp;
 
@@ -737,13 +738,13 @@
 			if (fp == NULL)
 				exit(1);
 
-			if (sizeof(int) >= 4)
+			if (sizeof(int) * CHAR_BIT >= 32)
 			{
 				fprintf(fp, "int\n");
 				exit(0);
 			}
 
-			if (sizeof(long) >= 4)
+			if (sizeof(long) * CHAR_BIT >= 32)
 			{
 				fprintf(fp, "long\n");
 				exit(0);
@@ -752,17 +753,17 @@
 			fprintf(fp, "unknown\n");
 			exit(1);
 		}],
-		[mercury_cv_int32_type=`cat conftest.tags`],
-		[mercury_cv_int32_type=unknown],
-		[mercury_cv_int32_type=unknown])
+		[mercury_cv_int_least32_type=`cat conftest.tags`],
+		[mercury_cv_int_least32_type=unknown],
+		[mercury_cv_int_least32_type=unknown])
 	)
-	AC_MSG_RESULT($mercury_cv_int32_type)
-	AC_DEFINE_UNQUOTED(INT32_TYPE, $mercury_cv_int32_type)
-	INT32_TYPE=$mercury_cv_int32_type
-	AC_SUBST(INT32_TYPE)
+	AC_MSG_RESULT($mercury_cv_int_least32_type)
+	AC_DEFINE_UNQUOTED(MR_INT_LEAST32_TYPE, $mercury_cv_int_least32_type)
+	MR_INT_LEAST32_TYPE=$mercury_cv_int_least32_type
+	AC_SUBST(MR_INT_LEAST32_TYPE)
 #-----------------------------------------------------------------------------#
-	AC_MSG_CHECKING(for a 16-bit integer type)
-	AC_CACHE_VAL(mercury_cv_int16_type,
+	AC_MSG_CHECKING(for an integer type of at least 16 bits)
+	AC_CACHE_VAL(mercury_cv_int_least16_type,
 		AC_TRY_RUN([
 		#include <stdio.h>
 		int main() {
@@ -772,13 +773,13 @@
 			if (fp == NULL)
 				exit(1);
 
-			if (sizeof(short) >= 2)
+			if (sizeof(short) * CHAR_BIT >= 16)
 			{
 				fprintf(fp, "short\n");
 				exit(0);
 			}
 
-			if (sizeof(int) >= 2)
+			if (sizeof(int) * CHAR_BIT >= 16)
 			{
 				fprintf(fp, "int\n");
 				exit(0);
@@ -787,14 +788,14 @@
 			fprintf(fp, "unknown\n");
 			exit(1);
 		}],
-		[mercury_cv_int16_type=`cat conftest.tags`],
-		[mercury_cv_int16_type=unknown],
-		[mercury_cv_int16_type=unknown])
+		[mercury_cv_int_least16_type=`cat conftest.tags`],
+		[mercury_cv_int_least16_type=unknown],
+		[mercury_cv_int_least16_type=unknown])
 	)
-	AC_MSG_RESULT($mercury_cv_int16_type)
-	AC_DEFINE_UNQUOTED(INT16_TYPE, $mercury_cv_int16_type)
-	INT16_TYPE=$mercury_cv_int16_type
-	AC_SUBST(INT16_TYPE)
+	AC_MSG_RESULT($mercury_cv_int_least16_type)
+	AC_DEFINE_UNQUOTED(MR_INT_LEAST16_TYPE, $mercury_cv_int_least16_type)
+	MR_INT_LEAST16_TYPE=$mercury_cv_int_least16_type
+	AC_SUBST(MR_INT_LEAST16_TYPE)
 fi # ! HAVE_STDINT_H = 1
 #-----------------------------------------------------------------------------#
 AC_MSG_CHECKING(the number of low tag bits available)
@@ -1332,7 +1333,7 @@
 # programs we attempt to compile below indirectly include it.
 test -f runtime/mercury_conf.h || {
 	cat > runtime/mercury_conf.h <<EOF
-#define WORD_TYPE $WORD_TYPE
+#define MR_WORD_TYPE $MR_WORD_TYPE
 EOF
 }
 #-----------------------------------------------------------------------------#
diff --recursive -u backup/doc/user_guide.texi mercury/doc/user_guide.texi
--- backup/doc/user_guide.texi	Tue Apr 27 12:24:09 1999
+++ mercury/doc/user_guide.texi	Tue Apr 27 12:49:56 1999
@@ -3404,6 +3404,9 @@
 @item --no-static-ground-terms
 Disable the optimization of constructing constant ground terms
 at compile time and storing them as static constants.
+Note that auxiliarity data structures created by the compiler
+for purposes such as debugging
+will still be created as static constants.
 
 @sp 1
 @item --no-smart-indexing
diff --recursive -u backup/runtime/mercury_layout_util.c mercury/runtime/mercury_layout_util.c
--- backup/runtime/mercury_layout_util.c	Tue Apr 27 12:18:11 1999
+++ mercury/runtime/mercury_layout_util.c	Tue Apr 27 16:24:10 1999
@@ -203,8 +203,8 @@
 int
 MR_get_register_number_short(MR_Short_Lval locn)
 {
-	if ((locn & 03) == MR_SHORT_LVAL_TYPE_R) {
-		return locn >> 2;
+	if (MR_SHORT_LVAL_TYPE(locn) == MR_SHORT_LVAL_TYPE_R) {
+		return locn >> MR_SHORT_LVAL_TAGBITS;
 	} else {
 		return -1;
 	}
@@ -349,8 +349,8 @@
 	*succeeded = FALSE;
 	value = 0;
 
-	locn_num = (int) locn >> 2;
-	switch (locn & 03) {
+	locn_num = (int) locn >> MR_SHORT_LVAL_TAGBITS;
+	switch (MR_SHORT_LVAL_TYPE(locn)) {
 		case MR_SHORT_LVAL_TYPE_R:
 			if (MR_print_locn) {
 				printf("r%d", locn_num);
@@ -442,11 +442,11 @@
 	bool	succeeded;
 	Word	*pseudo_type_info;
 
-	if (!MR_LIVE_TYPE_IS_VAR(MR_var_pti(vars, i))) {
+	pseudo_type_info = MR_LIVE_TYPE_GET_VAR_TYPE(MR_var_pti(vars, i));
+	if (!MR_LIVE_TYPE_IS_VAR(pseudo_type_info)) {
 		return FALSE;
 	}
 
-	pseudo_type_info = MR_LIVE_TYPE_GET_VAR_TYPE(MR_var_pti(vars, i));
 	*type_info = (Word) MR_create_type_info(type_params, pseudo_type_info);
 
 	if (i < MR_long_desc_var_count(vars)) {
diff --recursive -u backup/runtime/mercury_stack_layout.h mercury/runtime/mercury_stack_layout.h
--- backup/runtime/mercury_stack_layout.h	Tue Apr 27 12:18:13 1999
+++ mercury/runtime/mercury_stack_layout.h	Tue Apr 27 16:25:49 1999
@@ -100,8 +100,8 @@
 ** value giving the location of the pointer to the type class info.
 ** This MR_Long_Lval valud will *not* have an indirect tag.
 **
-** This data is generated in compiler/stack_layout.m, which must be kept
-** in sync with the constants defined here.
+** This data is generated in stack_layout__represent_locn_as_int,
+** which must be kept in sync with the constants and macros defined here.
 */
 
 typedef uint_least32_t	MR_Long_Lval;
@@ -120,7 +120,7 @@
 	MR_LONG_LVAL_TYPE_UNKNOWN 
 } MR_Long_Lval_Type;
 
-/* This must be in sync with stack_layout__tag_bits */
+/* This must be in sync with stack_layout__long_lval_tag_bits */
 #define MR_LONG_LVAL_TAGBITS	4
 
 #define MR_LONG_LVAL_TYPE(Locn) 					\
@@ -163,6 +163,9 @@
 **  stackvar(Num)	 1	Num (stack slot number)
 **  framevar(Num)	 2	Num (stack slot number)
 **  special reg		 3	MR_Long_Lval_Type
+**
+** This data is generated in stack_layout__represent_locn_as_byte,
+** which must be kept in sync with the constants and macros defined here.
 */
 
 typedef uint_least8_t	MR_Short_Lval;
@@ -174,14 +177,24 @@
 	MR_SHORT_LVAL_TYPE_SPECIAL
 } MR_Short_Lval_Type;
 
+/* This must be in sync with stack_layout__short_lval_tag_bits */
+#define MR_SHORT_LVAL_TAGBITS	2
+
+#define MR_SHORT_LVAL_TYPE(Locn) 					\
+	((MR_Short_Lval_Type)						\
+		(((Word) Locn) & ((1 << MR_SHORT_LVAL_TAGBITS) - 1)))
+
 #define	MR_SHORT_LVAL_STACKVAR(n)					\
-	((MR_Short_Lval) (((n) << 2) + MR_SHORT_LVAL_TYPE_STACKVAR))
+	((MR_Short_Lval) (((n) << MR_SHORT_LVAL_TAGBITS)		\
+		+ MR_SHORT_LVAL_TYPE_STACKVAR))
 
 #define	MR_SHORT_LVAL_FRAMEVAR(n)					\
-	((MR_Short_Lval) (((n) << 2) + MR_SHORT_LVAL_TYPE_FRAMEVAR))
+	((MR_Short_Lval) (((n) << MR_SHORT_LVAL_TAGBITS)		\
+		+ MR_SHORT_LVAL_TYPE_FRAMEVAR))
 
 #define	MR_SHORT_LVAL_R_REG(n)						\
-	((MR_Short_Lval) (((n) << 2) + MR_SHORT_LVAL_TYPE_R))
+	((MR_Short_Lval) (((n) << MR_SHORT_LVAL_TAGBITS)		\
+		+ MR_SHORT_LVAL_TYPE_R))
 
 /*-------------------------------------------------------------------------*/
 /*
diff --recursive -u backup/runtime/mercury_types.h mercury/runtime/mercury_types.h
--- backup/runtime/mercury_types.h	Tue Apr 27 12:18:15 1999
+++ mercury/runtime/mercury_types.h	Tue Apr 27 15:56:07 1999
@@ -27,16 +27,16 @@
 */
 
 #ifdef	HAVE_STDINT
-#include <stdint.h>
+  #include <stdint.h>
 #else
-typedef	unsigned WORD_TYPE	uintptr_t;
-typedef	WORD_TYPE		intptr_t;
-typedef	unsigned INT32_TYPE	uint_least32_t;
-typedef	INT32_TYPE		int_least32_t;
-typedef	unsigned INT16_TYPE	uint_least16_t;
-typedef	INT16_TYPE		int_least16_t;
-typedef	unsigned char		uint_least8_t;
-typedef	signed char		int_least8_t;
+  typedef unsigned MR_WORD_TYPE		uintptr_t;
+  typedef MR_WORD_TYPE			intptr_t;
+  typedef unsigned MR_INT_LEAST32_TYPE	uint_least32_t;
+  typedef MR_INT_LEAST32_TYPE		int_least32_t;
+  typedef unsigned MR_INT_LEAST16_TYPE	uint_least16_t;
+  typedef MR_INT_LEAST16_TYPE		int_least16_t;
+  typedef unsigned char			uint_least8_t;
+  typedef signed char			int_least8_t;
 #endif
 
 typedef	uintptr_t		Word;
--------------------------------------------------------------------------
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