[m-rev.] diff: remove non-LLDS-specific stuff from code_util.m
Zoltan Somogyi
zs at cs.mu.OZ.AU
Sat Mar 15 16:27:28 AEDT 2003
This diff just moves code around. There is no change in functionality,
but the diff removes some improper dependencies by other backends on LLDS
modules.
Zoltan.
compiler/code_util.m:
compiler/goal_form.m:
compiler/hlds_code_util.m:
Move functionality that is not part of the LLDS backend from
ll_backend__code_util to hlds__goal_form and to hlds__hlds_code_util.
Turn some predicates into functions.
compiler/*.m:
Conform to the changes above.
cvs diff: Diffing .
Index: add_heap_ops.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/add_heap_ops.m,v
retrieving revision 1.7
diff -u -b -r1.7 add_heap_ops.m
--- add_heap_ops.m 15 Mar 2003 03:08:42 -0000 1.7
+++ add_heap_ops.m 15 Mar 2003 03:56:47 -0000
@@ -41,12 +41,12 @@
:- import_module backend_libs__code_model.
:- import_module check_hlds__type_util.
+:- import_module hlds__goal_form.
:- import_module hlds__goal_util.
:- import_module hlds__hlds_data.
:- import_module hlds__hlds_goal.
:- import_module hlds__instmap.
:- import_module hlds__quantification.
-:- import_module ll_backend__code_util.
:- import_module parse_tree__inst.
:- import_module parse_tree__modules.
:- import_module parse_tree__prog_data.
@@ -124,7 +124,7 @@
%
(
{ CodeModel = model_non
- ; code_util__goal_may_allocate_heap(FirstDisjunct)
+ ; goal_may_allocate_heap(FirstDisjunct)
}
->
new_saved_hp_var(SavedHeapPointerVar),
@@ -180,7 +180,7 @@
% save the heap pointer so that we can
% restore it if the condition fails.
%
- ( { code_util__goal_may_allocate_heap(Cond0) } ->
+ ( { goal_may_allocate_heap(Cond0) } ->
new_saved_hp_var(SavedHeapPointerVar),
{ goal_info_get_context(GoalInfo, Context) },
gen_mark_hp(SavedHeapPointerVar, Context, MarkHeapPointerGoal),
@@ -269,7 +269,7 @@
%
(
{ MaybeSavedHeapPointerVar = no },
- { code_util__goal_may_allocate_heap(Goal) }
+ { goal_may_allocate_heap(Goal) }
->
% Generate code to save the heap pointer
new_saved_hp_var(SavedHeapPointerVar),
Index: bytecode_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/bytecode_gen.m,v
retrieving revision 1.71
diff -u -b -r1.71 bytecode_gen.m
--- bytecode_gen.m 15 Mar 2003 03:08:42 -0000 1.71
+++ bytecode_gen.m 15 Mar 2003 03:39:32 -0000
@@ -44,6 +44,7 @@
:- import_module check_hlds__type_util.
:- import_module hlds__error_util.
:- import_module hlds__goal_util.
+:- import_module hlds__hlds_code_util.
:- import_module hlds__hlds_data.
:- import_module hlds__hlds_goal.
:- import_module hlds__hlds_pred.
@@ -52,7 +53,6 @@
:- import_module libs__tree.
:- import_module ll_backend__arg_info.
:- import_module ll_backend__call_gen. % XXX for arg passing convention
-:- import_module ll_backend__code_util. % XXX for cons_id_to_tag
:- import_module parse_tree__prog_data.
:- import_module parse_tree__prog_out.
@@ -706,8 +706,7 @@
;
Functor = qualified(ModuleName, FunctorName)
),
- code_util__cons_id_to_tag(ConsId,
- Type, ModuleInfo, ConsTag),
+ ConsTag = cons_id_to_tag(ConsId, Type, ModuleInfo),
bytecode_gen__map_cons_tag(ConsTag, ByteConsTag),
ByteConsId = cons(ModuleName, FunctorName,
Arity, ByteConsTag)
Index: code_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.272
diff -u -b -r1.272 code_info.m
--- code_info.m 14 Mar 2003 08:10:05 -0000 1.272
+++ code_info.m 15 Mar 2003 03:41:02 -0000
@@ -49,6 +49,7 @@
:- import_module check_hlds__mode_util.
:- import_module check_hlds__type_util.
+:- import_module hlds__hlds_code_util.
:- import_module libs__options.
:- import_module libs__trace_params.
:- import_module libs__tree.
@@ -834,7 +835,7 @@
code_info__cons_id_to_tag(Var, ConsId, ConsTag) -->
code_info__variable_type(Var, Type),
code_info__get_module_info(ModuleInfo),
- { code_util__cons_id_to_tag(ConsId, Type, ModuleInfo, ConsTag) }.
+ { ConsTag = cons_id_to_tag(ConsId, Type, ModuleInfo) }.
%---------------------------------------------------------------------------%
Index: code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_util.m,v
retrieving revision 1.143
diff -u -b -r1.143 code_util.m
--- code_util.m 14 Mar 2003 08:10:05 -0000 1.143
+++ code_util.m 15 Mar 2003 03:36:53 -0000
@@ -19,12 +19,10 @@
:- import_module backend_libs__proc_label.
:- import_module backend_libs__rtti.
-:- import_module hlds__hlds_data.
:- import_module hlds__hlds_goal.
:- import_module hlds__hlds_module.
:- import_module hlds__hlds_pred.
:- import_module ll_backend__llds.
-:- import_module parse_tree__prog_data.
:- import_module list, std_util.
@@ -77,20 +75,6 @@
:- pred code_util__max_mentioned_reg(list(lval), int).
:- mode code_util__max_mentioned_reg(in, out) is det.
- % Determine whether a goal might allocate some heap space,
- % i.e. whether it contains any construction unifications
- % or predicate calls. BEWARE that this predicate is only
- % an approximation, used to decide whether or not to try to
- % reclaim the heap space; currently it fails even for some
- % goals which do allocate heap space, such as construction
- % of boxed constants.
-
-:- pred code_util__goal_may_allocate_heap(hlds_goal).
-:- mode code_util__goal_may_allocate_heap(in) is semidet.
-
-:- pred code_util__goal_list_may_allocate_heap(list(hlds_goal)).
-:- mode code_util__goal_list_may_allocate_heap(in) is semidet.
-
:- pred code_util__goal_may_alloc_temp_frame(hlds_goal).
:- mode code_util__goal_may_alloc_temp_frame(in) is semidet.
@@ -103,46 +87,6 @@
:- pred code_util__negate_the_test(list(instruction), list(instruction)).
:- mode code_util__negate_the_test(in, out) is det.
- % Find out how a function symbol (constructor) is represented
- % in the given type.
-
-:- pred code_util__cons_id_to_tag(cons_id, type, module_info, cons_tag).
-:- mode code_util__cons_id_to_tag(in, in, in, out) is det.
-
- % Succeed if execution of the given goal cannot encounter a context
- % that causes any variable to be flushed to its stack slot.
- % If such a goal needs a resume point, and that resume point cannot
- % be backtracked to once control leaves the goal, then the only entry
- % point we need for the resume point is the one with the resume
- % variables in their original locations.
-
-:- pred code_util__cannot_stack_flush(hlds_goal).
-:- mode code_util__cannot_stack_flush(in) is semidet.
-
- % Succeed if execution of the given goal cannot encounter a context
- % that causes any variable to be flushed to its stack slot or to a
- % register.
-
-:- pred code_util__cannot_flush(hlds_goal).
-:- mode code_util__cannot_flush(in) is semidet.
-
- % Succeed if the given goal cannot fail before encountering a context
- % that forces all variables to be flushed to their stack slots.
- % If such a goal needs a resume point, the only entry point we need
- % is the stack entry point.
-
-:- pred code_util__cannot_fail_before_stack_flush(hlds_goal).
-:- mode code_util__cannot_fail_before_stack_flush(in) is semidet.
-
- % code_util__count_recursive_calls(Goal, PredId, ProcId, Min, Max)
- % Given that we are in predicate PredId and procedure ProcId,
- % return the minimum and maximum number of recursive calls that
- % an execution of Goal may encounter.
-
-:- pred code_util__count_recursive_calls(hlds_goal, pred_id, proc_id,
- int, int).
-:- mode code_util__count_recursive_calls(in, in, in, out, out) is det.
-
% These predicates return the set of lvals referenced in an rval
% and an lval respectively. Lvals referenced indirectly through
% lvals of the form var(_) are not counted.
@@ -162,7 +106,6 @@
:- import_module backend_libs__builtin_ops.
:- import_module backend_libs__code_model.
-:- import_module check_hlds__type_util.
:- import_module hlds__special_pred.
:- import_module libs__globals.
:- import_module libs__options.
@@ -299,96 +242,6 @@
%-----------------------------------------------------------------------------%
-code_util__goal_may_allocate_heap(Goal) :-
- code_util__goal_may_allocate_heap(Goal, yes).
-
-code_util__goal_list_may_allocate_heap(Goals) :-
- code_util__goal_list_may_allocate_heap(Goals, yes).
-
-:- pred code_util__goal_may_allocate_heap(hlds_goal::in, bool::out) is det.
-
-code_util__goal_may_allocate_heap(Goal - _GoalInfo, May) :-
- code_util__goal_may_allocate_heap_2(Goal, May).
-
-:- pred code_util__goal_may_allocate_heap_2(hlds_goal_expr::in, bool::out)
- is det.
-
-code_util__goal_may_allocate_heap_2(generic_call(_, _, _, _), yes).
-code_util__goal_may_allocate_heap_2(call(_, _, _, Builtin, _, _), May) :-
- ( Builtin = inline_builtin ->
- May = no
- ;
- May = yes
- ).
-code_util__goal_may_allocate_heap_2(unify(_, _, _, Unification, _), May) :-
- ( Unification = construct(_,_,Args,_,_,_,_), Args = [_|_] ->
- May = yes
- ;
- May = no
- ).
- % We cannot safely say that a foreign code fragment does not
- % allocate memory without knowing all the #defined macros that
- % expand to incr_hp and variants thereof.
- % XXX although you could make it an attribute of the foreign code and
- % trust the programmer
-code_util__goal_may_allocate_heap_2(foreign_proc(_,_,_,_,_,_,_), yes).
-code_util__goal_may_allocate_heap_2(some(_Vars, _, Goal), May) :-
- code_util__goal_may_allocate_heap(Goal, May).
-code_util__goal_may_allocate_heap_2(not(Goal), May) :-
- code_util__goal_may_allocate_heap(Goal, May).
-code_util__goal_may_allocate_heap_2(conj(Goals), May) :-
- code_util__goal_list_may_allocate_heap(Goals, May).
-code_util__goal_may_allocate_heap_2(par_conj(_), yes).
-code_util__goal_may_allocate_heap_2(disj(Goals), May) :-
- code_util__goal_list_may_allocate_heap(Goals, May).
-code_util__goal_may_allocate_heap_2(switch(_Var, _Det, Cases), May) :-
- code_util__cases_may_allocate_heap(Cases, May).
-code_util__goal_may_allocate_heap_2(if_then_else(_Vars, C, T, E), May) :-
- ( code_util__goal_may_allocate_heap(C, yes) ->
- May = yes
- ; code_util__goal_may_allocate_heap(T, yes) ->
- May = yes
- ;
- code_util__goal_may_allocate_heap(E, May)
- ).
-code_util__goal_may_allocate_heap_2(shorthand(ShorthandGoal), May) :-
- code_util__goal_may_allocate_heap_2_shorthand(ShorthandGoal, May).
-
-:- pred code_util__goal_may_allocate_heap_2_shorthand(shorthand_goal_expr::in,
- bool::out) is det.
-
-code_util__goal_may_allocate_heap_2_shorthand(bi_implication(G1, G2), May) :-
- ( code_util__goal_may_allocate_heap(G1, yes) ->
- May = yes
- ;
- code_util__goal_may_allocate_heap(G2, May)
- ).
-
-
-
-:- pred code_util__goal_list_may_allocate_heap(list(hlds_goal)::in, bool::out)
- is det.
-
-code_util__goal_list_may_allocate_heap([], no).
-code_util__goal_list_may_allocate_heap([Goal | Goals], May) :-
- ( code_util__goal_may_allocate_heap(Goal, yes) ->
- May = yes
- ;
- code_util__goal_list_may_allocate_heap(Goals, May)
- ).
-
-:- pred code_util__cases_may_allocate_heap(list(case)::in, bool::out) is det.
-
-code_util__cases_may_allocate_heap([], no).
-code_util__cases_may_allocate_heap([case(_, Goal) | Cases], May) :-
- ( code_util__goal_may_allocate_heap(Goal, yes) ->
- May = yes
- ;
- code_util__cases_may_allocate_heap(Cases, May)
- ).
-
-%-----------------------------------------------------------------------------%
-
code_util__goal_may_alloc_temp_frame(Goal) :-
code_util__goal_may_alloc_temp_frame(Goal, yes).
@@ -527,273 +380,6 @@
;
code_util__negate_the_test(Instrs0, Instrs1),
Instrs = [Instr0 | Instrs1]
- ).
-
-%-----------------------------------------------------------------------------%
-
-code_util__cons_id_to_tag(int_const(X), _, _, int_constant(X)).
-code_util__cons_id_to_tag(float_const(X), _, _, float_constant(X)).
-code_util__cons_id_to_tag(string_const(X), _, _, string_constant(X)).
-code_util__cons_id_to_tag(code_addr_const(P,M), _, _, code_addr_constant(P,M)).
-code_util__cons_id_to_tag(pred_const(P,M,E), _, _, pred_closure_tag(P,M,E)).
-code_util__cons_id_to_tag(type_ctor_info_const(M,T,A), _, _,
- type_ctor_info_constant(M,T,A)).
-code_util__cons_id_to_tag(base_typeclass_info_const(M,C,_,N), _, _,
- base_typeclass_info_constant(M,C,N)).
-code_util__cons_id_to_tag(tabling_pointer_const(PredId,ProcId), _, _,
- tabling_pointer_constant(PredId,ProcId)).
-code_util__cons_id_to_tag(deep_profiling_proc_static(PPId), _, _,
- deep_profiling_proc_static_tag(PPId)).
-code_util__cons_id_to_tag(table_io_decl(PPId), _, _, table_io_decl_tag(PPId)).
-code_util__cons_id_to_tag(cons(Name, Arity), Type, ModuleInfo, Tag) :-
- (
- % handle the `character' type specially
- Type = term__functor(term__atom("character"), [], _),
- Name = unqualified(ConsName),
- string__char_to_string(Char, ConsName)
- ->
- char__to_int(Char, CharCode),
- Tag = int_constant(CharCode)
- ;
- % Tuples do not need a tag. Note that unary tuples are not
- % treated as no_tag types. There's no reason why they
- % couldn't be, it's just not worth the effort.
- type_is_tuple(Type, _)
- ->
- Tag = single_functor
- ;
- % Use the type to determine the type_ctor
- ( type_to_ctor_and_args(Type, TypeCtor0, _) ->
- TypeCtor = TypeCtor0
- ;
- % the type-checker should ensure that this never happens
- error("code_util__cons_id_to_tag: invalid type")
- ),
-
- % Given the type_ctor, lookup up the constructor tag
- % table for that type
- module_info_types(ModuleInfo, TypeTable),
- map__lookup(TypeTable, TypeCtor, TypeDefn),
- hlds_data__get_type_defn_body(TypeDefn, TypeBody),
- (
- TypeBody = du_type(_, ConsTable0, _, _, _, _)
- ->
- ConsTable = ConsTable0
- ;
- % this should never happen
- error(
- "code_util__cons_id_to_tag: type is not d.u. type?"
- )
- ),
- % Finally look up the cons_id in the table
- map__lookup(ConsTable, cons(Name, Arity), Tag)
- ).
-
-%-----------------------------------------------------------------------------%
-
-code_util__cannot_stack_flush(GoalExpr - _) :-
- code_util__cannot_stack_flush_2(GoalExpr).
-
-:- pred code_util__cannot_stack_flush_2(hlds_goal_expr).
-:- mode code_util__cannot_stack_flush_2(in) is semidet.
-
-code_util__cannot_stack_flush_2(unify(_, _, _, Unify, _)) :-
- Unify \= complicated_unify(_, _, _).
-code_util__cannot_stack_flush_2(call(_, _, _, BuiltinState, _, _)) :-
- BuiltinState = inline_builtin.
-code_util__cannot_stack_flush_2(conj(Goals)) :-
- code_util__cannot_stack_flush_goals(Goals).
-code_util__cannot_stack_flush_2(switch(_, _, Cases)) :-
- code_util__cannot_stack_flush_cases(Cases).
-code_util__cannot_stack_flush_2(not(unify(_, _, _, Unify, _) - _)) :-
- Unify \= complicated_unify(_, _, _).
-
-:- pred code_util__cannot_stack_flush_goals(list(hlds_goal)).
-:- mode code_util__cannot_stack_flush_goals(in) is semidet.
-
-code_util__cannot_stack_flush_goals([]).
-code_util__cannot_stack_flush_goals([Goal | Goals]) :-
- code_util__cannot_stack_flush(Goal),
- code_util__cannot_stack_flush_goals(Goals).
-
-:- pred code_util__cannot_stack_flush_cases(list(case)).
-:- mode code_util__cannot_stack_flush_cases(in) is semidet.
-
-code_util__cannot_stack_flush_cases([]).
-code_util__cannot_stack_flush_cases([case(_, Goal) | Cases]) :-
- code_util__cannot_stack_flush(Goal),
- code_util__cannot_stack_flush_cases(Cases).
-
-%-----------------------------------------------------------------------------%
-
-code_util__cannot_flush(GoalExpr - _) :-
- code_util__cannot_flush_2(GoalExpr).
-
-:- pred code_util__cannot_flush_2(hlds_goal_expr).
-:- mode code_util__cannot_flush_2(in) is semidet.
-
-code_util__cannot_flush_2(unify(_, _, _, Unify, _)) :-
- Unify \= complicated_unify(_, _, _).
-code_util__cannot_flush_2(call(_, _, _, BuiltinState, _, _)) :-
- BuiltinState = inline_builtin.
-code_util__cannot_flush_2(conj(Goals)) :-
- code_util__cannot_flush_goals(Goals).
-
-:- pred code_util__cannot_flush_goals(list(hlds_goal)).
-:- mode code_util__cannot_flush_goals(in) is semidet.
-
-code_util__cannot_flush_goals([]).
-code_util__cannot_flush_goals([Goal | Goals]) :-
- code_util__cannot_flush(Goal),
- code_util__cannot_flush_goals(Goals).
-
-%-----------------------------------------------------------------------------%
-
-code_util__cannot_fail_before_stack_flush(GoalExpr - GoalInfo) :-
- goal_info_get_determinism(GoalInfo, Detism),
- determinism_components(Detism, CanFail, _),
- ( CanFail = cannot_fail ->
- true
- ;
- code_util__cannot_fail_before_stack_flush_2(GoalExpr)
- ).
-
-:- pred code_util__cannot_fail_before_stack_flush_2(hlds_goal_expr).
-:- mode code_util__cannot_fail_before_stack_flush_2(in) is semidet.
-
-code_util__cannot_fail_before_stack_flush_2(conj(Goals)) :-
- code_util__cannot_fail_before_stack_flush_conj(Goals).
-
-:- pred code_util__cannot_fail_before_stack_flush_conj(list(hlds_goal)).
-:- mode code_util__cannot_fail_before_stack_flush_conj(in) is semidet.
-
-code_util__cannot_fail_before_stack_flush_conj([]).
-code_util__cannot_fail_before_stack_flush_conj([Goal | Goals]) :-
- Goal = GoalExpr - GoalInfo,
- (
- (
- GoalExpr = call(_, _, _, BuiltinState, _, _),
- BuiltinState \= inline_builtin
- ;
- GoalExpr = generic_call(_, _, _, _)
- )
- ->
- true
- ;
- goal_info_get_determinism(GoalInfo, Detism),
- determinism_components(Detism, cannot_fail, _)
- ->
- code_util__cannot_fail_before_stack_flush_conj(Goals)
- ;
- fail
- ).
-
-%-----------------------------------------------------------------------------%
-
-code_util__count_recursive_calls(Goal - _, PredId, ProcId, Min, Max) :-
- code_util__count_recursive_calls_2(Goal, PredId, ProcId, Min, Max).
-
-:- pred code_util__count_recursive_calls_2(hlds_goal_expr, pred_id, proc_id,
- int, int).
-:- mode code_util__count_recursive_calls_2(in, in, in, out, out) is det.
-
-code_util__count_recursive_calls_2(not(Goal), PredId, ProcId, Min, Max) :-
- code_util__count_recursive_calls(Goal, PredId, ProcId, Min, Max).
-code_util__count_recursive_calls_2(some(_, _, Goal),
- PredId, ProcId, Min, Max) :-
- code_util__count_recursive_calls(Goal, PredId, ProcId, Min, Max).
-code_util__count_recursive_calls_2(unify(_, _, _, _, _), _, _, 0, 0).
-code_util__count_recursive_calls_2(generic_call(_, _, _, _), _, _,
- 0, 0).
-code_util__count_recursive_calls_2(foreign_proc(_, _, _, _, _, _, _),
- _, _, 0, 0).
-code_util__count_recursive_calls_2(call(CallPredId, CallProcId, _, _, _, _),
- PredId, ProcId, Count, Count) :-
- (
- PredId = CallPredId,
- ProcId = CallProcId
- ->
- Count = 1
- ;
- Count = 0
- ).
-code_util__count_recursive_calls_2(conj(Goals), PredId, ProcId, Min, Max) :-
- code_util__count_recursive_calls_conj(Goals, PredId, ProcId, 0, 0,
- Min, Max).
-code_util__count_recursive_calls_2(par_conj(Goals), PredId, ProcId,
- Min, Max) :-
- code_util__count_recursive_calls_conj(Goals, PredId, ProcId, 0, 0,
- Min, Max).
-code_util__count_recursive_calls_2(disj(Goals), PredId, ProcId, Min, Max) :-
- code_util__count_recursive_calls_disj(Goals, PredId, ProcId, Min, Max).
-code_util__count_recursive_calls_2(switch(_, _, Cases), PredId, ProcId,
- Min, Max) :-
- code_util__count_recursive_calls_cases(Cases, PredId, ProcId, Min, Max).
-code_util__count_recursive_calls_2(if_then_else(_, Cond, Then, Else),
- PredId, ProcId, Min, Max) :-
- code_util__count_recursive_calls(Cond, PredId, ProcId, CMin, CMax),
- code_util__count_recursive_calls(Then, PredId, ProcId, TMin, TMax),
- code_util__count_recursive_calls(Else, PredId, ProcId, EMin, EMax),
- CTMin is CMin + TMin,
- CTMax is CMax + TMax,
- int__min(CTMin, EMin, Min),
- int__max(CTMax, EMax, Max).
-code_util__count_recursive_calls_2(shorthand(_),
- _, _, _, _) :-
- % these should have been expanded out by now
- error("code_util__count_recursive_calls_2: unexpected shorthand").
-
-:- pred code_util__count_recursive_calls_conj(list(hlds_goal),
- pred_id, proc_id, int, int, int, int).
-:- mode code_util__count_recursive_calls_conj(in, in, in, in, in, out, out)
- is det.
-
-code_util__count_recursive_calls_conj([], _, _, Min, Max, Min, Max).
-code_util__count_recursive_calls_conj([Goal | Goals], PredId, ProcId,
- Min0, Max0, Min, Max) :-
- code_util__count_recursive_calls(Goal, PredId, ProcId, Min1, Max1),
- Min2 is Min0 + Min1,
- Max2 is Max0 + Max1,
- code_util__count_recursive_calls_conj(Goals, PredId, ProcId,
- Min2, Max2, Min, Max).
-
-:- pred code_util__count_recursive_calls_disj(list(hlds_goal),
- pred_id, proc_id, int, int).
-:- mode code_util__count_recursive_calls_disj(in, in, in, out, out) is det.
-
-code_util__count_recursive_calls_disj([], _, _, 0, 0).
-code_util__count_recursive_calls_disj([Goal | Goals], PredId, ProcId,
- Min, Max) :-
- ( Goals = [] ->
- code_util__count_recursive_calls(Goal, PredId, ProcId,
- Min, Max)
- ;
- code_util__count_recursive_calls(Goal, PredId, ProcId,
- Min0, Max0),
- code_util__count_recursive_calls_disj(Goals, PredId, ProcId,
- Min1, Max1),
- int__min(Min0, Min1, Min),
- int__max(Max0, Max1, Max)
- ).
-
-:- pred code_util__count_recursive_calls_cases(list(case),
- pred_id, proc_id, int, int).
-:- mode code_util__count_recursive_calls_cases(in, in, in, out, out) is det.
-
-code_util__count_recursive_calls_cases([], _, _, _, _) :-
- error("empty cases in code_util__count_recursive_calls_cases").
-code_util__count_recursive_calls_cases([case(_, Goal) | Cases], PredId, ProcId,
- Min, Max) :-
- ( Cases = [] ->
- code_util__count_recursive_calls(Goal, PredId, ProcId,
- Min, Max)
- ;
- code_util__count_recursive_calls(Goal, PredId, ProcId,
- Min0, Max0),
- code_util__count_recursive_calls_cases(Cases, PredId, ProcId,
- Min1, Max1),
- int__min(Min0, Min1, Min),
- int__max(Max0, Max1, Max)
).
%-----------------------------------------------------------------------------%
Index: disj_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/disj_gen.m,v
retrieving revision 1.77
diff -u -b -r1.77 disj_gen.m
--- disj_gen.m 15 Mar 2003 03:08:44 -0000 1.77
+++ disj_gen.m 15 Mar 2003 03:51:14 -0000
@@ -32,13 +32,13 @@
:- implementation.
+:- import_module hlds__goal_form.
:- import_module hlds__hlds_data.
:- import_module hlds__hlds_llds.
:- import_module libs__globals.
:- import_module libs__options.
:- import_module libs__tree.
:- import_module ll_backend__code_gen.
-:- import_module ll_backend__code_util.
:- import_module ll_backend__trace.
:- import_module parse_tree__prog_data.
@@ -206,7 +206,7 @@
% saved previously.
(
{ ReclaimHeap = yes },
- { code_util__goal_may_allocate_heap(Goal) },
+ { goal_may_allocate_heap(Goal) },
{ MaybeHpSlot0 = no }
->
code_info__save_hp(SaveHpCode, HpSlot),
Index: goal_form.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/goal_form.m,v
retrieving revision 1.4
diff -u -b -r1.4 goal_form.m
--- goal_form.m 15 Mar 2003 03:08:46 -0000 1.4
+++ goal_form.m 15 Mar 2003 03:52:23 -0000
@@ -18,6 +18,7 @@
:- import_module hlds__hlds_goal.
:- import_module hlds__hlds_module.
+:- import_module hlds__hlds_pred.
:- import_module list.
@@ -56,14 +57,55 @@
:- pred goal_is_flat(hlds_goal).
:- mode goal_is_flat(in) is semidet.
+ % Determine whether a goal might allocate some heap space,
+ % i.e. whether it contains any construction unifications
+ % or predicate calls. BEWARE that this predicate is only
+ % an approximation, used to decide whether or not to try to
+ % reclaim the heap space; currently it fails even for some
+ % goals which do allocate heap space, such as construction
+ % of boxed constants.
+
+:- pred goal_may_allocate_heap(hlds_goal::in) is semidet.
+:- pred goal_list_may_allocate_heap(list(hlds_goal)::in) is semidet.
+
+ % Succeed if execution of the given goal cannot encounter a context
+ % that causes any variable to be flushed to its stack slot.
+ % If such a goal needs a resume point, and that resume point cannot
+ % be backtracked to once control leaves the goal, then the only entry
+ % point we need for the resume point is the one with the resume
+ % variables in their original locations.
+
+:- pred cannot_stack_flush(hlds_goal::in) is semidet.
+
+ % Succeed if execution of the given goal cannot encounter a context
+ % that causes any variable to be flushed to its stack slot or to a
+ % register.
+
+:- pred cannot_flush(hlds_goal::in) is semidet.
+
+ % Succeed if the given goal cannot fail before encountering a context
+ % that forces all variables to be flushed to their stack slots.
+ % If such a goal needs a resume point, the only entry point we need
+ % is the stack entry point.
+
+:- pred cannot_fail_before_stack_flush(hlds_goal::in) is semidet.
+
+ % count_recursive_calls(Goal, PredId, ProcId, Min, Max)
+ % Given that we are in predicate PredId and procedure ProcId,
+ % return the minimum and maximum number of recursive calls that
+ % an execution of Goal may encounter.
+
+:- pred count_recursive_calls(hlds_goal::in, pred_id::in, proc_id::in,
+ int::out, int::out) is det.
+
%---------------------------------------------------------------------------%
:- implementation.
-:- import_module hlds__hlds_pred.
+:- import_module hlds__hlds_data.
:- import_module transform_hlds__term_util.
-:- import_module std_util.
+:- import_module bool, int, std_util, require.
%-----------------------------------------------------------------------------%
@@ -200,5 +242,274 @@
goal_is_flat_list([Goal|Goals]) :-
goal_is_flat(Goal),
goal_is_flat_list(Goals).
+
+%-----------------------------------------------------------------------------%
+
+goal_may_allocate_heap(Goal) :-
+ goal_may_allocate_heap(Goal, yes).
+
+goal_list_may_allocate_heap(Goals) :-
+ goal_list_may_allocate_heap(Goals, yes).
+
+:- pred goal_may_allocate_heap(hlds_goal::in, bool::out) is det.
+
+goal_may_allocate_heap(Goal - _GoalInfo, May) :-
+ goal_may_allocate_heap_2(Goal, May).
+
+:- pred goal_may_allocate_heap_2(hlds_goal_expr::in, bool::out) is det.
+
+goal_may_allocate_heap_2(generic_call(_, _, _, _), yes).
+goal_may_allocate_heap_2(call(_, _, _, Builtin, _, _), May) :-
+ ( Builtin = inline_builtin ->
+ May = no
+ ;
+ May = yes
+ ).
+goal_may_allocate_heap_2(unify(_, _, _, Unification, _), May) :-
+ ( Unification = construct(_,_,Args,_,_,_,_), Args = [_|_] ->
+ May = yes
+ ;
+ May = no
+ ).
+ % We cannot safely say that a foreign code fragment does not
+ % allocate memory without knowing all the #defined macros that
+ % expand to incr_hp and variants thereof.
+ % XXX although you could make it an attribute of the foreign code and
+ % trust the programmer
+goal_may_allocate_heap_2(foreign_proc(_,_,_,_,_,_,_), yes).
+goal_may_allocate_heap_2(some(_Vars, _, Goal), May) :-
+ goal_may_allocate_heap(Goal, May).
+goal_may_allocate_heap_2(not(Goal), May) :-
+ goal_may_allocate_heap(Goal, May).
+goal_may_allocate_heap_2(conj(Goals), May) :-
+ goal_list_may_allocate_heap(Goals, May).
+goal_may_allocate_heap_2(par_conj(_), yes).
+goal_may_allocate_heap_2(disj(Goals), May) :-
+ goal_list_may_allocate_heap(Goals, May).
+goal_may_allocate_heap_2(switch(_Var, _Det, Cases), May) :-
+ cases_may_allocate_heap(Cases, May).
+goal_may_allocate_heap_2(if_then_else(_Vars, C, T, E), May) :-
+ ( goal_may_allocate_heap(C, yes) ->
+ May = yes
+ ; goal_may_allocate_heap(T, yes) ->
+ May = yes
+ ;
+ goal_may_allocate_heap(E, May)
+ ).
+goal_may_allocate_heap_2(shorthand(ShorthandGoal), May) :-
+ goal_may_allocate_heap_2_shorthand(ShorthandGoal, May).
+
+:- pred goal_may_allocate_heap_2_shorthand(shorthand_goal_expr::in, bool::out)
+ is det.
+
+goal_may_allocate_heap_2_shorthand(bi_implication(G1, G2), May) :-
+ ( goal_may_allocate_heap(G1, yes) ->
+ May = yes
+ ;
+ goal_may_allocate_heap(G2, May)
+ ).
+
+:- pred goal_list_may_allocate_heap(list(hlds_goal)::in, bool::out) is det.
+
+goal_list_may_allocate_heap([], no).
+goal_list_may_allocate_heap([Goal | Goals], May) :-
+ ( goal_may_allocate_heap(Goal, yes) ->
+ May = yes
+ ;
+ goal_list_may_allocate_heap(Goals, May)
+ ).
+
+:- pred cases_may_allocate_heap(list(case)::in, bool::out) is det.
+
+cases_may_allocate_heap([], no).
+cases_may_allocate_heap([case(_, Goal) | Cases], May) :-
+ ( goal_may_allocate_heap(Goal, yes) ->
+ May = yes
+ ;
+ cases_may_allocate_heap(Cases, May)
+ ).
+
+%-----------------------------------------------------------------------------%
+
+cannot_stack_flush(GoalExpr - _) :-
+ cannot_stack_flush_2(GoalExpr).
+
+:- pred cannot_stack_flush_2(hlds_goal_expr::in) is semidet.
+
+cannot_stack_flush_2(unify(_, _, _, Unify, _)) :-
+ Unify \= complicated_unify(_, _, _).
+cannot_stack_flush_2(call(_, _, _, BuiltinState, _, _)) :-
+ BuiltinState = inline_builtin.
+cannot_stack_flush_2(conj(Goals)) :-
+ cannot_stack_flush_goals(Goals).
+cannot_stack_flush_2(switch(_, _, Cases)) :-
+ cannot_stack_flush_cases(Cases).
+cannot_stack_flush_2(not(unify(_, _, _, Unify, _) - _)) :-
+ Unify \= complicated_unify(_, _, _).
+
+:- pred cannot_stack_flush_goals(list(hlds_goal)::in) is semidet.
+
+cannot_stack_flush_goals([]).
+cannot_stack_flush_goals([Goal | Goals]) :-
+ cannot_stack_flush(Goal),
+ cannot_stack_flush_goals(Goals).
+
+:- pred cannot_stack_flush_cases(list(case)::in) is semidet.
+
+cannot_stack_flush_cases([]).
+cannot_stack_flush_cases([case(_, Goal) | Cases]) :-
+ cannot_stack_flush(Goal),
+ cannot_stack_flush_cases(Cases).
+
+%-----------------------------------------------------------------------------%
+
+cannot_flush(GoalExpr - _) :-
+ cannot_flush_2(GoalExpr).
+
+:- pred cannot_flush_2(hlds_goal_expr::in) is semidet.
+
+cannot_flush_2(unify(_, _, _, Unify, _)) :-
+ Unify \= complicated_unify(_, _, _).
+cannot_flush_2(call(_, _, _, BuiltinState, _, _)) :-
+ BuiltinState = inline_builtin.
+cannot_flush_2(conj(Goals)) :-
+ cannot_flush_goals(Goals).
+
+:- pred cannot_flush_goals(list(hlds_goal)::in) is semidet.
+
+cannot_flush_goals([]).
+cannot_flush_goals([Goal | Goals]) :-
+ cannot_flush(Goal),
+ cannot_flush_goals(Goals).
+
+%-----------------------------------------------------------------------------%
+
+cannot_fail_before_stack_flush(GoalExpr - GoalInfo) :-
+ goal_info_get_determinism(GoalInfo, Detism),
+ determinism_components(Detism, CanFail, _),
+ ( CanFail = cannot_fail ->
+ true
+ ;
+ cannot_fail_before_stack_flush_2(GoalExpr)
+ ).
+
+:- pred cannot_fail_before_stack_flush_2(hlds_goal_expr::in) is semidet.
+
+cannot_fail_before_stack_flush_2(conj(Goals)) :-
+ cannot_fail_before_stack_flush_conj(Goals).
+
+:- pred cannot_fail_before_stack_flush_conj(list(hlds_goal)::in) is semidet.
+
+cannot_fail_before_stack_flush_conj([]).
+cannot_fail_before_stack_flush_conj([Goal | Goals]) :-
+ Goal = GoalExpr - GoalInfo,
+ (
+ (
+ GoalExpr = call(_, _, _, BuiltinState, _, _),
+ BuiltinState \= inline_builtin
+ ;
+ GoalExpr = generic_call(_, _, _, _)
+ )
+ ->
+ true
+ ;
+ goal_info_get_determinism(GoalInfo, Detism),
+ determinism_components(Detism, cannot_fail, _)
+ ->
+ cannot_fail_before_stack_flush_conj(Goals)
+ ;
+ fail
+ ).
+
+%-----------------------------------------------------------------------------%
+
+count_recursive_calls(Goal - _, PredId, ProcId, Min, Max) :-
+ count_recursive_calls_2(Goal, PredId, ProcId, Min, Max).
+
+:- pred count_recursive_calls_2(hlds_goal_expr::in, pred_id::in, proc_id::in,
+ int::out, int::out) is det.
+
+count_recursive_calls_2(not(Goal), PredId, ProcId, Min, Max) :-
+ count_recursive_calls(Goal, PredId, ProcId, Min, Max).
+count_recursive_calls_2(some(_, _, Goal), PredId, ProcId, Min, Max) :-
+ count_recursive_calls(Goal, PredId, ProcId, Min, Max).
+count_recursive_calls_2(unify(_, _, _, _, _), _, _, 0, 0).
+count_recursive_calls_2(generic_call(_, _, _, _), _, _, 0, 0).
+count_recursive_calls_2(foreign_proc(_, _, _, _, _, _, _), _, _, 0, 0).
+count_recursive_calls_2(call(CallPredId, CallProcId, _, _, _, _),
+ PredId, ProcId, Count, Count) :-
+ (
+ PredId = CallPredId,
+ ProcId = CallProcId
+ ->
+ Count = 1
+ ;
+ Count = 0
+ ).
+count_recursive_calls_2(conj(Goals), PredId, ProcId, Min, Max) :-
+ count_recursive_calls_conj(Goals, PredId, ProcId, 0, 0, Min, Max).
+count_recursive_calls_2(par_conj(Goals), PredId, ProcId, Min, Max) :-
+ count_recursive_calls_conj(Goals, PredId, ProcId, 0, 0, Min, Max).
+count_recursive_calls_2(disj(Goals), PredId, ProcId, Min, Max) :-
+ count_recursive_calls_disj(Goals, PredId, ProcId, Min, Max).
+count_recursive_calls_2(switch(_, _, Cases), PredId, ProcId, Min, Max) :-
+ count_recursive_calls_cases(Cases, PredId, ProcId, Min, Max).
+count_recursive_calls_2(if_then_else(_, Cond, Then, Else), PredId, ProcId,
+ Min, Max) :-
+ count_recursive_calls(Cond, PredId, ProcId, CMin, CMax),
+ count_recursive_calls(Then, PredId, ProcId, TMin, TMax),
+ count_recursive_calls(Else, PredId, ProcId, EMin, EMax),
+ CTMin = CMin + TMin,
+ CTMax = CMax + TMax,
+ int__min(CTMin, EMin, Min),
+ int__max(CTMax, EMax, Max).
+count_recursive_calls_2(shorthand(_), _, _, _, _) :-
+ % these should have been expanded out by now
+ error("count_recursive_calls_2: unexpected shorthand").
+
+:- pred count_recursive_calls_conj(list(hlds_goal)::in,
+ pred_id::in, proc_id::in, int::in, int::in, int::out, int::out) is det.
+
+count_recursive_calls_conj([], _, _, Min, Max, Min, Max).
+count_recursive_calls_conj([Goal | Goals], PredId, ProcId, Min0, Max0,
+ Min, Max) :-
+ count_recursive_calls(Goal, PredId, ProcId, Min1, Max1),
+ Min2 = Min0 + Min1,
+ Max2 = Max0 + Max1,
+ count_recursive_calls_conj(Goals, PredId, ProcId,
+ Min2, Max2, Min, Max).
+
+:- pred count_recursive_calls_disj(list(hlds_goal)::in,
+ pred_id::in, proc_id::in, int::out, int::out) is det.
+
+count_recursive_calls_disj([], _, _, 0, 0).
+count_recursive_calls_disj([Goal | Goals], PredId, ProcId, Min, Max) :-
+ ( Goals = [] ->
+ count_recursive_calls(Goal, PredId, ProcId, Min, Max)
+ ;
+ count_recursive_calls(Goal, PredId, ProcId, Min0, Max0),
+ count_recursive_calls_disj(Goals, PredId, ProcId, Min1, Max1),
+ int__min(Min0, Min1, Min),
+ int__max(Max0, Max1, Max)
+ ).
+
+:- pred count_recursive_calls_cases(list(case)::in, pred_id::in, proc_id::in,
+ int::out, int::out) is det.
+
+count_recursive_calls_cases([], _, _, _, _) :-
+ error("empty cases in count_recursive_calls_cases").
+count_recursive_calls_cases([case(_, Goal) | Cases], PredId, ProcId,
+ Min, Max) :-
+ ( Cases = [] ->
+ count_recursive_calls(Goal, PredId, ProcId,
+ Min, Max)
+ ;
+ count_recursive_calls(Goal, PredId, ProcId,
+ Min0, Max0),
+ count_recursive_calls_cases(Cases, PredId, ProcId,
+ Min1, Max1),
+ int__min(Min0, Min1, Min),
+ int__max(Max0, Max1, Max)
+ ).
%-----------------------------------------------------------------------------%
Index: hlds_code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_code_util.m,v
retrieving revision 1.3
diff -u -b -r1.3 hlds_code_util.m
--- hlds_code_util.m 15 Mar 2003 03:08:48 -0000 1.3
+++ hlds_code_util.m 15 Mar 2003 03:48:33 -0000
@@ -16,21 +16,29 @@
:- interface.
+:- import_module hlds__hlds_data.
:- import_module hlds__hlds_module.
-
-% XXX some of the stuff from code_util.m should be moved here.
+:- import_module parse_tree__prog_data.
:- type hlds_code_util ---> suppress_warning_about_nothing_exported.
% Are equivalence types fully expanded on this backend?
:- pred are_equivalence_types_expanded(module_info::in) is semidet.
+ % Find out how a function symbol (constructor) is represented
+ % in the given type.
+
+:- func cons_id_to_tag(cons_id, type, module_info) = cons_tag.
+
:- implementation.
+:- import_module check_hlds__type_util.
:- import_module libs__globals.
:- import_module libs__options.
-:- import_module bool.
+:- import_module bool, char, string, require, list, map, std_util, term.
+
+%-----------------------------------------------------------------------------%
are_equivalence_types_expanded(ModuleInfo) :-
module_info_globals(ModuleInfo, Globals),
@@ -38,3 +46,62 @@
HighLevelData = yes,
globals__get_target(Globals, Target),
( Target = il ; Target = java).
+
+%-----------------------------------------------------------------------------%
+
+cons_id_to_tag(int_const(X), _, _) = int_constant(X).
+cons_id_to_tag(float_const(X), _, _) = float_constant(X).
+cons_id_to_tag(string_const(X), _, _) = string_constant(X).
+cons_id_to_tag(code_addr_const(P,M), _, _) = code_addr_constant(P,M).
+cons_id_to_tag(pred_const(P,M,E), _, _) = pred_closure_tag(P,M,E).
+cons_id_to_tag(type_ctor_info_const(M,T,A), _, _) =
+ type_ctor_info_constant(M,T,A).
+cons_id_to_tag(base_typeclass_info_const(M,C,_,N), _, _) =
+ base_typeclass_info_constant(M,C,N).
+cons_id_to_tag(tabling_pointer_const(PredId,ProcId), _, _) =
+ tabling_pointer_constant(PredId,ProcId).
+cons_id_to_tag(deep_profiling_proc_static(PPId), _, _) =
+ deep_profiling_proc_static_tag(PPId).
+cons_id_to_tag(table_io_decl(PPId), _, _) = table_io_decl_tag(PPId).
+cons_id_to_tag(cons(Name, Arity), Type, ModuleInfo) = Tag :-
+ (
+ % handle the `character' type specially
+ Type = term__functor(term__atom("character"), [], _),
+ Name = unqualified(ConsName),
+ string__char_to_string(Char, ConsName)
+ ->
+ char__to_int(Char, CharCode),
+ Tag = int_constant(CharCode)
+ ;
+ % Tuples do not need a tag. Note that unary tuples are not
+ % treated as no_tag types. There's no reason why they
+ % couldn't be, it's just not worth the effort.
+ type_is_tuple(Type, _)
+ ->
+ Tag = single_functor
+ ;
+ % Use the type to determine the type_ctor
+ ( type_to_ctor_and_args(Type, TypeCtor0, _) ->
+ TypeCtor = TypeCtor0
+ ;
+ % the type-checker should ensure that this never happens
+ error("cons_id_to_tag: invalid type")
+ ),
+ % Given the type_ctor, lookup up the constructor tag
+ % table for that type
+ module_info_types(ModuleInfo, TypeTable),
+ map__lookup(TypeTable, TypeCtor, TypeDefn),
+ hlds_data__get_type_defn_body(TypeDefn, TypeBody),
+ (
+ TypeBody = du_type(_, ConsTable0, _, _, _, _)
+ ->
+ ConsTable = ConsTable0
+ ;
+ % this should never happen
+ error("cons_id_to_tag: type is not d.u. type?")
+ ),
+ % Finally look up the cons_id in the table
+ map__lookup(ConsTable, cons(Name, Arity), Tag)
+ ).
+
+%-----------------------------------------------------------------------------%
Index: ite_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ite_gen.m,v
retrieving revision 1.69
diff -u -b -r1.69 ite_gen.m
--- ite_gen.m 15 Mar 2003 03:08:54 -0000 1.69
+++ ite_gen.m 15 Mar 2003 03:53:34 -0000
@@ -36,13 +36,13 @@
:- implementation.
:- import_module backend_libs__builtin_ops.
+:- import_module hlds__goal_form.
:- import_module hlds__hlds_llds.
:- import_module hlds__instmap.
:- import_module libs__globals.
:- import_module libs__options.
:- import_module libs__tree.
:- import_module ll_backend__code_gen.
-:- import_module ll_backend__code_util.
:- import_module ll_backend__trace.
:- import_module parse_tree__prog_data.
@@ -90,7 +90,7 @@
{
globals__lookup_bool_option(Globals,
reclaim_heap_on_semidet_failure, yes),
- code_util__goal_may_allocate_heap(CondGoal)
+ goal_may_allocate_heap(CondGoal)
->
ReclaimHeap = yes
;
@@ -287,7 +287,7 @@
{
globals__lookup_bool_option(Globals,
reclaim_heap_on_semidet_failure, yes),
- code_util__goal_may_allocate_heap(Goal)
+ goal_may_allocate_heap(Goal)
->
ReclaimHeap = yes
;
Index: liveness.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/liveness.m,v
retrieving revision 1.123
diff -u -b -r1.123 liveness.m
--- liveness.m 15 Mar 2003 03:08:54 -0000 1.123
+++ liveness.m 15 Mar 2003 03:55:15 -0000
@@ -185,6 +185,7 @@
% HLDS modules
:- import_module check_hlds__mode_util.
:- import_module check_hlds__polymorphism.
+:- import_module hlds__goal_form.
:- import_module hlds__hlds_data.
:- import_module hlds__hlds_goal.
:- import_module hlds__hlds_llds.
@@ -195,7 +196,6 @@
% LLDS modules
:- import_module ll_backend__arg_info.
-:- import_module ll_backend__code_util.
:- import_module ll_backend__llds.
:- import_module ll_backend__trace.
@@ -1304,7 +1304,7 @@
% By minimizing the number of labels we use, we also minimize
% the amount of data movement code we emit between such labels.
(
- code_util__cannot_stack_flush(Cond1),
+ cannot_stack_flush(Cond1),
goal_info_get_code_model(GoalInfo0, CodeModel),
CodeModel \= model_non
->
@@ -1318,7 +1318,7 @@
% commits, which is why we choose to use stack_only here.
CondResumeLocs = stack_only
;
- code_util__cannot_fail_before_stack_flush(Cond1)
+ cannot_fail_before_stack_flush(Cond1)
->
CondResumeLocs = stack_only
;
@@ -1352,9 +1352,9 @@
% Figure out which entry labels we need at the resumption point.
% By minimizing the number of labels we use, we also minimize
% the amount of data movement code we emit between such labels.
- ( code_util__cannot_stack_flush(Goal1) ->
+ ( cannot_stack_flush(Goal1) ->
ResumeLocs = orig_only
- ; code_util__cannot_fail_before_stack_flush(Goal1) ->
+ ; cannot_fail_before_stack_flush(Goal1) ->
ResumeLocs = stack_only
;
ResumeLocs = stack_and_orig
@@ -1483,11 +1483,11 @@
% the amount of data movement code we emit between such labels.
(
MayUseOrigOnly = yes,
- code_util__cannot_stack_flush(Goal1)
+ cannot_stack_flush(Goal1)
->
ResumeLocs = orig_only
;
- code_util__cannot_fail_before_stack_flush(Goal1)
+ cannot_fail_before_stack_flush(Goal1)
->
ResumeLocs = stack_only
;
Index: ml_unify_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_unify_gen.m,v
retrieving revision 1.63
diff -u -b -r1.63 ml_unify_gen.m
--- ml_unify_gen.m 15 Mar 2003 03:09:00 -0000 1.63
+++ ml_unify_gen.m 15 Mar 2003 03:58:16 -0000
@@ -91,6 +91,7 @@
:- import_module check_hlds__mode_util.
:- import_module check_hlds__type_util.
:- import_module hlds__error_util.
+:- import_module hlds__hlds_code_util.
:- import_module hlds__hlds_out.
:- import_module hlds__hlds_pred.
:- import_module libs__globals.
@@ -102,10 +103,6 @@
:- import_module ml_backend__ml_util.
:- import_module parse_tree__prog_util.
-% XXX The following modules depend on the LLDS,
-% so ideally they should not be used here.
-:- import_module ll_backend__code_util. % needed for `cons_id_to_tag'.
-
:- import_module int, string, map, require, term, varset.
:- import_module assoc_list, set.
@@ -540,7 +537,7 @@
ml_cons_id_to_tag(ConsId, Type, Tag) -->
=(Info),
{ ml_gen_info_get_module_info(Info, ModuleInfo) },
- { code_util__cons_id_to_tag(ConsId, Type, ModuleInfo, Tag) }.
+ { Tag = cons_id_to_tag(ConsId, Type, ModuleInfo) }.
% generate code to construct a new object
:- pred ml_gen_compound(cons_tag, cons_id, prog_var, prog_vars,
Index: simplify.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.114
diff -u -b -r1.114 simplify.m
--- simplify.m 15 Mar 2003 03:09:10 -0000 1.114
+++ simplify.m 15 Mar 2003 03:44:20 -0000
@@ -2495,7 +2495,7 @@
simplify_info_maybe_clear_structs(BeforeAfter, Goal, Info0, Info) :-
(
- ( code_util__cannot_flush(Goal)
+ ( cannot_flush(Goal)
; simplify_do_more_common(Info0)
)
->
Index: switch_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/switch_gen.m,v
retrieving revision 1.80
diff -u -b -r1.80 switch_gen.m
--- switch_gen.m 15 Mar 2003 03:09:11 -0000 1.80
+++ switch_gen.m 15 Mar 2003 03:55:42 -0000
@@ -65,13 +65,13 @@
:- import_module backend_libs__switch_util.
:- import_module check_hlds__type_util.
+:- import_module hlds__goal_form.
:- import_module hlds__hlds_llds.
:- import_module libs__globals.
:- import_module libs__options.
:- import_module libs__tree.
:- import_module ll_backend__code_aux.
:- import_module ll_backend__code_gen.
-:- import_module ll_backend__code_util.
:- import_module ll_backend__dense_switch.
:- import_module ll_backend__lookup_switch.
:- import_module ll_backend__string_switch.
@@ -253,10 +253,8 @@
->
code_info__get_pred_id(PredId),
code_info__get_proc_id(ProcId),
- { code_util__count_recursive_calls(Goal1, PredId, ProcId,
- Min1, Max1) },
- { code_util__count_recursive_calls(Goal2, PredId, ProcId,
- Min2, Max2) },
+ { count_recursive_calls(Goal1, PredId, ProcId, Min1, Max1) },
+ { count_recursive_calls(Goal2, PredId, ProcId, Min2, Max2) },
{
Max1 = 0, % Goal1 is a base case
Min2 = 1 % Goal2 is probably singly recursive
cvs diff: Diffing notes
--------------------------------------------------------------------------
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