[m-rev.] for review: support --no-static-ground-terms in LLDS grades

Peter Wang novalazy at gmail.com
Tue Jan 15 16:21:53 AEDT 2008


Estimated hours taken: 2
Branches: main

Make the low-level code generator support the `--no-static-ground-terms'
option.  Previously it was always enabled.

compiler/handle_options.m:
	Don't force `--static-ground-terms' to be enabled when using a
	low-level grade.

compiler/var_locn.m:
	Add a type `may_use_static_ground_terms'.

	Make `var_locn_assign_cell_to_var' take an argument which tells it
	whether to generate references to static cells.

compiler/code_info.m:
	Keep the setting of `--static-ground-terms' in a new code_info_static
	field.

	Add a getter predicate for the field.

	Call `var_locn_assign_cell_to_var' with the value of that field.

Index: compiler/code_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.355
diff -u -r1.355 code_info.m
--- compiler/code_info.m	30 Dec 2007 08:23:32 -0000	1.355
+++ compiler/code_info.m	15 Jan 2008 03:55:18 -0000
@@ -42,6 +42,7 @@
 :- import_module ll_backend.layout.
 :- import_module ll_backend.llds.
 :- import_module ll_backend.trace_gen.
+:- import_module ll_backend.var_locn.
 :- import_module mdbcomp.prim_data.
 :- import_module mdbcomp.program_representation.
 :- import_module parse_tree.prog_data.
@@ -60,8 +61,8 @@
 
 :- implementation.
 
-:- import_module backend_libs.proc_label.
 :- import_module backend_libs.builtin_ops.
+:- import_module backend_libs.proc_label.
 :- import_module check_hlds.type_util.
 :- import_module hlds.arg_info.
 :- import_module hlds.hlds_code_util.
@@ -71,7 +72,6 @@
 :- import_module libs.trace_params.
 :- import_module libs.tree.
 :- import_module ll_backend.code_util.
-:- import_module ll_backend.var_locn.
 :- import_module parse_tree.prog_type.
 
 :- import_module int.
@@ -221,6 +221,9 @@
 
 :- pred get_auto_comments(code_info::in, bool::out) is det.
 
+:- pred get_static_ground_terms(code_info::in,
+    may_use_static_ground_terms::out) is det.
+
 :- pred get_lcmc_null(code_info::in, bool::out) is det.
 
 %---------------------------------------------------------------------------%
@@ -365,6 +368,9 @@
                 auto_comments       :: bool,
                                     % The setting of --auto-comments.
 
+                static_ground_terms :: may_use_static_ground_terms,
+                                    % The setting of --static-ground-terms.
+
                 lcmc_null           :: bool
                                     % The setting of --optimize-constructor-
                                     % last-call-null.
@@ -544,6 +550,15 @@
         EmitRegionOps = do_not_add_region_ops
     ),
     globals.lookup_bool_option(Globals, auto_comments, AutoComments),
