[m-rev.] for review: improve procname mangling for .NET backend.

Tyson Dowd trd at cs.mu.OZ.AU
Fri May 11 00:39:16 AEST 2001


Ok, I've made the suggested changes, and left alone the more advanced
mangling options we've discussed.  I also fixed mlds_to_gcc.m to
accomodate these changes.  I'll commit this change today.

--- zzlog.mangling4	Wed May  9 23:22:36 2001
+++ zzlog.mangling5	Thu May 10 21:30:57 2001
@@ -11,7 +11,11 @@
 compiler/mlds_to_c.m:
 compiler/mlds_to_java.m:
 	Add the code_model and a boolean indicating whether this
-	function has a non-default (in, in, in, out) mode to the proc_label.
+	function (if it is a function) *doesn't* have a return value
+	(i.e. it has a non-default mode).
+
+	Also move is_output_det_function into ml_code_util.m and rename it
+	ml_is_output_det_function.
 
 compiler/mlds_to_il.m:
 	Mangle much more carefully.  We still mangle in a predictable,
diff -u compiler/ml_code_util.m compiler/ml_code_util.m
--- compiler/ml_code_util.m
+++ compiler/ml_code_util.m
@@ -92,6 +92,17 @@
 		mlds__statement, mlds__defn, ml_gen_info, ml_gen_info).
 :- mode ml_gen_label_func(in, in, in, in, out, in, out) is det.
 
+	%
+	% Test to see if the procedure is 
+	% a model_det function whose function result has an output mode
+	% (whose type is not a dummy argument type like io__state),
+	% and if so, bind RetVar to the procedure's return value.
+	% These procedures need to handled specially: for such functions,
+	% we map the Mercury function result to an MLDS return value.
+	%
+:- pred ml_is_output_det_function(module_info, pred_id, proc_id, prog_var).
+:- mode ml_is_output_det_function(in, in, in, out) is semidet.
+
 %-----------------------------------------------------------------------------%
 %
 % Routines for generating types.
@@ -168,9 +179,9 @@
 		mlds__pred_label, mlds_module_name).
 :- mode ml_gen_pred_label(in, in, in, out, out) is det.
 
-:- pred ml_gen_pred_label_from_rtti(rtti_proc_label,
+:- pred ml_gen_pred_label_from_rtti(module_info, rtti_proc_label,
 		mlds__pred_label, mlds_module_name).
-:- mode ml_gen_pred_label_from_rtti(in, out, out) is det.
+:- mode ml_gen_pred_label_from_rtti(in, in, out, out) is det.
 
 	% Allocate a new label name, for use in label statements.
 	%
@@ -1115,6 +1126,26 @@
 	Name = data(var(Var)),
 	FuncArg = Name - MLDS_ArgType.
 
+
+ml_is_output_det_function(ModuleInfo, PredId, ProcId, RetArgVar) :-
+	module_info_pred_proc_info(ModuleInfo, PredId, ProcId, PredInfo,
+			ProcInfo),
+	
+	pred_info_get_is_pred_or_func(PredInfo, function),
+	proc_info_interface_code_model(ProcInfo, model_det),
+
+	proc_info_argmodes(ProcInfo, Modes),
+	pred_info_arg_types(PredInfo, ArgTypes),
+	proc_info_headvars(ProcInfo, ArgVars),
+	modes_to_arg_modes(ModuleInfo, Modes, ArgTypes, ArgModes),
+	pred_args_to_func_args(ArgModes, _InputArgModes, RetArgMode),
+	pred_args_to_func_args(ArgTypes, _InputArgTypes, RetArgType),
+	pred_args_to_func_args(ArgVars, _InputArgVars, RetArgVar),
+
+	RetArgMode = top_out,
+	\+ type_util__is_dummy_argument_type(RetArgType).
+
+
 %-----------------------------------------------------------------------------%
 %
 % Code for generating mlds__entity_names.
@@ -1177,13 +1208,14 @@
 	%
 ml_gen_pred_label(ModuleInfo, PredId, ProcId, MLDS_PredLabel, MLDS_Module) :-
 	RttiProcLabel = rtti__make_proc_label(ModuleInfo, PredId, ProcId),
-	ml_gen_pred_label_from_rtti(RttiProcLabel,
+	ml_gen_pred_label_from_rtti(ModuleInfo, RttiProcLabel,
 		MLDS_PredLabel, MLDS_Module).
 
-ml_gen_pred_label_from_rtti(RttiProcLabel, MLDS_PredLabel, MLDS_Module) :-
+ml_gen_pred_label_from_rtti(ModuleInfo, RttiProcLabel, MLDS_PredLabel,
+		MLDS_Module) :-
 	RttiProcLabel = rtti_proc_label(PredOrFunc, ThisModule, PredModule,	
-		PredName, PredArity, ArgTypes, _PredId, ProcId,
-		_VarSet, _HeadVars, ArgModes, CodeModel,
+		PredName, PredArity, ArgTypes, PredId, ProcId,
+		_VarSet, _HeadVars, _ArgModes, CodeModel,
 		IsImported, _IsPseudoImported, _IsExported,
 		IsSpecialPredInstance),
 	(
@@ -1247,26 +1279,22 @@
 		),
 		(
 			PredOrFunc = function,
-			not (default_func_arg_modes(ArgModes))
+			ml_is_output_det_function(ModuleInfo, PredId,
+				ProcId, _)
 		->
-			NonDefaultModeFunc = yes
+			NonOutputFunc = no
 		;
-			NonDefaultModeFunc = no
+			NonOutputFunc = yes
 		),
 		MLDS_PredLabel = pred(PredOrFunc, MaybeDeclaringModule,
 				PredName, PredArity, CodeModel,
-				NonDefaultModeFunc)
+				NonOutputFunc)
 	),
 	MLDS_Module = mercury_module_name_to_mlds(DefiningModule).
 
 ml_gen_new_label(Label) -->
 	ml_gen_info_new_label(LabelNum),
 	{ string__format("label_%d", [i(LabelNum)], Label) }.
