[m-dev.] for review: update alias branch
Simon Taylor
stayl at cs.mu.OZ.AU
Tue May 4 15:55:23 AEST 1999
Hi,
This is for review by David Overton.
The full diff is in /home/mercury0/stayl/alias2/mercury/diff.
Simon.
Estimated hours taken: 25
Update the alias branch to 3 May 1999.
This bootstraps successfully.
tests/hard_coded/ho_order.m, tests/hard_coded/ho_order2.m
and tests/hard_coded/type_spec.m fail.
Most of the changes were trivial.
compiler/context.m:
compiler/magic_util.m:
compiler/magic.m:
Run recompute_instmap_delta on the Aditi procedures after the
transformation. Take less care to maintain the instmap_deltas
during the transformation, since they will be recomputed.
compiler/rl.m:
Add an inst_table to the top-down goals for join conditions.
compiler/rl_exprn.m:
Thread an instmap through.
compiler/rl_block_opt.m:
When concatenating the goals of two projections being merged into
a single instruction, recompute_instmap_deltas.
compiler/rl_out.m:
Fix some bugs in the change to avoid compiling rl_code.m.
compiler/hlds_pred.m:
Provide a version of hlds_pred__define_new_pred which takes
the argument modes to use rather than computing them from
the goal's instmap_delta. This avoids problems with magic.m
messing about with the argument modes of the procedure and
not updating the instmap_deltas until after processing is complete.
compiler/higher_order.m:
Call recompute_instmap_delta where required.
compiler/table_gen.m:
Remove calls to instmap_delta_restrict, which doesn't work with
aliasing.
compiler/code_info.m:
Add a predicate code_info__resume_map_to_variable_locations,
which converts a resume_map to a map(prog_var, set(rval)),
discarding the reference elements. This is used to convert
the resume_map to the form expected by
continuation_info__find_typeinfos_for_tvars (typeinfos are never
passed by reference). I'm not entirely sure why the resume_maps
need a different representation.
The following modules are new to the alias branch, the diffs
are relative to the main branch.
--- /tmp/stayl/mercury/compiler/context.m Mon Dec 7 10:43:02 1998
+++ context.m Mon Dec 14 14:03:49 1998
@@ -489,12 +489,8 @@
{ Call = db_call(_, _ - GoalInfo0, _, Args, InputArgs, _, _) },
magic_info_get_curr_pred_proc_id(proc(PredId, ProcId)),
- magic_info_get_magic_proc_info(MagicProcInfo),
- { map__lookup(MagicProcInfo, proc(PredId, ProcId),
- ThisProcInfo) },
- { ThisProcInfo = magic_proc_info(OldArgModes, _, _, _, _) },
magic_util__create_input_test_unifications(Args, InputArgs,
- OldArgModes, NewArgs, [], Tests,
+ NewArgs, [], Tests,
GoalInfo0, GoalInfo),
magic_info_get_pred_info(PredInfo),
{ pred_info_module(PredInfo, PredModule) },
@@ -515,7 +511,7 @@
context__create_magic_call(MagicCall, RenameInputs, Subn, MagicInputArgs) -->
magic_util__magic_call_info(MagicPredId, MagicProcId, PredName,
- InputRels, InputArgs, MagicOutputModes),
+ InputRels, InputArgs, _MagicOutputModes),
magic_info_get_proc_info(ProcInfo0),
{ proc_info_vartypes(ProcInfo0, VarTypes0) },
@@ -528,22 +524,16 @@
{ map__from_corresponding_lists(InputArgs,
NewInputArgs, Subn) },
{ list__append(InputRels, InputArgs, MagicInputArgs) },
- { list__append(MagicInputArgs, NewInputArgs, MagicArgs) },
-
- { list__append(InputArgs, NewInputArgs, AllInputArgs) }
+ { list__append(MagicInputArgs, NewInputArgs, MagicArgs) }
;
{ map__init(Subn) },
{ list__append(InputRels, NewInputArgs, MagicInputArgs) },
- { list__append(MagicInputArgs, InputArgs, MagicArgs) },
-
- { list__append(NewInputArgs, InputArgs, AllInputArgs) }
+ { list__append(MagicInputArgs, InputArgs, MagicArgs) }
),
{ set__list_to_set(MagicArgs, NonLocals) },
- { list__append(MagicOutputModes, MagicOutputModes, AllOutputModes) },
- magic_info_get_module_info(ModuleInfo),
- { instmap_delta_from_mode_list(AllInputArgs, AllOutputModes,
- ModuleInfo, InstMapDelta) },
+ % To be filled in by recompute_instmap_delta.
+ { instmap_delta_init_reachable(InstMapDelta) },
{ goal_info_init(NonLocals, InstMapDelta, nondet, GoalInfo) },
{ MagicCall = call(MagicPredId, MagicProcId, MagicArgs,
--- /tmp/stayl/mercury/compiler/magic.m Wed Apr 28 11:18:36 1999
+++ magic.m Mon May 3 14:54:57 1999
@@ -208,7 +208,13 @@
% New procedures were created, so the dependency_info
% is out of date.
- { module_info_clobber_dependency_info(ModuleInfo3, ModuleInfo) }.
+ { module_info_clobber_dependency_info(ModuleInfo3, ModuleInfo4) },
+
+ % Recompute instmap_deltas for all Aditi procedures.
+ process_matching_nonimported_procs(
+ update_module(recompute_instmap_delta_proc),
+ hlds_pred__pred_info_is_aditi_relation,
+ ModuleInfo4, ModuleInfo).
%-----------------------------------------------------------------------------%
@@ -346,7 +352,8 @@
% Remove aditi:states, convert arguments to output.
{ pred_info_arg_types(PredInfo0, TVarSet, ExistQVars, ArgTypes0) },
- { proc_info_argmodes(ProcInfo0, ArgModes0) },
+ { proc_info_argmodes(ProcInfo0,
+ argument_modes(ArgInstTable, ArgModes0)) },
{ proc_info_headvars(ProcInfo0, HeadVars0) },
{ magic_util__remove_aditi_state(ArgTypes0, ArgTypes0, ArgTypes) },
{ magic_util__remove_aditi_state(ArgTypes0, ArgModes0, ArgModes1) },
@@ -358,7 +365,8 @@
{ pred_info_set_indexes(PredInfo0, Indexes, PredInfo1) },
{ pred_info_set_arg_types(PredInfo1, TVarSet, ExistQVars,
ArgTypes, PredInfo) },
- { proc_info_set_argmodes(ProcInfo0, ArgModes, ProcInfo1) },
+ { proc_info_set_argmodes(ProcInfo0,
+ argument_modes(ArgInstTable, ArgModes), ProcInfo1) },
{ proc_info_set_headvars(ProcInfo1, HeadVars, ProcInfo) },
{ module_info_set_pred_proc_info(ModuleInfo0,
PredProcId, PredInfo, ProcInfo, ModuleInfo) },
@@ -392,21 +400,26 @@
magic_info_get_module_info(ModuleInfo),
{ module_info_pred_proc_info(ModuleInfo, PredProcId,
PredInfo, ProcInfo) },
- { proc_info_argmodes(ProcInfo, ArgModes0) },
+ { proc_info_argmodes(ProcInfo,
+ argument_modes(ArgInstTable, ArgModes0)) },
{ pred_info_arg_types(PredInfo, ArgTypes0) },
{ magic_util__remove_aditi_state(ArgTypes0, ArgTypes0, ArgTypes) },
{ magic_util__remove_aditi_state(ArgTypes0, ArgModes0, ArgModes) },
- { partition_args(ModuleInfo, ArgModes, ArgModes, InputModes, _) },
- { partition_args(ModuleInfo, ArgModes, ArgTypes, InputTypes, _) },
+
+ { proc_info_get_initial_instmap(ProcInfo, ModuleInfo, InstMap) },
+ { partition_args(InstMap, ArgInstTable, ModuleInfo,
+ ArgModes, ArgModes, InputModes, _) },
+ { partition_args(InstMap, ArgInstTable, ModuleInfo,
+ ArgModes, ArgTypes, InputTypes, _) },
{ term__context_init(Context) },
{ Type = term__functor(term__atom("pred"), InputTypes, Context) },
{ GetOutputMode = lambda([ArgMode::in, OutputMode::out] is det, (
mode_get_insts(ModuleInfo, ArgMode, _, OutputInst),
- OutputMode = (free -> OutputInst)
+ OutputMode = (free(unique) -> OutputInst)
)) },
{ list__map(GetOutputMode, InputModes, InputRelModes) },
{ Inst = ground(unique, yes(pred_inst_info(predicate,
- InputRelModes, nondet))) },
+ argument_modes(ArgInstTable, InputRelModes), nondet))) },
{ Mode = (Inst -> Inst) },
magic__get_scc_inputs(PredProcIds, Types, Modes).
@@ -571,9 +584,13 @@
{ pred_info_arg_types(PredInfo0, TVarSet, ExistQVars, ArgTypes0) },
{ proc_info_headvars(ProcInfo0, HeadVars0) },
{ pred_info_context(PredInfo0, Context) },
- { proc_info_argmodes(ProcInfo0, ArgModes0) },
- magic_util__check_args(HeadVars0, ArgModes0, ArgTypes0, Context,
- arg_number),
+ magic_info_get_module_info(ModuleInfo0),
+ { proc_info_get_initial_instmap(ProcInfo0, ModuleInfo0, InstMap) },
+ { proc_info_argmodes(ProcInfo0,
+ argument_modes(ArgInstTable, ArgModes0)) },
+
+ magic_util__check_args(HeadVars0, InstMap, ArgInstTable, ArgModes0,
+ ArgTypes0, Context, arg_number),
%
% Strip out the aditi__state argument.
@@ -586,7 +603,6 @@
% Convert all of the original modes to output. The input
% will be carried in with the input closures.
%
- magic_info_get_module_info(ModuleInfo0),
{ list__map(magic_util__mode_to_output_mode(ModuleInfo0),
ArgModes1, ArgModes2) },
@@ -601,37 +617,30 @@
{ list__append(MagicModes, ArgModes2, ArgModes) },
{ list__append(MagicTypes, ArgTypes1, ArgTypes) },
- %
- % Ensure that the exported interface procedure gets the
- % correct argmodes.
- %
- { instmap_delta_from_mode_list(HeadVars, ArgModes,
- ModuleInfo0, InstMapDelta) },
- { proc_info_goal(ProcInfo1, Goal0 - GoalInfo0) },
- { goal_info_set_instmap_delta(GoalInfo0, InstMapDelta, GoalInfo) },
- { proc_info_set_goal(ProcInfo1, Goal0 - GoalInfo, ProcInfo2) },
-
% All Aditi procedures are considered nondet. The C interface
% procedures retain the old determinism, and abort if the number
% of answers returned doesn't match the determinism.
- { proc_info_set_inferred_determinism(ProcInfo2, nondet, ProcInfo3) },
+ { proc_info_set_inferred_determinism(ProcInfo1, nondet, ProcInfo3) },
- { partition_args(ModuleInfo0, ArgModes1,
+ { partition_args(InstMap, ArgInstTable, ModuleInfo0, ArgModes1,
ArgModes1, InputArgModes, _) },
- { partition_args(ModuleInfo0, ArgModes1,
+ { partition_args(InstMap, ArgInstTable, ModuleInfo0, ArgModes1,
ArgTypes1, InputArgTypes, _) },
{ pred_info_set_arg_types(PredInfo0, TVarSet, ExistQVars,
ArgTypes, PredInfo) },
{ proc_info_set_headvars(ProcInfo3, HeadVars, ProcInfo4) },
- { proc_info_set_argmodes(ProcInfo4, ArgModes, ProcInfo) },
+ { proc_info_set_argmodes(ProcInfo4,
+ argument_modes(ArgInstTable, ArgModes), ProcInfo) },
( { InterfaceRequired = yes(Index) } ->
+ { LocalArgModes = ArgModes },
magic__create_interface_proc(Index, CPredProcId,
AditiPredProcId, PredInfo0, ProcInfo3, ProcInfo,
- HeadVars1, ArgTypes1, ArgModes2, MagicVars,
- MagicTypes, MagicModes, LocalAditiPredProcId)
+ HeadVars1, ArgTypes1, ArgModes2, LocalArgModes,
+ MagicVars, MagicTypes, MagicModes,
+ LocalAditiPredProcId)
;
magic_info_get_module_info(ModuleInfo5),
{ module_info_set_pred_proc_info(ModuleInfo5, AditiPredProcId,
@@ -640,7 +649,8 @@
{ LocalAditiPredProcId = AditiPredProcId }
),
- { ThisProcInfo = magic_proc_info(ArgModes1, MagicVars,
+ { ThisProcInfo = magic_proc_info(InstMap,
+ argument_modes(ArgInstTable, ArgModes1), MagicVars,
MagicTypes, MagicModes, MaybeIndex) },
magic_info_get_magic_proc_info(MagicProcInfo0),
{ map__det_insert(MagicProcInfo0, LocalAditiPredProcId,
@@ -659,12 +669,13 @@
:- pred magic__create_interface_proc(int::in, pred_proc_id::in,
pred_proc_id::in, pred_info::in, proc_info::in, proc_info::in,
list(prog_var)::in, list(type)::in, list(mode)::in,
- list(prog_var)::in, list(type)::in, list(mode)::in,
- pred_proc_id::out, magic_info::in, magic_info::out) is det.
+ list(mode)::in, list(prog_var)::in, list(type)::in,
+ list(mode)::in, pred_proc_id::out,
+ magic_info::in, magic_info::out) is det.
magic__create_interface_proc(Index, CPredProcId, AditiPredProcId,
ExportedPredInfo0, ExportedProcInfo0, LocalProcInfo,
- HeadVars1, ArgTypes1, ArgModes1, MagicVars,
+ HeadVars1, ArgTypes1, ArgModes1, LocalArgModes, MagicVars,
MagicTypes, MagicModes, LocalPredProcId) -->
%
@@ -678,6 +689,7 @@
{ proc_info_headvars(LocalProcInfo, HeadVars) },
{ proc_info_vartypes(LocalProcInfo, VarTypes) },
{ proc_info_varset(LocalProcInfo, VarSet) },
+ { proc_info_inst_table(LocalProcInfo, InstTable) },
{ pred_info_get_markers(ExportedPredInfo0, Markers) },
{ pred_info_get_aditi_owner(ExportedPredInfo0, Owner) },
@@ -686,13 +698,13 @@
{ map__init(TCVarMap) },
{ varset__init(TVarSet) },
{ hlds_pred__define_new_pred(Goal, CallGoal, HeadVars, ExtraArgs,
- InstMap, PredName, TVarSet, VarTypes, ClassContext, TVarMap,
- TCVarMap, VarSet, Markers, Owner,
- ModuleInfo1, ModuleInfo2, LocalPredProcId) },
+ InstMap, LocalArgModes, PredName, TVarSet, VarTypes,
+ ClassContext, TVarMap, TCVarMap, VarSet, Markers, Owner,
+ InstTable, ModuleInfo1, ModuleInfo2, LocalPredProcId) },
{ ExtraArgs = [] ->
true
;
- error("magic__create_interface_proc: typeinfo arguments")
+ error("magic__create_interface_proc: extra typeinfo arguments")
},
magic_info_set_module_info(ModuleInfo2),
@@ -715,7 +727,8 @@
{ proc_info_set_headvars(ExportedProcInfo0,
ExportedHeadVars, ExportedProcInfo1) },
{ proc_info_set_argmodes(ExportedProcInfo1,
- ExportedArgModes, ExportedProcInfo2) },
+ argument_modes(InstTable, ExportedArgModes),
+ ExportedProcInfo2) },
{ pred_info_set_arg_types(ExportedPredInfo0, TVarSet, [],
ExportedArgTypes, ExportedPredInfo1) },
@@ -843,10 +856,13 @@
magic_info_get_module_info(ModuleInfo0),
{ module_info_pred_proc_info(ModuleInfo0, CPredProcId,
CPredInfo, CProcInfo) },
- { proc_info_argmodes(CProcInfo, ArgModes0) },
+ { proc_info_argmodes(CProcInfo,
+ argument_modes(ArgInstTable, ArgModes0)) },
+ { proc_info_get_initial_instmap(CProcInfo, ModuleInfo0, InstMap) },
+ { proc_info_inst_table(CProcInfo, InstTable) },
{ pred_info_arg_types(CPredInfo, ArgTypes) },
{ magic_util__remove_aditi_state(ArgTypes, ArgModes0, ArgModes) },
- { partition_args(ModuleInfo0, ArgModes, ArgModes,
+ { partition_args(InstMap, InstTable, ModuleInfo0, ArgModes, ArgModes,
InputArgModes, OutputArgModes) },
(
% If the Aditi procedure has no inputs we don't need to
@@ -875,8 +891,8 @@
% Build a call to the original C proc.
{ set__list_to_set(HeadVars, NonLocals) },
- { instmap_delta_from_mode_list(HeadVars0, ArgModes0,
- ModuleInfo0, Delta) },
+ % This will be filled in by recompute_instmap_delta.
+ { instmap_delta_init_reachable(Delta) },
{ proc_info_inferred_determinism(CProcInfo, Detism) },
{ goal_info_init(NonLocals, Delta, Detism, CallGoalInfo) },
{ pred_info_module(CPredInfo, PredModule) },
@@ -890,7 +906,8 @@
{ proc_info_set_headvars(JoinProcInfo0,
HeadVars, JoinProcInfo1) },
{ proc_info_set_argmodes(JoinProcInfo1,
- ArgModes, JoinProcInfo2) },
+ argument_modes(ArgInstTable, ArgModes),
+ JoinProcInfo2) },
% Imported procedures such as base relations have nothing
% in their vartypes field, so create it here.
@@ -909,8 +926,8 @@
{ magic_util__remove_aditi_state(ArgTypes,
HeadVars0, HeadVars) },
- { partition_args(ModuleInfo0, ArgModes, HeadVars,
- InputArgs, OutputArgs) },
+ { partition_args(InstMap, InstTable, ModuleInfo0,
+ ArgModes, HeadVars, InputArgs, OutputArgs) },
{ map__apply_to_list(InputArgs, VarTypes0, InputVarTypes) },
@@ -927,12 +944,13 @@
% Build a goal to call the input closure.
{ set__list_to_set([ClosureVar | InputArgs],
HOCallNonLocals) },
- { instmap_delta_from_mode_list(InputArgs, MagicArgModes,
- ModuleInfo0, HOCallDelta) },
+ % This will be filled in by recompute_instmap_delta.
+ { instmap_delta_init_reachable(HOCallDelta) },
{ goal_info_init(HOCallNonLocals, HOCallDelta, nondet,
InputGoalInfo) },
{ InputGoal = higher_order_call(ClosureVar,
- InputArgs, InputVarTypes, MagicArgModes,
+ InputArgs, InputVarTypes,
+ argument_modes(ArgInstTable, MagicArgModes),
nondet, predicate) - InputGoalInfo },
% Build a call to the original C proc.
@@ -953,10 +971,13 @@
),
{ ClosureInst = ground(shared,
- yes(pred_inst_info(predicate, MagicArgModes, nondet))) },
+ yes(pred_inst_info(predicate,
+ argument_modes(ArgInstTable, MagicArgModes), nondet))) },
{ ClosureMode = (ClosureInst -> ClosureInst) },
{ proc_info_set_argmodes(JoinProcInfo1,
- [ClosureMode | OutputArgModes], JoinProcInfo2) },
+ argument_modes(ArgInstTable,
+ [ClosureMode | OutputArgModes]),
+ JoinProcInfo2) },
{ proc_info_set_headvars(JoinProcInfo2,
[ClosureVar | OutputArgs], JoinProcInfo3) },
@@ -979,8 +1000,8 @@
CallNonLocals, Goals),
magic_info_get_module_info(ModuleInfo10),
- { instmap_delta_from_mode_list(OutputArgs, OutputArgModes,
- ModuleInfo10, GoalDelta) },
+ % This will be filled in by recompute_instmap_delta.
+ { instmap_delta_init_reachable(GoalDelta) },
{ set__list_to_set([ClosureVar | OutputArgs],
GoalNonLocals) },
{ goal_info_init(GoalNonLocals, GoalDelta, nondet, GoalInfo) },
@@ -1055,8 +1076,11 @@
CPredInfo0, CProcInfo0) },
{ pred_info_module(CPredInfo0, PredModule) },
{ pred_info_arg_types(CPredInfo0, TVarSet, ExistQVars, ArgTypes) },
- { proc_info_argmodes(CProcInfo0, ArgModes) },
+ { proc_info_argmodes(CProcInfo0,
+ argument_modes(ArgInstTable, ArgModes)) },
+ { proc_info_get_initial_instmap(CProcInfo0, ModuleInfo0, InstMap) },
{ proc_info_headvars(CProcInfo0, HeadVars) },
+ { proc_info_inst_table(CProcInfo0, InstTable) },
% Base relations will have an empty vartypes field, so fill it in here.
{ map__from_corresponding_lists(HeadVars, ArgTypes, VarTypes0) },
@@ -1076,13 +1100,14 @@
magic_info_get_module_info(ModuleInfo1),
- { partition_args(ModuleInfo1, ArgModes1, ArgTypes1,
- InputArgTypes, OutputArgTypes) },
- { partition_args(ModuleInfo1, ArgModes1, ArgModes1,
- InputArgModes, OutputArgModes) },
- { partition_args(ModuleInfo1, ArgModes1, TypeInfoVars,
+ { partition_args(InstMap, ArgInstTable, ModuleInfo1,
+ ArgModes1, ArgTypes1, InputArgTypes, OutputArgTypes) },
+ { partition_args(InstMap, ArgInstTable, ModuleInfo1,
+ ArgModes1, ArgModes1, InputArgModes, OutputArgModes) },
+ { partition_args(InstMap, ArgInstTable, ModuleInfo1,
+ ArgModes1, TypeInfoVars,
InputTypeInfoVars, OutputTypeInfoVars) },
- { partition_args(ModuleInfo1, ArgModes1,
+ { partition_args(InstMap, ArgInstTable, ModuleInfo1, ArgModes1,
HeadVars1, InputArgs, OutputArgs) },
{ construct_type(unqualified("int") - 0, [], IntType) },
@@ -1147,8 +1172,9 @@
{ map__init(TVarMap) },
{ map__init(TCVarMap) },
{ proc_info_create(VarSet, DoCallAditiVarTypes, DoCallAditiHeadVars,
- DoCallAditiArgModes, Detism, DummyGoal, DummyContext,
- TVarMap, TCVarMap, compact, DoCallAditiProcInfo) },
+ argument_modes(ArgInstTable, DoCallAditiArgModes),
+ Detism, DummyGoal, DummyContext, TVarMap, TCVarMap,
+ compact, InstTable, DoCallAditiProcInfo) },
{ CPredProcId = proc(_, CProcId) },
magic_util__make_pred_name(CPredInfo1, CProcId, "Do_Aditi_Call_For",
@@ -1173,8 +1199,8 @@
% Make the C procedure call the new alias for do_*_aditi_call.
%
{ set__list_to_set(DoCallAditiArgs, CallNonLocals) },
- { instmap_delta_from_mode_list(DoCallAditiArgs, DoCallAditiArgModes,
- ModuleInfo2, GoalDelta) },
+ % This will be filled in by recompute_instmap_delta.
+ { instmap_delta_init_reachable(GoalDelta) },
{ goal_info_init(CallNonLocals, GoalDelta, Detism, CallGoalInfo) },
{ DoCallAditiGoal = call(DoCallAditiPredId, DoCallAditiProcId,
DoCallAditiArgs, not_builtin, no, CallPredName)
@@ -1185,9 +1211,11 @@
{ goal_list_determinism(Goals, GoalDetism) },
{ goal_info_init(GoalNonLocals, GoalDelta, GoalDetism, GoalInfo) },
{ Goal = conj(Goals) - GoalInfo },
- { proc_info_set_goal(CProcInfo5, Goal, CProcInfo) },
+ { proc_info_set_goal(CProcInfo5, Goal, CProcInfo6) },
- { module_info_set_pred_proc_info(ModuleInfo3, CPredProcId,
+ { recompute_instmap_delta_proc(CProcInfo6, CProcInfo,
+ ModuleInfo3, ModuleInfo4) },
+ { module_info_set_pred_proc_info(ModuleInfo4, CPredProcId,
CPredInfo1, CProcInfo, ModuleInfo) },
magic_info_set_module_info(ModuleInfo).
@@ -1202,10 +1230,13 @@
{ module_info_pred_proc_info(ModuleInfo, CPredProcId,
CPredInfo, CProcInfo) },
{ pred_info_arg_types(CPredInfo, ArgTypes0) },
- { proc_info_argmodes(CProcInfo, ArgModes0) },
+ { proc_info_argmodes(CProcInfo,
+ argument_modes(ArgInstTable, ArgModes0)) },
+ { proc_info_get_initial_instmap(CProcInfo, ModuleInfo, InstMap) },
{ magic_util__remove_aditi_state(ArgTypes0, ArgTypes0, ArgTypes) },
{ magic_util__remove_aditi_state(ArgTypes0, ArgModes0, ArgModes) },
- { partition_args(ModuleInfo, ArgModes, ArgTypes, InputArgTypes, _) },
+ { partition_args(InstMap, ArgInstTable, ModuleInfo,
+ ArgModes, ArgTypes, InputArgTypes, _) },
{ rl__schema_to_string(ModuleInfo, InputArgTypes, InputSchema) }.
:- pred magic__make_type_info_vars(list(type)::in, list(prog_var)::out,
@@ -1231,9 +1262,9 @@
proc_info_create_var_from_type(ProcInfo0, Type, Var, ProcInfo),
set__singleton_set(NonLocals, Var),
Inst = bound(unique, [functor(ConsId, [])]),
- instmap_delta_init_reachable(Delta0),
- instmap_delta_insert(Delta0, Var, Inst, Delta),
- UnifyMode = (free -> Inst) - (Inst -> Inst),
+ % To be filled in by recompute_instmap_delta.
+ instmap_delta_init_reachable(Delta),
+ UnifyMode = (free(unique) - Inst) - (Inst - Inst),
Uni = construct(Var, ConsId, [], []),
Context = unify_context(explicit, []),
goal_info_init(NonLocals, Delta, det, GoalInfo),
@@ -1272,7 +1303,7 @@
InputModes0, OutputModes0) },
{ module_info_pred_proc_info(ModuleInfo0, PredProcId,
- PredInfo, _) },
+ PredInfo, ProcInfo) },
{ pred_info_get_markers(PredInfo, Markers) },
{ check_marker(Markers, context) ->
% For magic context predicates, we get two copies of
@@ -1296,6 +1327,7 @@
},
{ list__append(MagicArgs, InputArgs, AllArgs) },
+ { proc_info_inst_table(ProcInfo, InstTable) },
( { Index = yes(N) } ->
%
% If this predicate is an entry point to the sub-module,
@@ -1312,7 +1344,7 @@
{ goal_info_init(NonLocals0, InstMapDelta0,
nondet, GoalInfo0) },
{ Goal0 = higher_order_call(CurrPredVar, InputArgs0,
- InputTypes, OutputModes0,
+ InputTypes, argument_modes(InstTable, OutputModes0),
nondet, predicate) - GoalInfo0 },
( { IsContext = yes(ArgsAL) } ->
% Create assignments to assign to the extra arguments.
@@ -1347,8 +1379,10 @@
{ map__init(TCVarMap) },
{ DummyArgsMethod = compact }, % never used
- { proc_info_create(VarSet, VarTypes, AllArgs, AllArgModes, nondet,
- Goal, Context, TVarMap, TCVarMap, DummyArgsMethod, ProcInfo) },
+ { proc_info_create(VarSet, VarTypes, AllArgs,
+ argument_modes(InstTable, AllArgModes),
+ nondet, Goal, Context, TVarMap, TCVarMap,
+ DummyArgsMethod, InstTable, MagicProcInfo) },
%
% Fill in the pred_info.
@@ -1367,7 +1401,7 @@
{ ExistQVars = [] },
{ pred_info_create(ModuleName, SymName, TVarSet, ExistQVars,
AllArgTypes, true, Context, local, Markers, predicate,
- ClassConstraints, Owner, ProcInfo, MagicProcId,
+ ClassConstraints, Owner, MagicProcInfo, MagicProcId,
MagicPredInfo) },
{ module_info_get_predicate_table(ModuleInfo0, PredTable0) },
@@ -1398,7 +1432,7 @@
magic__create_assignments(ModuleInfo, [Arg0 - Arg | ArgsAL],
[Mode | Modes], [Goal - GoalInfo | Assigns]) :-
mode_get_insts(ModuleInfo, Mode, _, Inst),
- Goal = unify(Arg, var(Arg0), (free -> Inst) - (Inst -> Inst),
+ Goal = unify(Arg, var(Arg0), (free(unique) - Inst) - (Inst - Inst),
assign(Arg, Arg0), unify_context(explicit, [])),
set__list_to_set([Arg0, Arg], NonLocals),
instmap_delta_from_assoc_list([Arg - Inst], Delta),
@@ -1428,12 +1462,12 @@
{ proc_info_varset(ProcInfo0, VarSet0) },
{ proc_info_vartypes(ProcInfo0, VarTypes0) },
magic_info_get_module_info(ModuleInfo0),
+ { proc_info_inst_table(ProcInfo0, InstTable) },
{ proc_info_get_initial_instmap(ProcInfo0,
ModuleInfo0, InstMap) },
{ goal_util__switch_to_disjunction(Var, Cases,
- InstMap, Disjuncts, VarSet0, VarSet1,
- VarTypes0, VarTypes1, ModuleInfo0, ModuleInfo1) },
- magic_info_set_module_info(ModuleInfo1),
+ InstMap, InstTable, Disjuncts, VarSet0, VarSet1,
+ VarTypes0, VarTypes1, ModuleInfo0) },
{ proc_info_set_varset(ProcInfo0, VarSet1, ProcInfo1) },
{ proc_info_set_vartypes(ProcInfo1, VarTypes1, ProcInfo2) },
{ map__init(SM) },
@@ -1612,7 +1646,8 @@
).
% Introduce new variables and assignments to them for any
- % duplicates in the list.
+ % duplicates in the list. This ensures that the call is in
+ % superhomogenous form.
:- pred magic__preprocess_call_args(list(prog_var)::in, list(prog_var)::out,
set(prog_var)::in, list(prog_var)::in, list(prog_var)::out,
list(hlds_goal)::in, list(hlds_goal)::out,
@@ -1631,13 +1666,12 @@
ArgType, NewArg, ProcInfo) },
magic_info_set_proc_info(ProcInfo),
{ IntroducedArgs1 = [NewArg | IntroducedArgs0] },
- { in_mode(InMode) },
- { out_mode(OutMode) },
- { Inst = ground(shared, no) },
+ { Ground = ground(shared, no) },
{ set__list_to_set([Arg, NewArg], NonLocals) },
- { instmap_delta_from_assoc_list([NewArg - Inst], Delta) },
+ { instmap_delta_from_assoc_list([NewArg - Ground], Delta) },
{ goal_info_init(NonLocals, Delta, det, GoalInfo) },
- { ExtraGoal = unify(NewArg, var(Arg), OutMode - InMode,
+ { ExtraGoal = unify(NewArg, var(Arg),
+ (free(unique) - Ground) - (Ground - Ground),
assign(NewArg, Arg), unify_context(explicit, []))
- GoalInfo },
{ ExtraGoals1 = [ExtraGoal | ExtraGoals0] }
@@ -1792,8 +1826,9 @@
magic_info_set_proc_info(ProcInfo0),
magic_info_get_magic_proc_info(MagicProcInfo),
{ map__lookup(MagicProcInfo, PredProcId, ThisProcInfo) },
- { ThisProcInfo = magic_proc_info(OldArgModes, MagicInputs,
- _, _, _) },
+ { ThisProcInfo = magic_proc_info(OldInstMap,
+ argument_modes(ArgInstTable, OldArgModes),
+ MagicInputs, _, _, _) },
magic_info_set_magic_vars(MagicInputs),
{ set__init(ErrorVars) },
magic_info_set_error_vars(ErrorVars),
@@ -1802,7 +1837,7 @@
{ list__length(MagicInputs, NumMagicInputs) },
{ list__drop(NumMagicInputs, HeadVars, OldHeadVars) ->
- partition_args(ModuleInfo0,
+ partition_args(OldInstMap, ArgInstTable, ModuleInfo0,
OldArgModes, OldHeadVars, Inputs, Outputs)
;
error("magic__process_proc: list__drop failed")
@@ -1943,14 +1978,13 @@
magic__create_magic_call(MagicCall) -->
magic_util__magic_call_info(MagicPredId, MagicProcId, PredName,
- InputRels, InputArgs, MagicOutputModes),
+ InputRels, InputArgs, _MagicOutputModes),
{ list__append(InputRels, InputArgs, MagicArgs) },
{ set__list_to_set(MagicArgs, NonLocals) },
- magic_info_get_module_info(ModuleInfo),
- { instmap_delta_from_mode_list(InputArgs, MagicOutputModes,
- ModuleInfo, InstMapDelta) },
+ % To be filled in by recompute_instmap_delta.
+ { instmap_delta_init_reachable(InstMapDelta) },
{ goal_info_init(NonLocals, InstMapDelta, nondet, GoalInfo) },
{ MagicCall = call(MagicPredId, MagicProcId, MagicArgs,
--- /tmp/stayl/mercury/compiler/magic_util.m Mon Dec 7 10:43:41 1998
+++ magic_util.m Tue Dec 15 11:43:07 1998
@@ -15,14 +15,14 @@
:- interface.
:- import_module hlds_data, hlds_goal, hlds_module, hlds_pred, prog_data.
-:- import_module (inst), rl.
+:- import_module (inst), instmap, rl.
:- import_module bool, io, list, map, set, std_util.
% Check that the argument types and modes are legal for
% an Aditi relation.
-:- pred magic_util__check_args(list(prog_var)::in, list(mode)::in,
- list(type)::in, prog_context::in, magic_arg_id_type::in,
- magic_info::in, magic_info::out) is det.
+:- pred magic_util__check_args(list(prog_var)::in, instmap::in, inst_table::in,
+ list(mode)::in, list(type)::in, prog_context::in,
+ magic_arg_id_type::in, magic_info::in, magic_info::out) is det.
:- pred magic_util__report_errors(list(magic_error)::in, module_info::in,
bool::in, io__state::di, io__state::uo) is det.
@@ -89,7 +89,7 @@
% where the original mode was input. This will result in
% a join on the input attributes.
:- pred magic_util__create_input_test_unifications(list(prog_var)::in,
- list(prog_var)::in, list(mode)::in, list(prog_var)::out,
+ list(prog_var)::in, list(prog_var)::out,
list(hlds_goal)::in, list(hlds_goal)::out,
hlds_goal_info::in, hlds_goal_info::out,
magic_info::in, magic_info::out) is det.
@@ -269,10 +269,12 @@
module_info_pred_proc_info(ModuleInfo, PredId, ProcId,
PredInfo, ProcInfo),
pred_info_arg_types(PredInfo, ArgTypes),
- proc_info_argmodes(ProcInfo, ArgModes0),
+ proc_info_argmodes(ProcInfo, argument_modes(InstTable, ArgModes0)),
+ proc_info_get_initial_instmap(ProcInfo, ModuleInfo, InstMap),
magic_util__remove_aditi_state(ArgTypes, ArgModes0, ArgModes),
magic_util__remove_aditi_state(ArgTypes, Args0, Args),
- partition_args(ModuleInfo, ArgModes, Args, InputArgs, OutputArgs),
+ partition_args(InstMap, InstTable, ModuleInfo,
+ ArgModes, Args, InputArgs, OutputArgs),
Call = db_call(no, Goal0, proc(PredId, ProcId), Args,
InputArgs, OutputArgs, no).
@@ -388,14 +390,13 @@
% Convert input args to outputs, and test that
% the input matches the output.
magic_info_get_module_info(ModuleInfo),
- { module_info_pred_proc_info(ModuleInfo, PredProcId,
- PredInfo, ProcInfo) },
+ { module_info_pred_info(ModuleInfo, PredId,
+ PredInfo) },
{ pred_info_module(PredInfo, PredModule) },
{ pred_info_name(PredInfo, PredName) },
{ Name = qualified(PredModule, PredName) },
- { proc_info_argmodes(ProcInfo, ArgModes) },
magic_util__create_input_test_unifications(Args,
- InputArgs, ArgModes, NewArgs, [], Tests,
+ InputArgs, NewArgs, [], Tests,
CallGoalInfo0, CallGoalInfo),
{ CallGoal = call(PredId, ProcId, NewArgs,
not_builtin, no, Name)
@@ -421,9 +422,7 @@
InnerNonLocals1) },
magic_util__restrict_nonlocals(InnerNonLocals1,
InnerNonLocals),
- { goal_list_instmap_delta(NegGoals, InnerDelta0) },
- { instmap_delta_restrict(InnerDelta0,
- InnerNonLocals, InnerDelta) },
+ { goal_list_instmap_delta(NegGoals, InnerDelta) },
{ goal_list_determinism(NegGoals, InnerDet) },
{ goal_info_init(InnerNonLocals, InnerDelta,
InnerDet, InnerInfo) },
@@ -472,7 +471,7 @@
magic_info_get_magic_proc_info(MagicProcInfo),
{ map__lookup(MagicProcInfo, proc(PredId, ProcId),
CallProcInfo) },
- { CallProcInfo = magic_proc_info(_, MagicInputs, _, _, _) },
+ { CallProcInfo = magic_proc_info(_, _, MagicInputs, _, _, _) },
{ true_goal(InputGoal) },
magic_util__create_input_closures(MagicInputs, [], [],
@@ -513,10 +512,12 @@
magic_info_get_magic_proc_info(MagicProcInfo),
{ map__lookup(MagicProcInfo, PredProcId, CallProcInfo) },
- { CallProcInfo = magic_proc_info(OldArgModes, MagicInputs, _, _, _) },
+ { CallProcInfo = magic_proc_info(OldInstMap,
+ argument_modes(OldInstTable, OldArgModes),
+ MagicInputs, _, _, _) },
magic_info_get_module_info(ModuleInfo0),
- { partition_args(ModuleInfo0, OldArgModes,
+ { partition_args(OldInstMap, OldInstTable, ModuleInfo0, OldArgModes,
OldArgModes, InputArgModes, _) },
{ goal_info_get_context(GoalInfo0, Context) },
@@ -526,7 +527,7 @@
% Convert input args to outputs, and test that
% the input matches the output.
magic_util__create_input_test_unifications(Args, InputArgs,
- OldArgModes, NewOutputArgs, [], Tests, GoalInfo0, GoalInfo1),
+ NewOutputArgs, [], Tests, GoalInfo0, GoalInfo1),
% All database predicates are considered nondet after this.
{ goal_info_set_determinism(GoalInfo1,
@@ -558,17 +559,13 @@
{ CallGoal = call(PredId, ProcId, AllArgs, not_builtin, no,
qualified(PredModule, PredName)) - GoalInfo }.
-magic_util__create_input_test_unifications([], _, [_|_], _, _, _, _, _) -->
- { error("magic_util__create_input_test_unifications") }.
-magic_util__create_input_test_unifications([_|_], _, [], _, _, _, _, _) -->
- { error("magic_util__create_input_test_unifications") }.
-magic_util__create_input_test_unifications([], _, [], [], Tests, Tests,
+magic_util__create_input_test_unifications([], _, [], Tests, Tests,
CallInfo, CallInfo) --> [].
magic_util__create_input_test_unifications([Var | Vars], InputArgs,
- [Mode | Modes], [OutputVar | OutputVars], Tests0, Tests,
+ [OutputVar | OutputVars], Tests0, Tests,
CallInfo0, CallInfo) -->
( { list__member(Var, InputArgs) } ->
- magic_util__create_input_test_unification(Var, Mode,
+ magic_util__create_input_test_unification(Var,
OutputVar, Test, CallInfo0, CallInfo1),
{ Tests1 = [Test | Tests0] }
;
@@ -576,17 +573,16 @@
{ CallInfo1 = CallInfo0 },
{ Tests1 = Tests0 }
),
- magic_util__create_input_test_unifications(Vars, InputArgs, Modes,
+ magic_util__create_input_test_unifications(Vars, InputArgs,
OutputVars, Tests1, Tests, CallInfo1, CallInfo).
-:- pred magic_util__create_input_test_unification(prog_var::in, (mode)::in,
+:- pred magic_util__create_input_test_unification(prog_var::in,
prog_var::out, hlds_goal::out, hlds_goal_info::in,
hlds_goal_info::out, magic_info::in, magic_info::out) is det.
-magic_util__create_input_test_unification(Var, Mode, OutputVar, Test,
+magic_util__create_input_test_unification(Var, OutputVar, Test,
CallInfo0, CallInfo) -->
magic_info_get_module_info(ModuleInfo0),
- { mode_get_insts(ModuleInfo0, Mode, _, FinalInst) },
magic_info_get_proc_info(ProcInfo0),
{ proc_info_varset(ProcInfo0, VarSet0) },
{ varset__new_var(VarSet0, OutputVar, VarSet) },
@@ -600,13 +596,17 @@
{ set__list_to_set([Var, OutputVar], NonLocals) },
{ instmap_delta_init_reachable(InstMapDelta) },
{ goal_info_init(NonLocals, InstMapDelta, semidet, GoalInfo) },
+
+ % This is a safe approximation - recompute_instmap_delta
+ % should fix it up.
+ { FinalInst = ground(shared, no) },
( { type_is_atomic(VarType, ModuleInfo0) } ->
%
% The type is a builtin, so create a simple_test unification.
%
{ Unification = simple_test(Var, OutputVar) },
- { UnifyMode = ((FinalInst -> FinalInst)
- - (FinalInst -> FinalInst)) },
+ { UnifyMode = ((FinalInst - FinalInst)
+ - (FinalInst - FinalInst)) },
{ Test = unify(Var, var(OutputVar), UnifyMode,
Unification, unify_context(explicit, [])) - GoalInfo }
; { type_to_type_id(VarType, _TypeId, _ArgTypes) } ->
@@ -615,8 +615,8 @@
% go through the rigmarole of creating type_info variables
% (and then ignoring them in code generation).
{ Unification = simple_test(Var, OutputVar) },
- { UnifyMode = ((FinalInst -> FinalInst)
- - (FinalInst -> FinalInst)) },
+ { UnifyMode = ((FinalInst - FinalInst)
+ - (FinalInst - FinalInst)) },
{ Test = unify(Var, var(OutputVar), UnifyMode,
Unification, unify_context(explicit, [])) - GoalInfo }
@@ -648,10 +648,7 @@
{ goal_info_get_nonlocals(CallInfo0, CallNonLocals0) },
{ set__delete(CallNonLocals0, Var, CallNonLocals1) },
{ set__insert(CallNonLocals1, OutputVar, CallNonLocals) },
- { goal_info_get_instmap_delta(CallInfo0, CallDelta0) },
- { instmap_delta_insert(CallDelta0, OutputVar, FinalInst, CallDelta) },
- { goal_info_set_nonlocals(CallInfo0, CallNonLocals, CallInfo1) },
- { goal_info_set_instmap_delta(CallInfo1, CallDelta, CallInfo) }.
+ { goal_info_set_nonlocals(CallInfo0, CallNonLocals, CallInfo) }.
%-----------------------------------------------------------------------------%
@@ -665,7 +662,7 @@
magic_util__create_input_closures([_ | MagicVars], InputArgs,
InputArgModes, SuppCall, ThisProcInfo, CurrVar,
[InputGoal | InputGoals], [ClosureVar | ClosureVars]) -->
- { ThisProcInfo = magic_proc_info(_OldArgModes, _MagicInputs,
+ { ThisProcInfo = magic_proc_info(_, _OldArgModes, _MagicInputs,
MagicTypes, MagicModes, MaybeIndex) },
magic_info_get_proc_info(ProcInfo0),
@@ -799,11 +796,11 @@
{ Inst = ground(_, yes(PredInstInfo)) }
->
% Find the mode of the unification.
- { PredInstInfo = pred_inst_info(_, LambdaModes, _) },
- { LambdaInst = ground(shared,
- yes(pred_inst_info(predicate, LambdaModes, nondet))) },
- { UnifyMode = (free -> LambdaInst) -
- (LambdaInst -> LambdaInst) },
+ { PredInstInfo = pred_inst_info(_,
+ argument_modes(_, LambdaModes), _) },
+ { LambdaInst = Inst },
+ { UnifyMode = (free(unique) - LambdaInst) -
+ (LambdaInst - LambdaInst) },
{ mode_util__modes_to_uni_modes(LambdaModes, LambdaModes,
ModuleInfo, UniModes) },
@@ -822,9 +819,8 @@
% Construct a goal_info.
{ set__list_to_set([InputVar | LambdaInputs], NonLocals) },
- { instmap_delta_init_reachable(InstMapDelta0) },
- { instmap_delta_insert(InstMapDelta0, InputVar, LambdaInst,
- InstMapDelta) },
+ % This will be fixed up by recompute_instmap_delta.
+ { instmap_delta_init_reachable(InstMapDelta) },
{ goal_info_init(NonLocals, InstMapDelta, det, GoalInfo) },
{ InputGoal = unify(InputVar, Rhs, UnifyMode,
@@ -852,9 +848,13 @@
magic_info_get_module_info(ModuleInfo),
{ module_info_pred_proc_info(ModuleInfo, SuppPredId1,
SuppProcId1, _, SuppProcInfo) },
- { proc_info_argmodes(SuppProcInfo, SuppArgModes) },
- { partition_args(ModuleInfo, SuppArgModes,
- SuppArgs, SuppInputArgs, SuppOutputArgs) }
+ { proc_info_argmodes(SuppProcInfo,
+ argument_modes(SuppInstTable, SuppArgModes)) },
+ { proc_info_get_initial_instmap(SuppProcInfo,
+ ModuleInfo, SuppInstMap) },
+ { partition_args(SuppInstMap, SuppInstTable, ModuleInfo,
+ SuppArgModes, SuppArgs, SuppInputArgs,
+ SuppOutputArgs) }
;
{ error("magic_util__project_supp_call: not a call") }
),
@@ -877,6 +877,8 @@
%-----------------------------------------------------------------------------%
+:- import_module unsafe, io.
+
magic_util__add_to_magic_predicate(PredProcId, Rule, RuleArgs) -->
magic_info_get_magic_map(MagicMap),
{ map__lookup(MagicMap, PredProcId, MagicPred) },
@@ -901,13 +903,22 @@
%
{ map__from_corresponding_lists(RuleArgs, MagicProcHeadVars, Subn0) },
{ goal_util__goal_vars(Rule, RuleVars0) },
+
+ { io(io__write_string("Rule vars ")) },
+ { io(io__write(RuleVars0)) },
+ { io(io__nl) },
+
{ set__to_sorted_list(RuleVars0, RuleVars) },
{ goal_util__create_variables(RuleVars, MagicVarSet0, MagicVarTypes0,
Subn0, VarTypes, VarSet, MagicVarSet, MagicVarTypes, Subn) },
{ Rule = RuleExpr - RuleInfo0 },
{ set__list_to_set(RuleArgs, RuleArgSet) },
{ goal_info_set_nonlocals(RuleInfo0, RuleArgSet, RuleInfo) },
- { goal_util__must_rename_vars_in_goal(RuleExpr - RuleInfo,
+
+ % There may be variables in the instmap which don't occur
+ % in the goal due to aliasing, so we don't use
+ % goal_util__must_rename_vars_in_goal.
+ { goal_util__rename_vars_in_goal(RuleExpr - RuleInfo,
Subn, ExtraDisjunct) },
%
@@ -938,7 +949,8 @@
magic_info_get_curr_pred_proc_id(PredProcId),
magic_info_get_magic_proc_info(MagicProcInfo),
{ map__lookup(MagicProcInfo, PredProcId, ThisProcInfo) },
- { ThisProcInfo = magic_proc_info(OldArgModes, _, _, _, _) },
+ { ThisProcInfo = magic_proc_info(OldInstMap,
+ argument_modes(OldArgInstTable, OldArgModes), _, _, _, _) },
magic_info_get_module_info(ModuleInfo),
%
@@ -946,10 +958,14 @@
%
magic_info_get_proc_info(ProcInfo0),
{ proc_info_headvars(ProcInfo0, HeadVars) },
- { proc_info_argmodes(ProcInfo0, ArgModes) },
- { partition_args(ModuleInfo, ArgModes, HeadVars, _, OldHeadVars) },
- { partition_args(ModuleInfo, OldArgModes, OldHeadVars, InputArgs, _) },
- { partition_args(ModuleInfo, OldArgModes,
+ { proc_info_argmodes(ProcInfo0,
+ argument_modes(ArgInstTable, ArgModes)) },
+ { proc_info_get_initial_instmap(ProcInfo0, ModuleInfo, InstMap) },
+ { partition_args(InstMap, ArgInstTable, ModuleInfo, ArgModes,
+ HeadVars, _, OldHeadVars) },
+ { partition_args(OldInstMap, OldArgInstTable,
+ ModuleInfo, OldArgModes, OldHeadVars, InputArgs, _) },
+ { partition_args(OldInstMap, OldArgInstTable, ModuleInfo, OldArgModes,
OldArgModes, InputArgModes, _) },
{ list__map(magic_util__mode_to_output_mode(ModuleInfo),
InputArgModes, MagicOutputModes) },
@@ -1023,35 +1039,40 @@
%
% Compute a goal_info for the call.
%
- { goal_list_instmap_delta(Goals, Delta0) },
{ set__list_to_set(SuppArgs, SuppArgSet) },
- { instmap_delta_restrict(Delta0, SuppArgSet, Delta) },
+ { instmap_delta_init_reachable(Delta) },
{ goal_info_init(SuppArgSet, Delta, nondet, GoalInfo) },
+ { conj_list_to_goal(Goals, GoalInfo, ConjGoal) },
+ { list__length(SuppArgs, NumArgs) },
+ { list__duplicate(NumArgs, live, IsLives) },
+ magic_info_get_module_info(ModuleInfo0),
+ magic_info_get_proc_info(ProcInfo0),
+ { proc_info_vartypes(ProcInfo0, VarTypes) },
+ { proc_info_get_initial_instmap(ProcInfo0, ModuleInfo0, InstMap) },
+ { proc_info_inst_table(ProcInfo0, InstTable0) },
+ { recompute_instmap_delta(SuppArgs, IsLives, VarTypes, ConjGoal,
+ SuppGoal, InstMap, InstTable0, InstTable, _,
+ ModuleInfo0, ModuleInfo1) },
+ { proc_info_set_inst_table(ProcInfo0, InstTable, ProcInfo) },
+ magic_info_set_proc_info(ProcInfo),
%
% Verify that the supplementary predicate does not have any partially
% instantiated or higher-order arguments other than the input closures.
%
- magic_info_get_proc_info(ProcInfo),
- { proc_info_vartypes(ProcInfo, VarTypes) },
{ map__apply_to_list(SuppOutputArgs, VarTypes, SuppOutputTypes) },
+ { SuppGoal = _ - SuppGoalInfo },
+ { goal_info_get_instmap_delta(SuppGoalInfo, SuppDelta) },
+ { instmap__apply_instmap_delta(InstMap, SuppDelta, FinalInstMap) },
{ GetSuppMode =
- lambda([Var::in, Mode::out] is det, (
- ( instmap_delta_search_var(Delta, Var, NewInst) ->
- Mode = (free -> NewInst)
- ;
- % This is a lie, but we're only using this to check
- % that the output arguments aren't partially
- % instantiated. Any arguments that are partially
- % instantiated in the initial instmap for the
- % procedure will be reported there.
- Mode = (ground(shared, no) -> ground(shared, no))
- )
- )) },
+ lambda([Var::in, Mode::out] is det, (
+ instmap__lookup_var(FinalInstMap, Var, NewInst),
+ Mode = (free(unique) -> NewInst)
+ )) },
{ list__map(GetSuppMode, SuppOutputArgs, SuppOutputModes) },
- magic_util__check_args(SuppOutputArgs, SuppOutputModes,
- SuppOutputTypes, Context, var_name),
+ magic_util__check_args(SuppOutputArgs, InstMap, InstTable,
+ SuppOutputModes, SuppOutputTypes, Context, var_name),
%
% Fill in the fields of the new predicate.
@@ -1061,8 +1082,6 @@
magic_util__make_pred_name(PredInfo, ProcId, "Supp_Proc_For",
yes, NewName),
- magic_info_get_module_info(ModuleInfo0),
- { proc_info_get_initial_instmap(ProcInfo, ModuleInfo0, InstMap) },
{ pred_info_get_aditi_owner(PredInfo, Owner) },
{ pred_info_get_markers(PredInfo, Markers0) },
{ AddMarkers = lambda([Marker::in, Ms0::in, Ms::out] is det,
@@ -1071,7 +1090,6 @@
{ list__foldl(AddMarkers, ExtraMarkers, Markers0, Markers) },
% Add the predicate to the predicate table.
- { conj_list_to_goal(Goals, GoalInfo, SuppGoal) },
{ varset__init(TVarSet) },
{ ClassConstraints = constraints([], []) },
{ map__init(TVarMap) },
@@ -1081,11 +1099,11 @@
{ hlds_pred__define_new_pred(SuppGoal, SuppCall, SuppArgs, ExtraArgs,
InstMap, NewPredName, TVarSet, VarTypes, ClassConstraints,
TVarMap, TCVarMap, VarSet, Markers, Owner,
- ModuleInfo0, ModuleInfo, _) },
+ InstTable, ModuleInfo1, ModuleInfo, _) },
{ ExtraArgs = [] ->
true
;
- error("magic_util__create_supp_call: typeinfo arguments")
+ error("magic_util__create_supp_call: extra typeinfo arguments")
},
magic_info_set_module_info(ModuleInfo).
@@ -1093,25 +1111,31 @@
magic_util__mode_to_output_mode(ModuleInfo, Mode, OutputMode) :-
mode_get_insts(ModuleInfo, Mode, _, FinalInst),
- OutputMode = (free -> FinalInst).
+ OutputMode = (free(unique) -> FinalInst).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
-magic_util__check_args(Vars, Modes, Types, Context, IdType) -->
- ( magic_util__check_args_2(Vars, Modes, Types, Context, 1, IdType) ->
+magic_util__check_args(Vars, InstMap, InstTable, Modes,
+ Types, Context, IdType) -->
+ (
+ magic_util__check_args_2(Vars, InstMap, InstTable,
+ Modes, Types, Context, 1, IdType)
+ ->
[]
;
{ error("magic_util__check_args") }
).
-:- pred magic_util__check_args_2(list(prog_var)::in, list(mode)::in,
- list(type)::in, term__context::in, int::in, magic_arg_id_type::in,
+:- pred magic_util__check_args_2(list(prog_var)::in, instmap::in,
+ inst_table::in, list(mode)::in, list(type)::in, prog_context::in,
+ int::in, magic_arg_id_type::in,
magic_info::in, magic_info::out) is semidet.
-magic_util__check_args_2([], [], [], _, _, _) --> [].
-magic_util__check_args_2([Var | Vars], [ArgMode | ArgModes],
- [ArgType | ArgTypes], Context, ArgNo, ArgIdType) -->
+magic_util__check_args_2([], _, _, [], [], _, _, _) --> [].
+magic_util__check_args_2([Var | Vars], InstMap, InstTable,
+ [ArgMode | ArgModes], [ArgType | ArgTypes],
+ Context, ArgNo, ArgIdType) -->
magic_info_get_error_vars(ErrorVars0),
( { set__member(Var, ErrorVars0) } ->
[]
@@ -1130,7 +1154,10 @@
magic_info_get_curr_pred_proc_id(PredProcId),
magic_info_get_module_info(ModuleInfo),
( { type_is_aditi_state(ArgType) } ->
- ( { \+ mode_is_input(ModuleInfo, ArgMode) } ->
+ (
+ { \+ mode_is_input(InstMap, InstTable,
+ ModuleInfo, ArgMode) }
+ ->
% aditi__states must be input
{ StateError =
[argument_error(output_aditi_state,
@@ -1149,11 +1176,11 @@
% Check that partially instantiated modes are not used.
{ mode_get_insts(ModuleInfo, ArgMode, Inst1, Inst2) },
(
- { inst_is_free(ModuleInfo, Inst1)
- ; inst_is_ground(ModuleInfo, Inst1)
+ { inst_is_free(Inst1, InstMap, InstTable, ModuleInfo)
+ ; inst_is_ground(Inst1, InstMap, InstTable, ModuleInfo)
},
- { inst_is_free(ModuleInfo, Inst2)
- ; inst_is_ground(ModuleInfo, Inst2)
+ { inst_is_free(Inst2, InstMap, InstTable, ModuleInfo)
+ ; inst_is_ground(Inst2, InstMap, InstTable, ModuleInfo)
}
->
{ ErrorTypeList = ErrorTypeList0 }
@@ -1181,8 +1208,8 @@
magic_info_set_errors(Errors),
{ NextArgNo is ArgNo + 1 },
- magic_util__check_args_2(Vars, ArgModes, ArgTypes,
- Context, NextArgNo, ArgIdType)
+ magic_util__check_args_2(Vars, InstMap, InstTable,
+ ArgModes, ArgTypes, Context, NextArgNo, ArgIdType)
).
%-----------------------------------------------------------------------------%
@@ -1303,15 +1330,16 @@
% variables for a procedure.
:- type magic_proc_info
---> magic_proc_info(
- list(mode), % pre-transformation arg modes
+ instmap, % pre-transformation initial instmap.
+ argument_modes, % pre-transformation arg modes
% (minus aditi__states).
list(prog_var), % magic input vars.
list(type), % types of magic input vars.
list(mode), % modes of magic input vars.
maybe(int) % index of this proc's magic
% input var in the above lists,
- % no if the procedure is not
- % an entry point of the sub-module.
+ % `no' if the procedure is not
+ % an entry point of the SCC.
).
% Map from post-transformation pred_proc_id to the
--- /tmp/stayl/mercury/compiler/rl.m Wed Apr 28 11:18:38 1999
+++ rl.m Mon May 3 14:54:57 1999
@@ -390,6 +390,7 @@
prog_varset,
map(prog_var, type),
instmap, % instmap before goal
+ inst_table,
rl_goal_inputs,
rl_goal_outputs,
list(hlds_goal),
@@ -608,7 +609,7 @@
%-----------------------------------------------------------------------------%
rl__goal_is_independent_of_input(InputNo, RLGoal0, RLGoal) :-
- RLGoal0 = rl_goal(A, B, C, D, Inputs0, MaybeOutputs, Goals, H),
+ RLGoal0 = rl_goal(A, B, C, D, E, Inputs0, MaybeOutputs, Goals, I),
rl__select_input_args(InputNo, Inputs0, Inputs, InputArgs),
set__list_to_set(InputArgs, InputArgSet),
\+ (
@@ -624,7 +625,7 @@
set__intersect(NonLocals, InputArgSet, Intersection),
\+ set__empty(Intersection)
),
- RLGoal = rl_goal(A, B, C, D, Inputs, MaybeOutputs, Goals, H).
+ RLGoal = rl_goal(A, B, C, D, E, Inputs, MaybeOutputs, Goals, I).
:- pred rl__select_input_args(tuple_num::in, rl_goal_inputs::in,
rl_goal_inputs::out, list(prog_var)::out) is det.
@@ -640,16 +641,16 @@
one_input(Args1), Args).
rl__swap_goal_inputs(RLGoal0, RLGoal) :-
- RLGoal0 = rl_goal(A, B, C, D, Inputs0, F, G, H),
+ RLGoal0 = rl_goal(A, B, C, D, E, Inputs0, F, G, H),
( Inputs0 = two_inputs(Inputs1, Inputs2) ->
- RLGoal = rl_goal(A, B, C, D, two_inputs(Inputs2, Inputs1),
+ RLGoal = rl_goal(A, B, C, D, E, two_inputs(Inputs2, Inputs1),
F, G, H)
;
error("rl__swap_inputs: goal does not have two inputs to swap")
).
rl__goal_produces_tuple(RLGoal) :-
- RLGoal = rl_goal(_, _, _, _, _, yes(_), _, _).
+ RLGoal = rl_goal(_, _, _, _, _, _, yes(_), _, _).
%-----------------------------------------------------------------------------%
--- /tmp/stayl/mercury/compiler/rl_block_opt.m Mon Mar 8 17:07:14 1999
+++ rl_block_opt.m Mon May 3 14:54:57 1999
@@ -40,7 +40,7 @@
:- implementation.
:- import_module goal_util, hlds_goal, hlds_module, hlds_pred, inlining.
-:- import_module prog_data, rl, rl_key.
+:- import_module prog_data, rl, rl_key, instmap, mode_util.
:- import_module assoc_list, bool, int, map, multi_map.
:- import_module relation, require, set, std_util, string.
@@ -1054,11 +1054,14 @@
{ NodeInfo = node_info(Instr, [ProjOutputRel]) },
{ Instr = project(_, [ProjGoal], _) }
->
- dag_get_rl_opt_info(RLOptInfo),
- { rl_opt_info_get_module_info(ModuleInfo,
- RLOptInfo, _) },
- { rl_block_opt__conjoin_goals(ModuleInfo,
- Goal0, ProjGoal, Goal) },
+ dag_get_rl_opt_info(RLOptInfo0),
+ { rl_opt_info_get_module_info(ModuleInfo0,
+ RLOptInfo0, RLOptInfo1) },
+ { rl_block_opt__conjoin_goals(Goal0, ProjGoal, Goal,
+ ModuleInfo0, ModuleInfo) },
+ { rl_opt_info_set_module_info(ModuleInfo,
+ RLOptInfo1, RLOptInfo) },
+ dag_set_rl_opt_info(RLOptInfo),
{ FoundSingle1 = yes },
{ OutputRel = ProjOutputRel },
@@ -1094,13 +1097,14 @@
FoundSingle1, FoundSingle, Goals0, Goals,
OutputRels0, OutputRels).
-:- pred rl_block_opt__conjoin_goals(module_info::in, rl_goal::in,
- rl_goal::in, rl_goal::out) is det.
+:- pred rl_block_opt__conjoin_goals(rl_goal::in, rl_goal::in, rl_goal::out,
+ module_info::in, module_info::out) is det.
-rl_block_opt__conjoin_goals(ModuleInfo, RLGoal1, RLGoal2, RLGoal) :-
- RLGoal1 = rl_goal(_, VarSet1, VarTypes1, InstMap0,
+rl_block_opt__conjoin_goals(RLGoal1, RLGoal2, RLGoal,
+ ModuleInfo0, ModuleInfo) :-
+ RLGoal1 = rl_goal(_, VarSet1, VarTypes1, InstMap0, InstTable1,
Inputs1, Outputs1, Goals1, _),
- RLGoal2 = rl_goal(_, VarSet2, VarTypes2, _,
+ RLGoal2 = rl_goal(_, VarSet2, VarTypes2, _, _,
Inputs2, Outputs2, Goals2, _),
(
Outputs1 = no,
@@ -1134,17 +1138,47 @@
Outputs = no
),
+ (
+ Inputs1 = no_inputs,
+ set__init(NonLocals1)
+ ;
+ Inputs1 = one_input(NonLocalsList0),
+ set__list_to_set(NonLocalsList0, NonLocals1)
+ ;
+ Inputs1 = two_inputs(NonLocalsList0, NonLocalsList1),
+ set__list_to_set(NonLocalsList0, NonLocals0),
+ set__insert_list(NonLocals0, NonLocalsList1, NonLocals1)
+ ),
+ (
+ Outputs = yes(NonLocalsList2),
+ set__insert_list(NonLocals1, NonLocalsList2, NonLocals)
+ ;
+ Outputs = no,
+ NonLocals = NonLocals1
+ ),
+
( RenamedGoal = conj(RenamedGoals2) - _ ->
% XXX do some simplification, constraint propagation etc.
- list__append(Goals1, RenamedGoals2, Goals)
+ list__append(Goals1, RenamedGoals2, RenamedGoals),
+ goal_list_determinism(RenamedGoals, Detism),
+ instmap_delta_init_reachable(Delta),
+ goal_info_init(NonLocals, Delta, Detism, GoalInfo),
+ conj_list_to_goal(RenamedGoals, GoalInfo, Goal0)
;
error("rl_block_opt__conjoin_goals")
),
+ set__to_sorted_list(NonLocals, NonLocalsList),
+ list__length(NonLocalsList, NumNonLocals),
+ list__duplicate(NumNonLocals, live, IsLives),
+ recompute_instmap_delta(NonLocalsList, IsLives, VarTypes, Goal0, Goal,
+ InstMap0, InstTable1, InstTable, _, ModuleInfo0, ModuleInfo),
+ goal_to_conj_list(Goal, Goals),
+
rl_key__extract_indexing(Inputs1, Goals, ModuleInfo, VarTypes, Bounds),
- RLGoal = rl_goal(no, VarSet, VarTypes, InstMap0, Inputs1,
- Outputs, Goals, Bounds).
+ RLGoal = rl_goal(no, VarSet, VarTypes, InstMap0, InstTable,
+ Inputs1, Outputs, Goals, Bounds).
%-----------------------------------------------------------------------------%
--- /tmp/stayl/mercury/compiler/rl_dump.m Fri Mar 12 17:14:16 1999
+++ rl_dump.m Mon May 3 14:54:57 1999
@@ -588,7 +588,7 @@
io__state::di, io__state::uo) is det.
rl_dump__write_goal(ModuleInfo, RLGoal) -->
- { RLGoal = rl_goal(_, VarSet, _, _, Inputs,
+ { RLGoal = rl_goal(_, VarSet, _, InstMap, InstTable, Inputs,
MaybeOutputs, GoalList, Bounds) },
(
{ Inputs = no_inputs }
@@ -627,7 +627,7 @@
;
[]
),
- hlds_out__write_goal_list(GoalList, ModuleInfo,
+ hlds_out__write_goal_list(GoalList, InstMap, InstTable, ModuleInfo,
VarSet, yes, 2, ",\n", no).
:- pred rl_dump__write_bounds(module_info::in, prog_varset::in,
--- /tmp/stayl/mercury/compiler/rl_exprn.m Wed Apr 28 11:18:39 1999
+++ rl_exprn.m Mon May 3 14:54:57 1999
@@ -366,9 +366,10 @@
%-----------------------------------------------------------------------------%
rl_exprn__generate(ModuleInfo, RLGoal, Code, NumParams, Mode, Decls) :-
- RLGoal = rl_goal(_, VarSet, VarTypes, InstMap,
+ RLGoal = rl_goal(_, VarSet, VarTypes, InstMap, InstTable,
Inputs, MaybeOutputs, Goals, _),
- rl_exprn_info_init(ModuleInfo, InstMap, VarTypes, VarSet, Info0),
+ rl_exprn_info_init(ModuleInfo, InstMap, InstTable,
+ VarTypes, VarSet, Info0),
rl_exprn__generate_2(Inputs, MaybeOutputs, Goals,
Code, NumParams, Mode, Decls, Info0, _).
@@ -591,7 +592,12 @@
rl_exprn__goals([], _, empty) --> [].
rl_exprn__goals([Goal | Goals], Fail, Code) -->
+ rl_exprn_info_get_instmap(InstMap0),
rl_exprn__goal(Goal, Fail, Code0),
+ { Goal = _ - GoalInfo },
+ { goal_info_get_instmap_delta(GoalInfo, InstMapDelta) },
+ { instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap) },
+ rl_exprn_info_set_instmap(InstMap),
rl_exprn__goals(Goals, Fail, Code1),
{ Code = tree(Code0, Code1) }.
@@ -615,9 +621,16 @@
rl_exprn_info_get_next_label_id(StartElse),
rl_exprn_info_get_next_label_id(EndIte),
{ CondFail = node([rl_EXP_jmp(StartElse)]) },
+ rl_exprn_info_get_instmap(InstMap0),
rl_exprn__goal(Cond, CondFail, CondCode),
+ { Cond = _ - CondInfo },
+ { goal_info_get_instmap_delta(CondInfo, CondDelta) },
+ { instmap__apply_instmap_delta(InstMap0, CondDelta, InstMap) },
+ rl_exprn_info_set_instmap(InstMap),
rl_exprn__goal(Then, Fail, ThenCode),
+ rl_exprn_info_set_instmap(InstMap0),
rl_exprn__goal(Else, Fail, ElseCode),
+ rl_exprn_info_set_instmap(InstMap0),
{ Code =
tree(CondCode,
tree(ThenCode,
@@ -655,11 +668,16 @@
rl_exprn_info::in, rl_exprn_info::out) is det.
rl_exprn__cases(_, [], _, Fail, Fail) --> [].
-rl_exprn__cases(Var, [case(ConsId, Goal) | Cases], Succeed, Fail, Code) -->
+rl_exprn__cases(Var, [case(ConsId, InstMapDelta, Goal) | Cases],
+ Succeed, Fail, Code) -->
+ rl_exprn_info_get_instmap(InstMap0),
+ { instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap) },
+ rl_exprn_info_set_instmap(InstMap),
rl_exprn_info_get_next_label_id(NextCase),
{ Jmp = rl_EXP_jmp(NextCase) },
rl_exprn__functor_test(Var, ConsId, node([Jmp]), TestCode),
rl_exprn__goal(Goal, Fail, GoalCode),
+ rl_exprn_info_set_instmap(InstMap0),
rl_exprn__cases(Var, Cases, Succeed, Fail, Code1),
{ Code =
tree(TestCode,
@@ -675,10 +693,12 @@
rl_exprn__disj([], _, Fail, Fail) --> [].
rl_exprn__disj([Goal | Goals], Succeed, Fail, Code) -->
+ rl_exprn_info_get_instmap(InstMap0),
rl_exprn_info_get_next_label_id(NextDisj),
{ TryNext = node([rl_EXP_jmp(NextDisj)]) },
{ NextLabel = node([rl_PROC_label(NextDisj)]) },
rl_exprn__goal(Goal, TryNext, GoalCode),
+ rl_exprn_info_set_instmap(InstMap0),
rl_exprn__disj(Goals, Succeed, Fail, Code1),
{ Code =
tree(GoalCode,
@@ -1031,10 +1051,14 @@
( { set__member(Arg, NonLocals) } ->
rl_exprn_info_lookup_var_type(Arg, Type),
rl_exprn_info_get_module_info(ModuleInfo),
+ rl_exprn_info_get_instmap(InstMap),
+ rl_exprn_info_get_inst_table(InstTable),
{ Mode = ((LI - RI) -> (LF - RF)) },
- { mode_to_arg_mode(ModuleInfo, (LI -> LF), Type, LeftMode) },
- { mode_to_arg_mode(ModuleInfo, (RI -> RF), Type, RightMode) },
+ { mode_to_arg_mode(InstMap, InstTable, ModuleInfo,
+ (LI -> LF), Type, LeftMode) },
+ { mode_to_arg_mode(InstMap, InstTable, ModuleInfo,
+ (RI -> RF), Type, RightMode) },
(
{ LeftMode = top_in },
{ RightMode = top_in }
@@ -1390,10 +1414,7 @@
rl_exprn__aggregate(ModuleInfo, ComputeInitial, UpdateAcc, GrpByType,
NonGrpByType, AccType, AggCode, Decls) :-
- map__init(VarTypes),
- varset__init(VarSet),
- instmap__init_reachable(InstMap),
- rl_exprn_info_init(ModuleInfo, InstMap, VarTypes, VarSet, Info0),
+ rl_exprn_info_init(ModuleInfo, Info0),
rl_exprn__aggregate_2(ComputeInitial, UpdateAcc, GrpByType,
NonGrpByType, AccType, AggCode, Decls, Info0, _).
@@ -1569,8 +1590,11 @@
{ proc_info_goal(ProcInfo, Goal) },
{ Goal = _ - GoalInfo },
{ goal_info_get_nonlocals(GoalInfo, NonLocals) },
- { proc_info_argmodes(ProcInfo, ArgModes) },
- { partition_args(ModuleInfo, ArgModes, HeadVars, InputArgs, _) },
+ { proc_info_argmodes(ProcInfo, argument_modes(_, ArgModes)) },
+ { proc_info_get_initial_instmap(ProcInfo, ModuleInfo, InstMap) },
+ { proc_info_inst_table(ProcInfo, InstTable) },
+ { partition_args(InstMap, InstTable, ModuleInfo,
+ ArgModes, HeadVars, InputArgs, _) },
{ set__list_to_set(InputArgs, InputArgSet) },
{ set__intersect(InputArgSet, NonLocals, UsedInputArgs) },
( { set__empty(UsedInputArgs) } ->
@@ -1815,9 +1839,9 @@
:- type rl_exprn_info.
-:- pred rl_exprn_info_init(module_info, instmap, map(prog_var, type),
- prog_varset, rl_exprn_info).
-:- mode rl_exprn_info_init(in, in, in, in, out) is det.
+:- pred rl_exprn_info_init(module_info, instmap, inst_table,
+ map(prog_var, type), prog_varset, rl_exprn_info).
+:- mode rl_exprn_info_init(in, in, in, in, in, out) is det.
:- pred rl_exprn_info_init(module_info, rl_exprn_info).
:- mode rl_exprn_info_init(in, out) is det.
@@ -1891,10 +1915,13 @@
:- pred rl_exprn_info_get_decls(list(type), rl_exprn_info, rl_exprn_info).
:- mode rl_exprn_info_get_decls(out, in, out) is det.
+:- pred rl_exprn_info_get_inst_table(inst_table, rl_exprn_info, rl_exprn_info).
+:- mode rl_exprn_info_get_inst_table(out, in, out) is det.
+
:- type rl_exprn_info
---> rl_exprn_info(
module_info,
- instmap, % not yet used.
+ instmap,
map(prog_var, type),
prog_varset,
id_map(prog_var),
@@ -1903,7 +1930,9 @@
id_map(pair(rl_rule, exprn_tuple)),
set(pred_proc_id), % parent pred_proc_ids, used
% to abort on recursion.
- list(type) % variable declarations in reverse.
+ list(type), % variable declarations in reverse.
+ inst_table,
+ unit
).
:- type rl_rule
@@ -1955,59 +1984,63 @@
map__init(VarTypes),
varset__init(VarSet),
instmap__init_reachable(InstMap),
- rl_exprn_info_init(ModuleInfo, InstMap, VarTypes, VarSet, Info0).
+ inst_table_init(InstTable),
+ rl_exprn_info_init(ModuleInfo, InstMap, InstTable,
+ VarTypes, VarSet, Info0).
-rl_exprn_info_init(ModuleInfo, InstMap, VarTypes, VarSet, Info) :-
+rl_exprn_info_init(ModuleInfo, InstMap, InstTable, VarTypes, VarSet, Info) :-
id_map_init(VarMap),
id_map_init(ConstMap),
id_map_init(RuleMap),
set__init(Parents),
Label = 0,
- Info = rl_exprn_info(ModuleInfo, InstMap, VarTypes, VarSet,
- VarMap, Label, ConstMap, RuleMap, Parents, []).
+ Info = rl_exprn_info(ModuleInfo, InstMap, VarTypes, VarSet, VarMap,
+ Label, ConstMap, RuleMap, Parents, [], InstTable, unit).
rl_exprn_info_get_module_info(A, Info, Info) :-
- Info = rl_exprn_info(A,_,_,_,_,_,_,_,_,_).
+ Info = rl_exprn_info(A,_,_,_,_,_,_,_,_,_,_,_).
rl_exprn_info_get_instmap(B, Info, Info) :-
- Info = rl_exprn_info(_,B,_,_,_,_,_,_,_,_).
+ Info = rl_exprn_info(_,B,_,_,_,_,_,_,_,_,_,_).
rl_exprn_info_get_vartypes(C, Info, Info) :-
- Info = rl_exprn_info(_,_,C,_,_,_,_,_,_,_).
+ Info = rl_exprn_info(_,_,C,_,_,_,_,_,_,_,_,_).
rl_exprn_info_get_varset(D, Info, Info) :-
- Info = rl_exprn_info(_,_,_,D,_,_,_,_,_,_).
+ Info = rl_exprn_info(_,_,_,D,_,_,_,_,_,_,_,_).
rl_exprn_info_get_consts(G, Info, Info) :-
- Info = rl_exprn_info(_,_,_,_,_,_,G,_,_,_).
+ Info = rl_exprn_info(_,_,_,_,_,_,G,_,_,_,_,_).
rl_exprn_info_get_rules(H, Info, Info) :-
- Info = rl_exprn_info(_,_,_,_,_,_,_,H,_,_).
+ Info = rl_exprn_info(_,_,_,_,_,_,_,H,_,_,_,_).
rl_exprn_info_get_parent_pred_proc_ids(I, Info, Info) :-
- Info = rl_exprn_info(_,_,_,_,_,_,_,_,I,_).
+ Info = rl_exprn_info(_,_,_,_,_,_,_,_,I,_,_,_).
rl_exprn_info_get_decls(J, Info, Info) :-
- Info = rl_exprn_info(_,_,_,_,_,_,_,_,_,J0),
+ Info = rl_exprn_info(_,_,_,_,_,_,_,_,_,J0,_,_),
list__reverse(J0, J).
+rl_exprn_info_get_inst_table(K, Info, Info) :-
+ Info = rl_exprn_info(_,_,_,_,_,_,_,_,_,_,K,_).
rl_exprn_info_set_instmap(B, Info0, Info) :-
- Info0 = rl_exprn_info(A,_,C,D,E,F,G,H,I,J),
- Info = rl_exprn_info(A,B,C,D,E,F,G,H,I,J).
+ Info0 = rl_exprn_info(A,_,C,D,E,F,G,H,I,J,K,L),
+ Info = rl_exprn_info(A,B,C,D,E,F,G,H,I,J,K,L).
rl_exprn_info_set_vartypes(C, Info0, Info) :-
- Info0 = rl_exprn_info(A,B,_,D,E,F,G,H,I,J),
- Info = rl_exprn_info(A,B,C,D,E,F,G,H,I,J).
+ Info0 = rl_exprn_info(A,B,_,D,E,F,G,H,I,J,K,L),
+ Info = rl_exprn_info(A,B,C,D,E,F,G,H,I,J,K,L).
rl_exprn_info_set_varset(D, Info0, Info) :-
- Info0 = rl_exprn_info(A,B,C,_,E,F,G,H,I,J),
- Info = rl_exprn_info(A,B,C,D,E,F,G,H,I,J).
+ Info0 = rl_exprn_info(A,B,C,_,E,F,G,H,I,J,K,L),
+ Info = rl_exprn_info(A,B,C,D,E,F,G,H,I,J,K,L).
rl_exprn_info_set_vars(E, Info0, Info) :-
- Info0 = rl_exprn_info(A,B,C,D,_,F,G,H,I,J),
- Info = rl_exprn_info(A,B,C,D,E,F,G,H,I,J).
+ Info0 = rl_exprn_info(A,B,C,D,_,F,G,H,I,J,K,L),
+ Info = rl_exprn_info(A,B,C,D,E,F,G,H,I,J,K,L).
rl_exprn_info_set_parent_pred_proc_ids(I, Info0, Info) :-
- Info0 = rl_exprn_info(A,B,C,D,E,F,G,H,_,J),
- Info = rl_exprn_info(A,B,C,D,E,F,G,H,I,J).
+ Info0 = rl_exprn_info(A,B,C,D,E,F,G,H,_,J,K,L),
+ Info = rl_exprn_info(A,B,C,D,E,F,G,H,I,J,K,L).
rl_exprn_info_get_free_reg(Type, Loc, Info0, Info) :-
- Info0 = rl_exprn_info(A,B,C,D,VarMap0,F,G,H,I,RegTypes0),
+ Info0 = rl_exprn_info(A,B,C,D,VarMap0,F,G,H,I,RegTypes0,K,L),
VarMap0 = Map - Loc,
Loc1 is Loc + 1,
VarMap = Map - Loc1,
RegTypes = [Type | RegTypes0],
- Info = rl_exprn_info(A,B,C,D,VarMap,F,G,H,I,RegTypes).
+ Info = rl_exprn_info(A,B,C,D,VarMap,F,G,H,I,RegTypes,K,L).
rl_exprn_info_lookup_var(Var, Loc, Info0, Info) :-
- Info0 = rl_exprn_info(A,B,VarTypes,D,VarMap0,F,G,H,I,RegTypes0),
+ Info0 = rl_exprn_info(A,B,VarTypes,D,VarMap0,F,G,H,I,RegTypes0,K,L),
id_map_lookup(Var, Loc, Added, VarMap0, VarMap),
( Added = yes ->
map__lookup(VarTypes, Var, Type),
@@ -2015,19 +2048,19 @@
;
RegTypes = RegTypes0
),
- Info = rl_exprn_info(A,B,VarTypes,D,VarMap,F,G,H,I,RegTypes).
+ Info = rl_exprn_info(A,B,VarTypes,D,VarMap,F,G,H,I,RegTypes,K,L).
rl_exprn_info_get_next_label_id(Label0, Info0, Info) :-
- Info0 = rl_exprn_info(A,B,C,D,E,Label0,G,H,I,J),
+ Info0 = rl_exprn_info(A,B,C,D,E,Label0,G,H,I,J,K,L),
Label is Label0 + 1,
- Info = rl_exprn_info(A,B,C,D,E,Label,G,H,I,J).
+ Info = rl_exprn_info(A,B,C,D,E,Label,G,H,I,J,K,L).
rl_exprn_info_lookup_const(Const, Loc, Info0, Info) :-
- Info0 = rl_exprn_info(A,B,C,D,E,F,Consts0,H,I,J),
+ Info0 = rl_exprn_info(A,B,C,D,E,F,Consts0,H,I,J,K,L),
id_map_lookup(Const, Loc, Consts0, Consts),
- Info = rl_exprn_info(A,B,C,D,E,F,Consts,H,I,J).
+ Info = rl_exprn_info(A,B,C,D,E,F,Consts,H,I,J,K,L).
rl_exprn_info_lookup_rule(Rule, Loc, Info0, Info) :-
- Info0 = rl_exprn_info(A,B,C,D,E,F,G,Rules0,I,J),
+ Info0 = rl_exprn_info(A,B,C,D,E,F,G,Rules0,I,J,K,L),
id_map_lookup(Rule, Loc, Rules0, Rules),
- Info = rl_exprn_info(A,B,C,D,E,F,G,Rules,I,J).
+ Info = rl_exprn_info(A,B,C,D,E,F,G,Rules,I,J,K,L).
rl_exprn_info_lookup_var_type(Var, Type) -->
rl_exprn_info_get_vartypes(VarTypes),
--- /tmp/stayl/mercury/compiler/rl_gen.m Wed Apr 28 11:18:42 1999
+++ rl_gen.m Mon May 3 14:54:57 1999
@@ -184,13 +184,16 @@
{ EntryPoint = proc(PredId, ProcId) },
{ module_info_pred_proc_info(ModuleInfo, PredId,
ProcId, PredInfo, ProcInfo) },
- { proc_info_argmodes(ProcInfo, ArgModes) },
+ { proc_info_argmodes(ProcInfo, argument_modes(_, ArgModes)) },
+ { proc_info_get_initial_instmap(ProcInfo, ModuleInfo, InstMap) },
+ { proc_info_inst_table(ProcInfo, InstTable) },
{ pred_info_arg_types(PredInfo, ArgTypes) },
{ map__init(InputMap0) },
% The input arguments are the same for each
% procedure in the SCC.
- rl_gen__scc_list_input_args(EntryPoint, 1, ArgModes,
+ rl_gen__scc_list_input_args(EntryPoint, 1,
+ InstMap, InstTable, ArgModes,
ArgTypes, [], InputRels, InputMap0, InputMap),
rl_gen__scc_list_output_args([EntryPoint | EntryPoints], OutputRels),
{ list__append(InputRels, OutputRels, AllArgs) },
@@ -202,19 +205,19 @@
% corresponding input arguments for each entry point have the
% same value.
:- pred rl_gen__scc_list_input_args(pred_proc_id::in, int::in,
- list(mode)::in, list(type)::in, list(relation_id)::in,
- list(relation_id)::out, map(int, relation_id)::in,
- map(int, relation_id)::out, rl_info::rl_info_di,
- rl_info::rl_info_uo) is det.
+ instmap::in, inst_table::in, list(mode)::in, list(type)::in,
+ list(relation_id)::in, list(relation_id)::out,
+ map(int, relation_id)::in, map(int, relation_id)::out,
+ rl_info::rl_info_di, rl_info::rl_info_uo) is det.
-rl_gen__scc_list_input_args(EntryPoint, ArgNo, ArgModes, ArgTypes,
- RevInputRels0, InputRels, InputMap0, InputMap) -->
+rl_gen__scc_list_input_args(EntryPoint, ArgNo, InstMap, InstTable, ArgModes,
+ ArgTypes, RevInputRels0, InputRels, InputMap0, InputMap) -->
(
{ ArgModes = [Mode | Modes] },
{ ArgTypes = [Type | Types] }
->
rl_info_get_module_info(ModuleInfo),
- ( { mode_is_input(ModuleInfo, Mode) } ->
+ ( { mode_is_input(InstMap, InstTable, ModuleInfo, Mode) } ->
(
{ type_is_higher_order(Type,
predicate, PredArgTypes) }
@@ -244,8 +247,9 @@
{ InputMap1 = InputMap0 }
),
{ NextArgNo is ArgNo + 1 },
- rl_gen__scc_list_input_args(EntryPoint, NextArgNo, Modes,
- Types, RevInputRels1, InputRels, InputMap1, InputMap)
+ rl_gen__scc_list_input_args(EntryPoint, NextArgNo, InstMap,
+ InstTable, Modes, Types, RevInputRels1, InputRels,
+ InputMap1, InputMap)
;
{ ArgModes = [] },
{ ArgTypes = [] }
@@ -977,12 +981,16 @@
InputArgs, OutputArgs, GoalInfo) }
;
{ CallGoal = higher_order_call(Var, Args, _,
- ArgModes, _, predicate) - GoalInfo }
+ argument_modes(_, ArgModes), _, predicate) - GoalInfo }
->
{ CallId = ho_called_var(Var) },
rl_info_get_module_info(ModuleInfo),
- { partition_args(ModuleInfo, ArgModes, Args,
- InputArgs, OutputArgs) },
+ rl_info_get_proc_info(ProcInfo),
+ { proc_info_inst_table(ProcInfo, InstTable) },
+ { proc_info_get_initial_instmap(ProcInfo,
+ ModuleInfo, InstMap) },
+ { partition_args(InstMap, InstTable, ModuleInfo, ArgModes,
+ Args, InputArgs, OutputArgs) },
{ DBCall = db_call(CallId, MaybeNegGoals, InputArgs,
OutputArgs, GoalInfo) }
;
--- /tmp/stayl/mercury/compiler/rl_info.m Mon Dec 7 10:45:19 1998
+++ rl_info.m Mon May 3 14:54:57 1999
@@ -12,7 +12,7 @@
:- interface.
-:- import_module hlds_module, hlds_pred, prog_data, rl, tree.
+:- import_module hlds_data, hlds_module, hlds_pred, prog_data, rl, tree.
:- import_module bool, io, list, map, set, std_util, string.
:- type rl_info.
@@ -214,6 +214,9 @@
:- pred rl_info_get_var_type(prog_var, (type), rl_info, rl_info).
:- mode rl_info_get_var_type(in, out, rl_info_di, rl_info_uo) is det.
+:- pred rl_info_get_inst_table(inst_table, rl_info, rl_info).
+:- mode rl_info_get_inst_table(out, rl_info_di, rl_info_uo) is det.
+
%-----------------------------------------------------------------------------%
:- pred rl_info_bind_var_to_relation(prog_var, relation_id, rl_info, rl_info).
@@ -541,6 +544,10 @@
{ proc_info_vartypes(ProcInfo, VarTypes) },
{ map__lookup(VarTypes, Var, Type) }.
+rl_info_get_inst_table(InstTable) -->
+ rl_info_get_proc_info(ProcInfo),
+ { proc_info_inst_table(ProcInfo, InstTable) }.
+
%-----------------------------------------------------------------------------%
rl_info_lookup_var_relation(Var, RelationId) -->
@@ -573,8 +580,10 @@
rl_info_get_module_info(ModuleInfo),
{ module_info_pred_proc_info(ModuleInfo, PredId,
ProcId, _, ProcInfo) },
- { proc_info_argmodes(ProcInfo, ArgModes) },
- { partition_args(ModuleInfo, ArgModes,
+ { proc_info_argmodes(ProcInfo, argument_modes(_, ArgModes)) },
+ { proc_info_inst_table(ProcInfo, InstTable) },
+ { proc_info_get_initial_instmap(ProcInfo, ModuleInfo, InstMap) },
+ { partition_args(InstMap, InstTable, ModuleInfo, ArgModes,
AllArgs, InputArgs, OutputArgs) }.
%-----------------------------------------------------------------------------%
@@ -582,17 +591,23 @@
rl_info_get_current_proc_output_schema(schema(OutputArgTypes)) -->
rl_info_get_pred_info(PredInfo),
rl_info_get_proc_info(ProcInfo),
- { proc_info_argmodes(ProcInfo, ArgModes) },
- { pred_info_arg_types(PredInfo, ArgTypes) },
rl_info_get_module_info(ModuleInfo),
- { partition_args(ModuleInfo, ArgModes, ArgTypes, _, OutputArgTypes) }.
+ { proc_info_argmodes(ProcInfo, argument_modes(_, ArgModes)) },
+ { proc_info_get_initial_instmap(ProcInfo, ModuleInfo, InstMap) },
+ { proc_info_inst_table(ProcInfo, InstTable) },
+ { pred_info_arg_types(PredInfo, ArgTypes) },
+ { partition_args(InstMap, InstTable, ModuleInfo,
+ ArgModes, ArgTypes, _, OutputArgTypes) }.
rl_info_get_current_proc_output_vars(Vars) -->
rl_info_get_proc_info(ProcInfo),
{ proc_info_headvars(ProcInfo, HeadVars) },
- { proc_info_argmodes(ProcInfo, ArgModes) },
+ { proc_info_argmodes(ProcInfo,
+ argument_modes(ArgInstTable, ArgModes)) },
rl_info_get_module_info(ModuleInfo),
- { partition_args(ModuleInfo, ArgModes, HeadVars, _, Vars) }.
+ { proc_info_get_initial_instmap(ProcInfo, ModuleInfo, InstMap) },
+ { partition_args(InstMap, ArgInstTable,
+ ModuleInfo, ArgModes, HeadVars, _, Vars) }.
rl_info_get_proc_schema(proc(PredId, ProcId), schema(Schema)) -->
rl_info_get_module_info(ModuleInfo),
@@ -603,8 +618,12 @@
( { check_marker(Markers, base_relation) } ->
{ Schema = ArgTypes }
;
- { proc_info_argmodes(ProcInfo, ArgModes) },
- { partition_args(ModuleInfo, ArgModes, ArgTypes, _, Schema) }
+ { proc_info_argmodes(ProcInfo, argument_modes(_, ArgModes)) },
+ { proc_info_inst_table(ProcInfo, InstTable) },
+ { proc_info_get_initial_instmap(ProcInfo,
+ ModuleInfo, InstMap) },
+ { partition_args(InstMap, InstTable, ModuleInfo,
+ ArgModes, ArgTypes, _, Schema) }
).
rl_info_write_message(FormatStr, Items) -->
--- /tmp/stayl/mercury/compiler/rl_key.m Mon Dec 7 10:45:23 1998
+++ rl_key.m Mon May 3 14:54:57 1999
@@ -549,7 +549,7 @@
rl_key__extract_key_range_switch(_, _Var, [], Maps, Maps) --> [].
rl_key__extract_key_range_switch(Cnstrs0, Var, [Case | Cases],
Maps0, Maps) -->
- { Case = case(ConsId, Goal) },
+ { Case = case(ConsId, _, Goal) },
key_info_set_constraints(Cnstrs0),
rl_key__add_functor_constraint(Var, ConsId),
rl_key__extract_key_range(Goal),
--- /tmp/stayl/mercury/compiler/rl_out.pp Wed Apr 28 11:18:44 1999
+++ rl_out.pp Tue May 4 13:26:09 1999
@@ -20,9 +20,9 @@
:- interface.
-:- import_module rl, rl_file, hlds_module, tree.
+:- import_module rl, rl_file, hlds_module.
#if INCLUDE_ADITI_OUTPUT % See ../Mmake.common.in.
-:- import_module rl_code.
+:- import_module rl_code, tree.
#else
#endif
@@ -57,7 +57,7 @@
:- implementation.
:- import_module code_util, hlds_data, hlds_pred, prog_data, prog_out.
-:- import_module llds, globals, options, rl_code, tree, type_util, passes_aux.
+:- import_module llds, globals, options, tree, type_util, passes_aux.
:- import_module rl_file, getopt, modules, prog_util, magic_util.
#if INCLUDE_ADITI_OUTPUT % See ../Mmake.common.in.
@@ -115,6 +115,24 @@
io__write_strings([ModuleName, ":", PredName, "/", PredArity, "\t",
Owner, "/", ModuleName, "/", RelName, "\t", RelSchema, "\n"]).
+:- pred rl_out__get_perm_rel_info(module_info::in, pred_proc_id::in,
+ string::out, string::out, string::out, int::out,
+ string::out, string::out) is det.
+
+rl_out__get_perm_rel_info(ModuleInfo, PredProcId, Owner, PredModule,
+ PredName, PredArity, RelName, SchemaString) :-
+ PredProcId = proc(PredId, _),
+ module_info_pred_info(ModuleInfo, PredId, PredInfo),
+ pred_info_name(PredInfo, PredName),
+ pred_info_module(PredInfo, PredModule0),
+ prog_out__sym_name_to_string(PredModule0, PredModule),
+ pred_info_get_aditi_owner(PredInfo, Owner),
+ pred_info_arity(PredInfo, PredArity),
+ string__format("%s__%i", [s(PredName), i(PredArity)], RelName),
+ pred_info_arg_types(PredInfo, ArgTypes0),
+ magic_util__remove_aditi_state(ArgTypes0, ArgTypes0, ArgTypes),
+ rl__schema_to_string(ModuleInfo, ArgTypes, SchemaString).
+
%-----------------------------------------------------------------------------%
% If the RL procedure is callable from the query shell or Mercury,
@@ -145,7 +163,51 @@
;
[]
).
-
+
+:- pred rl_out__get_proc_schema(module_info::in, relation_info_map::in,
+ list(relation_id)::in, string::out) is det.
+
+rl_out__get_proc_schema(ModuleInfo, Relations, Args, SchemaString) :-
+ list__map(
+ (pred(Arg::in, ArgSchema::out) is det :-
+ map__lookup(Relations, Arg, ArgInfo),
+ ArgInfo = relation_info(_, ArgSchema, _, _)
+ ), Args, ArgSchemas),
+ rl__schemas_to_strings(ModuleInfo, ArgSchemas,
+ TypeDecls, ArgSchemaStrings),
+ list__map_foldl(
+ (pred(ArgSchemaString::in, ArgSchemaDecl::out,
+ Index::in, (Index + 1)::out) is det :-
+ ArgPrefix = "__arg_",
+ string__int_to_string(Index, ArgString),
+ string__append_list(
+ [":", ArgPrefix, ArgString, "=",
+ ArgPrefix, ArgString, "(",
+ ArgSchemaString, ") "],
+ ArgSchemaDecl)
+ ), ArgSchemaStrings, ArgSchemaDeclList, 1, _),
+ rl_out__get_proc_schema_2(1, Args, "", SchemaString0),
+ list__condense([[TypeDecls | ArgSchemaDeclList], ["("],
+ [SchemaString0, ")"]], SchemaStrings),
+ string__append_list(SchemaStrings, SchemaString).
+
+:- pred rl_out__get_proc_schema_2(int::in, list(T)::in,
+ string::in, string::out) is det.
+
+rl_out__get_proc_schema_2(_, [], SchemaList, SchemaList).
+rl_out__get_proc_schema_2(ArgNo, [_ | Args], SchemaList0, SchemaList) :-
+ ArgPrefix = "__arg_",
+ ( Args = [] ->
+ Comma = ""
+ ;
+ Comma = ","
+ ),
+ string__int_to_string(ArgNo, ArgString),
+ string__append_list([SchemaList0, ":T", ArgPrefix, ArgString, Comma],
+ SchemaList1),
+ rl_out__get_proc_schema_2(ArgNo + 1,
+ Args, SchemaList1, SchemaList).
+
%-----------------------------------------------------------------------------%
#if INCLUDE_ADITI_OUTPUT % See ../Mmake.common.in,
@@ -284,9 +346,12 @@
),
maybe_write_string(Verbose, "done\n").
#else
-rl_out__generate_rl_bytecode(_, _, _) -->
- { error(
- "rl_out.pp: `--aditi' requires `INCLUDE_ADITI_OUTPUT'") }.
+rl_out__generate_rl_bytecode(_, _, MaybeRLFile) -->
+ { semidet_succeed ->
+ error("rl_out.pp: `--aditi' requires `INCLUDE_ADITI_OUTPUT'")
+ ;
+ MaybeRLFile = no
+ }.
#endif
#if INCLUDE_ADITI_OUTPUT
@@ -459,24 +524,6 @@
),
rl_out__collect_permanent_rels(Rels, Codes1, Codes).
-:- pred rl_out__get_perm_rel_info(module_info::in, pred_proc_id::in,
- string::out, string::out, string::out, int::out,
- string::out, string::out) is det.
-
-rl_out__get_perm_rel_info(ModuleInfo, PredProcId, Owner, PredModule,
- PredName, PredArity, RelName, SchemaString) :-
- PredProcId = proc(PredId, _),
- module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_name(PredInfo, PredName),
- pred_info_module(PredInfo, PredModule0),
- prog_out__sym_name_to_string(PredModule0, PredModule),
- pred_info_get_aditi_owner(PredInfo, Owner),
- pred_info_arity(PredInfo, PredArity),
- string__format("%s__%i", [s(PredName), i(PredArity)], RelName),
- pred_info_arg_types(PredInfo, ArgTypes0),
- magic_util__remove_aditi_state(ArgTypes0, ArgTypes0, ArgTypes),
- rl__schema_to_string(ModuleInfo, ArgTypes, SchemaString).
-
%-----------------------------------------------------------------------------%
:- pred rl_out__get_rel_var_list(list(relation_id)::in, byte_tree::out,
@@ -502,50 +549,6 @@
rl_out_info_get_relations(Relations),
{ rl_out__get_proc_schema(ModuleInfo, Relations, Args, SchemaString) },
rl_out_info_assign_const(string(SchemaString), SchemaOffset).
-
-:- pred rl_out__get_proc_schema(module_info::in, relation_info_map::in,
- list(relation_id)::in, string::out) is det.
-
-rl_out__get_proc_schema(ModuleInfo, Relations, Args, SchemaString) :-
- list__map(
- (pred(Arg::in, ArgSchema::out) is det :-
- map__lookup(Relations, Arg, ArgInfo),
- ArgInfo = relation_info(_, ArgSchema, _, _)
- ), Args, ArgSchemas),
- rl__schemas_to_strings(ModuleInfo, ArgSchemas,
- TypeDecls, ArgSchemaStrings),
- list__map_foldl(
- (pred(ArgSchemaString::in, ArgSchemaDecl::out,
- Index::in, (Index + 1)::out) is det :-
- ArgPrefix = "__arg_",
- string__int_to_string(Index, ArgString),
- string__append_list(
- [":", ArgPrefix, ArgString, "=",
- ArgPrefix, ArgString, "(",
- ArgSchemaString, ") "],
- ArgSchemaDecl)
- ), ArgSchemaStrings, ArgSchemaDeclList, 1, _),
- rl_out__generate_proc_schema_2(1, Args, "", SchemaString0),
- list__condense([[TypeDecls | ArgSchemaDeclList], ["("],
- [SchemaString0, ")"]], SchemaStrings),
- string__append_list(SchemaStrings, SchemaString).
-
-:- pred rl_out__generate_proc_schema_2(int::in, list(T)::in,
- string::in, string::out) is det.
-
-rl_out__generate_proc_schema_2(_, [], SchemaList, SchemaList).
-rl_out__generate_proc_schema_2(ArgNo, [_ | Args], SchemaList0, SchemaList) :-
- ArgPrefix = "__arg_",
- ( Args = [] ->
- Comma = ""
- ;
- Comma = ","
- ),
- string__int_to_string(ArgNo, ArgString),
- string__append_list([SchemaList0, ":T", ArgPrefix, ArgString, Comma],
- SchemaList1),
- rl_out__generate_proc_schema_2(ArgNo + 1,
- Args, SchemaList1, SchemaList).
%-----------------------------------------------------------------------------%
--- /tmp/stayl/mercury/compiler/rl_relops.m Thu Apr 1 16:03:16 1999
+++ rl_relops.m Mon May 3 14:54:58 1999
@@ -96,7 +96,7 @@
:- implementation.
:- import_module code_aux, hlds_data, hlds_module, hlds_pred, mode_util.
-:- import_module tree, rl_key, globals, options.
+:- import_module tree, rl_key, globals, options, inst_match.
:- import_module int, map, require, set.
%-----------------------------------------------------------------------------%
@@ -143,11 +143,11 @@
{ goal_info_get_instmap_delta(GoalInfo, InstMapDelta) },
{ instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap) },
rl_info_get_module_info(ModuleInfo),
+ rl_info_get_inst_table(InstTable),
{ IsInput =
lambda([Var::in] is semidet, (
instmap__lookup_var(InstMap0, Var, Inst0),
- instmap__lookup_var(InstMap, Var, Inst),
- mode_is_input(ModuleInfo, (Inst0 -> Inst))
+ inst_is_bound(Inst0, InstMap0, InstTable, ModuleInfo)
)) },
{ list__filter(IsInput, NonLocalsList, InputNonLocalsList) },
{ set__sorted_list_to_set(InputNonLocalsList, InputNonLocals) },
@@ -434,10 +434,11 @@
rl_info_get_proc_info(ProcInfo),
{ proc_info_varset(ProcInfo, VarSet) },
{ proc_info_vartypes(ProcInfo, VarTypes) },
+ { proc_info_inst_table(ProcInfo, InstTable) },
{ rl_key__extract_indexing(Inputs, Goals,
ModuleInfo, VarTypes, Bounds) },
{ RLGoal = rl_goal(yes(PredProcId), VarSet, VarTypes,
- InstMap, Inputs, Outputs, Goals, Bounds) }.
+ InstMap, InstTable, Inputs, Outputs, Goals, Bounds) }.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
--- /tmp/stayl/mercury/compiler/rl_sort.m Mon Dec 7 10:45:44 1998
+++ rl_sort.m Mon May 3 14:54:58 1999
@@ -825,7 +825,7 @@
rl_sort__interpret_project(RLGoal, sort(SortSpec0) - Reqs,
sort(SortSpec) - Reqs) :-
- RLGoal = rl_goal(_, _, _, _, Inputs, Outputs, _, _),
+ RLGoal = rl_goal(_, _, _, _, _, Inputs, Outputs, _, _),
Inputs = one_input(InputArgs),
(
% A select.
@@ -1035,7 +1035,7 @@
rl_sort__find_useful_join_indexes(ModuleInfo, Indexes,
Goal, TupleNum, IndexRanges) :-
- Goal = rl_goal(_, _, VarTypes, _, Inputs, _, _, VarBounds),
+ Goal = rl_goal(_, _, VarTypes, _, _, Inputs, _, _, VarBounds),
( VarBounds = [] ->
IndexRanges = []
;
@@ -1137,7 +1137,7 @@
rl_sort__find_useful_project_indexes(ModuleInfo, Indexes, OutputRel - Goal,
proj_output(OutputRel, Goal, IndexRanges)) :-
- Goal = rl_goal(_, _, VarTypes, _, Inputs, _, _, VarBounds),
+ Goal = rl_goal(_, _, VarTypes, _, _, Inputs, _, _, VarBounds),
( VarBounds = [] ->
IndexRanges = []
;
--------------------------------------------------------------------------
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