+    globals.lookup_bool_option(Globals, static_ground_terms,
+        StaticGroundTerms),
+    (
+        StaticGroundTerms = yes,
+        MayUseStaticGroundTerms = may_use_static_ground_terms
+    ;
+        StaticGroundTerms = no,
+        MayUseStaticGroundTerms = may_not_use_static_ground_terms
+    ),
     globals.lookup_bool_option(Globals, optimize_constructor_last_call_null,
         LCMCNull),
     CodeInfo0 = code_info(
@@ -563,6 +578,7 @@
             EmitRegionOps,
             OptRegionOps,
             AutoComments,
+            MayUseStaticGroundTerms,
             LCMCNull
         ),
         code_info_loc_dep(
@@ -629,6 +645,7 @@
 get_emit_region_ops(CI, CI ^ code_info_static ^ emit_region_ops).
 get_opt_region_ops(CI, CI ^ code_info_static ^ opt_region_ops).
 get_auto_comments(CI, CI ^ code_info_static ^ auto_comments).
+get_static_ground_terms(CI, CI ^ code_info_static ^ static_ground_terms).
 get_lcmc_null(CI, CI ^ code_info_static ^ lcmc_null).
 get_forward_live_vars(CI, CI ^ code_info_loc_dep ^ forward_live_vars).
 get_instmap(CI, CI ^ code_info_loc_dep ^ instmap).
@@ -3703,9 +3720,11 @@
     get_var_locn_info(!.CI, VarLocnInfo0),
     get_static_cell_info(!.CI, StaticCellInfo0),
     get_module_info(!.CI, ModuleInfo),
+    get_static_ground_terms(!.CI, MayUseStaticGroundTerms),
     var_locn_assign_cell_to_var(ModuleInfo, Var, ReserveWordAtStart, Ptag,
         MaybeRvals, HowToConstruct, MaybeSize, FieldAddrs, TypeMsg,
-        MayUseAtomic, Code, StaticCellInfo0, StaticCellInfo,
+        MayUseStaticGroundTerms, MayUseAtomic, Code,
+        StaticCellInfo0, StaticCellInfo,
         VarLocnInfo0, VarLocnInfo),
     set_static_cell_info(StaticCellInfo, !CI),
     set_var_locn_info(VarLocnInfo, !CI).
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.315
diff -u -r1.315 handle_options.m
--- compiler/handle_options.m	14 Jan 2008 00:08:00 -0000	1.315
+++ compiler/handle_options.m	15 Jan 2008 03:55:18 -0000
@@ -1976,15 +1976,6 @@
 :- pred postprocess_options_lowlevel(globals::in, globals::out) is det.
 
 postprocess_options_lowlevel(!Globals) :-
-        % The low level code generator assumes that const(_) rvals are
-        % really constant, and that create(_) rvals with constant
-        % arguments can be materialized in an assignable rval without
-        % further code. For float_consts, the former is true only if
-        % either static_ground_terms or unboxed_floats is true, and
-        % the latter cannot be true without static_ground_terms.
-    option_neg_implies(highlevel_code, static_ground_terms, bool(yes),
-        !Globals),
-
         % --optimize-saved-vars-cell requires --use-local-vars for
         % acceptable performance.
     option_implies(optimize_saved_vars_cell, use_local_vars, bool(yes),
Index: compiler/var_locn.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/var_locn.m,v
retrieving revision 1.52
diff -u -r1.52 var_locn.m
--- compiler/var_locn.m	23 Nov 2007 07:35:33 -0000	1.52
+++ compiler/var_locn.m	15 Jan 2008 03:55:23 -0000
@@ -40,6 +40,10 @@
 
 :- type var_locn_info.
 
+:- type may_use_static_ground_terms
+    --->    may_use_static_ground_terms
+    ;       may_not_use_static_ground_terms.
+
     % init_var_locn_state(Arguments, Liveness, VarSet, VarTypes, StackSlots,
     %   FollowVars, Opts, VarLocnInfo):
     %
@@ -167,8 +171,8 @@
     var_locn_info::in, var_locn_info::out) is det.
 
     % var_locn_assign_cell_to_var(ModuleInfo, Var, ReserveWordAtStart, Ptag,
-    %   MaybeRvals, MaybeSize, FieldAddrs, TypeMsg, MayUseAtomic, Code,
-    %   !StaticCellInfo, !VarLocnInfo):
+    %   MaybeRvals, MaybeSize, FieldAddrs, TypeMsg, MayUseStaticGroundTerms,
+    %   MayUseAtomic, Code, !StaticCellInfo, !VarLocnInfo):
     %
     % Generates code to assign to Var a pointer, tagged by Ptag, to the cell
     % whose contents are given by the other arguments, and updates the state
@@ -184,9 +188,9 @@
     %
 :- pred var_locn_assign_cell_to_var(module_info::in, prog_var::in, bool::in,
     tag::in, list(maybe(rval))::in, how_to_construct::in,
-    maybe(term_size_value)::in, list(int)::in,
-    string::in, may_use_atomic_alloc::in, code_tree::out,
-    static_cell_info::in, static_cell_info::out,
+    maybe(term_size_value)::in, list(int)::in, string::in,
+    may_use_static_ground_terms::in, may_use_atomic_alloc::in,
+    code_tree::out, static_cell_info::in, static_cell_info::out,
     var_locn_info::in, var_locn_info::out) is det.
 
     % var_locn_place_var(ModuleInfo, Var, Lval, Code, !VarLocnInfo):
@@ -363,6 +367,7 @@
 
 :- import_module check_hlds.type_util.
 :- import_module libs.compiler_util.
+:- import_module libs.globals.
 :- import_module libs.options.
 :- import_module libs.tree.
 :- import_module ll_backend.code_util.
@@ -820,7 +825,7 @@
 
 var_locn_assign_cell_to_var(ModuleInfo, Var, ReserveWordAtStart, Ptag,
         MaybeRvals0, HowToConstruct, MaybeSize, FieldAddrs, TypeMsg,
-        MayUseAtomic, Code, !StaticCellInfo, !VLI) :-
+        MayUseStaticGroundTerms, MayUseAtomic, Code, !StaticCellInfo, !VLI) :-
     (
         MaybeSize = yes(SizeSource),
         (
@@ -842,6 +847,7 @@
     % We can make the cell a constant only if all its fields are filled in,
     % and they are all constants.
     (
+        MayUseStaticGroundTerms = may_use_static_ground_terms,
         FieldAddrs = [],
         cell_is_constant(VarStateMap, ExprnOpts, MaybeRvals, RvalsTypes)
     ->

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list