Change the MLDS calling convention so that for model_det Mercury functions

Estimated hours taken: 6

Change the MLDS calling convention so that for model_det Mercury functions
with output mode results, the function results get mapped to MLDS function
return values rather than to by-ref parameters.  The rationale for this is
to make interoperability simpler (especially for the IL & Java back-ends).

compiler/lambda.m:
	Change the rules for compatibility of closures so that for
	MLDS grades function closures are not treated as compatible
	with predicate closures.

compiler/ml_code_util.m:
	Change ml_gen_params so that it takes a pred_or_func parameter, and
	for model_det functions it maps the output-moded function results
	to MLDS return values.

compiler/ml_code_gen.m:
	For model_det functions with output mode results,
	return the function result by value.
	Rename the `output_vars' field of the ml_gen_info as
	`byref_output_vars'.

compiler/ml_call_gen.m:
	Pass down the pred_or_func parameter to ml_gen_params.
	For calls to model_det functions with output mode results,
	return the function result by value.

compiler/hlds_goal.m:
	Add new predicate generic_call_pred_or_func, for use by ml_call_gen.m.

compiler/ml_unify_gen.m:
	Modify the code for generating wrapper functions for closures so
	that it reflects the new calling convention for Mercury functions.

compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/ml_code_gen.m:
	Don't handle model_det functions with output mode results specially
	in `pragma export' anymore, since the internal MLDS form now
	has the same prototype as the exported one.
This commit is contained in:
Fergus Henderson
2000-10-30 07:09:04 +00:00
parent 32a32dc6f0
commit 4fd150c78f
8 changed files with 296 additions and 201 deletions

View File

@@ -395,21 +395,32 @@ lambda__process_lambda(PredOrFunc, EvalMethod, Vars, Modes, Detism,
list__member(InitialVar, Vars)
),
proc_info_interface_code_model(Call_ProcInfo, Call_CodeModel),
determinism_to_code_model(Detism, CodeModel),
% Check that the code models are compatible.
% Note that det is not compatible with semidet,
% and semidet is not compatible with nondet,
% since the calling conventions are different.
% But if we're using the LLDS back-end
% If we're using the LLDS back-end
% (i.e. not --high-level-code),
% det is compatible with nondet.
( CodeModel = Call_CodeModel
; CodeModel = model_non, Call_CodeModel = model_det,
module_info_globals(ModuleInfo0, Globals),
globals__lookup_bool_option(Globals,
highlevel_code, no)
% If we're using the MLDS back-end,
% then predicates and functions have different
% calling conventions.
proc_info_interface_code_model(Call_ProcInfo, Call_CodeModel),
determinism_to_code_model(Detism, CodeModel),
module_info_globals(ModuleInfo0, Globals),
globals__lookup_bool_option(Globals, highlevel_code, HighLevelCode),
(
HighLevelCode = no,
( CodeModel = Call_CodeModel
; CodeModel = model_non, Call_CodeModel = model_det
)
;
HighLevelCode = yes,
pred_info_get_is_pred_or_func(Call_PredInfo, Call_PredOrFunc),
PredOrFunc = Call_PredOrFunc,
CodeModel = Call_CodeModel
),
% check that the curried arguments are all input
proc_info_argmodes(Call_ProcInfo, Call_ArgModes),
list__length(InitialVars, NumInitialVars),