mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-16 22:35:41 +00:00
fc29b6c0b6922bb81092ecff6e33fb84cf8c2824
8 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
257efbd678 |
Store double-precision `float' constructor arguments in unboxed form,
Branches: main Store double-precision `float' constructor arguments in unboxed form, in high-level C grades on 32-bit platforms, i.e. `float' (and equivalent) arguments may occupy two machine words. As the C code generated by the MLDS back-end makes use of MR_Float variables and parameters, float (un)boxing may be reduced substantially in many programs. compiler/prog_data.m: Add `double_word' as a new option for constructor argument widths, only used for float arguments as yet. compiler/make_hlds_passes.m: Set constructor arguments to have `double_word' width if required, and possible. compiler/type_util.m: Add helper predicate. compiler/builtin_ops.m: compiler/c_util.m: compiler/llds.m: Add two new binary operators used by the MLDS back-end. compiler/arg_pack.m: Handle `double_word' arguments. compiler/ml_code_util.m: Deciding whether or not a float constructor argument requires boxing now depends on the width of the field. compiler/ml_global_data.m: When a float constant appears as an initialiser of a generic array element, it is now always unboxed, irrespective of --unboxed-float. compiler/ml_type_gen.m: Take double-word arguments into account when generating structure fields. compiler/ml_unify_gen.m: Handle double-word float constructor arguments in (de)constructions. In some cases we break a float argument into its two words, so generating two assignments statements or two separate rvals. Take double-word arguments into account when calculating field offsets. compiler/mlds_to_c.m: The new binary operators require no changes here. As a special case, write `MR_float_from_dword_ptr(&X)' instead of `MR_float_from_dword(X, Y)' when X, Y are consecutive words within a field. The definition of `MR_float_from_dword_ptr' is more straightforward, and gcc produces better code than if we use the more general `MR_float_from_dword'. compiler/rtti_out.m: For double-word arguments, generate MR_DuArgLocn structures with MR_arg_bits set to -1. compiler/rtti_to_mlds.m: Handle double-word arguments in field offset calculation. compiler/unify_gen.m: Partially handle double_word arguments in LLDS back-end. compiler/handle_options.m: Set --unboxed-float when targetting Java, C# and Erlang. compiler/structure_reuse.direct.choose_reuse.m: Rename a predicate. compiler/bytecode.m: compiler/equiv_type.m: compiler/equiv_type_hlds.m: compiler/llds_to_x86_64.m: compiler/mlds_to_gcc.m: compiler/mlds_to_il.m: compiler/opt_debug.m: Conform to changes. library/construct.m: library/store.m: Handle double-word constructor arguments. runtime/mercury_conf.h.in: Clarify what `MR_BOXED_FLOAT' now means. runtime/mercury_float.h: Add helper macros for converting between doubles and word/dwords. runtime/mercury_deconstruct.c: runtime/mercury_deconstruct.h: Add a macro `MR_arg_value' and a helper function to extract a constructor argument value. This replaces `MR_unpack_arg'. runtime/mercury_type_info.h: Remove `MR_unpack_arg'. Document that MR_DuArgLocn.MR_arg_bits may be -1. runtime/mercury_deconstruct_macros.h: runtime/mercury_deep_copy_body.h: runtime/mercury_ml_arg_body.h: runtime/mercury_table_type_body.h: runtime/mercury_tabling.c: runtime/mercury_type_info.c: Handle double-word constructor arguments. tests/hard_coded/Mercury.options: tests/hard_coded/Mmakefile: tests/hard_coded/lco_double.exp: tests/hard_coded/lco_double.m: tests/hard_coded/pack_args_float.exp: tests/hard_coded/pack_args_float.m: Add test cases. trace/mercury_trace_vars.c: Conform to changes. |
||
|
|
0ae65de577 |
Pack consecutive enumeration arguments in discriminated union types into a
Branches: main Pack consecutive enumeration arguments in discriminated union types into a single word to reduce cell sizes. Argument packing is only enabled on C back-ends with low-level data, and reordering arguments to improve opportunities for packing is not yet attempted. The RTTI implementations for other back-ends will need to be updated, but that is best left until after any argument reordering change. Modules which import abstract enumeration types are notified so by writing declarations of the form: :- type foo where type_is_abstract_enum(NumBits). into the interface file for the module which defines the type. compiler/prog_data.m: Add an `arg_width' argument to constructor arguments. Replace `is_solver_type' by `abstract_type_details', with an extra option for abstract exported enumeration types. compiler/handle_options.m: compiler/options.m: Add an internal option `--allow-argument-packing'. compiler/make_hlds_passes.m: Determine whether and how to pack enumeration arguments, updating the `arg_width' fields of constructor arguments before constructors are added to the HLDS. compiler/mercury_to_mercury.m: compiler/modules.m: Write `where type_is_abstract_enum(NumBits)' to interface files for abstract exported enumeration types. compiler/prog_io_type_defn.m: Parse `where type_is_abstract_enum(NumBits)' attributes on type definitions. compiler/arg_pack.m: compiler/backend_libs.m: Add a new module. This mainly contains a predicate which packs rvals according to arg_widths, which is used by both LLDS and MLDS back-ends. compiler/ml_unify_gen.m: compiler/unify_gen.m: Take argument packing into account when generating code for constructions and deconstructions. Only a relatively small part of the compiler actually needs to understand argument packing. The rest works at the HLDS level with constructor arguments and variables, or at the LLDS and MLDS levels with structure fields. compiler/code_info.m: compiler/var_locn.m: Add assign_field_lval_expr_to_var and var_locn_assign_field_lval_expr_to_var. Allow more kinds of rvals in assign_cell_arg. I do not know why it was previously restricted, except that the other kinds of rvals were not encountered as cell arguments before. compiler/mlds.m: We can now rely on the compiler to pack arguments in the mlds_decl_flags type instead of doing it manually. A slight downside is that though the type is packed down to a single word cell, it will still incur a memory allocation per cell. However, I did not notice any difference in compiler speed. compiler/rtti.m: compiler/rtti_out.m: Add and output a new field for MR_DuFunctorDesc instances, which, if any arguments are packed, points to an array of MR_DuArgLocn. Each array element describes the offset in the cell at which the argument's value is held, and which bits of the word it occupies. In the more common case where no arguments are packed, the new field is simply null. compiler/rtti_to_mlds.m: Generate the new field to MR_DuFunctorDesc. compiler/structure_reuse.direct.choose_reuse.m: For now, prevent structure reuse reusing a dead cell which has a different constructor to the new cell. The code to determine whether a dead cell will hold the arguments of a new cell with a different constructor will need to be updated to account for argument packing. compiler/type_ctor_info.m: Bump RTTI version number. Conform to changes. compiler/add_type.m: compiler/check_typeclass.m: compiler/equiv_type.m: compiler/equiv_type_hlds.m: compiler/erl_rtti.m: compiler/hlds_data.m: compiler/hlds_out_module.m: compiler/intermod.m: compiler/make_tags.m: compiler/mlds_to_gcc.m: compiler/opt_debug.m: compiler/prog_type.m: compiler/recompilation.check.m: compiler/recompilation.version.m: compiler/special_pred.m: compiler/type_constraints.m: compiler/type_util.m: compiler/unify_proc.m: compiler/xml_documentation.m: Conform to changes. Reduce code duplication in classify_type_defn. compiler/hlds_goal.m: Clarify a comment. library/construct.m: Make `construct' pack arguments when necessary. Remove an old RTTI version number check as recommended in mercury_grade.h. library/store.m: Deal with packed arguments in this module. runtime/mercury_grade.h: Bump binary compatibility version number. runtime/mercury_type_info.c: runtime/mercury_type_info.h: Bump RTTI version number. Add MR_DuArgLocn structure definition. Add a macro to unpack an argument as described by MR_DuArgLocn. Add a function to determine a cell's size, since the number of arguments is no longer correct. runtime/mercury_deconstruct.c: runtime/mercury_deconstruct.h: runtime/mercury_deconstruct_macros.h: runtime/mercury_ml_arg_body.h: runtime/mercury_ml_expand_body.h: Deal with packed arguments when deconstructing. Remove an old RTTI version number check as recommended in mercury_grade.h. runtime/mercury_deep_copy_body.h: Deal with packed arguments when copying. runtime/mercury_table_type_body.h: Deal with packed arguments in tabling. runtime/mercury_dotnet.cs.in: Add DuArgLocn field to DuFunctorDesc. Argument packing is not enabled for the C# back-end yet so this is unused. trace/mercury_trace_vars.c: Deal with packed arguments in MR_select_specified_subterm, use for the `hold' command. java/runtime/DuArgLocn.java: java/runtime/DuFunctorDesc.java: Add DuArgLocn field to DuFunctorDesc. Argument packing is not enabled for the Java back-end yet so this is unused. extras/trailed_update/tr_store.m: Deal with packed arguments in this module (untested). extras/trailed_update/samples/interpreter.m: extras/trailed_update/tr_array.m: Conform to argument reordering in the array, map and other modules in previous changes. tests/hard_coded/Mercury.options: tests/hard_coded/Mmakefile: tests/hard_coded/lco_pack_args.exp: tests/hard_coded/lco_pack_args.m: tests/hard_coded/pack_args.exp: tests/hard_coded/pack_args.m: tests/hard_coded/pack_args_copy.exp: tests/hard_coded/pack_args_copy.m: tests/hard_coded/pack_args_intermod1.exp: tests/hard_coded/pack_args_intermod1.m: tests/hard_coded/pack_args_intermod2.m: tests/hard_coded/pack_args_reuse.exp: tests/hard_coded/pack_args_reuse.m: tests/hard_coded/store_ref.exp: tests/hard_coded/store_ref.m: tests/invalid/Mmakefile: tests/invalid/where_abstract_enum.err_exp: tests/invalid/where_abstract_enum.m: tests/tabling/Mmakefile: tests/tabling/pack_args_memo.exp: tests/tabling/pack_args_memo.m: Add new test cases. tests/hard_coded/deconstruct_arg.exp: tests/hard_coded/deconstruct_arg.exp2: tests/hard_coded/deconstruct_arg.m: Add constructors with packed arguments to these cases. tests/invalid/where_direct_arg.err_exp: Update expected output. |
||
|
|
6de3b102ba |
Add support for deconstructing by functor number rather than name,
Estimated hours taken: 20 Branches: main Add support for deconstructing by functor number rather than name, for use by write_binary. library/deconstruct.m: runtime/mercury_deconstruct.h: runtime/mercury_deconstruct.c: runtime/mercury_ml_expand_body.h: runtime/mercury_ml_deconstruct_body.h: Add predicates deconstruct.functor_number and deconstruct.deconstruct.du, which returns a functor number suitable for use by construct.construct rather than a functor name. library/construct.m: library/term.m: browser/term_rep.m: extras/quickcheck/qcheck.m: tests/valid/agc_unbound_typevars.m: tests/valid/agc_unbound_typevars2.m: Add a function get_functor_lex, which returns the lexicographic functor number given an ordinal functor number. Add equivalence types to make it clearer which ordering is being used by which functor numbers. Remove a C-ism: num_functors now fails rather than returning -1 for types without functors. NEWS: Document the new predicates and functions. runtime/mercury_type_info.h: runtime/mercury_builtin_types.c: runtime/mercury_mcpp.h: compiler/rtti.m: compiler/rtti_out.m: compiler/type_ctor_info.m: compiler/rtti_to_mlds.m: compiler/opt_debug.m: Add a field to MR_TypeCtorInfo which contains a mapping from an ordinal functor number to a lexicographic functor number which can be passed to construct.construct. Bump MR_RTTI_VERSION. tests/hard_coded/expand.m: tests/hard_coded/expand.exp: tests/hard_coded/expand.exp2: tests/hard_coded/construct_test.m: tests/hard_coded/construct_test.exp: tests/hard_coded/construct_test_exist.m: tests/hard_coded/construct_test_exist.exp: Test cases. |
||
|
|
d1c13d57c5 |
Fix some layout issues in these files. There are no algorithmic
Estimated hours taken: 0.3 Branches: main runtime/mercury_accurate_gc.h: runtime/mercury_agc_debug.h: runtime/mercury_array_macros.h: runtime/mercury_construct.h: runtime/mercury_deconstruct.h: runtime/mercury_init.h: runtime/mercury_layout_util.h: runtime/mercury_stack_layout.h: runtime/mercury_stack_trace.h: runtime/mercury_trail.h: Fix some layout issues in these files. There are no algorithmic changes. |
||
|
|
d1edaa88a4 |
Fix indentation.
Estimated hours taken: 0.1 Branches: main runtime/mercury_deconstruct.h: Fix indentation. |
||
|
|
b7c4a317e9 |
Add MR_ prefixes to the remaining non-prefixed symbols.
Estimated hours taken: 4 Branches: main Add MR_ prefixes to the remaining non-prefixed symbols. This change will require all workspaces to be updated The compiler will start generating references to MR_TRUE, MR_bool, etc., which are not defined in the old runtime header files. runtime/mercury_std.h: Add MR_ prefixes to bool, TRUE, FALSE, max, min, streq, strdiff, strtest, strntest, strneq, strndiff, strntest, NO_RETURN. Delete a commented out definition of `reg'. runtime/mercury_tags.h: Add an MR_ prefix to TAGBITS. configure.in: runtime/mercury_goto.h: runtime/machdeps/i386_regs.h/mercury_goto.h: Add an MR_ prefix to PIC. runtime/mercury_conf_param.h: Allow non-prefixed PIC and HIGHTAGS to be defined on the command line. runtime/mercury_bootstrap.h: Add backwards compatibility definitions. RESERVED_MACRO_NAMES: Remove the renamed macros. compiler/export.m: compiler/ml_code_gen.m: Use MR_bool rather than MR_Bool (MR_Bool is meant to be for references to the Mercury type bool__bool). runtime/mercury_types.h: Add a comment the MR_Bool is for references to bool__bool. */*.c: */*.h: */*.m: Add MR_ prefixes. |
||
|
|
fcccbd166f |
Reorganize deconstruct.m so that each predicate that deconstructs terms has
Estimated hours taken: 12
Branches: main
Reorganize deconstruct.m so that each predicate that deconstructs terms has
three variants:
- One that aborts when attempting to deconstruct non-canonical terms.
- One that succeeds when attempting to deconstruct a term of a non-canonical
type, but returns a constant such as "<<noncanonical>>" for such
deconstructions. It still aborts when deconstructing a noncanonical term
of an ordinarily canonical type, which can happen with HAL if the term
is currently a variable.
- One that succeeds when attempting to deconstruct non-canonical terms of both
kinds, but whose determinism requires its caller to be in a committed choice
context.
Each of the predicates function, arg, named_arg, deconstruct and
limited_deconstruct now has an extra argument that selects one of the three
variants above. Each of these predicates now has three modes, one for each
value of this argument. The separate predicates with _cc at the ends of their
names are now superseded by one of these modes.
At the same time, I also eliminated the distinction between arg and argument.
Arg used to check if the returned argument was of the expected type, and fail
if it wasn't, while argument used to return a univ. The new arg now returns
a value of an existential type, which the caller can now typecheck or put
into a univ as it pleases.
The descriptions of the changes:
library/deconstruct.m:
Implement the changes discussed above. Work around a bug by making
the foreign_procs return a univ from which we later extract the value;
this inefficiency should be fixed later, when the typechecker has been
fixed to allow different clauses to return existentially typed values.
library/std_util.m:
Reimplement the forwarding predicates that call deconstruct.m in terms
of its new interface.
library/io.m:
Make use of the new functionality in deconstruct.m to offer versions
of io__print and io__write that allow the user to choose how to print
noncanonical terms.
library/private_builtin.m:
Export the `sorry' predicate for use in deconstruct.m and elsewhere.
runtime/mercury_deconstruct.[ch]:
runtime/mercury_ml_expand_body.h:
runtime/mercury_ml_arg_body.h:
runtime/mercury_ml_deconstruct_body.h:
runtime/mercury_ml_functor_body.h:
Implement the new functionality.
library/store.m:
extras/trailed_update/tr_store.m:
Conform to the new interfaces of some functions in the updated files
in the runtime.
tests/debugger/polymorphic_output.exp*:
Update for an updated error message.
tests/hard_coded/deconstruct_arg.{m,exp*}:
Update the test case to test the committed choice versions of the
deconstruction predicates as well as the usual versions. (The aborting
versions cannot all be tested in a single test case.)
|
||
|
|
ce62be8669 |
Add committed choice versions of the functions and predicates that deconstruct
Estimated hours taken: 12
Branches: main
Add committed choice versions of the functions and predicates that deconstruct
terms. These versions succeed even if the the term being deconstructed is of a
non-canonical type.
NEWS:
Mention the new procedures.
library/std_util.m:
Add the following procedures: functor_cc, argument_cc, det_argument_cc,
named_argument_cc, det_named_argument_cc, deconstruct_cc and
limited_deconstruct_cc.
To avoid code duplication, factor out the code common to several
procedures and put it into three new files in the runtime directory,
mercury_ml_{fuctor,arg,deconstruct__body.h.
Add arguments to the various expansion functions to control what they
should do for non-canonical types. Move them to mercury_deconstruct.c
in the runtime directory to make it easier to access them from other
places.
Fix some bugs in the code for det_arg and family in the computation
of abort messages.
library/store.m:
extras/trailed_update/tr_store.m:
trace/mercury_trace_vars.c:
Adjust the references to the expansion functions.
runtime/mercury_deconstruct.[ch]:
A new module to contain the expansion functions.
runtime/mercury_ml_arg_body.h:
runtime/mercury_ml_deconstruct_body.h:
runtime/mercury_ml_functor_body.h:
New files to contain the bodies of the std_util procedures for
deconstructing terms.
runtime/mercury_deconstruct_macros.h:
A new header file for macros used in several places.
library/Mmakefile:
runtime/Mmakefile:
Add the new files to the required lists.
|