Files
mercury/compiler/transform.m
Zoltan Somogyi 649b6908c3 Rename branch_delay_slot to have_delay_slot.
Estimated hours taken: 8

options.m:
	Rename branch_delay_slot to have_delay_slot.
	Set optimize_delay_slot in -O2 only if have_delay_slot was set earlier.
	This is possible now because the default optimization level is now
	set in mc.

mercury_compile:
	Change verbose output a bit to be more consistent.

dead_proc_elim:
	Export the predicates that will eventually be needed by inlining.m.

inlining.m:
	Use the information about the number of times each procedure is called
	to inline local nonrecursive procedures that are called exactly once.
	EXCEPT that this is turned off at the moment, since the inlining of
	parse_dcg_goal_2 in prog_io, which this change enables, causes the
	compiler to emit incorrect code.

prog_io:
	Moved the data type definitions to prog_data. (Even though prog_io.m
	is ten times the size of prog_data.m, the sizes of the .c files are
	not too dissimilar.)
1996-04-24 01:00:23 +00:00

79 lines
2.8 KiB
Mathematica

%-----------------------------------------------------------------------------%
% Copyright (C) 1995 University of Melbourne.
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------%
% File: transform.m
% Main author: bromage.
%
% This module defines the primitive operations that may be performed
% on a logic program. These include:
%
% - unfold (NYI)
% Replaces a goal with its possible expansions.
%
% - fold (NYI)
% Opposite of unfold (not surprisingly).
%
% - definition (NYI)
% Define a new predicate with a given goal.
%
% - identity (NYI)
% Apply an identity (such as the associative law for
% addition) to a goal.
%
% These operations form the basis of most high-level transformations.
%
% Also included is a conjunction rescheduler. Useful just in case
% your transformer upset the ordering in a conjunction.
%-----------------------------------------------------------------------------%
:- module transform.
:- interface.
:- import_module hlds_goal, llds, mode_info.
%:- pred unfold__in_proc(pred_id, proc_id, hlds__goal_expr,
% mode_info, mode_info).
%:- mode unfold__in_proc(in, in, out, mode_info_di, module_info_uo) is det.
:- pred transform__reschedule_conj(list(hlds__goal), list(hlds__goal),
mode_info, mode_info).
:- mode transform__reschedule_conj(in, out, mode_info_di, mode_info_uo) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- implementation.
:- import_module list, map, set, std_util.
:- import_module mode_util, delay_info, term, require.
:- import_module varset, code_aux, prog_data.
%-----------------------------------------------------------------------------%
% unfold__in_proc(
%-----------------------------------------------------------------------------%
transform__reschedule_conj([], []) --> [].
transform__reschedule_conj([Goal0 | Goals0], Goals) -->
=(ModeInfo0),
{ mode_info_get_instmap(ModeInfo0, InstMap0) },
{ mode_info_get_delay_info(ModeInfo0, DelayInfo0) },
{ delay_info__wakeup_goals(DelayInfo0, WokenGoals, DelayInfo1) },
mode_info_set_delay_info(DelayInfo1),
( { WokenGoals \= [] } ->
{ list__append(WokenGoals, [Goal0 | Goals0], Goals1) },
transform__reschedule_conj(Goals1, Goals)
;
{ Goal0 = _Goal0Goal - Goal0Info },
{ goal_info_get_instmap_delta(Goal0Info, InstMapDelta) },
{ apply_instmap_delta(InstMap0, InstMapDelta, InstMap1) },
mode_info_set_instmap(InstMap1),
transform__reschedule_conj(Goals0, Goals1),
{ Goals = [Goal0 | Goals1] }
).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%