[m-dev.] for review: implement pragma export for MLDS backend

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Jul 18 08:02:21 AEST 2000


On 17-Jul-2000, Peter Ross <peter.ross at miscrit.be> wrote:
...
> Implement `pragma export' for the MLDS backend.
> 
> +++ compiler/ml_code_gen.m	2000/07/17 12:58:18
> @@ -662,13 +661,14 @@
>  
>  :- import_module ml_type_gen, ml_call_gen, ml_unify_gen, ml_code_util.
>  :- import_module llds. % XXX needed for `code_model'.
> -:- import_module export, llds_out. % XXX needed for pragma C code
> +:- import_module arg_info, export, llds_out. % XXX needed for pragma C code

arg_info shold not be needed -- see my comments below.

> +	%
> +	% Test to see if the procedure is of the following form
> +	%   :- func (T::in, U::in) = V::out is det.
> +	% as these need to handled specially.
> +	%
> +:- pred is_forward_mode_det_function(module_info, pred_id, proc_id).
> +:- mode is_forward_mode_det_function(in, in, in) is semidet.

The comment here and the name of the function are both
misleading.  The condition that this actually tests for
is for a procedure of the form

	%  :- func <Name>(...) = <Type>::out is det.

It's not checking that this is a "forward" mode, it is just checking
that the mode of the function result is output (or more specifically any
`top_out' mode).

> +is_forward_mode_det_function(ModuleInfo, PredId, ProcId) :-
> +	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, CodeModel),
> +
> +	CodeModel = model_det,

Please be consistent: either write that as

	pred_info_get_is_pred_or_func(PredInfo, function),
	proc_info_interface_code_model(ProcInfo, model_det)

or as

	pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
	PredOrFunc = function,

	proc_info_interface_code_model(ProcInfo, CodeModel),
	CodeModel = model_det,

> +		% XXX I am sure that there is a better way to do this,
> +		% but this is how export.m figures it out!
> +	proc_info_argmodes(ProcInfo, ArgModes),
> +	pred_info_arg_types(PredInfo, ArgTypes),
> +	make_arg_infos(ArgTypes, ArgModes, CodeModel, ModuleInfo, ArgInfos),
> +
> +	assoc_list__from_corresponding_lists(ArgInfos, ArgTypes,
> +			ArgInfoTypes),
> +
> +	pred_args_to_func_args(ArgInfoTypes, _InputArgInfoTypes,
> +			arg_info(_RetArgLoc, RetArgMode) - RetType),

Here's a better way to do it:

	proc_info_argmodes(ProcInfo, Modes),
	pred_info_arg_types(PredInfo, ArgTypes),
	modes_to_arg_modes(ModuleInfo, Modes, ArgTypes, ArgModes),
	pred_args_to_func_args(ArgModes, _InputArgModes, RetArgMode),
	pred_args_to_func_args(ArgTypes, _InputArgTypes, RetArgType),

[I haven't finished reviewing this change yet.]

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- 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