diff --git a/compiler/arg_info.m b/compiler/arg_info.m index a27740df6..f0b7b4dbb 100644 --- a/compiler/arg_info.m +++ b/compiler/arg_info.m @@ -33,7 +33,6 @@ :- import_module hlds.hlds_markers. :- import_module hlds.hlds_module. :- import_module hlds.hlds_proc. -:- import_module hlds.pred_info_types. :- import_module parse_tree. :- import_module parse_tree.prog_data. :- import_module parse_tree.var_table. diff --git a/compiler/call_gen.m b/compiler/call_gen.m index 5ec49e72f..05efffdab 100644 --- a/compiler/call_gen.m +++ b/compiler/call_gen.m @@ -21,7 +21,7 @@ :- import_module hlds. :- import_module hlds.code_model. :- import_module hlds.hlds_goal. -:- import_module hlds.pred_info_types. +:- import_module hlds.hlds_llds. :- import_module hlds.pred_proc_id. :- import_module libs. :- import_module libs.globals. @@ -76,7 +76,6 @@ :- import_module backend_libs.builtin_ops. :- import_module hlds.arg_info. :- import_module hlds.hlds_class. -:- import_module hlds.hlds_llds. :- import_module hlds.hlds_markers. :- import_module hlds.hlds_module. :- import_module hlds.hlds_pred. diff --git a/compiler/closure_gen.m b/compiler/closure_gen.m index 96ba08120..f42ed226b 100644 --- a/compiler/closure_gen.m +++ b/compiler/closure_gen.m @@ -47,7 +47,6 @@ :- import_module hlds.hlds_pred. :- import_module hlds.hlds_proc. :- import_module hlds.hlds_proc_util. -:- import_module hlds.pred_info_types. :- import_module hlds.type_classify. :- import_module libs. :- import_module libs.globals. diff --git a/compiler/code_info.m b/compiler/code_info.m index 62f261b49..7202c6c9a 100644 --- a/compiler/code_info.m +++ b/compiler/code_info.m @@ -33,7 +33,6 @@ :- import_module hlds.hlds_module. :- import_module hlds.hlds_pred. :- import_module hlds.hlds_proc. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_proc_id. :- import_module libs. :- import_module libs.globals. diff --git a/compiler/code_loc_dep.m b/compiler/code_loc_dep.m index a32b36e61..1b77ad7d5 100644 --- a/compiler/code_loc_dep.m +++ b/compiler/code_loc_dep.m @@ -46,7 +46,6 @@ :- import_module hlds.hlds_goal. :- import_module hlds.hlds_llds. :- import_module hlds.instmap. -:- import_module hlds.pred_info_types. :- import_module libs. :- import_module libs.options. :- import_module ll_backend.code_info. @@ -195,7 +194,7 @@ code_loc_dep_init(FollowVars, ResumePoint, !CI, !:CLD) :- get_proc_info(!.CI, ProcInfo), module_info_get_globals(ModuleInfo, Globals), proc_info_get_initial_instmap(ModuleInfo, ProcInfo, InstMap), - proc_info_get_liveness_info(ProcInfo, Liveness), + proc_info_get_initial_liveness(ProcInfo, Liveness), CodeModel = proc_info_interface_code_model(ProcInfo), build_input_arg_list(ProcInfo, ArgList), get_var_table(!.CI, VarTable), diff --git a/compiler/code_util.m b/compiler/code_util.m index 09b61540a..5beecf946 100644 --- a/compiler/code_util.m +++ b/compiler/code_util.m @@ -21,7 +21,6 @@ :- import_module hlds.hlds_module. :- import_module hlds.hlds_proc. :- import_module hlds.hlds_rtti. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_proc_id. :- import_module libs. :- import_module libs.optimization_options. diff --git a/compiler/continuation_info.m b/compiler/continuation_info.m index 3a72e1321..3f72c123b 100644 --- a/compiler/continuation_info.m +++ b/compiler/continuation_info.m @@ -54,12 +54,12 @@ :- import_module hlds. :- import_module hlds.hlds_goal. +:- import_module hlds.hlds_llds. :- import_module hlds.hlds_module. :- import_module hlds.hlds_pred. :- import_module hlds.hlds_proc. :- import_module hlds.hlds_rtti. :- import_module hlds.instmap. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_proc_id. :- import_module hlds.proc_info_types. :- import_module libs. @@ -417,7 +417,6 @@ :- implementation. -:- import_module hlds.hlds_llds. :- import_module hlds.hlds_proc_util. :- import_module libs.options. :- import_module ll_backend.code_util. diff --git a/compiler/deep_profiling.m b/compiler/deep_profiling.m index 6bdc83ba6..09e6da063 100644 --- a/compiler/deep_profiling.m +++ b/compiler/deep_profiling.m @@ -81,7 +81,6 @@ :- import_module hlds.instmap. :- import_module hlds.make_goal. :- import_module hlds.mode_top_functor. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_name. :- import_module hlds.pred_table. :- import_module hlds.proc_info_types. diff --git a/compiler/export.m b/compiler/export.m index 2788eb165..b864c31d1 100644 --- a/compiler/export.m +++ b/compiler/export.m @@ -19,8 +19,8 @@ :- interface. :- import_module hlds. +:- import_module hlds.hlds_llds. :- import_module hlds.hlds_module. -:- import_module hlds.pred_info_types. :- import_module parse_tree. :- import_module parse_tree.prog_data. :- import_module parse_tree.prog_foreign. @@ -92,7 +92,6 @@ :- import_module hlds.arg_info. :- import_module hlds.code_model. :- import_module hlds.hlds_data. -:- import_module hlds.hlds_llds. :- import_module hlds.hlds_pred. :- import_module hlds.hlds_proc. :- import_module hlds.hlds_proc_util. diff --git a/compiler/fact_table_gen.m b/compiler/fact_table_gen.m index 8db58171a..d525a5798 100644 --- a/compiler/fact_table_gen.m +++ b/compiler/fact_table_gen.m @@ -138,7 +138,6 @@ :- import_module hlds.inst_test. :- import_module hlds.mode_test. :- import_module hlds.mode_util. -:- import_module hlds.pred_info_types. :- import_module libs. :- import_module libs.file_util. :- import_module libs.globals. diff --git a/compiler/follow_vars.m b/compiler/follow_vars.m index 6a39d3642..ed59915ed 100644 --- a/compiler/follow_vars.m +++ b/compiler/follow_vars.m @@ -58,7 +58,6 @@ :- import_module hlds.code_model. :- import_module hlds.hlds_pred. :- import_module hlds.hlds_proc_util. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_proc_id. :- import_module ll_backend.call_gen. :- import_module parse_tree.prog_data. diff --git a/compiler/foreign_proc_gen.m b/compiler/foreign_proc_gen.m index c992915a9..8b65e558d 100644 --- a/compiler/foreign_proc_gen.m +++ b/compiler/foreign_proc_gen.m @@ -72,7 +72,6 @@ :- import_module hlds.hlds_pred. :- import_module hlds.instmap. :- import_module hlds.mode_top_functor. -:- import_module hlds.pred_info_types. :- import_module hlds.type_util. :- import_module libs. :- import_module libs.globals. diff --git a/compiler/hlds_clauses.m b/compiler/hlds_clauses.m index a817804f6..799ed4e30 100644 --- a/compiler/hlds_clauses.m +++ b/compiler/hlds_clauses.m @@ -42,8 +42,9 @@ :- import_module hlds.hlds_args. :- import_module hlds.hlds_goal. :- import_module hlds.hlds_rtti. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_proc_id. +:- import_module libs. +:- import_module libs.globals. :- import_module mdbcomp. :- import_module mdbcomp.prim_data. :- import_module parse_tree. @@ -146,6 +147,12 @@ %---------------------% +:- type implementation_language + ---> impl_lang_mercury + ; impl_lang_foreign(foreign_language). + +%---------------------% + :- type clause ---> clause( % The modes for which this clause applies. diff --git a/compiler/hlds_llds.m b/compiler/hlds_llds.m index daa4c8bd7..44731a9f0 100644 --- a/compiler/hlds_llds.m +++ b/compiler/hlds_llds.m @@ -31,6 +31,17 @@ :- import_module map. :- import_module maybe. +%-----------------------------------------------------------------------------% + +:- type arg_info + ---> arg_info( + arg_loc, % Stored location. + top_functor_mode % Mode of top functor. + ). + +:- type arg_loc + ---> reg(reg_type, int). + % reg_r are the general purpose registers. % % reg_f are float registers. diff --git a/compiler/hlds_proc.m b/compiler/hlds_proc.m index 9b1e00338..5ca3c3786 100644 --- a/compiler/hlds_proc.m +++ b/compiler/hlds_proc.m @@ -23,7 +23,6 @@ :- import_module hlds.hlds_llds. :- import_module hlds.hlds_module. :- import_module hlds.hlds_rtti. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_proc_id. :- import_module hlds.proc_info_types. :- import_module parse_tree. @@ -104,7 +103,7 @@ has_user_event::out, has_tail_rec_call::out, list(oisu_pred_kind_for)::out, maybe(require_tail_recursion)::out, set_of_progvar::out, maybe(list(arg_info))::out, maybe(special_proc_return)::out, - liveness_info::out, stack_slots::out, needs_maxfr_slot::out, + codegen_liveness::out, stack_slots::out, needs_maxfr_slot::out, maybe(prog_var)::out, maybe(proc_table_io_info)::out, maybe(table_attributes)::out, maybe(list(sym_name_arity))::out, maybe(deep_profile_proc_info)::out, maybe(arg_size_info)::out, @@ -125,7 +124,7 @@ has_user_event::in, has_tail_rec_call::in, list(oisu_pred_kind_for)::in, maybe(require_tail_recursion)::in, set_of_progvar::in, maybe(list(arg_info))::in, maybe(special_proc_return)::in, - liveness_info::in, stack_slots::in, needs_maxfr_slot::in, + codegen_liveness::in, stack_slots::in, needs_maxfr_slot::in, maybe(prog_var)::in, maybe(proc_table_io_info)::in, maybe(table_attributes)::in, maybe(list(sym_name_arity))::in, maybe(deep_profile_proc_info)::in, maybe(arg_size_info)::in, @@ -235,7 +234,8 @@ maybe(list(arg_info))::out) is det. :- pred proc_info_get_maybe_special_return(proc_info::in, maybe(special_proc_return)::out) is det. -:- pred proc_info_get_liveness_info(proc_info::in, liveness_info::out) is det. +:- pred proc_info_get_initial_liveness(proc_info::in, + codegen_liveness::out) is det. :- pred proc_info_get_stack_slots(proc_info::in, stack_slots::out) is det. :- pred proc_info_get_needs_maxfr_slot(proc_info::in, needs_maxfr_slot::out) is det. @@ -319,7 +319,7 @@ proc_info::in, proc_info::out) is det. :- pred proc_info_set_maybe_special_return(maybe(special_proc_return)::in, proc_info::in, proc_info::out) is det. -:- pred proc_info_set_liveness_info(liveness_info::in, +:- pred proc_info_set_initial_liveness(codegen_liveness::in, proc_info::in, proc_info::out) is det. :- pred proc_info_set_stack_slots(stack_slots::in, proc_info::in, proc_info::out) is det. @@ -1025,7 +1025,7 @@ proc_info_reset_imported_structure_reuse(!ProcInfo) :- psi_maybe_special_return :: maybe(special_proc_return), % The initial liveness, for code generation. - psi_initial_liveness :: liveness_info, + psi_initial_liveness :: codegen_liveness, % Allocation of variables to stack slots. psi_stack_slots :: stack_slots, @@ -1185,7 +1185,7 @@ proc_info_get_maybe_arg_info(PI, X) :- X = PI ^ proc_sub_info ^ psi_maybe_arg_info. proc_info_get_maybe_special_return(PI, X) :- X = PI ^ proc_sub_info ^ psi_maybe_special_return. -proc_info_get_liveness_info(PI, X) :- +proc_info_get_initial_liveness(PI, X) :- X = PI ^ proc_sub_info ^ psi_initial_liveness. proc_info_get_stack_slots(PI, X) :- X = PI ^ proc_sub_info ^ psi_stack_slots. @@ -1271,7 +1271,7 @@ proc_info_set_arg_info(X, !PI) :- !PI ^ proc_sub_info ^ psi_maybe_arg_info := yes(X). proc_info_set_maybe_special_return(X, !PI) :- !PI ^ proc_sub_info ^ psi_maybe_special_return := X. -proc_info_set_liveness_info(X, !PI) :- +proc_info_set_initial_liveness(X, !PI) :- !PI ^ proc_sub_info ^ psi_initial_liveness := X. proc_info_set_stack_slots(X, !PI) :- !PI ^ proc_sub_info ^ psi_stack_slots := X. diff --git a/compiler/hlds_proc_util.m b/compiler/hlds_proc_util.m index 90cf78470..fcda2c10a 100644 --- a/compiler/hlds_proc_util.m +++ b/compiler/hlds_proc_util.m @@ -17,11 +17,11 @@ :- import_module check_hlds. :- import_module check_hlds.mode_constraint_robdd. +:- import_module hlds.hlds_llds. :- import_module hlds.hlds_module. :- import_module hlds.hlds_pred. :- import_module hlds.hlds_proc. :- import_module hlds.instmap. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_proc_id. :- import_module parse_tree. :- import_module parse_tree.prog_data. diff --git a/compiler/hlds_rtti.m b/compiler/hlds_rtti.m index ee9a7cc35..7dbc35362 100644 --- a/compiler/hlds_rtti.m +++ b/compiler/hlds_rtti.m @@ -19,7 +19,6 @@ :- interface. :- import_module hlds.hlds_module. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_name. :- import_module hlds.pred_proc_id. :- import_module mdbcomp. diff --git a/compiler/instance_method_clauses.m b/compiler/instance_method_clauses.m index 1439ecaac..d90013151 100644 --- a/compiler/instance_method_clauses.m +++ b/compiler/instance_method_clauses.m @@ -49,7 +49,6 @@ :- import_module hlds.instmap. :- import_module hlds.make_hlds.add_clause. :- import_module hlds.make_hlds.state_var. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_proc_id. :- import_module mdbcomp.sym_name. :- import_module parse_tree.maybe_error. diff --git a/compiler/lco.m b/compiler/lco.m index 3d4b65295..b740085de 100644 --- a/compiler/lco.m +++ b/compiler/lco.m @@ -186,7 +186,6 @@ :- import_module hlds.instmap. :- import_module hlds.mode_top_functor. :- import_module hlds.passes_aux. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_name. :- import_module hlds.pred_proc_id. :- import_module hlds.pred_table. diff --git a/compiler/liveness.m b/compiler/liveness.m index 3355a1148..52610f053 100644 --- a/compiler/liveness.m +++ b/compiler/liveness.m @@ -204,7 +204,6 @@ :- import_module hlds.hlds_rtti. :- import_module hlds.instmap. :- import_module hlds.mode_top_functor. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_name. :- import_module hlds.quantification. :- import_module libs. @@ -332,7 +331,7 @@ detect_liveness_proc_2(ModuleInfo, PredId, !ProcInfo) :- DebugThisPred, PredId, !.ProcInfo, VarTable, Goal, !IO) ), proc_info_set_goal(Goal, !ProcInfo), - proc_info_set_liveness_info(Liveness0, !ProcInfo). + proc_info_set_initial_liveness(Liveness0, !ProcInfo). :- pred maybe_debug_liveness(module_info::in, string::in, bool::in, pred_id::in, proc_info::in, var_table::in, hlds_goal::in, diff --git a/compiler/mark_tail_calls.m b/compiler/mark_tail_calls.m index 9347c0f3a..2b0013c15 100644 --- a/compiler/mark_tail_calls.m +++ b/compiler/mark_tail_calls.m @@ -219,7 +219,6 @@ :- import_module hlds.hlds_goal. :- import_module hlds.hlds_proc_util. :- import_module hlds.mode_top_functor. -:- import_module hlds.pred_info_types. :- import_module hlds.proc_info_types. :- import_module hlds.type_util. :- import_module libs.options. diff --git a/compiler/ml_args_util.m b/compiler/ml_args_util.m index bfc73acaf..0ddbdd21a 100644 --- a/compiler/ml_args_util.m +++ b/compiler/ml_args_util.m @@ -20,7 +20,6 @@ :- import_module hlds.code_model. :- import_module hlds.hlds_module. :- import_module hlds.hlds_rtti. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_proc_id. :- import_module mdbcomp. :- import_module mdbcomp.prim_data. diff --git a/compiler/ml_closure_gen.m b/compiler/ml_closure_gen.m index b0daac39e..319de91b9 100644 --- a/compiler/ml_closure_gen.m +++ b/compiler/ml_closure_gen.m @@ -86,7 +86,6 @@ :- import_module hlds.hlds_pred. :- import_module hlds.hlds_proc. :- import_module hlds.mark_tail_calls. % for ntrcr_program -:- import_module hlds.pred_info_types. :- import_module hlds.type_util. :- import_module libs. :- import_module libs.globals. diff --git a/compiler/ml_foreign_proc_gen.m b/compiler/ml_foreign_proc_gen.m index feaf4503c..c13e4b5d3 100644 --- a/compiler/ml_foreign_proc_gen.m +++ b/compiler/ml_foreign_proc_gen.m @@ -51,7 +51,6 @@ :- import_module hlds.hlds_pred. :- import_module hlds.hlds_proc_util. :- import_module hlds.mode_top_functor. -:- import_module hlds.pred_info_types. :- import_module hlds.type_util. :- import_module libs. :- import_module libs.globals. diff --git a/compiler/ml_proc_gen.m b/compiler/ml_proc_gen.m index 44fdb35ee..a90001c4e 100644 --- a/compiler/ml_proc_gen.m +++ b/compiler/ml_proc_gen.m @@ -50,7 +50,6 @@ :- import_module hlds.hlds_proc_util. :- import_module hlds.mark_tail_calls. :- import_module hlds.passes_aux. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_proc_id. :- import_module hlds.proc_info_types. :- import_module hlds.quantification. diff --git a/compiler/ml_unify_gen_construct.m b/compiler/ml_unify_gen_construct.m index 8a08868ca..83d46c451 100644 --- a/compiler/ml_unify_gen_construct.m +++ b/compiler/ml_unify_gen_construct.m @@ -91,7 +91,6 @@ :- import_module hlds.hlds_code_util. :- import_module hlds.hlds_data. :- import_module hlds.mode_top_functor. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_proc_id. :- import_module hlds.type_classify. :- import_module hlds.type_util. diff --git a/compiler/ml_unify_gen_util.m b/compiler/ml_unify_gen_util.m index 0833ef19f..3865d2be5 100644 --- a/compiler/ml_unify_gen_util.m +++ b/compiler/ml_unify_gen_util.m @@ -217,7 +217,6 @@ :- import_module backend_libs.builtin_ops. :- import_module hlds.hlds_code_util. :- import_module hlds.mode_top_functor. -:- import_module hlds.pred_info_types. :- import_module hlds.type_util. :- import_module libs. :- import_module libs.globals. diff --git a/compiler/mode_top_functor.m b/compiler/mode_top_functor.m index 1175335a1..ca94a00eb 100644 --- a/compiler/mode_top_functor.m +++ b/compiler/mode_top_functor.m @@ -17,7 +17,6 @@ :- interface. :- import_module hlds.hlds_module. -:- import_module hlds.pred_info_types. :- import_module parse_tree. :- import_module parse_tree.prog_data. diff --git a/compiler/modecheck_unify.m b/compiler/modecheck_unify.m index e33a9d41b..901ee7ad1 100644 --- a/compiler/modecheck_unify.m +++ b/compiler/modecheck_unify.m @@ -65,7 +65,6 @@ :- import_module hlds.mode_test. :- import_module hlds.mode_top_functor. :- import_module hlds.mode_util. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_proc_id. :- import_module hlds.type_classify. :- import_module hlds.type_util. diff --git a/compiler/pred_info_types.m b/compiler/pred_info_types.m index 531ca8243..a9c38b16d 100644 --- a/compiler/pred_info_types.m +++ b/compiler/pred_info_types.m @@ -10,22 +10,17 @@ % File: hlds_pred.m. % Main authors: fjh, conway. % -% This module defines the part of the HLDS that deals with predicates -% and procedures. +% This module defines types that are specific to fields of pred_infos. % %---------------------------------------------------------------------------% :- module hlds.pred_info_types. :- interface. -:- import_module hlds.hlds_llds. -:- import_module libs. -:- import_module libs.globals. :- import_module parse_tree. :- import_module parse_tree.prog_data. :- import_module parse_tree.prog_data_pragma. :- import_module parse_tree.prog_data_rare. -:- import_module parse_tree.set_of_var. :- import_module bool. :- import_module map. @@ -34,10 +29,6 @@ %---------------------------------------------------------------------------% -:- type implementation_language - ---> impl_lang_mercury - ; impl_lang_foreign(foreign_language). - % A predicate, and the goal inside it, may implement a promise declaration, % or it may be an ordinary predicate. :- type goal_type @@ -51,11 +42,11 @@ % % We use this information in two ways. % - % First, intermod.m needs to know whether a predicate's definition - % contains any foreign_procs, because if it does, then it cannot append - % variable numbers after variable names for disambiguation, in e.g. clause - % heads, since that would screw up references to those variables in the - % foreign code. + % First, intermodule optimization needs to know whether a predicate's + % definition contains any foreign_procs, because if it does, then + % it cannot append variable numbers after variable names for + % disambiguation (in e.g. clause heads) since that would screw up + % references to those variables in the foreign code. % % Second, purity.m has special handling for predicates that are defined % *only* by foreign procs. @@ -73,55 +64,10 @@ ; np_goal_type_foreign ; np_goal_type_clause_and_foreign. - % NOTE: `liveness_info' records liveness in the sense used by code - % generation. This is *not* the same thing as the notion of liveness - % used by mode analysis! See compiler/notes/glossary.html. - % -:- type liveness_info == set_of_progvar. % The live variables. - -:- type arg_info - ---> arg_info( - arg_loc, % Stored location. - top_functor_mode % Mode of top functor. - ). - - % The top_functor_mode specifies the mode of the top-level functor - % of a term (excluding `no_tag' functors, since those have no - % representation). It is used by the code generators when determining - % how to pass the argument. - % - % For the LLDS back-end, top_in arguments are passed in registers, - % and top_out values are returned in registers; top_unused values - % are not passed at all, but they are treated as if they were top_out - % for the purpose of assigning arguments to registers. (So e.g. if - % a det procedure has three arguments with top_functor_modes top_out, - % top_unused, and top_out respectively, the last argument will be - % returned in register r3, not r2.) - % - % For the MLDS back-end, top_in values are passed as arguments. - % Top_out values are normally passed by reference, except that - % - if the procedure is model_nondet, and the --nondet-copy-out option - % is set, top_out values are passed by value to the continuation - % function; - % - if the procedure is model_det or model_semi, and the - % --det-copy-out option is set, top_out arguments in the HLDS - % are mapped to (multiple) return values in the MLDS; and - % - if the HLDS function return value for a det function has mode - % `top_out', it is mapped to an MLDS return value. - % top_unused arguments are not passed at all. - % -:- type top_functor_mode - ---> top_in - ; top_out - ; top_unused. - -:- type arg_loc - ---> reg(reg_type, int). - %---------------------% - % This type is isomorphic to the module_section type, but defining it here - % allows us not to depend on parse_tree.prog_item.m. + % This type is isomorphic to the module_section type, but + % defining it here allows us not to depend on prog_parse_tree.m. :- type decl_section ---> decl_interface ; decl_implementation. @@ -137,6 +83,8 @@ item_seq_num ). +%---------------------% + :- type format_call_info ---> format_call_info( % The context of the format_call pragma whose info @@ -150,6 +98,8 @@ one_or_more(format_string_values) ). +%---------------------% + % Mode information for the arguments of a procedure. % The first map gives the instantiation state on entry of the node % corresponding to the prog_var. The second map gives the instantiation diff --git a/compiler/proc_info_types.m b/compiler/proc_info_types.m index 1093d2caa..8259eb03e 100644 --- a/compiler/proc_info_types.m +++ b/compiler/proc_info_types.m @@ -10,8 +10,7 @@ % File: hlds_pred.m. % Main authors: fjh, conway. % -% This module defines the part of the HLDS that deals with predicates -% and procedures. +% This module defines types that are specific to fields of proc_infos. % %---------------------------------------------------------------------------% @@ -31,6 +30,7 @@ :- import_module parse_tree.prog_data. :- import_module parse_tree.prog_data_pragma. :- import_module parse_tree.prog_data_rare. +:- import_module parse_tree.set_of_var. :- import_module parse_tree.var_table. :- import_module bool. @@ -40,6 +40,12 @@ %---------------------------------------------------------------------------% + % NOTE: `codegen_liveness' records liveness in the sense used by code + % generation. This is *not* the same thing as the notion of liveness + % used by mode analysis! See compiler/notes/glossary.html. + % +:- type codegen_liveness == set_of_progvar. % The live variables. + :- type is_address_taken ---> address_is_taken ; address_is_not_taken. @@ -118,10 +124,10 @@ ---> hlds_deep_excp_vars( top_csd :: prog_var, middle_csd :: prog_var, + + % This field is needed only with the save/restore approach, + % not the activation counting approach. old_outermost :: maybe(prog_var) - % Needed only with the save/restore - % approach, not the activation counting - % approach. ). :- type hlds_deep_layout @@ -312,16 +318,27 @@ map(prog_var, list(prog_var)) ). -:- type detism_decl - ---> detism_decl_explicit - ; detism_decl_implicit - ; detism_decl_none. - % The determinism of the procedure is not declared. - :- type can_process ---> cannot_process_yet ; can_process_now. + % Values of this type are used only for choosing the wording of + % determinism diagnostics. +:- type detism_decl + ---> detism_decl_explicit + ; detism_decl_implicit + % The determinism of the procedure is not declared, + % but the procedure needs no declaration, because either + % + % - the procedure is for a function, which are implicitly det + % unless explicitly declared otherwise, or + % + % - the procedure was created by the compiler, e.g. + % to implement a unify/index/compare predicate, + % to implement an instance method, or as implied mode. + ; detism_decl_none. + % The determinism of the procedure is not declared. + :- type needs_maxfr_slot ---> needs_maxfr_slot ; does_not_need_maxfr_slot. diff --git a/compiler/prog_data.m b/compiler/prog_data.m index 5aeba4345..31b9588d2 100644 --- a/compiler/prog_data.m +++ b/compiler/prog_data.m @@ -1661,6 +1661,40 @@ prog_constraint_get_arg_types(Constraint) = Constraint ^ constraint_arg_types. :- type from_to_insts ---> from_to_insts(mer_inst, mer_inst). + % The top_functor_mode specifies the mode of the top-level functor + % of a term (excluding `no_tag' functors, since those have no + % representation). It is used by the code generators when determining + % how to pass the argument. + % + % For the LLDS back-end, top_in arguments are passed in registers, + % and top_out values are returned in registers. top_unused values + % are not passed at all, but they are treated as if they were top_out + % for the purpose of assigning arguments to registers. (So e.g. if + % a det procedure has three arguments with top_functor_modes top_out, + % top_unused, and top_out respectively, the last argument will be + % returned in register r3, not r2.) + % + % For the MLDS back-end, top_in values are passed as arguments. + % Top_out values are normally passed by reference, except that + % + % - if the procedure is model_nondet, and the --nondet-copy-out option + % is set, top_out values are passed by value to the continuation + % function; + % + % - if the procedure is model_det or model_semi, and the + % --det-copy-out option is set, top_out arguments in the HLDS + % are mapped to (multiple) return values in the MLDS; and + % + % - if the HLDS function return value for a det function has mode + % `top_out', it is mapped to an MLDS return value. + % + % top_unused arguments are not passed at all. + % +:- type top_functor_mode + ---> top_in + ; top_out + ; top_unused. + %---------------------------------------------------------------------------% % % Determinism. diff --git a/compiler/stack_layout.m b/compiler/stack_layout.m index dc99c0c7c..14242397b 100644 --- a/compiler/stack_layout.m +++ b/compiler/stack_layout.m @@ -111,7 +111,6 @@ :- import_module hlds.hlds_llds. :- import_module hlds.hlds_proc_util. :- import_module hlds.hlds_rtti. -:- import_module hlds.pred_info_types. :- import_module hlds.type_util. :- import_module libs. :- import_module libs.globals. diff --git a/compiler/structure_reuse.lfu.m b/compiler/structure_reuse.lfu.m index 454f0e3dd..8de46b06e 100644 --- a/compiler/structure_reuse.lfu.m +++ b/compiler/structure_reuse.lfu.m @@ -61,7 +61,7 @@ forward_use_information(!ProcInfo) :- proc_info_get_goal(!.ProcInfo, Goal0), % Set of variables initially instantiated. - proc_info_get_liveness_info(!.ProcInfo, InstantiatedVars0), + proc_info_get_initial_liveness(!.ProcInfo, InstantiatedVars0), % Set of variables initially "dead" = instantiated variables that % syntactically do not occur in the remainder of the goal. set_of_var.init(DeadVars0), diff --git a/compiler/structure_sharing.domain.m b/compiler/structure_sharing.domain.m index 60f415aee..b9cde5110 100644 --- a/compiler/structure_sharing.domain.m +++ b/compiler/structure_sharing.domain.m @@ -312,7 +312,6 @@ :- import_module hlds.inst_test. :- import_module hlds.mode_top_functor. :- import_module hlds.mode_util. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_name. :- import_module hlds.proc_info_types. :- import_module hlds.status. diff --git a/compiler/trace_gen.m b/compiler/trace_gen.m index 8dd603769..7bc4ee7d1 100644 --- a/compiler/trace_gen.m +++ b/compiler/trace_gen.m @@ -51,9 +51,9 @@ :- import_module hlds. :- import_module hlds.hlds_goal. +:- import_module hlds.hlds_llds. :- import_module hlds.hlds_module. :- import_module hlds.hlds_proc. -:- import_module hlds.pred_info_types. :- import_module libs. :- import_module libs.globals. :- import_module libs.trace_params. @@ -246,7 +246,6 @@ :- import_module backend_libs. :- import_module backend_libs.builtin_ops. :- import_module hlds.code_model. -:- import_module hlds.hlds_llds. :- import_module hlds.hlds_markers. :- import_module hlds.hlds_proc_util. :- import_module hlds.inst_test. diff --git a/compiler/types_into_modes.m b/compiler/types_into_modes.m index 294371c8f..7f75d4651 100644 --- a/compiler/types_into_modes.m +++ b/compiler/types_into_modes.m @@ -52,7 +52,6 @@ :- import_module hlds.hlds_goal. :- import_module hlds.hlds_markers. :- import_module hlds.hlds_proc. -:- import_module hlds.pred_info_types. :- import_module libs. :- import_module libs.globals. :- import_module mdbcomp. diff --git a/compiler/unify_gen_construct.m b/compiler/unify_gen_construct.m index b2d7671ea..8cc83b803 100644 --- a/compiler/unify_gen_construct.m +++ b/compiler/unify_gen_construct.m @@ -65,7 +65,6 @@ :- import_module hlds.hlds_data. :- import_module hlds.hlds_rtti. :- import_module hlds.mode_top_functor. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_name. :- import_module hlds.pred_proc_id. :- import_module hlds.type_classify. diff --git a/compiler/unify_gen_util.m b/compiler/unify_gen_util.m index 1abde448c..94a2944bb 100644 --- a/compiler/unify_gen_util.m +++ b/compiler/unify_gen_util.m @@ -93,7 +93,6 @@ :- import_module backend_libs. :- import_module backend_libs.builtin_ops. :- import_module hlds.mode_top_functor. -:- import_module hlds.pred_info_types. :- import_module hlds.type_util. :- import_module mdbcomp. :- import_module mdbcomp.sym_name. diff --git a/compiler/unify_proc.m b/compiler/unify_proc.m index b680230ad..f2c50c6d6 100644 --- a/compiler/unify_proc.m +++ b/compiler/unify_proc.m @@ -92,7 +92,6 @@ :- import_module hlds.hlds_rtti. :- import_module hlds.instmap. :- import_module hlds.make_goal. -:- import_module hlds.pred_info_types. :- import_module hlds.pred_table. :- import_module hlds.quantification. :- import_module hlds.special_pred. diff --git a/compiler/var_origins.m b/compiler/var_origins.m index 95a4cbd96..474237fe0 100644 --- a/compiler/var_origins.m +++ b/compiler/var_origins.m @@ -212,7 +212,6 @@ :- import_module hlds.hlds_clauses. :- import_module hlds.hlds_out. :- import_module hlds.hlds_out.hlds_out_util. -:- import_module hlds.pred_info_types. :- import_module parse_tree.parse_tree_out_cons_id. :- import_module parse_tree.parse_tree_out_info. :- import_module parse_tree.parse_tree_out_term.