-
-:- pred default_func_arg_modes(list(arg_mode)::in) is semidet.
-default_func_arg_modes([top_out]).
-default_func_arg_modes([top_in, ArgMode2 | ArgModes]) :- 
-	default_func_arg_modes([ArgMode2 | ArgModes]).
 
 %-----------------------------------------------------------------------------%
 %
diff -u compiler/ml_elim_nested.m compiler/ml_elim_nested.m
--- compiler/ml_elim_nested.m
+++ compiler/ml_elim_nested.m
@@ -607,7 +607,7 @@
 :- func ml_pred_label_name(mlds__pred_label) = string.
 
 ml_pred_label_name(pred(PredOrFunc, MaybeDefiningModule, Name, Arity,
-		_CodeModel, _NonDefaultModeFunc)) = LabelName :-
+		_CodeModel, _NonOutputFunc)) = LabelName :-
 	( PredOrFunc = predicate, Suffix = "p"
 	; PredOrFunc = function, Suffix = "f"
 	),
diff -u compiler/mlds.m compiler/mlds.m
--- compiler/mlds.m
+++ compiler/mlds.m
@@ -1377,7 +1377,8 @@
 			string,			% name
 			arity,			% arity
 			code_model,		% code model
-			bool			% non-default mode function
+			bool			% function without return value
+						% (i.e. non-default mode)
 		)
 			
 	;	special_pred(
diff -u compiler/mlds_to_c.m compiler/mlds_to_c.m
--- compiler/mlds_to_c.m
+++ compiler/mlds_to_c.m
@@ -1424,7 +1424,7 @@
 :- mode mlds_output_pred_label(in, di, uo) is det.
 
 mlds_output_pred_label(pred(PredOrFunc, MaybeDefiningModule, Name, Arity,
-		_CodeModel, _NonDefaultModeFunc)) -->
+		_CodeModel, _NonOutputFunc)) -->
 	( { PredOrFunc = predicate, Suffix = "p" }
 	; { PredOrFunc = function, Suffix = "f" }
 	),
diff -u compiler/mlds_to_il.m compiler/mlds_to_il.m
--- compiler/mlds_to_il.m
+++ compiler/mlds_to_il.m
@@ -2040,7 +2040,7 @@
 	% user names in the case where there is a <modulename>. - fjh
 	%
 predlabel_to_id(pred(PredOrFunc, MaybeModuleName, Name, Arity, CodeModel,
-	NonDefaultModeFunc), ProcId, MaybeSeqNum, Id) :-
+	NonOutputFunc), ProcId, MaybeSeqNum, Id) :-
 		( MaybeModuleName = yes(ModuleName) ->
 			mlds_to_il__sym_name_to_string(ModuleName, MStr),
 			string__format("%s_", [s(MStr)], MaybeModuleStr)
@@ -2054,7 +2054,7 @@
 			PredOrFuncStr = "_p" 
 		;
 			PredOrFunc = function,
-			NonDefaultModeFunc = yes
+			NonOutputFunc = yes
 		->
 			PredOrFuncStr = "_f" 
 		;
diff -u compiler/mlds_to_java.m compiler/mlds_to_java.m
--- compiler/mlds_to_java.m
+++ compiler/mlds_to_java.m
@@ -1120,7 +1120,7 @@
 :- mode output_pred_label(in, di, uo) is det.
 
 output_pred_label(pred(PredOrFunc, MaybeDefiningModule, Name, Arity,
-		_CodeModel, _NonDefaultModeFunc)) -->
+		_CodeModel, _NonOutputFunc)) -->
 	( { PredOrFunc = predicate, Suffix = "p" }
 	; { PredOrFunc = function, Suffix = "f" }
 	),
