[m-rev.] for review: fix two_way_unif
Zoltan Somogyi
zs at csse.unimelb.edu.au
Mon Jun 2 11:36:50 AEST 2008
This is for review by Peter Wang, since it relates to a change he made
during the summer.
Zoltan.
Fix the failure of the valid/two_way_unif test case, which used to get a code
generator abort. The root cause of the abort was a mismatch between two
meanings of the option --static-ground-terms. The code in exprn_aux.m
was using it to govern whether an unboxed float was considered to be
a constant or not, whereas code_info.m and var_locn.m assumed that
*all* function symbols of arity 0, including floats, are always constants.
The fix is to rename the name of the option inside the compiler from
static_ground_terms to static_ground_cells (keeping the user-visible
name the same), and to add another option, static_ground_floats that
governs whether floats are considered static data. For now, and until
(if ever) the code generator is modified, they always are.
I also took the opportunity to add another option, static_code_addresses,
that is set based on the values of a couple of other options. This avoids
the repeated execution of a computation.
compiler/options.m:
Make the changes described above.
compiler/handle_options.m:
Add code to set the values of the two new options.
compiler/var_locn.m:
compiler/code_info.m:
Move the data structure that packages up the values of the options
relevant to the code generation of expressions from the var_locn
structure directly to the code_info structure, to allow parts of
the code generator *outside* var_locn to also access it. Put the
values of the new options in it too.
Add a XXX marker for some redundant data.
compiler/exprn_aux.m:
compiler/llds.m:
Move the definition of that data structure from exprn_aux.m to llds.m,
to allow those parts of the code generator outside var_locn to use it
without importing exprn_aux.m.
Change the fields of this data structure from confusable bools to
purpose-specific types.
compiler/disj_gen.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/globals.m:
compiler/liveness.m:
compiler/llds_out.m:
compiler/lookup_switch.m:
compiler/lookup_util.m:
compiler/mercury_compile.m:
compiler/stack_layout.m:
Take advantage of (or just conform to) the above changes.
In llds_out.m, avoid generating unnecessary casts for string
comparisons.
cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing boehm_gc/windows-untested
cvs diff: Diffing boehm_gc/windows-untested/vc60
cvs diff: Diffing boehm_gc/windows-untested/vc70
cvs diff: Diffing boehm_gc/windows-untested/vc71
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/code_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.361
diff -u -b -r1.361 code_info.m
--- compiler/code_info.m 27 Feb 2008 07:23:03 -0000 1.361
+++ compiler/code_info.m 30 May 2008 16:32:11 -0000
@@ -113,6 +113,10 @@
%
:- pred get_globals(code_info::in, globals::out) is det.
+ % Get the exprn_opts.
+ %
+:- pred get_exprn_opts(code_info::in, exprn_opts::out) is det.
+
% Get the HLDS of the entire module.
%
:- pred get_module_info(code_info::in, module_info::out) is det.
@@ -311,6 +315,7 @@
---> code_info_static(
% For the code generation options.
cis_globals :: globals,
+ cis_exprn_opts :: exprn_opts,
% The module_info structure - you just never know
% when you might need it.
@@ -461,7 +466,7 @@
proc_info_get_varset(ProcInfo, VarSet),
proc_info_get_vartypes(ProcInfo, VarTypes),
proc_info_get_stack_slots(ProcInfo, StackSlots),
- globals.get_options(Globals, Options),
+ ExprnOpts = init_exprn_opts(Globals),
globals.get_trace_level(Globals, TraceLevel),
(
eff_trace_level_is_none(ModuleInfo, PredInfo, ProcInfo, TraceLevel)
@@ -475,7 +480,7 @@
EffLiveness = Liveness
),
init_var_locn_state(ArgList, EffLiveness, VarSet, VarTypes, StackSlots,
- FollowVars, Options, VarLocnInfo),
+ FollowVars, VarLocnInfo),
stack.init(ResumePoints),
globals.lookup_bool_option(Globals, allow_hijacks, AllowHijack),
(
@@ -524,6 +529,7 @@
CodeInfo0 = code_info(
code_info_static(
Globals,
+ ExprnOpts,
ModuleInfo,
PredId,
ProcId,
@@ -570,6 +576,60 @@
init_fail_info(CodeModel, MaybeFailVars, ResumePoint,
CodeInfo1, CodeInfo).
+:- func init_exprn_opts(globals) = exprn_opts.
+
+init_exprn_opts(Globals) = ExprnOpts :-
+ globals.lookup_bool_option(Globals, gcc_non_local_gotos, OptNLG),
+ (
+ OptNLG = yes,
+ NLG = have_non_local_gotos
+ ;
+ OptNLG = no,
+ NLG = do_not_have_non_local_gotos
+ ),
+ globals.lookup_bool_option(Globals, asm_labels, OptASM),
+ (
+ OptASM = yes,
+ ASM = have_asm_labels
+ ;
+ OptASM = no,
+ ASM = do_not_have_asm_labels
+ ),
+ globals.lookup_bool_option(Globals, static_ground_cells, OptSGCell),
+ (
+ OptSGCell = yes,
+ SGCell = have_static_ground_cells
+ ;
+ OptSGCell = no,
+ SGCell = do_not_have_static_ground_cells
+ ),
+ globals.lookup_bool_option(Globals, unboxed_float, OptUBF),
+ (
+ OptUBF = yes,
+ UBF = have_unboxed_floats
+ ;
+ OptUBF = no,
+ UBF = do_not_have_unboxed_floats
+ ),
+ globals.lookup_bool_option(Globals, static_ground_floats, OptSGFloat),
+ (
+ OptSGFloat = yes,
+ SGFloat = have_static_ground_floats
+ ;
+ OptSGFloat = no,
+ SGFloat = do_not_have_static_ground_floats
+ ),
+ globals.lookup_bool_option(Globals, static_code_addresses,
+ OptStaticCodeAddr),
+ (
+ OptStaticCodeAddr = yes,
+ StaticCodeAddrs = have_static_code_addresses
+ ;
+ OptStaticCodeAddr = no,
+ StaticCodeAddrs = do_not_have_static_code_addresses
+ ),
+ ExprnOpts = exprn_opts(NLG, ASM, UBF, SGCell, SGFloat, StaticCodeAddrs).
+
:- pred init_maybe_trace_info(trace_level::in, globals::in,
module_info::in, pred_info::in, proc_info::in, trace_slot_info::out,
code_info::in, code_info::out) is det.
@@ -591,6 +651,7 @@
get_globals(CI, CI ^ code_info_static ^ cis_globals).
get_module_info(CI, CI ^ code_info_static ^ cis_module_info).
+get_exprn_opts(CI, CI ^ code_info_static ^ cis_exprn_opts).
get_pred_id(CI, CI ^ code_info_static ^ cis_pred_id).
get_proc_id(CI, CI ^ code_info_static ^ cis_proc_id).
get_pred_info(CI, CI ^ code_info_static ^ cis_pred_info).
@@ -3660,13 +3721,15 @@
get_var_locn_info(!.CI, VarLocnInfo0),
get_static_cell_info(!.CI, StaticCellInfo),
get_module_info(!.CI, ModuleInfo),
- var_locn_assign_lval_to_var(ModuleInfo, Var, Lval, StaticCellInfo, Code,
- VarLocnInfo0, VarLocnInfo),
+ var_locn_assign_lval_to_var(ModuleInfo, Var, Lval,
+ StaticCellInfo, Code, VarLocnInfo0, VarLocnInfo),
set_var_locn_info(VarLocnInfo, !CI).
assign_const_to_var(Var, ConstRval, !CI) :-
get_var_locn_info(!.CI, VarLocnInfo0),
- var_locn_assign_const_to_var(Var, ConstRval, VarLocnInfo0, VarLocnInfo),
+ get_exprn_opts(!.CI, ExprnOpts),
+ var_locn_assign_const_to_var(ExprnOpts, Var, ConstRval,
+ VarLocnInfo0, VarLocnInfo),
set_var_locn_info(VarLocnInfo, !CI).
assign_expr_to_var(Var, Rval, Code, !CI) :-
@@ -3688,8 +3751,9 @@
get_var_locn_info(!.CI, VarLocnInfo0),
get_static_cell_info(!.CI, StaticCellInfo0),
get_module_info(!.CI, ModuleInfo),
- var_locn_assign_cell_to_var(ModuleInfo, Var, ReserveWordAtStart, Ptag,
- MaybeRvals, HowToConstruct, MaybeSize, FieldAddrs, TypeMsg,
+ get_exprn_opts(!.CI, ExprnOpts),
+ var_locn_assign_cell_to_var(ModuleInfo, ExprnOpts, Var, ReserveWordAtStart,
+ Ptag, MaybeRvals, HowToConstruct, MaybeSize, FieldAddrs, TypeMsg,
MayUseAtomic, Label, Code, StaticCellInfo0, StaticCellInfo,
VarLocnInfo0, VarLocnInfo),
set_static_cell_info(StaticCellInfo, !CI),
Index: compiler/disj_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/disj_gen.m,v
retrieving revision 1.109
diff -u -b -r1.109 disj_gen.m
--- compiler/disj_gen.m 23 Jan 2008 11:44:45 -0000 1.109
+++ compiler/disj_gen.m 30 May 2008 08:40:24 -0000
@@ -43,6 +43,7 @@
:- import_module libs.tree.
:- import_module ll_backend.code_gen.
:- import_module ll_backend.continuation_info.
+:- import_module ll_backend.exprn_aux.
:- import_module ll_backend.global_data.
:- import_module ll_backend.lookup_util.
:- import_module ll_backend.trace_gen.
@@ -133,7 +134,7 @@
% Lookup disjunctions rely on static ground terms to work.
get_globals(!.CI, Globals),
- globals.lookup_bool_option(Globals, static_ground_terms, yes),
+ globals.lookup_bool_option(Globals, static_ground_cells, yes),
% XXX The code to generate lookup disjunctions hasn't yet been updated
% to handle region operations.
@@ -182,9 +183,9 @@
),
reset_to_position(CurPos, !CI),
- get_globals(!.CI, Globals),
- globals.lookup_bool_option(Globals, unboxed_float, UnboxFloat),
- find_general_llds_types(UnboxFloat, OutTypes, Solns, LLDSTypes),
+ get_exprn_opts(!.CI, ExprnOpts),
+ UnboxFloats = get_unboxed_floats(ExprnOpts),
+ find_general_llds_types(UnboxFloats, OutTypes, Solns, LLDSTypes),
LookupDisjInfo = lookup_disj_info(OutVars, StoreMap, MaybeEnd, Liveness,
CurSlot, ResumeMap, FlushCode, SaveTicketCode, MaybeTicketSlot,
SaveHpCode, MaybeHpSlot, HijackInfo, PrepareHijackCode,
Index: compiler/exprn_aux.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/exprn_aux.m,v
retrieving revision 1.87
diff -u -b -r1.87 exprn_aux.m
--- compiler/exprn_aux.m 11 Feb 2008 03:56:07 -0000 1.87
+++ compiler/exprn_aux.m 30 May 2008 16:42:37 -0000
@@ -13,7 +13,6 @@
:- module ll_backend.exprn_aux.
:- interface.
-:- import_module libs.options.
:- import_module ll_backend.llds.
:- import_module parse_tree.prog_data.
@@ -23,16 +22,6 @@
%-----------------------------------------------------------------------------%
-:- type exprn_opts
- ---> nlg_asm_sgt_ubf(
- non_local_gotos :: bool,
- asm_labels :: bool,
- static_ground_terms :: bool,
- unboxed_float :: bool
- ).
-
-:- pred init_exprn_opts(option_table::in, exprn_opts::out) is det.
-
% Determine whether an rval_const can be used as the initializer
% of a C static constant.
%
@@ -121,36 +110,22 @@
%-----------------------------------------------------------------------------%
-init_exprn_opts(Options, ExprnOpts) :-
- getopt_io.lookup_bool_option(Options, gcc_non_local_gotos, NLG),
- getopt_io.lookup_bool_option(Options, asm_labels, ASM),
- getopt_io.lookup_bool_option(Options, static_ground_terms, SGT),
- getopt_io.lookup_bool_option(Options, unboxed_float, UBF),
- ExprnOpts = nlg_asm_sgt_ubf(NLG, ASM, SGT, UBF).
-
% Determine whether a const (well, what _we_ consider to be a const)
% is constant as far as the C compiler is concerned -- specifically,
-% determine whether it can be used as the initializer of a C static
-% constant.
+% determine whether it can be used as the initializer of a C static constant.
const_is_constant(llconst_true, _, yes).
const_is_constant(llconst_false, _, yes).
const_is_constant(llconst_int(_), _, yes).
const_is_constant(llconst_foreign(_, _), _, yes).
const_is_constant(llconst_float(_), ExprnOpts, IsConst) :-
- ExprnOpts = nlg_asm_sgt_ubf(_NLG, _ASM, StaticGroundTerms, UnboxedFloat),
+ SGFloats = ExprnOpts ^ static_ground_floats,
(
- UnboxedFloat = yes,
- % If we're using unboxed (single-precision) floats,
- % floating point values are always constants.
+ SGFloats = have_static_ground_floats,
IsConst = yes
;
- UnboxedFloat = no,
- % If we're using boxed floats, then we can generate a static constant
- % variable to hold a float constant, and gcc doesn't mind us converting
- % from its address to word in a static initializer. However, we only do
- % this if --static-ground-terms is enabled.
- IsConst = StaticGroundTerms
+ SGFloats = do_not_have_static_ground_floats,
+ IsConst = no
).
const_is_constant(llconst_string(_), _, yes).
const_is_constant(llconst_multi_string(_), _, yes).
@@ -161,11 +136,16 @@
:- pred addr_is_constant(code_addr::in, exprn_opts::in, bool::out) is det.
addr_is_constant(code_label(Label), ExprnOpts, IsConst) :-
- ExprnOpts = nlg_asm_sgt_ubf(NonLocalGotos, AsmLabels, _SGT, _UBF),
- label_is_constant(Label, NonLocalGotos, AsmLabels, IsConst).
+ label_is_constant(Label, ExprnOpts, IsConst).
addr_is_constant(code_imported_proc(_), ExprnOpts, IsConst) :-
- ExprnOpts = nlg_asm_sgt_ubf(NonLocalGotos, AsmLabels, _SGT, _UBF),
- globals.imported_is_constant(NonLocalGotos, AsmLabels, IsConst).
+ StaticCodeAddrs = ExprnOpts ^ static_code_addresses,
+ (
+ StaticCodeAddrs = have_static_code_addresses,
+ IsConst = yes
+ ;
+ StaticCodeAddrs = do_not_have_static_code_addresses,
+ IsConst = no
+ ).
addr_is_constant(code_succip, _, no).
addr_is_constant(do_succeed(_), _, no).
addr_is_constant(do_redo, _, no).
@@ -176,17 +156,32 @@
addr_is_constant(do_call_class_method(_), _, no).
addr_is_constant(do_not_reached, _, no).
-:- pred label_is_constant(label::in, bool::in, bool::in, bool::out) is det.
+:- pred label_is_constant(label::in, exprn_opts::in, bool::out) is det.
+
+label_is_constant(Label, ExprnOpts, IsConst) :-
+ (
+ Label = entry_label(EntryLabelType, _),
+ (
-label_is_constant(entry_label(entry_label_exported, _),
- NonLocalGotos, AsmLabels, IsConst) :-
- globals.imported_is_constant(NonLocalGotos, AsmLabels, IsConst).
-label_is_constant(entry_label(entry_label_local, _),
- NonLocalGotos, AsmLabels, IsConst) :-
- globals.imported_is_constant(NonLocalGotos, AsmLabels, IsConst).
-label_is_constant(entry_label(entry_label_c_local, _),
- _NonLocalGotos, _AsmLabels, yes).
-label_is_constant(internal_label(_, _), _NonLocalGotos, _AsmLabels, yes).
+ ( EntryLabelType = entry_label_exported
+ ; EntryLabelType = entry_label_local
+ ),
+ StaticCodeAddrs = ExprnOpts ^ static_code_addresses,
+ (
+ StaticCodeAddrs = have_static_code_addresses,
+ IsConst = yes
+ ;
+ StaticCodeAddrs = do_not_have_static_code_addresses,
+ IsConst = no
+ )
+ ;
+ EntryLabelType = entry_label_c_local,
+ IsConst = yes
+ )
+ ;
+ Label = internal_label(_, _),
+ IsConst = yes
+ ).
%-----------------------------------------------------------------------------%
Index: compiler/global_data.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/global_data.m,v
retrieving revision 1.36
diff -u -b -r1.36 global_data.m
--- compiler/global_data.m 11 Feb 2008 03:56:08 -0000 1.36
+++ compiler/global_data.m 30 May 2008 08:03:58 -0000
@@ -69,7 +69,8 @@
:- type static_cell_info.
-:- func init_static_cell_info(module_name, bool, bool) = static_cell_info.
+:- func init_static_cell_info(module_name, have_unboxed_floats, bool)
+ = static_cell_info.
:- pred add_scalar_static_cell(assoc_list(rval, llds_type)::in, data_addr::out,
static_cell_info::in, static_cell_info::out) is det.
@@ -77,7 +78,7 @@
:- pred add_scalar_static_cell_natural_types(list(rval)::in, data_addr::out,
static_cell_info::in, static_cell_info::out) is det.
-:- pred find_general_llds_types(bool::in, list(mer_type)::in,
+:- pred find_general_llds_types(have_unboxed_floats::in, list(mer_type)::in,
list(list(rval))::in, list(llds_type)::out) is semidet.
:- pred add_vector_static_cell(list(llds_type)::in,
@@ -97,7 +98,7 @@
% is data_ptr (i.e. the type of the boxed value) rather than float
% (the type of the unboxed value).
%
-:- pred rval_type_as_arg(rval::in, bool::in, llds_type::out) is det.
+:- func rval_type_as_arg(have_unboxed_floats, rval) = llds_type.
%-----------------------------------------------------------------------------%
@@ -263,7 +264,7 @@
:- type static_cell_sub_info
---> static_cell_sub_info(
module_name :: module_name, % base file name
- unbox_float :: bool,
+ unbox_float :: have_unboxed_floats,
common_data :: bool
).
@@ -385,7 +386,7 @@
find_general_llds_types_2(UnboxFloat, Types, Vectors,
LLDSTypes0, LLDSTypes).
-:- pred find_general_llds_types_2(bool::in, list(mer_type)::in,
+:- pred find_general_llds_types_2(have_unboxed_floats::in, list(mer_type)::in,
list(list(rval))::in, list(llds_type)::in, list(llds_type)::out)
is semidet.
@@ -394,8 +395,9 @@
find_general_llds_types_in_cell(UnboxFloat, Types, Vector, !LLDSTypes),
find_general_llds_types_2(UnboxFloat, Types, Vectors, !LLDSTypes).
-:- pred find_general_llds_types_in_cell(bool::in, list(mer_type)::in,
- list(rval)::in, list(llds_type)::in, list(llds_type)::out) is semidet.
+:- pred find_general_llds_types_in_cell(have_unboxed_floats::in,
+ list(mer_type)::in, list(rval)::in, list(llds_type)::in,
+ list(llds_type)::out) is semidet.
find_general_llds_types_in_cell(_UnboxFloat, [], [], [], []).
find_general_llds_types_in_cell(UnboxFloat, [_Type | Types], [Rval | Rvals],
@@ -597,24 +599,24 @@
%-----------------------------------------------------------------------------%
-rval_type_as_arg(Rval, UnboxedFloat, Type) :-
+rval_type_as_arg(UnboxedFloat, Rval) = Type :-
natural_type(UnboxedFloat, Rval, Type).
-:- pred natural_type(bool::in, rval::in, llds_type::out) is det.
+:- pred natural_type(have_unboxed_floats::in, rval::in, llds_type::out) is det.
natural_type(UnboxFloat, Rval, Type) :-
llds.rval_type(Rval, Type0),
(
Type0 = float,
- UnboxFloat = no
+ UnboxFloat = do_not_have_unboxed_floats
->
Type = data_ptr
;
Type = Type0
).
-:- pred associate_natural_type(bool::in, rval::in, pair(rval, llds_type)::out)
- is det.
+:- pred associate_natural_type(have_unboxed_floats::in, rval::in,
+ pair(rval, llds_type)::out) is det.
associate_natural_type(UnboxFloat, Rval, Rval - Type) :-
natural_type(UnboxFloat, Rval, Type).
Index: compiler/globals.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/globals.m,v
retrieving revision 1.88
diff -u -b -r1.88 globals.m
--- compiler/globals.m 18 Feb 2008 23:57:44 -0000 1.88
+++ compiler/globals.m 30 May 2008 07:25:00 -0000
@@ -195,22 +195,11 @@
% More complex options
%
- % Check if static code addresses are available in the
- % current grade of compilation.
- %
-:- pred have_static_code_addresses(globals::in, bool::out) is det.
-
% Check if we should include variable information in the layout
% structures of call return sites.
%
:- pred want_return_var_layouts(globals::in, bool::out) is det.
- % imported_is_constant(NonLocalGotos, AsmLabels, IsConst)
- % figures out whether an imported label address is a constant.
- % This depends on how we treat labels.
- %
-:- pred imported_is_constant(bool::in, bool::in, bool::out) is det.
-
% Check that the current grade supports tabling.
%
:- pred current_grade_supports_tabling(globals::in, bool::out) is det.
@@ -527,18 +516,6 @@
%-----------------------------------------------------------------------------%
-have_static_code_addresses(Globals, IsConst) :-
- get_options(Globals, OptionTable),
- have_static_code_addresses_2(OptionTable, IsConst).
-
-:- pred have_static_code_addresses_2(option_table::in, bool::out) is det.
-
-have_static_code_addresses_2(OptionTable, IsConst) :-
- getopt_io.lookup_bool_option(OptionTable, gcc_non_local_gotos,
- NonLocalGotos),
- getopt_io.lookup_bool_option(OptionTable, asm_labels, AsmLabels),
- imported_is_constant(NonLocalGotos, AsmLabels, IsConst).
-
current_grade_supports_tabling(Globals, TablingSupported) :-
globals.get_target(Globals, Target),
globals.get_gc_method(Globals, GC_Method),
@@ -619,26 +596,6 @@
WantReturnLayouts = no
).
- % The logic of this function and how it is used to select the default
- % type_info method must agree with the code in runtime/typeinfo.h.
-
-imported_is_constant(NonLocalGotos, AsmLabels, IsConst) :-
- (
- NonLocalGotos = yes,
- AsmLabels = no
- ->
- %
- % With non-local gotos but no asm labels, jumps to code addresses
- % in different c_modules must be done via global variables; the value
- % of these global variables is not constant (i.e. not computable at
- % load time), since they can't be initialized until we call
- % init_modules().
- %
- IsConst = no
- ;
- IsConst = yes
- ).
-
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.319
diff -u -b -r1.319 handle_options.m
--- compiler/handle_options.m 16 May 2008 08:10:51 -0000 1.319
+++ compiler/handle_options.m 30 May 2008 16:39:37 -0000
@@ -523,7 +523,7 @@
globals.set_option(unboxed_enums, bool(no), !Globals),
globals.set_option(unboxed_no_tag_types, bool(no), !Globals),
% globals.set_option(num_reserved_addresses, int(1), !Globals)
- globals.set_option(static_ground_terms, bool(no), !Globals),
+ globals.set_option(static_ground_cells, bool(no), !Globals),
globals.set_option(libgrade_install_check, bool(no), !Globals),
(
@@ -624,7 +624,7 @@
globals.set_option(det_copy_out, bool(yes), !Globals),
globals.set_option(num_tag_bits, int(0), !Globals),
globals.set_option(unboxed_no_tag_types, bool(no), !Globals),
- globals.set_option(static_ground_terms, bool(no), !Globals),
+ globals.set_option(static_ground_cells, bool(no), !Globals),
globals.set_option(put_nondet_env_on_heap, bool(yes), !Globals),
globals.set_option(libgrade_install_check, bool(no), !Globals),
@@ -1638,9 +1638,7 @@
globals.lookup_string_option(!.Globals, fullarch, FullArch),
- %
% Add the standard library directory.
- %
globals.lookup_maybe_string_option(!.Globals,
mercury_standard_library_directory, MaybeStdLibDir),
(
@@ -1649,28 +1647,21 @@
globals.set_options(option_table_add_mercury_library_directory(
OptionTable2, StdLibDir), !Globals),
- %
- % Add `-L' and `-R' options for the location
- % of the GC libraries.
- %
+ % Add `-L' and `-R' options for the location of the GC libraries.
globals.lookup_accumulating_option(!.Globals,
link_library_directories, LinkLibDirs0),
globals.set_option(link_library_directories,
- accumulating([StdLibDir/"lib" | LinkLibDirs0]),
- !Globals),
+ accumulating([StdLibDir/"lib" | LinkLibDirs0]), !Globals),
globals.lookup_accumulating_option(!.Globals,
runtime_link_library_directories, Rpath0),
globals.set_option(runtime_link_library_directories,
accumulating([StdLibDir/"lib" | Rpath0]), !Globals)
-
;
MaybeStdLibDir = no
),
- %
% Add the path to mercury_conf.h.
- %
globals.lookup_maybe_string_option(!.Globals,
mercury_configuration_directory, MaybeConfDir),
(
@@ -1683,9 +1674,7 @@
MaybeConfDir = no
),
- %
% Find the configuration file.
- %
globals.lookup_maybe_string_option(!.Globals, config_file,
ConfigFile),
% yes("") means `--config-file' was not passed on the command line.
@@ -1702,11 +1691,9 @@
true
),
- %
% Handle the `.opt', C and Erlang header, init file and library search
% directories for installed libraries. These couldn't be handled by
% options.m because they are grade dependent.
- %
globals.lookup_accumulating_option(!.Globals,
mercury_library_directories, MercuryLibDirs),
grade_directory_component(!.Globals, GradeString),
@@ -1789,7 +1776,6 @@
ToGradeSubdir = (func(Dir) = Dir/"Mercury"/GradeString/FullArch),
(
UseGradeSubdirs = yes,
- %
% With `--use-grade-subdirs', `.opt', `.trans_opt' and
% `.mih' files are placed in a directory named
% `Mercury/<grade>/<fullarch>/Mercury/<ext>s'.
@@ -1798,12 +1784,10 @@
% for installed files work, so we need to add
% `--intermod-directory Mercury/<grade>/<fullarch>'
% to find the `.opt' files in the current directory.
- %
GradeSubdir = "Mercury"/GradeString/FullArch,
- %
+
% Directories listed with --search-library-files-directories need
% to be treated in the same way as the current directory.
- %
SearchLibFilesGradeSubdirs = list.map(ToGradeSubdir,
SearchLibFilesDirs),
IntermodDirs3 = [GradeSubdir] ++ SearchLibFilesGradeSubdirs ++
@@ -1821,12 +1805,10 @@
init_file_directories, InitDirs2),
(
UseGradeSubdirs = yes,
- %
% With --use-grade-subdirs we need to search in
% `Mercury/<grade>/<fullarch>/Mercury/lib' for libraries and
% `Mercury/<grade>/<fullarch>/Mercury/inits' for init files,
% for each directory listed with --search-library-files-directory.
- %
ToGradeLibDir = (func(Dir) = ToGradeSubdir(Dir)/"Mercury"/"lib"),
SearchGradeLibDirs = list.map(ToGradeLibDir, SearchLibFilesDirs),
LinkLibDirs = SearchGradeLibDirs ++ LinkLibDirs2,
@@ -1845,12 +1827,10 @@
globals.set_option(init_file_directories,
accumulating(InitDirs), !Globals),
- %
% When searching for a header (.mh, .mih, .hrl) file,
% module_name_to_file_name uses the plain header name, so we need to
% add the full path to the header files in the current directory,
% and any directories listed with --search-library-files-directory.
- %
globals.lookup_bool_option(!.Globals, use_subdirs, UseSubdirs),
(
(
@@ -2032,7 +2012,48 @@
globals.set_option(optimize_repeat, int(1), !Globals)
;
true
- ).
+ ),
+
+ % The setting of static_ground_floats is governed only by the settings
+ % of unboxed_float and static_ground_cells.
+ globals.lookup_bool_option(!.Globals, unboxed_float, UnboxedFloat),
+ (
+ UnboxedFloat = yes,
+ % If we're using unboxed (MR_Word-sized) floats, floating point values
+ % are always constants.
+ StaticGroundFloats = yes
+ ;
+ UnboxedFloat = no,
+ % If we're using boxed floats, then we can generate a static constant
+ % variable to hold a float constant, and gcc doesn't mind us converting
+ % from its address to MR_Word in a static initializer. In theory,
+ % we should do this with --static-ground-terms. However, the code
+ % generator does not yet handle the dynamic creation of boxed float
+ % constants, and assumes that binding a variable to a constant
+ % generates no code.
+ StaticGroundFloats = yes
+ ),
+ globals.set_option(static_ground_floats, bool(StaticGroundFloats),
+ !Globals),
+
+ % The setting of static_code_addresses is governed only by the settings
+ % of gcc_non_local_gotos and asm_labels.
+ globals.lookup_bool_option(!.Globals, gcc_non_local_gotos, NonLocalGotos),
+ globals.lookup_bool_option(!.Globals, asm_labels, AsmLabels),
+ (
+ NonLocalGotos = yes,
+ AsmLabels = no
+ ->
+ % With non-local gotos but no asm labels, jumps to code addresses
+ % in different c_modules must be done via global variables; the value
+ % of these global variables is not constant (i.e. not computable at
+ % load time), since they can't be initialized until we call
+ % init_modules().
+ StaticCodeAddrs = no
+ ;
+ StaticCodeAddrs = yes
+ ),
+ globals.set_option(static_code_addresses, bool(StaticCodeAddrs), !Globals).
% option_implies(SourceBoolOption, ImpliedOption, ImpliedOptionValue):
% If the SourceBoolOption is set to yes, then the ImpliedOption is set
Index: compiler/liveness.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/liveness.m,v
retrieving revision 1.164
diff -u -b -r1.164 liveness.m
--- compiler/liveness.m 27 Feb 2008 07:23:08 -0000 1.164
+++ compiler/liveness.m 29 May 2008 03:03:30 -0000
@@ -217,9 +217,8 @@
%-----------------------------------------------------------------------------%
:- typeclass debug_liveness_io(T) where [
- pred maybe_debug_liveness(string::in, int::in, int::in,
- hlds_goal::in, prog_varset::in, module_info::in,
- T::di, T::uo) is det
+ pred maybe_debug_liveness(string::in, int::in, int::in, hlds_goal::in,
+ prog_varset::in, module_info::in, T::di, T::uo) is det
].
:- instance debug_liveness_io(io) where [
@@ -254,8 +253,8 @@
detect_liveness_preds_parallel_3(PredIds, HLDS0, !HLDS) :-
list.map(detect_liveness_pred(HLDS0), PredIds, PredInfos),
- list.foldl_corresponding(module_info_set_pred_info,
- PredIds, PredInfos, !HLDS).
+ list.foldl_corresponding(module_info_set_pred_info, PredIds, PredInfos,
+ !HLDS).
:- pred detect_liveness_pred(module_info::in, pred_id::in, pred_info::out)
is det.
@@ -343,8 +342,7 @@
proc_info_set_liveness_info(Liveness0, !ProcInfo).
:- pred io_maybe_debug_liveness(string::in, int::in, int::in,
- hlds_goal::in, prog_varset::in, module_info::in,
- io::di, io::uo) is det.
+ hlds_goal::in, prog_varset::in, module_info::in, io::di, io::uo) is det.
io_maybe_debug_liveness(Message, DebugLiveness, PredIdInt,
Goal, VarSet, ModuleInfo, !IO) :-
@@ -401,8 +399,8 @@
set.difference(FinalLiveness, Liveness, PostDeaths),
set.difference(Liveness, FinalLiveness, PostBirths)
),
- % We initialize all the fields in order to obliterate any
- % annotations left by a previous invocation of this module.
+ % We initialize all the fields in order to obliterate any annotations
+ % left by a previous invocation of this module.
goal_info_initialize_liveness_info(PreBirths, PostBirths,
PreDeaths, PostDeaths, no_resume_point, GoalInfo0, GoalInfo).
@@ -1657,13 +1655,13 @@
;
unexpected(this_file, "initial_liveness: list length mismatch")
),
- %
+
% If a variable is unused in the goal, it shouldn't be in the initial
% liveness. (If we allowed it to start live, it wouldn't ever become dead,
% because it would have to be used to be killed). So we intersect the
% headvars with the non-locals and (if doing typeinfo liveness calculation)
% their typeinfo vars.
- %
+
module_info_get_globals(ModuleInfo, Globals),
proc_info_get_goal(ProcInfo, hlds_goal(_Goal, GoalInfo)),
NonLocals0 = goal_info_get_code_gen_nonlocals(GoalInfo),
@@ -1764,14 +1762,13 @@
;
true
),
- find_value_giving_occurrences(Vars, LiveInfo, InstMapDelta,
- !ValueVars).
+ find_value_giving_occurrences(Vars, LiveInfo, InstMapDelta, !ValueVars).
%-----------------------------------------------------------------------------%
% Get the nonlocals, and, if doing typeinfo liveness, add the
% typeinfo vars for the nonlocals.
-
+ %
:- pred liveness.get_nonlocals_and_typeinfos(live_info::in,
hlds_goal_info::in, set(prog_var)::out, set(prog_var)::out) is det.
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.360
diff -u -b -r1.360 llds.m
--- compiler/llds.m 11 Feb 2008 21:25:57 -0000 1.360
+++ compiler/llds.m 30 May 2008 16:42:55 -0000
@@ -1309,6 +1309,47 @@
:- func get_defining_module_name(proc_label) = module_name.
+:- type have_non_local_gotos
+ ---> have_non_local_gotos
+ ; do_not_have_non_local_gotos.
+
+:- type have_asm_labels
+ ---> have_asm_labels
+ ; do_not_have_asm_labels.
+
+:- type have_unboxed_floats
+ ---> have_unboxed_floats
+ ; do_not_have_unboxed_floats.
+
+:- type have_static_ground_cells
+ ---> have_static_ground_cells
+ ; do_not_have_static_ground_cells.
+
+:- type have_static_ground_floats
+ ---> have_static_ground_floats
+ ; do_not_have_static_ground_floats.
+
+:- type have_static_code_addresses
+ ---> have_static_code_addresses
+ ; do_not_have_static_code_addresses.
+
+:- type exprn_opts
+ ---> exprn_opts(
+ non_local_gotos :: have_non_local_gotos,
+ asm_labels :: have_asm_labels,
+ unboxed_floats :: have_unboxed_floats,
+ static_ground_cells :: have_static_ground_cells,
+ static_ground_floats :: have_static_ground_floats,
+ static_code_addresses :: have_static_code_addresses
+ ).
+
+:- func get_nonlocal_gotos(exprn_opts) = have_non_local_gotos.
+:- func get_asm_labels(exprn_opts) = have_asm_labels.
+:- func get_unboxed_floats(exprn_opts) = have_unboxed_floats.
+:- func get_static_ground_cells(exprn_opts) = have_static_ground_cells.
+:- func get_static_ground_floats(exprn_opts) = have_static_ground_floats.
+:- func get_static_code_addresses(exprn_opts) = have_static_code_addresses.
+
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -1507,6 +1548,13 @@
get_defining_module_name(special_proc_label(ModuleName, _, _, _, _, _))
= ModuleName.
+get_nonlocal_gotos(ExprnOpts) = ExprnOpts ^ non_local_gotos.
+get_asm_labels(ExprnOpts) = ExprnOpts ^ asm_labels.
+get_static_ground_cells(ExprnOpts) = ExprnOpts ^ static_ground_cells.
+get_unboxed_floats(ExprnOpts) = ExprnOpts ^ unboxed_floats.
+get_static_ground_floats(ExprnOpts) = ExprnOpts ^ static_ground_floats.
+get_static_code_addresses(ExprnOpts) = ExprnOpts ^ static_code_addresses.
+
%-----------------------------------------------------------------------------%
:- func this_file = string.
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.325
diff -u -b -r1.325 llds_out.m
--- compiler/llds_out.m 11 Feb 2008 21:25:58 -0000 1.325
+++ compiler/llds_out.m 31 May 2008 01:44:49 -0000
@@ -3311,16 +3311,16 @@
output_data_addr_decls_format(DataAddr, FirstIndent, LaterIndent,
!N, !DeclSet, !IO)
; Const = llconst_float(FloatVal) ->
- % If floats are boxed, and the static ground terms option is enabled,
- % then for each float constant which we might want to box we declare
- % a static const variable holding that constant.
+ % If floats are boxed, but are allocated statically, then for each
+ % float constant which we might want to box we declare a static const
+ % variable holding that constant.
globals.io_lookup_bool_option(unboxed_float, UnboxedFloat, !IO),
- globals.io_lookup_bool_option(static_ground_terms, StaticGroundTerms,
+ globals.io_lookup_bool_option(static_ground_floats, StaticGroundFloats,
!IO),
(
UnboxedFloat = no,
- StaticGroundTerms = yes
+ StaticGroundFloats = yes
->
float_literal_name(FloatVal, FloatName),
FloatLabel = decl_float_label(FloatName),
@@ -3359,11 +3359,11 @@
c_util.binop_category_string(Op, Category, OpStr),
( Category = float_arith_binop ->
globals.io_lookup_bool_option(unboxed_float, UnboxFloat, !IO),
- globals.io_lookup_bool_option(static_ground_terms, StaticGroundTerms,
+ globals.io_lookup_bool_option(static_ground_floats, StaticGroundFloats,
!IO),
(
UnboxFloat = no,
- StaticGroundTerms = yes,
+ StaticGroundFloats = yes,
float_const_binop_expr_name(Op, Rval1, Rval2, FloatName)
->
FloatLabel = decl_float_label(FloatName),
@@ -4074,7 +4074,7 @@
c_data_const_string(Globals, InclCodeAddr) =
(
InclCodeAddr = yes,
- globals.have_static_code_addresses(Globals, no)
+ globals.lookup_bool_option(Globals, static_code_addresses, no)
->
""
;
@@ -4839,15 +4839,15 @@
:- pred output_float_rval(rval::in, bool::in, io::di, io::uo) is det.
output_float_rval(Rval, IsPtr, !IO) :-
- % For float constant expressions, if we're using boxed boxed floats
- % and --static-ground-terms is enabled, we just refer to the static const
+ % For float constant expressions, if we're using boxed floats
+ % and --static-ground-floats is enabled, we just refer to the static const
% which we declared earlier.
globals.io_lookup_bool_option(unboxed_float, UnboxFloat, !IO),
- globals.io_lookup_bool_option(static_ground_terms, StaticGroundTerms,
+ globals.io_lookup_bool_option(static_ground_floats, StaticGroundFloats,
!IO),
(
UnboxFloat = no,
- StaticGroundTerms = yes,
+ StaticGroundFloats = yes,
float_const_expr_name(Rval, FloatName)
->
(
@@ -5078,10 +5078,20 @@
unexpected(this_file, "output_rval: compound_compare_binop")
;
Category = string_compare_binop,
- io.write_string("(strcmp((char *)", !IO),
- output_rval_as_type(X, word, !IO),
- io.write_string(", (char *)", !IO),
- output_rval_as_type(Y, word, !IO),
+ io.write_string("(strcmp(", !IO),
+ ( X = const(llconst_string(XConst)) ->
+ output_rval_const(llconst_string(XConst), !IO)
+ ;
+ io.write_string("(char *) ", !IO),
+ output_rval_as_type(X, data_ptr, !IO)
+ ),
+ io.write_string(", ", !IO),
+ ( Y = const(llconst_string(YConst)) ->
+ output_rval_const(llconst_string(YConst), !IO)
+ ;
+ io.write_string("(char *) ", !IO),
+ output_rval_as_type(Y, data_ptr, !IO)
+ ),
io.write_string(")", !IO),
io.write_string(" ", !IO),
io.write_string(OpStr, !IO),
Index: compiler/lookup_switch.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/lookup_switch.m,v
retrieving revision 1.80
diff -u -b -r1.80 lookup_switch.m
--- compiler/lookup_switch.m 27 Feb 2008 07:23:08 -0000 1.80
+++ compiler/lookup_switch.m 30 May 2008 09:13:10 -0000
@@ -167,7 +167,7 @@
% it right, so, lets just use a simple one - no static ground terms,
% no lookup switch.
get_globals(!.CI, Globals),
- globals.lookup_bool_option(Globals, static_ground_terms, yes),
+ globals.lookup_bool_option(Globals, static_ground_cells, yes),
CodeModel = goal_info_get_code_model(GoalInfo),
(
@@ -261,9 +261,9 @@
% we only use CaseValues to find out the right LLDSTypes, this is OK.
project_solns_to_rval_lists(CaseSolns, [], CaseValues)
),
- get_globals(!.CI, Globals),
- globals.lookup_bool_option(Globals, unboxed_float, UnboxFloat),
- find_general_llds_types(UnboxFloat, OutTypes, CaseValues, LLDSTypes),
+ get_exprn_opts(!.CI, ExprnOpts),
+ UnboxFloats = get_unboxed_floats(ExprnOpts),
+ find_general_llds_types(UnboxFloats, OutTypes, CaseValues, LLDSTypes),
LookupSwitchInfo = lookup_switch_info(FirstVal, LastVal, CaseConsts,
OutVars, LLDSTypes, NeedRangeCheck, NeedBitVecCheck, Liveness).
Index: compiler/lookup_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/lookup_util.m,v
retrieving revision 1.6
diff -u -b -r1.6 lookup_util.m
--- compiler/lookup_util.m 26 Nov 2007 05:13:20 -0000 1.6
+++ compiler/lookup_util.m 30 May 2008 09:08:08 -0000
@@ -153,9 +153,7 @@
tree.tree_of_lists_is_empty(Code),
get_forward_live_vars(!.CI, Liveness),
- get_globals(!.CI, Globals),
- globals.get_options(Globals, Options),
- exprn_aux.init_exprn_opts(Options, ExprnOpts),
+ get_exprn_opts(!.CI, ExprnOpts),
get_arm_rvals(Vars, CaseRvals, !CI, ExprnOpts),
(
SetToUnknown = no
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.470
diff -u -b -r1.470 mercury_compile.m
--- compiler/mercury_compile.m 28 May 2008 00:52:28 -0000 1.470
+++ compiler/mercury_compile.m 30 May 2008 16:40:23 -0000
@@ -112,6 +112,7 @@
:- import_module ll_backend.follow_code.
:- import_module ll_backend.global_data.
:- import_module ll_backend.liveness.
+:- import_module ll_backend.llds.
:- import_module ll_backend.llds_out.
:- import_module ll_backend.optimize.
:- import_module ll_backend.proc_gen.
@@ -2759,9 +2760,16 @@
backend_pass(!HLDS, GlobalData, LLDS, !DumpInfo, !IO) :-
module_info_get_name(!.HLDS, ModuleName),
- globals.io_lookup_bool_option(unboxed_float, UnboxFloat, !IO),
+ globals.io_lookup_bool_option(unboxed_float, OptUnboxFloat, !IO),
globals.io_lookup_bool_option(common_data, DoCommonData, !IO),
- StaticCellInfo0 = init_static_cell_info(ModuleName, UnboxFloat,
+ (
+ OptUnboxFloat = yes,
+ UnboxFloats = have_unboxed_floats
+ ;
+ OptUnboxFloat = no,
+ UnboxFloats = do_not_have_unboxed_floats
+ ),
+ StaticCellInfo0 = init_static_cell_info(ModuleName, UnboxFloats,
DoCommonData),
global_data_init(StaticCellInfo0, GlobalData0),
@@ -3474,9 +3482,9 @@
module_info::in, module_info::out, io::di, io::uo) is det.
maybe_mark_static_terms(Verbose, Stats, !HLDS, !IO) :-
- globals.io_lookup_bool_option(static_ground_terms, StaticGroundTerms, !IO),
+ globals.io_lookup_bool_option(static_ground_cells, SGCells, !IO),
(
- StaticGroundTerms = yes,
+ SGCells = yes,
maybe_write_string(Verbose, "% Marking static ground terms...\n", !IO),
maybe_flush_output(Verbose, !IO),
process_all_nonimported_procs(update_proc(mark_static_terms),
@@ -3484,7 +3492,7 @@
maybe_write_string(Verbose, "% done.\n", !IO),
maybe_report_stats(Stats, !IO)
;
- StaticGroundTerms = no
+ SGCells = no
).
%-----------------------------------------------------------------------------%
Index: compiler/options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.618
diff -u -b -r1.618 options.m
--- compiler/options.m 28 May 2008 00:52:28 -0000 1.618
+++ compiler/options.m 31 May 2008 16:19:31 -0000
@@ -648,7 +648,11 @@
; binary_switch_size
; switch_single_rec_base_first
; switch_multi_rec_base_first
- ; static_ground_terms
+
+ ; static_ground_cells
+ ; static_ground_floats
+ ; static_code_addresses
+
; use_atomic_cells
; middle_rec
; simple_neg
@@ -1437,7 +1441,9 @@
binary_switch_size - int(4),
switch_single_rec_base_first - bool(no),
switch_multi_rec_base_first - bool(yes),
- static_ground_terms - bool(no),
+ static_ground_cells - bool(no),
+ static_ground_floats - bool(no),
+ static_code_addresses - bool(no),
use_atomic_cells - bool(no),
middle_rec - bool(no),
simple_neg - bool(no),
@@ -2271,7 +2277,11 @@
long_option("binary-switch-size", binary_switch_size).
long_option("switch-single-rec-base-first", switch_single_rec_base_first).
long_option("switch-multi-rec-base-first", switch_multi_rec_base_first).
-long_option("static-ground-terms", static_ground_terms).
+long_option("static-ground-terms", static_ground_cells).
+% static_ground_floats should be set only in handle_options.m.
+% long_option("static-ground-floats", static_ground_floats).
+% static_code_addresses should be set only in handle_options.m.
+% long_option("static-code-addresses", static_code_addresses).
long_option("use-atomic-cells", use_atomic_cells).
long_option("middle-rec", middle_rec).
long_option("simple-neg", simple_neg).
@@ -2847,7 +2857,7 @@
optimize - bool(yes),
optimize_repeat - int(1),
optimize_peep - bool(yes),
- static_ground_terms - bool(yes),
+ static_ground_cells - bool(yes),
smart_indexing - bool(yes),
optimize_jumps - bool(yes),
optimize_labels - bool(yes),
Index: compiler/stack_layout.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/stack_layout.m,v
retrieving revision 1.140
diff -u -b -r1.140 stack_layout.m
--- compiler/stack_layout.m 11 Feb 2008 21:26:08 -0000 1.140
+++ compiler/stack_layout.m 30 May 2008 09:12:11 -0000
@@ -121,9 +121,17 @@
globals.lookup_bool_option(Globals, trace_stack_layout, TraceLayout),
globals.lookup_bool_option(Globals, procid_stack_layout, ProcIdLayout),
globals.lookup_bool_option(Globals, profile_deep, DeepProfiling),
+ globals.lookup_bool_option(Globals, static_code_addresses, StaticCodeAddr),
+ globals.lookup_bool_option(Globals, unboxed_float, OptUnboxedFloat),
+ (
+ OptUnboxedFloat = yes,
+ UnboxedFloat = have_unboxed_floats
+ ;
+ OptUnboxedFloat = no,
+ UnboxedFloat = do_not_have_unboxed_floats
+ ),
globals.get_trace_level(Globals, TraceLevel),
globals.get_trace_suppress(Globals, TraceSuppress),
- globals.have_static_code_addresses(Globals, StaticCodeAddr),
map.init(LayoutLabels0),
map.init(StringMap0),
@@ -132,7 +140,7 @@
global_data_get_static_cell_info(!.GlobalData, StaticCellInfo0),
counter.init(1, LabelCounter0),
LayoutInfo0 = stack_layout_info(ModuleInfo,
- AgcLayout, TraceLayout, ProcIdLayout, StaticCodeAddr,
+ AgcLayout, TraceLayout, ProcIdLayout, StaticCodeAddr, UnboxedFloat,
LabelCounter0, [], [], [], LayoutLabels0, [],
StringTable0, LabelTables0, StaticCellInfo0, no),
lookup_string_in_table("", _, LayoutInfo0, LayoutInfo1),
@@ -1521,10 +1529,8 @@
Type = unsigned
;
LvalOrConst = const(_Const),
- get_module_info(!.Info, ModuleInfo),
- module_info_get_globals(ModuleInfo, Globals),
- globals.lookup_bool_option(Globals, unboxed_float, UnboxedFloat),
- rval_type_as_arg(LvalOrConst, UnboxedFloat, LLDSType),
+ get_unboxed_floats(!.Info, UnboxedFloats),
+ LLDSType = rval_type_as_arg(UnboxedFloats, LvalOrConst),
get_layout_static_cell_info(!.Info, StaticCellInfo0),
add_scalar_static_cell([LvalOrConst - LLDSType], DataAddr,
@@ -1785,6 +1791,7 @@
trace_stack_layout :: bool, % generate tracing info?
procid_stack_layout :: bool, % generate proc id info?
static_code_addresses :: bool, % have static code addresses?
+ unboxed_floats :: have_unboxed_floats,
label_counter :: counter,
table_infos :: list(layout_data),
proc_layouts :: list(layout_data),
@@ -1810,6 +1817,8 @@
:- pred get_trace_stack_layout(stack_layout_info::in, bool::out) is det.
:- pred get_procid_stack_layout(stack_layout_info::in, bool::out) is det.
:- pred get_static_code_addresses(stack_layout_info::in, bool::out) is det.
+:- pred get_unboxed_floats(stack_layout_info::in, have_unboxed_floats::out)
+ is det.
:- pred get_table_infos(stack_layout_info::in, list(layout_data)::out) is det.
:- pred get_proc_layout_data(stack_layout_info::in, list(layout_data)::out)
is det.
@@ -1829,6 +1838,7 @@
get_trace_stack_layout(LI, LI ^ trace_stack_layout).
get_procid_stack_layout(LI, LI ^ procid_stack_layout).
get_static_code_addresses(LI, LI ^ static_code_addresses).
+get_unboxed_floats(LI, LI ^ unboxed_floats).
get_table_infos(LI, LI ^ table_infos).
get_proc_layout_data(LI, LI ^ proc_layouts).
get_internal_layout_data(LI, LI ^ internal_layouts).
Index: compiler/var_locn.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/var_locn.m,v
retrieving revision 1.62
diff -u -b -r1.62 var_locn.m
--- compiler/var_locn.m 26 May 2008 07:20:36 -0000 1.62
+++ compiler/var_locn.m 30 May 2008 09:45:54 -0000
@@ -24,7 +24,6 @@
:- import_module hlds.hlds_goal.
:- import_module hlds.hlds_llds.
:- import_module hlds.hlds_module.
-:- import_module libs.options.
:- import_module ll_backend.global_data.
:- import_module ll_backend.llds.
:- import_module parse_tree.prog_data.
@@ -41,7 +40,7 @@
:- type var_locn_info.
% init_var_locn_state(Arguments, Liveness, VarSet, VarTypes, StackSlots,
- % FollowVars, Opts, VarLocnInfo):
+ % FollowVars, VarLocnInfo):
%
% Produces an initial state of the VarLocnInfo given
% an association list of variables and lvalues. The initial
@@ -54,13 +53,11 @@
% of all the procedure's variables. StackSlots maps each variable
% to its stack slot, if it has one. FollowVars is the initial
% follow_vars set; such sets give guidance as to what lvals
- % (if any) each variable will be needed in next. Opts gives
- % the table of options; this is used to decide what expressions
- % are considered constants.
+ % (if any) each variable will be needed in next.
%
:- pred init_var_locn_state(assoc_list(prog_var, lval)::in, set(prog_var)::in,
prog_varset::in, vartypes::in, stack_slots::in, abs_follow_vars::in,
- option_table::in, var_locn_info::out) is det.
+ var_locn_info::out) is det.
% reinit_var_locn_state(VarLocs, !VarLocnInfo):
%
@@ -147,12 +144,13 @@
static_cell_info::in, code_tree::out,
var_locn_info::in, var_locn_info::out) is det.
- % var_locn_assign_const_to_var(Var, ConstRval, !VarLocnInfo):
+ % var_locn_assign_const_to_var(ExprnOpts, Var, ConstRval,
+ % !VarLocnInfo):
%
% Reflects the effect of the assignment Var := const(ConstRval)
% in the state of !VarLocnInfo.
%
-:- pred var_locn_assign_const_to_var(prog_var::in, rval::in,
+:- pred var_locn_assign_const_to_var(exprn_opts::in, prog_var::in, rval::in,
var_locn_info::in, var_locn_info::out) is det.
% var_locn_assign_expr_to_var(Var, Rval, Code, !VarLocnInfo):
@@ -166,9 +164,9 @@
:- pred var_locn_assign_expr_to_var(prog_var::in, rval::in, code_tree::out,
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, Label, Code,
- % !StaticCellInfo, !VarLocnInfo):
+ % var_locn_assign_cell_to_var(ModuleInfo, ExprnOpts, Var,
+ % ReserveWordAtStart, Ptag, MaybeRvals, MaybeSize, FieldAddrs, TypeMsg,
+ % MayUseAtomic, Label, 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
@@ -182,10 +180,10 @@
% and MaybeSize should not be yes / yes(_), because that will cause an
% obvious conflict.) Label can be used in the generated code if necessary.
%
-:- 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, label::in, code_tree::out,
+:- pred var_locn_assign_cell_to_var(module_info::in, exprn_opts::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, label::in, code_tree::out,
static_cell_info::in, static_cell_info::out,
var_locn_info::in, var_locn_info::out) is det.
@@ -450,16 +448,14 @@
:- type var_locn_info
---> var_locn_info(
% The varset and vartypes from the proc_info.
+ % XXX These fields are redundant; they are also stored
+ % in the code_info.
vli_varset :: prog_varset,
vli_vartypes :: vartypes,
% Maps each var to its stack slot, if it has one.
vli_stack_slots :: stack_slots,
- % The values of the options that are relevant to decisions
- % about which rvals are constants.
- vli_exprn_opts :: exprn_opts,
-
% Where vars are needed next.
vli_follow_vars_map :: abs_follow_vars_map,
@@ -489,15 +485,14 @@
%----------------------------------------------------------------------------%
init_var_locn_state(VarLocs, Liveness, VarSet, VarTypes, StackSlots,
- FollowVars, Options, VarLocnInfo) :-
+ FollowVars, VarLocnInfo) :-
map.init(VarStateMap0),
map.init(LocVarMap0),
init_var_locn_state_2(VarLocs, yes(Liveness), VarStateMap0, VarStateMap,
LocVarMap0, LocVarMap),
- exprn_aux.init_exprn_opts(Options, ExprnOpts),
FollowVars = abs_follow_vars(FollowVarMap, NextNonReserved),
set.init(AcquiredRegs),
- VarLocnInfo = var_locn_info(VarSet, VarTypes, StackSlots, ExprnOpts,
+ VarLocnInfo = var_locn_info(VarSet, VarTypes, StackSlots,
FollowVarMap, NextNonReserved, VarStateMap, LocVarMap,
AcquiredRegs, 0, []).
@@ -507,9 +502,9 @@
init_var_locn_state_2(VarLocs, no, VarStateMap0, VarStateMap,
LocVarMap0, LocVarMap),
set.init(AcquiredRegs),
- !.VarLocnInfo = var_locn_info(VarSet, VarTypes, StackSlots, ExprnOpts,
+ !.VarLocnInfo = var_locn_info(VarSet, VarTypes, StackSlots,
FollowVarMap, NextNonReserved, _, _, _, _, _),
- !:VarLocnInfo = var_locn_info(VarSet, VarTypes, StackSlots, ExprnOpts,
+ !:VarLocnInfo = var_locn_info(VarSet, VarTypes, StackSlots,
FollowVarMap, NextNonReserved, VarStateMap, LocVarMap,
AcquiredRegs, 0, []).
@@ -759,11 +754,10 @@
%----------------------------------------------------------------------------%
-var_locn_assign_const_to_var(Var, ConstRval0, !VLI) :-
+var_locn_assign_const_to_var(ExprnOpts, Var, ConstRval0, !VLI) :-
check_var_is_unknown(!.VLI, Var),
var_locn_get_var_state_map(!.VLI, VarStateMap0),
- var_locn_get_exprn_opts(!.VLI, ExprnOpts),
( expr_is_constant(VarStateMap0, ExprnOpts, ConstRval0, ConstRval) ->
State = var_state(set.init, yes(ConstRval), no, set.init, doa_alive),
map.det_insert(VarStateMap0, Var, State, VarStateMap),
@@ -809,8 +803,8 @@
%----------------------------------------------------------------------------%
-var_locn_assign_cell_to_var(ModuleInfo, Var, ReserveWordAtStart, Ptag,
- MaybeRvals0, HowToConstruct, MaybeSize, FieldAddrs, TypeMsg,
+var_locn_assign_cell_to_var(ModuleInfo, ExprnOpts, Var, ReserveWordAtStart,
+ Ptag, MaybeRvals0, HowToConstruct, MaybeSize, FieldAddrs, TypeMsg,
MayUseAtomic, Label, Code, !StaticCellInfo, !VLI) :-
(
MaybeSize = yes(SizeSource),
@@ -829,19 +823,18 @@
MaybeOffset = no
),
var_locn_get_var_state_map(!.VLI, VarStateMap),
- var_locn_get_exprn_opts(!.VLI, ExprnOpts),
- StaticGroundTerms = ExprnOpts ^ static_ground_terms,
+ StaticGroundCells = get_static_ground_cells(ExprnOpts),
% We can make the cell a constant only if all its fields are filled in,
% and they are all constants.
(
- StaticGroundTerms = yes,
+ StaticGroundCells = have_static_ground_cells,
FieldAddrs = [],
cell_is_constant(VarStateMap, ExprnOpts, MaybeRvals, RvalsTypes)
->
add_scalar_static_cell(RvalsTypes, DataAddr, !StaticCellInfo),
CellPtrConst = const(llconst_data_addr(DataAddr, MaybeOffset)),
CellPtrRval = mkword(Ptag, CellPtrConst),
- var_locn_assign_const_to_var(Var, CellPtrRval, !VLI),
+ var_locn_assign_const_to_var(ExprnOpts, Var, CellPtrRval, !VLI),
Code = empty
;
var_locn_assign_dynamic_cell_to_var(ModuleInfo, Var,
@@ -2101,7 +2094,7 @@
cell_is_constant(VarStateMap, ExprnOpts, [yes(Rval0) | MaybeRvals],
[Rval - LldsType | RvalsTypes]) :-
expr_is_constant(VarStateMap, ExprnOpts, Rval0, Rval),
- rval_type_as_arg(Rval, ExprnOpts ^ unboxed_float, LldsType),
+ LldsType = rval_type_as_arg(get_unboxed_floats(ExprnOpts), Rval),
cell_is_constant(VarStateMap, ExprnOpts, MaybeRvals, RvalsTypes).
% expr_is_constant(VarStateMap, ExprnOpts, Rval0, Rval):
@@ -2499,7 +2492,6 @@
:- pred var_locn_get_varset(var_locn_info::in, prog_varset::out) is det.
:- pred var_locn_get_vartypes(var_locn_info::in, vartypes::out) is det.
-:- pred var_locn_get_exprn_opts(var_locn_info::in, exprn_opts::out) is det.
:- pred var_locn_get_var_state_map(var_locn_info::in, var_state_map::out)
is det.
:- pred var_locn_get_loc_var_map(var_locn_info::in, loc_var_map::out) is det.
@@ -2526,7 +2518,6 @@
var_locn_get_varset(VI, VI ^ vli_varset).
var_locn_get_vartypes(VI, VI ^ vli_vartypes).
var_locn_get_stack_slots(VI, VI ^ vli_stack_slots).
-var_locn_get_exprn_opts(VI, VI ^ vli_exprn_opts).
var_locn_get_follow_var_map(VI, VI ^ vli_follow_vars_map).
var_locn_get_next_non_reserved(VI, VI ^ vli_next_non_res).
var_locn_get_var_state_map(VI, VI ^ vli_var_state_map).
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/base64
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/fixed
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_allegro
cvs diff: Diffing extras/graphics/mercury_allegro/examples
cvs diff: Diffing extras/graphics/mercury_allegro/samples
cvs diff: Diffing extras/graphics/mercury_allegro/samples/demo
cvs diff: Diffing extras/graphics/mercury_allegro/samples/mandel
cvs diff: Diffing extras/graphics/mercury_allegro/samples/pendulum2
cvs diff: Diffing extras/graphics/mercury_allegro/samples/speed
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/log4m
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/mopenssl
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/net
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/posix/samples
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/standalone_c
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/solver_types
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing ssdb
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/par_conj
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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