only in patch2:
--- compiler/rtti_to_mlds.m	2001/05/02 11:36:41	1.13
+++ compiler/rtti_to_mlds.m	2001/05/10 13:37:29
@@ -527,7 +527,8 @@
 	% construct an rval for the address of this procedure
 	% (this is similar to ml_gen_proc_addr_rval)
 	%
-        ml_gen_pred_label_from_rtti(RttiProcId, PredLabel, PredModule),
+        ml_gen_pred_label_from_rtti(ModuleInfo, RttiProcId, PredLabel,
+		PredModule),
 	ProcId = RttiProcId^proc_id,
         QualifiedProcLabel = qual(PredModule, PredLabel - ProcId),
 	Params = ml_gen_proc_params_from_rtti(ModuleInfo, RttiProcId),
only in patch2:
--- compiler/mlds_to_gcc.m	2001/05/08 05:36:50	1.38
+++ compiler/mlds_to_gcc.m	2001/05/10 13:37:22
@@ -134,7 +134,7 @@
 :- import_module globals, options, passes_aux.
 :- import_module builtin_ops, modules.
 :- import_module prog_data, prog_out, prog_util, type_util, error_util.
-:- import_module pseudo_type_info.
+:- import_module pseudo_type_info, code_model.
 
 :- import_module bool, int, string, library, list, map.
 :- import_module assoc_list, term, std_util, require.
@@ -1543,7 +1543,8 @@
 		% necessarily need to be unique.
 		%
 		(
-			PredLabel = pred(_PorF, _ModuleName, PredName, _Arity),
+			PredLabel = pred(_PorF, _ModuleName, PredName, _Arity,
+				_CodeModel, _NonOutputFunc),
 		  	FuncName = PredName
 		;
 			PredLabel = special_pred(SpecialPredName, _ModuleName,
@@ -1559,8 +1560,8 @@
 :- pred get_pred_label_name(mlds__pred_label, string).
 :- mode get_pred_label_name(in, out) is det.
 
-get_pred_label_name(pred(PredOrFunc, MaybeDefiningModule, Name, Arity),
-		LabelName) :-
+get_pred_label_name(pred(PredOrFunc, MaybeDefiningModule, Name, Arity,
+			_CodeMode, _NonOutputFunc), LabelName) :-
 	( PredOrFunc = predicate, Suffix = "p"
 	; PredOrFunc = function, Suffix = "f"
 	),
@@ -2149,7 +2150,8 @@
 			% don't module-qualify main/2
 			%
 			Name = function(PredLabel, _, _, _),
-			PredLabel = pred(predicate, no, "main", 2)
+			PredLabel = pred(predicate, no, "main", 2,
+				model_det, no)
 		;
 			%
 			% don't module-qualify base_typeclass_infos
only in patch2:
--- compiler/ml_code_gen.m	2001/05/09 11:30:56	1.85
+++ compiler/ml_code_gen.m	2001/05/10 13:37:20
@@ -858,35 +858,6 @@
 			MLDS_FuncParams, MLDS_Context).
 
 
-	%
-	% Test to see if the procedure is 
-	% a model_det function whose function result has an output mode
-	% (whose type is not a dummy argument type like io__state),
-	% and if so, bind RetVar to the procedure's return value.
-	% These procedures need to handled specially: for such functions,
-	% we map the Mercury function result to an MLDS return value.
-	%
-:- pred is_output_det_function(module_info, pred_id, proc_id, prog_var).
-:- mode is_output_det_function(in, in, in, out) is semidet.
-
-is_output_det_function(ModuleInfo, PredId, ProcId, RetArgVar) :-
-	module_info_pred_proc_info(ModuleInfo, PredId, ProcId, PredInfo,
-			ProcInfo),
-	
-	pred_info_get_is_pred_or_func(PredInfo, function),
-	proc_info_interface_code_model(ProcInfo, model_det),
-
-	proc_info_argmodes(ProcInfo, Modes),
-	pred_info_arg_types(PredInfo, ArgTypes),
-	proc_info_headvars(ProcInfo, ArgVars),
-	modes_to_arg_modes(ModuleInfo, Modes, ArgTypes, ArgModes),
-	pred_args_to_func_args(ArgModes, _InputArgModes, RetArgMode),
-	pred_args_to_func_args(ArgTypes, _InputArgTypes, RetArgType),
-	pred_args_to_func_args(ArgVars, _InputArgVars, RetArgVar),
-
-	RetArgMode = top_out,
-	\+ type_util__is_dummy_argument_type(RetArgType).
-
 %-----------------------------------------------------------------------------%
 %
 % Stuff to generate MLDS code for HLDS predicates & functions.
@@ -1155,7 +1126,7 @@
 		% variables are passed by reference
 		ml_gen_info_get_pred_id(MLDSGenInfo0, PredId),
 		ml_gen_info_get_proc_id(MLDSGenInfo0, ProcId),
-		is_output_det_function(ModuleInfo, PredId,
+		ml_is_output_det_function(ModuleInfo, PredId,
 			ProcId, ResultVar)
 	->
 		CopiedOutputVars = [ResultVar],

-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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