mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 05:44:58 +00:00
ae94e32d467e05454ba71ddd988f3b53646e92bd
79 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ae94e32d46 |
Support 64-bit integers in static ground terms with the LLDS backend.
compiler/handle_options.m:
compiler/options.m:
Add a new internal option --static-ground-int64s, whose value
says whether 64-bit integers may be placed in static data.
(As with floats currently, we always do this.)
compiler/llds_out_data.m:
If 64-bit integers are boxed, then emit a static constant to hold
the value of each 64-bit integer literal.
compiler/llds.m:
compiler/llds_out_util.m:
compiler/code_info.m:
Keep track of whether we are using unboxed int64s and static ground int64s
at various points in the code generator.
Add decl_ids for the labels we generate for 64-bit integer constants.
compiler/exprn_aux.m:
Fix an XXX: properly determine whether an expression containing 64-bit
integers is constant or not.
compiler/c_util.m:
Add functions for converting 64-bit integers into strings giving
the C literal representation of those integers.
|
||
|
|
f519e26173 |
Add builtin 64-bit integer types -- Part 1.
Add the new builtin types: int64 and uint64.
Support for these new types will need to be bootstrapped over several changes.
This is the first such change and does the following:
- Extends the compiler to recognise 'int64' and 'uint64' as builtin types.
- Extends the set of builtin arithmetic, bitwise and relational operators
to cover the new types.
- Adds the new internal option '--unboxed-int64s' to the compiler; this will be
used to control whether 64-bit integer types are boxed or not.
- Extends all of the code generators to handle the new types.
- Extends the runtimes to support the new types.
- Adds new modules to the standard library intend to contain basic operations
on the new types. (These are currently empty and not documented.)
There are bunch of limitations marks with "XXX INT64"; these will be lifted in
part 2 of this change. Also, 64-bit integer types are currently always boxed,
again this limitation will be lifted in later changes.
compiler/options.m:
Add the new option --unboxed-int64s.
compiler/prog_type.m:
compiler/prog_data.m:
compiler/builtin_lib_types.m:
Recognise int64 and uint64 as builtin types.
compiler/builtin_ops.m:
Add builtin operations for the new types.
compiler/hlds_data.m:
Add new tag types for the new types.
compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/export.m:
compiler/foreign.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_dependency_graph.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/implementation_defined_literals.m:
compiler/inst_check.m:
compiler/mercury_to_mercury.m:
compiler/mode_util.m:
compiler/module_qual.qualify_items.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/parse_tree_to_term.m:
compiler/parse_type_name.m:
compiler/polymorphism.m:
compiler/prog_out.m:
compiler/prog_util.m:
compiler/rbmm.execution_path.m:
compiler/rtti.m:
compiler/table_gen.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
Conform to the above changes to the parse tree and HLDS.
compiler/c_util.m:
Support writing out constants of the new types.
compiler/llds.m:
Add a representation for constants of the new types to the LLDS.
compiler/stack_layout.m:
Add a new field to the stack layout params that records whether
64-bit integers are boxed or not.
compiler/call_gen.:m
compiler/code_info.m:
compiler/disj_gen.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/jumpopt.m:
compiler/llds_out_data.m:
compiler/llds_out_instr.m:
compiler/lookup_switch.m:
compiler/mercury_compile_llds_back_end.m:
compiler/prog_rep.m:
compiler/prog_rep_tables.m:
compiler/var_locn.m b/compiler/var_locn.m:
Support the new types in the LLDS code generator.
compiler/mlds.m:
Support constants of the new types in the MLDS.
compiler/ml_call_gen.m:
compiler/ml_code_util.m:
compiler/ml_global_data.m:
compiler/ml_rename_classes.m:
compiler/ml_top_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_target_util.m:
compiler/rtti_to_mlds.m:
Conform to the above changes to the MLDS.
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
Generate the appropriate target code for constants of the new types
and operations involving them.
compiler/bytecode.m:
compiler/bytecode_gen.m:
Handle the new types in the bytecode generator; we just abort if we
encounter them for now.
compiler/elds.m:
compiler/elds_to_erlang.m:
compiler/erl_call_gen.m:
compiler/erl_code_util.m:
compiler/erl_unify_gen.m:
Handle the new types in the Erlang code generator.
library/private_builtin.m:
Add placeholders for the builtin unify and compare operations for
the new types. Since the bootstrapping compiler will not recognise
the new types we give them polymorphic arguments. These can be
replaced after this change has bootstrapped.
Update the Java list of TypeCtorRep constants here.
library/int64.m:
library/uint64.m:
New modules that will eventually contain builtin operations on the new
types.
library/library.m:
library/MODULES_UNDOC:
Do not include the above modules in the library documentation for now.
library/construct.m:
library/erlang_rtti_implementation.m:
library/rtti_implementation.m:
library/table_statistics.m:
deep_profiler/program_representation_utils.m:
mdbcomp/program_representation.m:
Handle the new types.
configure.ac:
runtime/mercury_conf.h.in:
Define the macro MR_BOXED_INT64S. For now it is always defined, support for
unboxed 64-bit integers will be enabled in a later change.
runtime/mercury_dotnet.cs.in:
java/runtime/TypeCtorRep.java:
runtime/mercury_type_info.h:
Update the list of type_ctor reps.
runtime/mercury.h:
runtime/mercury_int.[ch]:
Add macros for int64 / uint64 -> MR_Word conversion, boxing and
unboxing.
Add functions for hashing 64-bit integer types suitable for use
with the tabling mechanism.
runtime/mercury_tabling.[ch]:
Add additional HashTableSlot structs for 64-bit integer types.
Omit the '%' character from the conversion specifiers we pass via
the 'key_format' argument to the macros that generate the table lookup
function. This is so we can use the C99 exact size integer conversion
specifiers (e.g. PRIu64 etc.) directly here.
runtime/mercury_hash_lookup_or_add_body.h:
Add the '%' character that was omitted above to the call to debug_key_msg.
runtime/mercury_memory.h:
Add new builtin allocation sites for boxed 64-bit integer types.
runtime/mercury_builtin_types.[ch]:
runtime/mercury_builitn_types_proc_layouts.h:
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_table_type_body.h:
runtime/mercury_tabling_macros.h:
runtime/mercury_tabling_preds.h:
runtime/mercury_term_size.c:
runtime/mercury_unify_compare_body.h:
Add the new builtin types and handle them throughout the runtime.
runtime/Mmakefile:
Add mercury_int.c to the list of .c files.
doc/reference_manual.texi:
Add the new types to the list of reserved type names.
Add the mapping from the new types to their target language types.
These are commented out for now.
|
||
|
|
3f28b096ef |
Add builtin 8, 16 and 32 bit integer types -- Part 2.
Enable support for literals of the new types.
Begin implementing library support for 8, 16, and 32 bit types.
Update the compiler to represent values of their own constants.
library/int8.m:
library/int16.m:
library/int32.m:
library/uint8.m:
library/uint16.m:
library/uint32.m:
Begin filling these modules out.
library/uint.m:
Unrelated change: add the predicates plus/2, minus/2 and
times/2 for uints.
library/integer.m:
Add predicates for converting integer/0 values into values
of the new types.
Add functions for converting values of the new types into
integer/0 values.
library/string.m:
Add functions for converting values of the new types to strings.
library/private_builtin.m:
Replace the placeholder definitions for the builtin unify and compare
predicates for the new types with their actual definitions.
library/erlang_rtti_implementation.m:
library/rtti_implementation.m:
Replace placeholder definitions for the new types with their
actual definitions.
library/io.m:
Add predicates for writing values of the new types to file streams.
library/stream.string_writer.m:
Implement generic write and print for values of the new types.
library/string.to_string.m:
Likewise for string/1.
library/term.m:
library/term_conversion.m:
Add predicates and functions for converting the new types to
and from terms.
compiler/builtin_ops.m:
compiler/elds.m:
compiler/hlds_data.m:
compiler/llds.m:
compiler/mlds.m:
compiler/prog_data.m:
Replace placeholders for the new types with the new types.
compiler/superhomogeneous.m:
Enable literals of the new types.
compiler/mlds_to_cs.m:
Avoid a warning from the C# compiler for bitwise-or operators
with sbyte operands.
compiler/c_util.m:
compiler/elds_to_erlang.m:
compiler/hlds_out_util.m:
compiler/llds_out_data.m:
compiler/lookup_switch.m:
compiler/mlds_to_c.m:
compiler/mlds_to_java.m:
compiler/opt_debug.m:
compiler/parse_tree_out_info.m:
compiler/parse_tree_to_term.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_util.m:
Replace placeholder code for the new types with code that uses the new
types.
tests/invalid/invalid_int.m:
tests/invalid/invalid_int.err_exp2:
Extend this test case to cover the fixed size integer types.
|
||
|
|
8a240ba3f0 |
Add builtin 8, 16 and 32 bit integer types -- Part 1.
Add the new builtin types: int8, uint8, int16, uint16, int32 and uint32.
Support for these new types will need to be bootstrapped over several changes.
This is the first such change and does the following:
- Extends the compiler to recognise 'int8', 'uint8', 'int16', 'uint16', 'int32'
and 'uint32' as builtin types.
- Extends the set of builtin arithmetic, bitwise and relational operators to
cover the new types.
- Extends all of the code generators to handle new types. There currently lots
of limitations and placeholders marked by 'XXX FIXED SIZE INT'. These will
be lifted in later changes.
- Extends the runtimes to support the new types.
- Adds new modules to the standard library intended to hold the basic
operations on the new types. (These are currently empty and not documented.)
This change does not introduce the two 64-bit types, 'int64' and 'uint64'.
Their implementation is more complicated and is best left to a separate change.
compiler/prog_type.m:
compiler/prog_data.m:
compiler/builtin_lib_types.m:
Recognise int8, uint8, int16, uint16, int32 and uint32 as builtin types.
Add new type, int_type/0,that enumerates all the possible integer types.
Extend the cons_id/0 type to cover the new types.
compiler/builtin_ops.m:
Parameterize the integer operations in the unary_op/0 and binary_op/0
types by the new int_type/0 type.
Add builtin operations for all the new types.
compiler/hlds_data.m:
Add new tag types for the new types.
compiler/hlds_pred.m:
Parameterize integers in the table_trie_step/0 type.
compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/export.m:
compiler/foreign.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_dependency_graph.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/implementation_defined_literals.m:
compiler/inst_check.m:
compiler/mercury_to_mercury.m:
compiler/mode_util.m:
compiler/module_qual.qualify_items.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/parse_tree_out_info.m:
compiler/parse_tree_to_term.m:
compiler/parse_type_name.m:
compiler/polymorphism.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_rep_tables.m:
compiler/prog_util.m:
compiler/rbmm.exection_path.m:
compiler/rtti.m:
compiler/rtti_to_mlds.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/type_constraints.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
Conform to the above changes to the parse tree and HLDS.
compiler/c_util.m:
Support generating the builtin operations for the new types.
doc/reference_manual.texi:
Add the new types to the list of reserved type names.
Add the mapping from the new types to their target language types.
These are commented out for now.
compiler/llds.m:
Replace the lt_integer/0 and lt_unsigned functors of the llds_type/0,
with a single lt_int/1 functor that is parameterized by the int_type/0
type.
Add a representations for constants of the new types to the LLDS.
compiler/call_gen.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/jumpopt.m:
compiler/llds_out_data.m:
compiler/llds_out_global.m:
compiler/llds_out_instr.m:
compiler/lookup_switch.m:
compiler/middle_rec.m:
compiler/peephole.m:
compiler/pragma_c_gen.m:
compiler/stack_layout.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/tag_switch.m:
compiler/trace_gen.m:
compiler/transform_llds.m:
Support the new types in the LLDS code generator.
compiler/mlds.m:
Support constants of the new types in the MLDS.
compiler/ml_accurate_gc.m:
compiler/ml_call_gen.m:
compiler/ml_code_util.m:
compiler/ml_disj_gen.m:
compiler/ml_foreign_proc_gen.m:
compiler/ml_global_data.m:
compiler/ml_lookup_switch.m:
compiler/ml_simplify_switch.m:
compiler/ml_string_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_target_util.m:
Conform to the above changes to the MLDS.
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
Generate the appropriate target code for constants of the new
types and operations involving them.
compiler/bytecode.m:
compiler/bytecode_gen.m:
Handle the new types in the bytecode generator; we just abort if we
encounter them for now.
compiler/elds.m:
compiler/elds_to_erlang.m:
compiler/erl_call_gen.m:
compiler/erl_code_util.m:
compiler/erl_rtti.m:
compiler/erl_unify_gen.m:
Handle the new types in the Erlang code generator.
library/private_builtin.m:
Add placeholders for the builtin unify and compare operations for
the new types. Since the bootstrapping compiler will not recognise
the new types we give the polymorphic arguments. These can be
replaced after this change has bootstrapped.
Update the Java list of TypeCtorRep constants.
library/int8.m:
library/int16.m:
library/int32.m:
library/uint8.m:
library/uint16.m:
library/uint32.m:
New modules that will eventually contain builtin operations
on the new types.
library/library.m:
library/MODULES_UNDOC:
Do not include the above modules in the library documentation
for now.
library/construct.m:
library/erlang_rtti_implementation.m:
library/rtti_implementation.m:
deep_profiler/program_representation_utils.m:
mdbcomp/program_representation.m:
Handle the new types.
runtime/mercury_dotnet.cs.in:
java/runtime/TypeCtorRep.java:
runtime/mercury_type_info.h:
Update the list of TypeCtorReps.
configure.ac:
runtime/mercury_conf.h.in:
Check for the header stdint.h.
runtime/mercury_std.h:
Include stdint.h; abort if that header is no present.
runtime/mercury_builtin_types.[ch]:
runtime/mercury_builtin_types_proc_layouts.h:
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h
runtime/mercury_table_type_body.h:
runtime/mercury_tabling_macros.h:
runtime/mercury_tabling_preds.h:
runtime/mercury_term_size.c:
runtime/mercury_unify_compare_body.h:
Add the new builtin types and handle them throughout the runtime.
|
||
|
|
fe297f25f5 |
Add more builtin ops on uints (part 1).
compiler/builtin_ops.m:
Add unchecked left and right shifts for uints as well
as the reverse modes of addition and subtraction.
library/uint.m:
Add commented out mode declarations for addition and
subtraction; they can be uncommented once the above
has bootstrapped.
compiler/bytecode.m:
compiler/c_util.m:
compiler/erl_call_gen.m:
compiler/llds.m:
compiler/llds_out_data.m:
compiler/ml_global_data.m:
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
compiler/opt_debug.m:
Conform to the above changes.
|
||
|
|
8e8fc26209 |
Add a builtin unsigned word sized integer type -- Part 2.
Begin implementing library support for uints.
Update the compiler to use the uint type.
library/uint.m:
Begin filling this module in.
library/private_builtin.m:
Use the proper argument type for builtin_{unify,compare}_uint
and provide actual implementations for them.
library/table_builtin.m:
Add tabling builtins for uints.
library/string.m:
Add a function to convert a uint to a decimal string.
(XXX NYI for Erlang).
library/io.m:
Add write_uint/[45].
Add the stream instance for uints and text output streams.
library/stream.string_writer.m:
Add put_uint/4.
Support uints in string_writer.write etc.
library/pprint.m:
Make uint an instance of the doc/1 type class.
library/pretty_printer.m:
Add a default formatter for uints.
library/int.m:
Unrelated change: fix formatting.
compiler/builtin_ops.m:
compiler/elds.m:
compiler/elds_to_erlang.m:
compiler/hlds_data.m:
compiler/llds.m:
compiler/llds_out_data.m:
compiler/mercury_to_mercury.m:
compiler/ml_lookup_switch.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/opt_debug.m
compiler/parse_tree_out.m:
compiler/parse_tree_out_info.m:
compiler/prog_data.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/hlds_out_util.m:
Use the uint type in places where we should.
compiler/mlds_to_java.m:
Fix a bug that causes us to generate badly typed Java.
For div and mod we need to cast the entire expression to
an int, not just the first operand.
compiler/c_util.m:
compiler/mlds_to_cs.m:
Add predicates for outputting unsigned integers in C and C#.
tests/hard_coded/test_pretty_printer_defaults.exp:
Conform to the above change to the pretty_printer module.
|
||
|
|
ff592131b3 |
Add a builtin unsigned word sized integer type -- Part 1b.
compiler/builtin_ops.m:
Implement unchecked_quotient, unchecked_rem, /\, \/, xor and \
as builtin operations.
compiler/bytecode.m:
compiler/c_util.m:
compiler/llds.m:
compiler/llds_out_data.m:
compiler/ml_global_data.m:
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
compiler/opt_debug.m:
Conform to the above change.
compiler/ml_unify_gen.m:
Fix a bug in my previous change: we should use uint_eq to test
for equality of uints, not eq.
compiler/hlds_data.m:
Document uint_tag/1.
runtime/mercury_tabling_macros.h:
Address review comment from Peter.
runtime/mercury_tabling_preds.h:
Add tabling macros for uints that I missed the first time around.
|
||
|
|
092e175f45 |
Add a builtin unsigned word sized integer type -- Part 1.
Add a new builtin type: uint, which is an unsigned word sized integer type.
Support for this new type will need be bootstrapped over several changes.
This is the first such change and does the following:
- Extends the compiler to recognize 'uint' as a builtin type.
- Extends the set of builtin operations to include relational and (some)
arithmetic operations on uints.
- Extends all of the code generators to handle the above. There are some
limitations currently marked by 'XXX UINT'. These will be lifted once
the compiler recognised uint and additional library support becomes
available.
- Extends the runtime to support uints.
compiler/prog_type.m:
compiler/prog_data.m:
compiler/builtin_lib_types.m:
Recognize uint as a builtin type.
Add a new alternative to the cons_id/0 type corresponding to the uint type
-- for bootstrapping purposes its argument is currently an int.
compiler/builtin_ops.m:
Add builtin relational and arithmetic operations on uints. Note that the
existing 'unsigned_le' operation is actually intended for use with signed
values. Rather than attempt to modify its meaning, I have just added new
operations specific to the uint type.
compiler/hlds_data.m:
Add a new tag type for uints.
compiler/type_ctor_info.m:
Recognise uint as a builtin.
Bump the RTTI version number here.
compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/dependency_graph.m:
compiler/export.m:
compiler/foreign.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/hlds_pred.m:
compiler/implementation_defined_literals.m:
compiler/inst_check.m:
compiler/mercury_to_mercury.m:
compiler/mode_util.m:
compiler/module_qual.qualify_items.m:
compiler/parse_tree_to_term.m:
compiler/parse_type_name.m:
compiler/polymorphism.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_rep_tables.m:
compiler/prog_util.m:
compiler/rbmm.execution_path.m:
compiler/rtti.m:
compiler/special_pred.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/type_constraints.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/unused_imports.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the above changes to the parse tree and HLDS.
compiler/c_util.m:
Support generating builtin operations for uints.
compiler/llds.m:
Add a representation for uint constants to the LLDS.
Map uints onto MR_Unsigned.
compiler/call_gen.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/jumpopt.m:
compiler/llds_out_data.m:
compiler/llds_out_instr.m:
compiler/opt_debug.m:
compiler/opt_util.m:
Support uints in the LLDS code generator.
compiler/mlds.m:
Support uint constants in the MLDS.
compiler/ml_accurate_gc.m:
compiler/ml_call_gen.m:
compiler/ml_global_data.m:
compiler/ml_simplify_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/rtti_to_mlds.m:
Conform to the above change to the MLDS.
compiler/mlds_to_c.m:
compiler/mlds_to_java.m:
compiler/mlds_to_cs.m:
Generate the appropriate target code for uint constants and uint
relational operations.
compiler/bytecode.m:
compiler/bytecode_gen.m:
Handle uints in the bytecode generator: we just abort if we
encounter them for now.
compiler/elds.m:
compiler/elds_to_erlang.m:
compiler/erl_call_gen.m:
compiler/erl_code_util.m:
compiler/erl_rtti.m:
compiler/erl_unify_gen.m:
Handle uints in the Erlang code generator.
library/private_builtin.m:
Add placeholders for builtin_{unify,compare}_uint. Since the
bootstrapping compiler will not recognize uint as a type, we
give them polymorphic arguments. These can be replaced after
this change has bootstrapped.
Update the Java list of TypeCtorRep constants, which for some
reason is defined here.
library/uint.m:
New module that will eventually contain operations on uints.
library/MODULES_DOCS:
library/library.m:
Add the uint module.
library/construct.m:
library/erlang_rtti_implementation.m:
library/rtti_implementation.m:
mdbcomp/program_representation.m:
Handle uints.
deep_profiler/program_representation_utils.m:
Conform to the above change.
runtime/mercury_dotnet.cs.in:
Update the list of TypeCtorReps for C#
java/runtime/TypeCtorRep.java:
Update this, although the actual TypeCtorRep constants
are defined the library.
runtime/mercury_type_info.h:
Bump the RTTI version number.
Add an alternative for uints to the tyepctor rep enum.
runtime/mercury_builtin_types.{h,c}:
runtime/mercury_builtin_types_proc_layouts.h:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_table_type_body.h:
runtime/mercury_tabling.h:
runtime/mercury_tabling_macros.h:
runtime/mercury_unify_compare_body.h:
Add uint as a builtin type and handle it throughout the runtime.
runtime/mercury_grade.h:
Bump the binary compatibility version.
runtime/mercury_term_size.c:
runtime/mercury_ml_expand_body.h:
Handle uint and fix probable bugs with the handling of ints on
64-bit Windows.
|
||
|
|
31ad78c1a9 |
Make c_util.m and file_util.m use explicit streams.
compiler/c_util.m:
compiler/file_util.m:
Replace every predicate that implicitly wrote to the current output stream
with two predicates: a predicate with the old name that takes an explicit
output stream parameter, and a predicate that still writes to the current
output stream, but whose name makes this fact clear.
Make some other minor improvements.
compiler/bytecode.m:
compiler/elds_to_erlang.m:
compiler/export.m:
compiler/fact_table.m:
compiler/layout_out.m:
compiler/llds_out_data.m:
compiler/llds_out_file.m:
compiler/llds_out_global.m:
compiler/llds_out_instr.m:
compiler/llds_out_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
compiler/rtti_out.m:
Conform to the changes above.
|
||
|
|
1ab13edca6 |
Switch over unary and binary ops in Java and C# code generators.
Fix more failing test cases in the non-C grades.
compiler/mlds_to_java.m:
compiler/mlds_to_cs.m:
Always switch over unary and binary ops. The existing code predates
the addition of multi-arm switches to the language and was intended to
the code duplication that would result in the absence of that feature.
Since we now have multi-arm switches it is by far preferable to use
a switch in these places.
XXX for binary ops the above change replicates what the existing code
did; I think it should actually abort in some cases.
Fix spelling.
Delete trailing whitespace.
compiler/java_util.m:
Delete this module, it isn't used anymore.
compiler/ml_backend.m:
Delete the include of the java_util module.
compiler/c_util.m:
Update a comment.
tests/exceptions/Mmakefile:
Fix the failure of 'test_uncaught_exception' in the java grade by
filtering out the stack trace generated by the JVM.
tests/hard_coded/float_reg.exp4:
Alternative expected output for this due to the way floats are
printed.
tests/invalid_purity/purity.m:
tests/invalid_purity/purity.err_exp:
Add C# and Java foreign_procs and updated the expected output.
tests/warnings/Mmakefile:
Fix my previous change, which broke things in non-Erlang grades.
|
||
|
|
4a84bb5c7f |
Add list.reverse_prepend.
reverse_prepend is the helper for non-naive reverse. It is useful in its own right so we export it here. library/list.m: Add predicate `reverse_prepend/3' and function `reverse_prepend/2'. compiler/c_util.m: Delete own copy of the same predicate. NEWS: Announce addition. |
||
|
|
f24b81f682 |
Delete more left over IL backend stuff.
runtime/mercury_il.il:
Delete this file -- it is no longer required.
compiler/options.m:
Delete references to the IL backend and 'il' and 'ilc' grades.
compiler/c_util.m:
Delete some references to the IL backend; add them
for the C# backend.
|
||
|
|
410c75c81f |
Respect --no-line-numbers-for-c-headers when writing .mh files.
This fixes mantis bug 393.
We already had an option named line_numbers_for_c_headers that was
supposed to govern whether we put #line directives into C header files,
While the default for the line_numbers option is "on", the default for
line_numbers_for_c_headers is "off".
The bug was that the distinction between the two options was respected only
by the code that output .mih files (in mlds_to_c.m), and not by the separate
code that output .mh files (in export.m).
compiler/c_util.m:
Change the predicates that output #line directives. Previously, they
always looked up the value of the line_numbers option. Now, they
use a flag provided by the caller.
Fix a sort-of related bug: we never write to .mh files, we write to .mh.tmp
files, and then rename them to .mh. This meant that the code that reset
the context after a code inclusion reset it to a file name that shortly
wouldn't exist. Fix that by getting the caller to provide the eventual
name, with the .mh suffix.
compiler/export.m:
Pass the flag based on the value of line_numbers_for_c_headers,
and the eventual name of the file being written, not its current name.
compiler/llds_out_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_managed.m:
Conform to the change in c_util.m.
|
||
|
|
47e93e5f29 | Convert (C->T;E) to (if C then T else E). | ||
|
|
bbb2535eb5 |
Break up mercury_to_mercury.m.
With almost 6000 lines, mercury_to_mercury.m was one of the biggest modules
of compiler, but it was far from cohesive. This diff carves seven new modules
out of it, each of which is much more cohesive. The stuff remaining in
mercury_to_mercury.m is still not as cohesive as one would like, but it is
now small enough that moving its individually-cohesive parts into modules
of their own would be overkill.
Three consequences of the old mercury_to_mercury.m's lack of cohesion
were that
- the order of predicate declarations often did not match the order of
their implementation;
- related predicates were not grouped together;
- even when they were grouped together, the order of those groups
was often random.
This diff fixes all three of these problems for all eight successor modules
of mercury_to_mercury.m: the seven new modules, and the new
mercury_to_mercury.m itself.
In some cases, this diff adds or improves the documentation of the predicates
in mercury_to_mercury.m's successor modules. In some other cases, it just
documents the lack of documentation :-(. In yet other cases, it removes
"documentation" that says nothing that isn't obvious from the predicate's name.
There are some algorithmic changes, but they are all trivial.
compiler/parse_tree_out.m:
New module containing the code to print out the top levels of parse trees,
including most sorts of items.
compiler/parse_tree_out_clause.m:
New module containing the code to print out clauses and goals.
compiler/parse_tree_out_pragma.m:
New module containing the code to print out pragmas.
compiler/parse_tree_out_pred_decl.m:
New module containing the code to print out predicate, function and
mode declarations. It is separate from parse_tree_out.m because a
significant number of compiler modules need only its functionality,
and not parse_tree_out.m's functionality.
compiler/parse_tree_out_inst.m:
New module containing the code to print out insts and modes.
compiler/parse_tree_out_term.m:
New module containing the code to print out variables and terms.
compiler/parse_tree_out_info.m:
New module containing the infrastructure of both mercury_to_mercury.m
and the other new modules.
compiler/parse_tree.m:
Include the new modules.
compiler/notes/compiler_design.html:
Document the new modules.
compiler/Mercury.options:
Transfer an option from mercury_to_mercury.m to the successor module
that needs it.
compiler/*.m:
Import one of the new modules either as well as, or instead of,
mercury_to_mercury.m. In most cases, we need to import only one
or two of mercury_to_mercury.m's successor modules; nowhere do we
need to import all eight.
Clean up some code in termination.m around a call to one of the
new modules.
tools/speedtest:
Replace mercury_to_mercury.m on the list of the ten largest modules
of the compiler.
|
||
|
|
4ac91a2d81 |
Fix how large negative integers are written for C89.
C does not have negative integer constants so "(MR_Integer) -nnnn" is the negation of a positive integer constant nnnn, converted to MR_Integer. In C89/C90 an unsuffixed decimal integer constant must be typed `int' or `long int' or `unsigned long int', whichever fits first. The negated result will have the same type. If nnnn > LONG_MAX then it will be typed `unsigned long int'. If MR_Integer is wider than `unsigned long int' then the conversion to MR_Integer yields a positive value, not negative. The solution here is essentially to write "-(MR_Integer) nnnn" so the integer constant is converted to a signed MR_Integer before negation. After this fix we no longer get these warnings from gcc: "this decimal constant is unsigned only in ISO C90". It turns out gcc was trying to tell us something. compiler/c_util.m: Add predicate `output_int_expr' to write ints in a way that avoids the problem. compiler/llds_out_data.m: compiler/mlds_to_c.m: Use `output_int_expr' to write ints. tests/hard_coded/Mmakefile: tests/hard_coded/c89_neg_int.exp: tests/hard_coded/c89_neg_int.m: Add test case. |
||
|
|
62ec97d443 |
Report imports shadowed by other imports.
If a module has two or more import_module or use_module declarations
for the same module, (typically, but not always, one being in its interface
and one in its implementation), generate an informational message about
each redundant declaration if --warn-unused-imports is enabled.
compiler/hlds_module.m:
We used to record the set of imported/used modules, and the set of
modules imported/used in the interface of the current module. However,
these sets
- did not record the distinction between imports and uses;
- did not allow distinction between single and multiple imports/uses;
- did not record the locations of the imports/uses.
The first distinction was needed only by module_qual.m, which *did*
pay attention to it; the other two were not needed at all.
To generate messages for imports/uses shadowing other imports/uses,
we need all three, so change the data structure storing such information
for *direct* imports to one that records all three of the above kinds
of information. (For imports made by read-in interface and optimization
files, the old set of modules approach is fine, and this diff leaves
the set of thus *indirectly* imported module names alone.)
compiler/unused_imports.m:
Use the extra information now available to generate a
severity_informational message about any import or use that is made
redundant by an earlier, more general import or use.
Fix two bugs in the code that generated warnings for just plain unused
modules.
(1) It did not consider that a use of the builtin type char justified
an import of char.m, but without that import, the type is not visible.
(2) It scanned cons_ids in goals in procedure bodies, but did not scan
cons_ids that have been put into the const_struct_db. (I did not update
the code here when I added the const_struct_db.)
Also, add a (hopefully temporary) workaround for a bug in
make_hlds_passes.m, which is noted below.
However, there are at least three problems that prevent us from enabling
--warn-unused-imports by default.
(1) In some places, the import of a module is used only by clauses for
a predicate that also has foreign procs. When compiled in a grade that
selects one of those foreign_procs as the implementation of the predicate,
the clauses are discarded *without* being added to the HLDS at all.
This leads unused_imports.m to generate an uncalled-for warning in such
cases. To fix this, we would need to preserve the Mercury clauses for
*all* predicates, even those with foreign procs, and do all the semantic
checks on them before throwing them away. (I tried to do this once, and
failed, but the task should be easier after the item list change.)
(2) We have two pieces of code to generate import warnings. The one in
unused_imports.m operates on the HLDS after type and mode checking,
while module_qual.m operates on the parse tree before the creation of
the HLDS. The former is more powerful, since it knows e.g. what types and
modes are used in the bodies of predicates, and hence can generate warnings
about an import being unused *anywhere* in a module, as opposed to just
unused in its interface.
If --warn-unused-imports is enabled, we will get two separate set of
reports about an interface import being unused in the interface,
*unless* we get a type or mode error, in which case unused_imports.m
won't be invoked. But in case we do get such errors, we don't want to
throw away the warnings from module_qual.m. We could store them and
throw them away only after we know we won't need them, or just get
the two modules to generate identical error_specs for each warning,
so that the sort_and_remove_dups of the error specs will do the
throwing away for us for free, if we get that far.
(3) The valid/bug100.m test case was added as a regression test for a bug
that was fixed in module_qual.m. However the bug is still present in
unused_imports.m.
compiler/make_hlds_passes.m:
Give hlds_module.m the extra information it now needs for each item_avail.
Add an XXX for a bug that cannot be fixed right now: the setting of
the status of abstract instances to abstract_imported. (The "abstract"
part is correct; the "imported" part may not be.)
compiler/intermod.m:
compiler/try_expand.m:
compiler/xml_documentation.m:
Conform to the change in hlds_module.m.
compiler/module_qual.m:
Update the documentation of the relationship of this module
with unused_imports.m.
compiler/hlds_data.m:
Document a problem with the status of instance definitions.
compiler/hlds_out_module.m:
Update the code that prints out the module_info to conform to the change
to hlds_module.m.
Print status information about instances, which was needed to diagnose
one of the bugs in unused_imports.m. Format the output for instances
nicer.
compiler/prog_item.m:
Add a convenience predicate.
compiler/prog_data.m:
Remove a type synonym that makes things harder to understand, not easier.
compiler/modules.m:
Delete an XXX that asks for the feature this diff implements.
Add another XXX about how that feature could be improved.
compiler/Mercury.options.m:
Add some more modules to the list of modules on which the compiler
should be invoked with --no-warn-unused-imports.
compiler/*.m:
library/*.m:
mdbcomp/*.m:
browser/*.m:
deep_profiler/*.m:
mfilterjavac/*.m:
Delete unneeded imports. Many of these shadow other imports, and some
are just plain unneeded, as shown by --warn-unused-imports. In a few
modules, there were a *lot* of unneeded imports, but most had just
one or two.
In a few cases, removing an import from a module, because it *itself*
does not need it, required adding that same import to those of its
submodules which *do* need it.
In a few cases, conform to other changes above.
tests/invalid/Mercury.options:
Test the generation of messages about import shadowing on the existing
import_in_parent.m test case (although it was also tested very thoroughly
when giving me the information needed for the deletion of all the
unneeded imports above).
tests/*/*.{m,*exp}:
Delete unneeded imports, and update any expected error messages
to expect the now-smaller line numbers.
|
||
|
|
d041b83943 |
Implement string switches via tries for the MLDS backend.
The code we emit to decide which arm of the switch is selected looks like this:
case_num = -1;
switch (MR_nth_code_unit(switchvar, 0)) {
case '98':
switch (MR_nth_code_unit(switchvar, 1)) {
case '99':
if (MR_offset_streq(2, switchvar, "abc"))
case_num = 0;
break;
case '100':
if (MR_offset_streq(2, switchvar, "aceg"))
case_num = 1;
break;
}
break;
case '99':
if (MR_offset_streq(2, switchvar, "bbb"))
case_num = 2;
break;
}
The part that acts on this will look like this for lookup switches:
if (case_num < 0)
succeeded = MR_FALSE;
else {
outvar1 = vector_common[case_num].f1;
...
outvarn = vector_common[case_num].fn;
succeeded = MR_TRUE;
}
and like this for non-lookup switches:
switch (case_num) {
case 0:
<code for case 0>
break;
...
case n:
<code for case n>
break;
default: /* if the switch is can_fail */
<code for failure>
break;
}
compiler/ml_string_switch.m:
Implement both non-lookup and lookup string switches via tries,
along the lines shown above.
compiler/ml_switch_gen.m:
Invoke the predicates that implement string switches via tries
in the circumstances in which option values call for them.
For now, we generate tries only for the C backend. Once the
problems identified for mlds_to_{cs,java,managed} below are fixed,
we can enable them on those backends as well.
compiler/options.m:
doc/user_guide.texi:
Add an option that governs the minimum size of trie switches.
compiler/ml_lookup_switch.m:
Factor out the code common to the implementation of all model-non
lookup switches, both in ml_lookup_switch.m and ml_string_switch.m,
and put it all into a new exported predicate.
The previously existing MLDS implementation methods for lookup switches
all build their lookup tables from maps that maps each cons_id
in the switch cases to the values of the output arguments of those cases.
For switch cases that apply to more than one cons_id, this map had
one entry for each of those cons_ids. For tries, we need a map
from *case ids*, not *cons ids* to the outputs. Since it is
easier to convert the one-to-one case_id->outputs map to the
many-to-one cons_id->outputs map than vice versa, change the
main data structure from which lookup tables are built to store data
in a case_id->outputs format, and provide predicates for its conversion
to the other (previously the only) format.
Rename ml_gen_lookup_switch to ml_gen_atomic_lookup_swith to distinguish
it from other predicates that also generate (other kinds of) lookup
switches.
compiler/switch_util.m:
Have the types representating lookup tables represent their contents
as a map, not as the assoc list derived from the map. Previously,
we didn't do anything with the map other than flatten it to the assoc list,
but for the MLDS backend, we may now also need to convert it to another
form of map (see immediately above).
compiler/builtin_ops.m:
Add two new builtin ops. The first, string_unsafe_index_code_unit,
returns the nth code unit in a string; the second, offset_str_eq,
does a string equality test on the nth and later code units of
two strings. They are used in the implementation of tries.
compiler/c_util.m:
Add a new binop category for each new binop, since they are not like
existing binops.
Put some existing binops into their own categories as well, since
bundling them with the other ops they were bundled with seems like
a bad idea.
compiler/hlds_goal.m:
Make the identifier of switch arms in tagged_cases a separate type
from int.
compiler/mlds_to_c.m:
compiler/llds_out_data.m:
Handle the new kinds of binops.
When writing out binop expressions, we used to do a switch on the binop
to get its category, and then another switch on the category. We now
switch on the binop directory, since this much harder to write out
code using new binops badly, and should be faster to boot.
In mlds_to_c.m, also make some cosmetic changes to the output to make it
easier to read, and thus to debug.
compiler/mlds_to_il.m:
Handle the new kinds of binops.
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
Do not handle the new kinds of binops, since doing so would require
changing the whole approach of how these modules handle binops.
Clean up some predicates.
compiler/bytecode.m:
compiler/erl_call_gen.m:
compiler/lookup_switch.m:
compiler/ml_global_data.m:
compiler/ml_optimize.m:
compiler/ml_tag_switch.m:
compiler/opt_debug.m:
compiler/string_switch.m:
Conform to the changes above.
compiler/ml_code_gen.m:
Put the predicates of this module into a consistent order.
library/string.m:
Fix white space.
runtime/mercury_string.h:
Add a macro for each of the two new builtin operations.
|
||
|
|
4776d05cbc | Fix the I/O section of the transition guide. | ||
|
|
8dc5a0071c |
Miscellaneous cleanups.
Just fixes to comments, better variable and predicate names, and the like. No algorithmic changes. |
||
|
|
82618c6e83 |
Make pointer_equal a builtin.
There was an inline pragma on its definition, but most programs, including
the compiler, are (most of the time) not compiled with the intermodule
optimization options that would allow this to take effect. Making it a builtin
gets around this "problem".
compiler/builtin_ops.m:
Add private_builtin.pointer_equal as a builtin op.
Factor out some more commonalities between existing builtin ops.
compiler/bytecode.m:
Add the new pointer_equal_conservative op. The bytecode backend
doesn't handle it, but then again, it doesn't handle really anything
else either.
compiler/c_util.m:
Handle the new operator, including adding a new category for it.
compiler/llds.m:
compiler/ml_global_data.m:
Record the output type of the new operator.
compiler/llds_out_data.m:
Generate code for the new operator for the LLDS backend.
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
compiler/mlds_to_il.m:
Generate code for the new operator for the MLDS backend
when targeting C, C#, Java and IL respectively. The IL version
just aborts, since I don't know IL well enough to know what
code to generate for "false" (the conservative approximation,
also used for Erlang), but this should be ok, since the backend
is not functional anyway.
compiler/erl_call_gen.m:
Generate code for the new operator for the ELDS backend.
The code we generate always returns false, which is allowed by the
operator, since this is a conservative approximation.
Start using require_complete_switch to ensure that we handle all
operators. Add code to handle the old operators that this code
did not used to handle.
compiler/java_util.m:
Add an XXX comment about a scheme to handle operators that does not allow
anything similar to such a require_complete_switch.
compiler/opt_debug.m:
Pretty print the new operator.
compiler/options.m:
Allow the definition of builtins such as pointer_equal while this
change is bootstrapped.
library/private_builtin.m:
Remove the inline pragma from pointer_equal, because the compiler
can't handle such a pragma for a builtin, even when being bootstrapped.
This could be fixed, but isn't worth the bother. A compiler builtin
is like an inline pragma that works even without intermodule optimization.
|
||
|
|
13b6f03f46 |
Module qualify end_module declarations.
compiler/*.m:
Module qualify the end_module declarations. In some cases, add them.
compiler/table_gen.m:
Remove an unused predicate, and inline another in the only place
where it is used.
compiler/add_pragma.m:
Give some predicates more meaningful names.
|
||
|
|
8f6bbc437c |
Print version information more succinctly
In the Mercury compiler itself, and in a number of tools we print a version
string on one line,
$ mmc --version
Mercury Compiler, version rotd-2013-10-01, configured for x86_64-unknown-linux-gnu
Copyright (C) 1993-2013 The University of Melbourne
When the version number is sufficiently long, such as for an ROTD release, this
will wrap on 80 column terminals. This change splits these strings into two
parts: the version and the architecture string. These can then either be
printed more succinctly on one line
$ mmc --version
Mercury Compiler, version rotd-2013-10-01, on x86_64-unknown-linux-gnu
Copyright (C) 1993-2013 The University of Melbourne
Or when written to a file such as the .c files that mmc generates, can be
written out onto two lines:
XXX
library/library.m:
Make the version predicate return two values, one for the version number
and the other for the architecture name. This makes it easier to format
the version information in the various places it is used.
compiler/handle_options.m:
deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_create_feedback.m:
deep_profiler/mdprof_report_feedback.m:
deep_profiler/mdprof_test.m:
profiler/mercury_profile.m:
Format this as shown above for the Mercury compiler and other tools.
compiler/c_util.m:
compiler/elds_to_erlang.m:
compiler/export.m:
compiler/fact_table.m:
compiler/llds_out_file.m:
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/write_deps_file.m:
Format version information on two lines when it is used in the
compiler's various output files.
|
||
|
|
ad4b79e6ee |
Add a `pregen' grade component.
Add a `pregen' grade component and associated option `--pregenerated-dist',
intended for use in the pre-generated C files in the source distribution
ONLY.
Traditionally, by forcing the use of 2 tag bits and boxed floats, we
could provide one set of pre-generated C files, nominally targeting
32-bit platforms but also working on 64-bit platforms.
This became insufficient after I made two data representation changes.
The same constructor may have different layouts of its arguments
for --bits-per-word=32 and --bits-per-word=64:
- double-precision `float' arguments can be stored across two
words on 32-bit, whereas only one word is required on 64-bit;
- consecutive enum arguments can be packed into a single word
but the number of arguments that can be packed differs.
As a result, data structures created in a user module could be
misinterpreted when passed to a pre-generated standard library module,
and vice versa. (The enum case probably does not occur in practice.)
The solution adopted here is to allow configure to detect normal 64-bit
settings (3 tag bits, unboxed floats) irrespective of whether a usable
Mercury installation already exists. When present, the `pregen' grade
component causes the compiler and scripts to override the configuration
and enforce settings for portable C source files. The source
distribution should supply C source files from a `pregen' grade.
During installation, if required, the pre-generated C source files are
used to build and install a Mercury compiler _in a .pregen grade_.
Then it is used to install the libraries _in non-.pregen grades_,
so that configured settings have their usual effect.
Another benefit is that a user on a 64-bit system will get the "optimal"
installation using 3 tag bits and unboxed floats without additional
effort.
A small disadvantage is that a minimal installation of Mercury takes
slightly longer, as the default library grade no longer comes from the
pre-generated C source files.
compiler/options.m:
Add `--pregenerated-dist' option (same as `pregen' grade component).
Add `--arg-pack-bits <n>' internal option.
`--allow-argument-packing' is obsolete.
Add `--allow-double-word-fields' internal option.
compiler/handle_options.m:
Add `pregen' grade component. `pregen' implies boxed floats and
`spf' (single-prec float) implies unboxed floats, so we consider
them incompatible. There should be no need to use both at once.
In `pregen' grades, override settings to create portable C
source files.
Handle the internal `--arg-pack-bits <n>' option.
compiler/make_hlds_passes.m:
Pack only as many consecutive arguments as will fit into the
number of bits specified by `--arg-pack-bits', rather than into
the number of word bits. `pregen' implies --arg-pack-bits=32
Use `--allow-double-word-fields' to decide whether to store
floats across two words. `pregen' disables it.
compiler/compile_target_code.m:
Define MR_PREGENERATED_DIST when compiling C files in a `pregen'
grade.
compiler/c_util.m:
Write PREGENERATED_DIST={yes,no} into the grade info header at
the top of C files. This is checked by configure.
runtime/mercury_conf_param.h:
Make MR_PREGENERATED_DIST force the same settings as the
`--pregenerated-dist' option.
runtime/mercury_grade.h:
Add "_pregen" to the MR_GRADE macro so that `pregen' and
non-`pregen' object files are not accidentally mixed.
configure.ac:
As above, do NOT force 2 tag bits and unboxed floats when there
is no usable Mercury compiler installed.
BOOTSTRAP_GRADE is now a grade containing `.pregen'.
Make a minimal installation install $BEST_GRADE_FOR_COMPILER as
the default grade, not the grade that the compiler happens to be
built in, which might be a `pregen' grade.
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/parse_grade_options.sh-subr:
Support `pregen' grade component and `--pregenerated-dist'
in shell scripts.
tools/test_mercury:
Add a note.
|
||
|
|
16bd4acd2f |
Shorten lines longer than 79 characters.
Estimated hours taken: 2 Branches: main compiler/*.m: Shorten lines longer than 79 characters. |
||
|
|
c650eaddd2 |
A bunch of individually small changes to speed up the compiler when compiling
Estimated hours taken: 8
Branches: main
A bunch of individually small changes to speed up the compiler when compiling
training_cars_full.m. Altogether, the changes speed up the compiler on that
task by a bit more than 11% when the target grade is asm_fast.gc, and by a bit
more than 7% when the target grade is hlc.gc. (Several of the changes affect
the code that optimizes the LLDS; we don't have corresponding optimizers
for the MLDS.)
compiler/c_util.m:
Specialize the code that prints out quoted strings for the target
language. We don't want to check the target language during
the conversion of EVERY SINGLE CHARACTER.
compiler/dead_proc_elim.m:
When we analyze the module for inlining, we are only after the
use counts of procedures. We do not need to traverse ground structures
to get those counts.
compiler/dupelim.m:
Do the search and insertion in the standardized code sequence map
in one pass.
compiler/global_data.m:
compiler/ml_global_data.m:
Do the search and insertion in the scalar data map in one pass.
library/bimap.m:
Add a search_insert predicate to make possible the changes in
{ml_,}global_data.m.
NEWS:
Mention the new predicate in bimap.m.
compiler/inst_match.m:
Do searches and insertions in sets of expansions in one pass.
Highlight discrepancies between comments on the declarations
of two predicates and comments on their code.
compiler/llds_out_global.m:
compiler/post_typecheck.m:
Reorder the bodies of some test conditions to put the cheaper and
more-frequently-failing tests first.
compiler/labelopt.m:
compiler/opt_util.m:
Do not require opt_util to return a list of code addresses that
labelopt then throws away; allow opt_util.m not to gather those
addresses in the first place (if the unused_args optimization
is applied to it, which it is by default.)
In opt_util.m, make an unnecessarily-exported predicate private.
compiler/prog_data.m:
Use predicates in varset.m that do directly what we want, instead
of using a different predicate and then post-processing its output.
(The code was originally written before the directly useful predicate
in varset.m was available.)
compiler/type_util.m:
Specialize the frequently occurring case of no typeclass constraints
at all.
compiler/typecheck_info.m:
Give the field names of some types identifying prefixes.
Make a function symbol's name more meaningful.
compiler/typecheck.m:
compiler/typecheck_errors.m:
Conform to the changes in typecheck_info.m.
|
||
|
|
48adbbd8c2 |
Fix bug #240 and bug #211. When MR_Float is wider than MR_Word, the C compiler
Branches: main Fix bug #240 and bug #211. When MR_Float is wider than MR_Word, the C compiler may introduce padding for the structure field following the MR_Float. When MR_Float is narrower than MR_Word the C compiler may pack consecutive MR_Float fields. In both cases the C structure layout does not match what was intended by the Mercury compiler. A test case was committed earlier. runtime/mercury_float.h: Add a typedef `MR_Float_Aligned' which forces word alignment using C extensions provided by gcc/clang/MSVC. compiler/llds_out_global.m: compiler/mlds_to_c.m: Use `MR_Float_Aligned' in place of `MR_Float' in structure definitions. Output #pragma pack directives around scalar cell group structures. This is for MSVC. compiler/c_util.m: Add helper predicates to output #pragma pack directives for MSVC. runtime/mercury_conf.h.in: Define MR_BYTES_PER_WORD. The necessary code in configure.in already exists. |
||
|
|
4c2846593a |
Make it possible to store double-precision `float' constructor arguments in
Branches: main Make it possible to store double-precision `float' constructor arguments in unboxed form, in low-level C grades on 32-bit platforms, i.e. `float' (and equivalent) arguments may occupy two machine words. However, until we implement float registers, this does more harm than good so it remains disabled. compiler/llds.m: Add a type `cell_arg' to hold information about an argument of a cell being constructed. Change `heap_ref' so that we can refer to a pointer with an unknown tag. compiler/unify_gen.m: Use the `cell_arg' type to simplify code related to generating constructions. Handle double word arguments in constructions and deconstructions. Update enumeration packing code to account for the presence of double width arguments and the `cell_arg' type. Take double width arguments into account when generating ground terms. compiler/code_info.m: Extend `assign_field_lval_expr_to_var' to work for expressions involving multiple field lvals of the same variable. Make `assign_cell_to_var' conform to changes. compiler/code_util.m: Add a predicate to calculate the size of a cell given its cell_args. compiler/var_locn.m: Conform to the use of the `cell_arg' type and the presense of double width arguments. Calculate cell size correctly in places. Move sanity checking from `var_locn_assign_field_lval_expr_to_var' to `code_info.assign_field_lval_expr_to_var'. compiler/global_data.m: Make `rval_type_as_arg' take into account the width of the argument. Conform to changes. compiler/c_util.m: Add a new binop category. Unlike the existing macro_binop category, the arguments of macros in this category cannot all be assumed to be of integral types. compiler/llds_out_data.m: compiler/llds_out_instr.m: Output calls to the macros `MR_float_word_bits', `MR_float_from_dword' and `MR_float_from_dword_ptr' which were introduced previously. When a `heap_ref' has an unknown tag, make the generated code mask off the tag bits. compiler/lco.m: Disable the optimisation when float arguments are present, on the basis of whether Mercury floats are wider than a machine word. The comments about when floats are stored in boxed form are out of date. compiler/arg_pack.m: Rename a predicate. compiler/make_hlds_passes.m: Update a comment. compiler/disj_gen.m: compiler/exprn_aux.m: compiler/global_data.m: compiler/llds_to_x86_64.m: compiler/lookup_switch.m: compiler/mlds_to_c.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/stack_layout.m: compiler/string_switch.m: Conform to changes. runtime/mercury_float.h: Add a cast to `MR_float_word_bits' to avoid a gcc error. tests/hard_coded/Mercury.options: tests/hard_coded/Mmakefile: tests/hard_coded/heap_ref_mask_tag.exp: tests/hard_coded/heap_ref_mask_tag.m: tests/hard_coded/reuse_double.exp: tests/hard_coded/reuse_double.m: Add test cases. tests/hard_coded/lookup_disj.exp: tests/hard_coded/lookup_disj.m: Extend existing test case. |
||
|
|
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. |
||
|
|
3788a9d6fb |
Improve Unicode support.
Branches: main
Improve Unicode support.
Declare that we use the Unicode character set, and UTF-8 or UTF-16 for the
internal string representation (depending on the backend). User code may be
written to those assumptions. Other external encodings can be supported in
the future by translating to/from Unicode internally.
The `char' type now represents a Unicode code point.
NOTE: questions about how to handle unpaired surrogate code points, etc. have
been left for later.
library/char.m:
Define a `char' to be a Unicode code point and extend ranges
appropriately.
Add predicates: to_utf8, to_utf16, is_surrogate, is_noncharacter.
Update some documentation.
library/io.m:
Declare I/O predicates on text streams to read/write code points, not
ambiguous "characters". Text files are expected to use UTF-8 encoding.
Supporting other encodings is for future work.
Update the C and Erlang implementations to understand UTF-8 encoding.
Update Java and C# implementations to read/write code points (Mercury
char) instead of UTF-16 code units.
Add `may_not_duplicate' attributes to some foreign_procs.
Improve Erlang implementations of seeking and getting the stream size.
library/string.m:
Declare the string representations, as described earlier.
Distinguish between code units and code points everywhere.
Existing functions and predicates which take offset and length
arguments continue to take them in terms of code units.
Add procedures: count_code_units, count_codepoints, codepoint_offset,
to_code_unit_list, from_code_unit_list, index_next, unsafe_index_next,
unsafe_prev_index, unsafe_index_code_unit, split_by_codepoint,
left_by_codepoint, right_by_codepoint, substring_by_codepoint.
Make index, index_det call error/1 if an illegal sequence is detected,
as they already do for invalid offsets.
Clarify that is_all_alpha, is_all_alnum_or_underscore,
is_alnum_or_underscore only succeed for the ASCII characters under each
of those categories.
Clarify that whitespace stripping functions only strip whitespace
characters in the ASCII range.
Add comments about the future treatment of surrogate code points
(not yet implemented).
Use Mercury format implementation when necessary instead of `sprintf'.
The %c specifier does not work for code points which require multi-byte
representation. The field width modifier for %s only works if the
string contains only single-byte code points.
library/lexer.m:
Conform to string encoding changes.
Simplify code dealing with \uNNNN escapes now that encoding/decoding
is handled by the string module.
library/term_io.m:
Allow code points above 126 directly in Mercury source.
NOTE: \x and \o codes are treated as code points by this change.
runtime/mercury_types.h:
Redefine `MR_Char' to be `int' to hold a Unicode code point.
`MR_String' has to be defined as a pointer to `char' instead of a
pointer to `MR_Char'. Some C foreign code will be affected by this
change.
runtime/mercury_string.c:
runtime/mercury_string.h:
Add UTF-8 helper routines and macros.
Make hash routines conform to type changes.
compiler/c_util.m:
Fix output_quoted_string_lang so that it correctly outputs non-ASCII
characters for each of the target languages.
Fix quote_char for non-ASCII characters.
compiler/elds_to_erlang.m:
Write out code points above 126 normally instead of using escape
syntax.
Conform to string encoding changes.
compiler/mlds_to_cs.m:
Change Mercury `char' to be represented by C# `int'.
compiler/mlds_to_java.m:
Change Mercury `char' to be represented by Java `int'.
doc/reference_manual.texi:
Uncomment description of \u and \U escapes in string literals.
Update description of C# and Java representations for Mercury `char'
which are now `int'.
tests/debugger/tailrec1.m:
Conform to renaming.
tests/general/string_replace.exp:
tests/general/string_replace.m:
Test non-ASCII characters to string.replace.
tests/general/string_test.exp:
tests/general/string_test.m:
Test non-ASCII characters to string.duplicate_char,
string.pad_right, string.pad_left, string.format_table.
tests/hard_coded/char_unicode.exp:
tests/hard_coded/char_unicode.m:
Add test for new procedures in `char' module.
tests/hard_coded/contains_char_2.m:
Test non-ASCII characters to string.contains_char.
tests/hard_coded/nonascii.exp:
tests/hard_coded/nonascii.m:
tests/hard_coded/nonascii_gen.c:
Add code points above 255 to this test case.
Change test data encoding to UTF-8.
tests/hard_coded/string_class.exp:
tests/hard_coded/string_class.m:
Add test case for string.is_alpha, etc.
tests/hard_coded/string_codepoint.exp:
tests/hard_coded/string_codepoint.exp2:
tests/hard_coded/string_codepoint.m:
Add test case for new string procedures dealing with code points.
tests/hard_coded/string_first_char.exp:
tests/hard_coded/string_first_char.m:
Add test case for all modes of string.first_char.
tests/hard_coded/string_hash.m:
Don't use buggy random.random/5 predicate which can overflow on
a large range (such as the range of code points).
tests/hard_coded/string_presuffix.exp:
tests/hard_coded/string_presuffix.m:
Add test case for string.prefix, string.suffix, etc.
tests/hard_coded/string_set_char.m:
Test non-ASCII characters to string.set_char.
tests/hard_coded/string_strip.exp:
tests/hard_coded/string_strip.m:
Test non-ASCII characters to string stripping procedures.
tests/hard_coded/string_sub_string_search.m:
Test non-ASCII characters to string.sub_string_search.
tests/hard_coded/unicode_test.exp:
Update expected output due to change of behaviour of
`string.to_char_list'.
tests/hard_coded/unicode_test.m:
Test non-ASCII character in separator string argument to
string.join_list.
tests/hard_coded/utf8_io.exp:
tests/hard_coded/utf8_io.m:
Add tests for UTF-8 I/O.
tests/hard_coded/words_separator.exp:
tests/hard_coded/words_separator.m:
Add test case for `string.words_separator'.
tests/hard_coded/Mmakefile:
Add new test cases.
Make special_char test case run on all backends.
tests/hard_coded/special_char.exp:
tests/valid/mercury_java_parser_follow_code_bug.m:
Reencode these files in UTF-8.
NEWS:
Add a news entry.
|
||
|
|
9319cc4b03 |
Use the supported time profiling method, i.e. real time, on Cygwin by default
Branches: main, 11.01 Use the supported time profiling method, i.e. real time, on Cygwin by default rather than attempting to use an unsupported method. Avoid a C compiler warning on Cygwin. runtime/mercury_wrapper.c: Make real time the default time profiling method on Cygwin since the other methods are not supported on that platform. (According to the Cygwin implementation notes on only ITIMER_REAL is supported with setitimer.) doc/user_guide.texi: Mention that -Tr is the default time method for time profiling on Cygwin. (The existing text referred to Windows, but that's not accurate - time profiling doesn't work at all with MinGW.) Unrelated change: Erlang is also supported as a foreign language. compiler/c_util.m: Avoid a warning from the C compiler on Cygwin. |
||
|
|
bf5c9a79a5 |
Until now, all hash tables on strings used a single standard hash function.
Estimated hours taken: 3 Branches: main Until now, all hash tables on strings used a single standard hash function. However, any single hash function has a pretty good probability of generating collisions on small hash tables. This diff adds two new hash functions on strings. When generating hash tables, we now try out all three hash functions, and use the one that generates the fewest collisions. runtime/mercury_string.h: Add C implementations of the new hash functions. library/string.m: Add Mercury implementations of the new hash functions. compiler/builtin_ops.m: Add the new hash functions as builtin operations. compiler/switch_util.m: Select the best hash function for each hash switch on strings. compiler/ml_string_switch.m: compiler/string_switch.m: Use the selected hash function for each hash table. compiler/bytecode.m: compiler/c_util.m: compiler/java_util.m: compiler/llds.m: compiler/llds_tox86_64.m: compiler/mlds_to_gcc.m: compiler/mlds_to_il.m: compiler/opt_debumlds_to_ilg.m: Conform to the presence of the new hash functions. |
||
|
|
4db9b2adbf |
Until now, the only indexing we did for switches on strings was using a hash
Estimated hours taken: 40
Branches: main
Until now, the only indexing we did for switches on strings was using a hash
table containing jump targets (represented as indices into a list of labels).
This diff supplements this with
- binary searches of tables containing jump targets,
- binary searches of tables containing values (lookup tables), and
- hash searches of tables containing values (lookup tables).
For now, the new methods exist in the LLDS backend only.
NEWS:
Mention the new capability.
compiler/string_switch.m:
Add predicates that implement the new indexing methods on strings.
Factor out code from existing predicates as required for this.
compiler/switch_gen.m:
Invoke the new predicates in string_switch.m when relevant.
Avoid passing the constant "no" as the initial value of !MaybeEnd
to predicates where we know this will ALWAYS happen.
compiler/options.m:
doc/user_guide.texi:
Add an option to control when we use binary searches for switches
on strings.
compiler/lookup_switch.m:
This module previously handled lookup switches on integers.
Generalize it so that pieces of it are now also usable to help
implement lookup switches on strings. Rename the predicates specific
to switches on integers to make clear this specificity, and separate
them from the predicates that help implement lookup switches on
variables of all the supported types.
Export some types, predicates and functions for use in string_switch.m.
Fix the code so that it correctly handles det switches, which
can happen e.g. if we know the possible set of values of the
switched-on variable.
Use tail-recursive code to handle the list of switch arms, to allow us
to handle very large switches.
Remove an obsolete comment from the top about a previously implemented
optimization.
compiler/lookup_util.m:
Make set_liveness_and_end_branch update MaybeEnd, to account for the
reservation of stack slots for holding the current and last rows in
later solutions tables for model_non lookup switches.
compiler/switch_util.m:
Make the exported predicates of this module more general, making them
usable for switches on strings as well as ints. Also make them easier
to use. In one case this meant bundling two predicates that were always
used together into one predicate. In another, it meant splitting one
predicate into two, since some of its callers needed an intermediate
result. In the case of a type, it means reordering its fields
to make the order match the order of their use in the implementation.
Add some predicates specifically for switches on strings.
compiler/ml_lookup_switch.m:
compiler/ml_string_switch.m:
compiler/ml_switch_gen.m:
Conform to the changes to switch_util.m.
compiler/jumpopt.m:
If the comment associated with a label ends with "nofulljump", then
inhibit fulljump optimization of jumps to that label. That
optimization would replace the jumps with the code starting at that
label. This is avoids the overhead of jump instructions, and it is a
good idea in the usual case of forward jumps. However, for the few
backward jumps we generate, the block that replaces the jump
instruction can actually END with the same jump instruction (which may
be conditionally executed), which means that our usual repeated
invocation of jumpopt can replace the original jump instruction
with MANY copies of the block it jumps to. In some cases, such as those
in hash switches, you get more copies than can ever be executed in any
actual execution. Lookup switches therefore now mark the labels that
are targets of backward jumps with this marker.
compiler/llds.m:
Document the new behavior of jumpopt.
compiler/code_info.m:
Export a predicate for use in improving the code we generate for lookup
switches.
Make some other predicates simpler and/or more efficient.
compiler/builtin_ops.m:
Add a builtin op for doing string comparisons by calling strcmp.
This is to prevent the need for two traversals of the strings being
compared in each iteration of binary search.
compiler/bytecode.m:
compiler/c_util.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/llds.m:
compiler/llds_to_x86_64.m:
Conform to the change in builtin_ops.m.
compiler/disj_gen.m:
Conform to the change in lookup_util.m
compiler/frameopt.m:
compiler/proc_gen.m:
compiler/unify_gen.m:
Take advantage of the change in fulljump optimization.
compiler/opt_debug.m:
Improve the string representation of rvals by recording the types of
the operands of binary operations, and making the output a bit more
consistent looking.
compiler/dupproc.m:
compiler/var_locn.m:
Minor style fixes.
runtime/mercury_string.h:
Add a version of strcmp for use by our code generator. This version
casts the arguments before calling the real strcmp. We need it since we
usually specify the arguments as r1, r2 etc, which are declared as
MR_Word, not char *.
tests/hard_coded/lookup_disj.{m,exp}:
tests/hard_coded/string_switch.{m,exp}:
Make these existing tests significantly tougher by making them exercise
a wider range of use scenarios.
tests/hard_coded/string_switch{2,3}.{m,exp}:
tests/hard_coded/Mercury.options
While the string_switch test case tests the handling of jump switches,
these two new test cases test the handling of binary search tables and
hash tables respectively. Their code is identical to the code of
the string_switch test case, but Mercury.options causes them to be
compiled with different options.
tests/hard_coded/int_switch.{m,exp}:
A new test case, equivalent in structure to the string switch test
cases, to test the handling of lookup switches on atomic values.
|
||
|
|
57f9013259 |
Start a C# backend, adapted from mlds_to_java.m.
Branches: main
Start a C# backend, adapted from mlds_to_java.m.
Some `pragma foreign_*' declarations are commented out in this change because
no bootstrap compiler will yet accept "C#" in the language specification.
The compiler already supported C# foreign_procs for the IL backend, but the IL
backend and this new backend do not agree on naming and calling conventions so
the changes to the existing C# foreign_procs will further break the IL backend.
Nobody cares.
Only tested so far with Mono on Linux.
compiler/mlds_to_cs.m:
New module. In the CVS Attic there exists an obsolete file named
mlds_to_csharp.m (replaced by mlds_to_managed.m) which we don't want to
conflict with.
For C# we need to know if a `pragma foreign_type' is a value or
reference type. Currently this is done by accepting a fake keyword
`valuetype' before the type name, like for IL.
compiler/ml_backend.m:
compiler/mercury_compile.m:
compiler/mercury_compile_mlds_back_end.m:
Hook up the C# backend.
compiler/globals.m:
Add `target_csharp' as a target language.
compiler/options.m:
Add `--csharp' and `--csharp-only' options and their synonyms.
compiler/handle_options.m:
Handle `target_csharp' like `target_java', except for features which
are still to be implemented.
compiler/add_pragma.m:
Allow C# as a `pragma foreign_export' language.
Allow C# for `pragma foreign_export_enum'.
Conform to changes.
compiler/hlds_data.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
Accept C# as a language for `pragma foreign_type'.
Accept `csharp' as the name of a grade in trace parameters.
compiler/make_hlds_passes.m:
Reuse most of the code for implementing mutables on Java for C#.
compiler/mlds.m:
Add a new MLDS target language, `ml_target_csharp'.
Conform to changes.
compiler/ml_foreign_proc_gen.m:
Generate foreign_procs for C#.
compiler/foreign.m:
Update predicates to support C# targets.
compiler/c_util.m:
Make `quote_string' use hexadecimal escapes in C# string literals.
compiler/parse_tree.m:
compiler/java_names.m:
Add C# equivalents for predicates in this module. `java_names' is a
misleading module name, but the predicates for C# and Java share some
code and may possibly be combined in the future.
compiler/rtti.m:
Add predicates to return the names of RTTI structures in C#.
compiler/simplify.m:
Handle the trace parameter `grade(csharp)'.
compiler/compile_target_code.m:
compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
Add some support for building of executables and libraries with
`--target csharp'.
compiler/ml_global_data.m:
compiler/ml_optimize.m:
compiler/ml_proc_gen.m:
compiler/ml_switch_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/granularity.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_to_mercury.m:
compiler/ml_code_util.m:
compiler/ml_disj_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/modules.m:
compiler/pragma_c_gen.m:
compiler/prog_foreign.m:
compiler/special_pred.m:
compiler/write_deps_file.m:
Conform to changes.
library/builtin.m:
library/rtti_implementation.m:
library/type_desc.m:
Implement RTTI procedures for the new backend, which uses a high-level
data representation (like the Java backend). The existing C# code was
designed for the IL backend, which used a low-level representation of
the RTTI data structures.
Most (if not all) of the the "new" code is exactly the same as the Java
versions, with only syntactic changes.
Rename the C# class `void_0' to `Void_0' to match the naming convention
used by mlds_to_cs.m.
library/array.m:
Update the existing C# code to work with the new backend.
Use `object[]' as the type of all array of non-primitive types.
The problem is one we encountered on the Java backend: when creating a
new array based on the type of a single element, we don't know whether
the new array should contain elements of the class or superclass.
library/bool.m:
Export `bool' constants to C#.
library/exception.m:
Update the existing C# code to work with the new backend.
Move the `mercury.runtime.Exception' C# class to mercury_dotnet.cs.
library/float.m:
Add C# implementations of `is_nan' and `is_inf'.
library/list.m:
Add methods for manipulating lists from hand-written C# code.
library/string.m:
Add C# implementations of string procedures which were missing.
library/dir.m:
library/io.m:
library/library.m:
Update the existing C# code to work with the new backend.
library/private_builtin.m:
Update the existing C# code to work with the new backend.
Delete the static constants which are duplicated in mercury_dotnet.cs.
The mlds_to_cs.m will emit references to the constants in the latter
only.
library/backjump.m:
library/bitmap.m:
library/mutvar.m:
library/par_builtin.m:
library/region_builtin.m:
library/store.m:
library/thread.m:
library/thread.semaphore.m:
library/time.m:
library/univ.m:
Make these modules compile with the C# backend.
runtime/mercury_dotnet.cs.in:
Add RTTI classes to the `mercury.runtime' namespace, equivalent to
those on the Java backend.
Use enumerations `MR_TYPECTOR_REP_*' and `MR_SECTAG_*' constants so we
can switch on them.
Add the `UnreachableDefault' exception class.
Hide old classes which are unused with the new backend behind
#ifdef !MR_HIGHLEVEL_DATA.
|
||
|
|
5aa3d14ee5 |
Preparation for building the source distribution in high-level C grades.
compiler/c_util.m: Output whether we are using high-level code or not in the comments at the head of generated .c files. |
||
|
|
4ebe3d0d7e |
Stop storing globals in the I/O state, and divide mercury_compile.m
Estimated hours taken: 60 Branches: main Stop storing globals in the I/O state, and divide mercury_compile.m into smaller, more cohesive modules. (This diff started out as doing only the latter, but it became clear that this was effectively impossible without the former, and the former ended up accounting for the bulk of the changes.) Taking the globals out of the I/O state required figuring out how globals data flowed between pieces of code that were often widely separated. Such flows were invisible when globals could be hidden in the I/O state, but now they are visible, because the affected code now passes around globals structures explicitly. In some cases, the old flow looked buggy, as when one job invoked by mmc --make could affect the globals value of its parent or the globals value passed to the next job. I tried to fix such problems when I saw them. I am not 100% sure I succeeded in every case (I may have replaced old bugs with new ones), but at least now the flow is out in the open, and any bugs should be much easier to track down and fix. In most cases, changes the globals after the initial setup are intended to be in effect only during the invocation of a few calls. This used to be done by remembering the initial values of the to-be-changed options, changing their values in the globals in the I/O state, making the calls, and restoring the old values of the options. We now simply create a new version of the globals structure, pass it to the calls to be affected, and then discard it. In two cases, when discovering reasons why (1) smart recompilation should not be done or (2) item version numbers should not be generated, the record of the discovery needs to survive this discarding. This is why in those cases, we record the discovery by setting a mutable attached to the I/O state. We use pure code (with I/O states) both to read and to write the mutables, so this is no worse semantically than storing the information in the globals structure inside the I/O state. (Also, we were already using such a mutable for recording whether -E could add more information.) In many modules, the globals information had to be threaded through several predicates in the module. In some places, this was made more difficult by predicates being defined by many clauses. In those cases, this diff converts those predicates to using explicit disjunctions. compiler/globals.m: Stop storing the globals structure in the I/O state, and remove the predicates that accessed it there. Move a mutable and its access predicate here from handle_options.m, since here is when the mutables treated the same way are. In a couple of cases, the value of an option is available in a mutable for speed of access from inside performance-critical code. Set the values of those mutables from the option when the processing of option values is finished, not when it is starting, since otherwise the copies of each option could end up inconsistent. Validate the reuse strategy option here, since doing it during ctgc analysis (a) is too late, and (b) would require an update to the globals to be done at an otherwise inconvenient place in the code. Put the reuse strategy into the globals structure. Two fields in the globals structure were unused. One (have_printed_usage) was made redundant when the one predicate that used it itself became unused; the other (source_file_map) was effectively replaced by a mutable some time ago. Delete these fields from the globals. Give the fields of the globals structure a distinguishing prefix. Put the type declarations, predicate declarations and predicate definitions in a consistent order. compiler/source_file_map.m: Record this module's results only in the mutable (it serves as a cache), not in globals structure. Use explicitly passed globals structure for other purposes. compiler/handle_options.m: Rename handle_options as handle_given_options, since it does not process THE options to the program, but the options it is given, and even during the processing of a single module, it can be invoked up the three times in a row, each time being given different options. (It was up to four times in a row before this diff.) Make handle_given_options explicitly return the globals structure it creates. Since it does not take an old global structure as input and globals are not stored in the I/O state, it is now clear that the globals structure it returns is affected only by the default values of the options and the options it processes. Before this diff, in the presence of errors in the options, handle_options *could* return (implicitly, in the I/O state) the globals structure that happened to be in the I/O state when it was invoked. Provide a separate predicate for generating a dummy globals based only on the default values of options. This allows by mercury_compile.m to stop abusing a more general-purpose predicate from handle_options.m, which we no longer export. Remove the mutable and access predicate moved to globals.m. compiler/options.m: Document the fact that two options, smart_recompilation and generate_item_version_numbers, should not be used without seeing whether the functionalities they call for have been disabled. compiler/mercury_compile_front_end.m: compiler/mercury_compile_middle_passes.m: compiler/mercury_compile_llds_back_end.m: compiler/mercury_compile_mlds_back_end.m: compiler/mercury_compile_erl_back_end.m: New modules carved out of the old mercury_compile.m. They each cover exactly the areas suggested by their names. Each of the modules is more cohesive than the old mercury_compile.m. Their code is also arranged in a more logical order, with predicates representing compiler passes being defined in the order of their invocation. Some of these modules export predicates for use by their siblings, showing the dependencies between the groups of passes. compiler/top_level.m: compiler/notes/compiler_design.html: Add the new modules. compiler/mark_static_terms.m: Move this module from the ml_backend package to the hlds package, since (a) it does not depend on the MLDS in any way, and (b) it is also needed by a compiler pass (loop invariants) in the middle passes. compiler/hlds.m: compiler/ml_backend.m: compiler/notes/compiler_design.html: Reflect mark_static_terms.m's change of package. compiler/passes_aux.m: Move the predicates for dumping out the hLDS here from mercury_compile.m, since the new modules also need them. Look up globals in the HLDS, not the I/O state. compiler/hlds_module.m: Store the prefix (common part) of HLDS dump file names in the HLDS itself, so that the code moved to passes_aux.m can figure out the file name for a HLDS dump without doing system calls. Give the field names of some structures prefixes to avoid ambiguity. compiler/mercury_compile.m: Remove the code moved to the other modules. This module now looks after only option handling (such as deciding whether to generate .int3 files, .int files, .opt files etc), and the compilation passes up to and including the creation of the first version of the HLDS. Everything after that is subcontracted to the new modules. Simplify and make explicit the flow of globals information. When invoking predicates that could disable smart recompilation, check whether they have done so, and if yes, update the globals accordingly. When compiling via gcc, we need to link into the executable the object files of any separate C files we generate for C code foreign_procs, which we cannot translate into gcc's internal structures without becoming a C compiler as well as a Mercury compiler. Instead of adding such files to the accumulating option for extra object files in the globals structure, we return their names using the already existing mechanism we have always used to link the object files of fact tables into the executable. Give several predicates more descriptive names. Put predicates in a more logical order. compiler/make.m: compiler/make.dependencies.m: compiler/make.module_target.m: compiler/make.module_dep_file.m: compiler/make.program_target.m: compiler/make.util.m: Require callers to supply globals structures explicitly, not via the I/O state. Afterward pass them around explicitly, passing modified versions to mercury_compile.m when invoking it with module- and/or task-specific options. Due the extensive use of partial application for higher order code in these modules, passing around the globals structures explicitly is quite tricky here. There may be cases where a predicate uses an old globals structure it got from a closure instead of the updated module- and/or task-specific globals it should be using, or vice versa. However, it is just as likely that, this diff fixes old problems by preventing the implicit flow of updated-only-for-one-invocation globals structures back to the original invoking context. Although I have tried to be careful about this, it is also possible that in some places, the code is using an updated-for-an-invocation globals structure in some but not all of the places where it SHOULD be used. compiler/c_util.m: compiler/compile_target_code.m: compiler/compiler_util.m: compiler/error_util.m: compiler/file_names.m: compiler/file_util.m: compiler/ilasm.m: compiler/ml_optimize.m: compiler/mlds_to_managed.m: compiler/module_cmds.m: compiler/modules.m: compiler/options_file.m: compiler/pd_debug.m: compiler/prog_io.m: compiler/transform_llds.m: compiler/write_deps_file.m: Require callers to supply globals structures explicitly, not via the I/O state. In some cases, the explicit globals structure argument allows a predicate to dispense with the I/O states previously passed to it. In some modules, rename some predicates, types and/or function symbols to avoid ambiguity. compiler/read_modules.m: Require callers to supply globals structures explicitly, not via the I/O state. Record when smart recompilation and the generation of item version numbers should be disabled. compiler/opt_debug.m: compiler/process_util.m: Require callers to supply the needed options explicitly, not via the globals in the I/O state. compiler/analysis.m: compiler/analysis.file.m: compiler/mmc_analysis.m: Make the analysis framework's methods take their global structures as explicit arguments, not as implicit data stored in the I/O state. Stop using `with_type` and `with_inst` declarations unnecessarily. Rename some predicates to avoid ambiguity. compiler/hlds_out.m: compiler/llds_out.m: compiler/mercury_to_mercury.m: compiler/mlds_to_c.m: compiler/mlds_to_java.m: compiler/optimize.m: Make these modules stop accessing the globals from the I/O state. Do this by requiring the callers of their top predicates to explicitly supply a globals structure. To compensate for the cost of having to pass around a representation of the options, look up the values of the options of interest just once, to make further access much faster. (In the case of mlds_to_c.m, the code already did much of this, but it still had a few accesses to globals in the I/O state that this diff eliminates.) If the module exports a predicate that needs these pre-looked-up options, then export the type of this data structure and its initialization function. compiler/frameopt.m: Since this module needs only one option from the globals, pass that option instead of the globals. compiler/accumulator.m: compiler/add_clause.m: compiler/closure_analysis.m: compiler/complexity.m: compiler/deforest.m: compiler/delay_construct.m: compiler/elds_to_erlang.m: compiler/exception_analysis.m: compiler/fact_table.m: compiler/intermod.m: compiler/mode_constraints.m: compiler/mode_errors.m: compiler/pd_util.m: compiler/post_term_analysis.m: compiler/recompilation.usage.m: compiler/size_prof.usage.m: compiler/structure_reuse.analysis.m: compiler/structure_reuse.direct.choose_reuse.m: compiler/structure_reuse.direct.m: compiler/structure_sharing.analysis.m: compiler/tabling_analysis.m: compiler/term_constr_errors.m: compiler/term_constr_fixpoint.m: compiler/term_constr_initial.m: compiler/term_constr_main.m: compiler/term_constr_util.m: compiler/trailing_analysis.m: compiler/trans_opt.m: compiler/typecheck_info.m: Look up globals information from the HLDS, not the I/O state. Conform to the changes above. compiler/gcc.m: compiler/maybe_mlds_to_gcc.pp: compiler/mlds_to_gcc.m: Look up globals information from the HLDS, not the I/O state. Conform to the changes above. Convert these modules to our current programming style. compiler/termination.m: Look up globals information from the HLDS, not the I/O state. Conform to the changes above. Report some warnings with error_specs, instead of immediately printing them out. compiler/export.m: compiler/il_peephole.m: compiler/layout_out.m: compiler/rtti_out.m: compiler/liveness.m: compiler/make_hlds.m: compiler/make_hlds_passes.m: compiler/mlds_to_il.m: compiler/mlds_to_ilasm.m: compiler/recompilation.check.m: compiler/stack_opt.m: compiler/superhomogeneous.m: compiler/tupling..m: compiler/unneeded_code.m: compiler/unused_args.m: compiler/unused_import.m: compiler/xml_documentation.m: Conform to the changes above. compiler/equiv_type_hlds.m: Give the field names of a structure prefixes to avoid ambiguity. Stop using `with_type` and `with_inst` declarations unnecessarily. compiler/loop_inv.m: compiler/pd_info.m: compiler/stack_layout.m: Give the field names of some structures prefixes to avoid ambiguity. compiler/add_pragma.m: Add notes. compiler/string.m: NEWS: Add a det version of remove_suffix, for use by new code above. |
||
|
|
15983e3826 |
Delete a stray printf().
compiler/c_util.m: Delete a stray printf(). |
||
|
|
4c4c80b5f6 |
More compiler speedups for hlc grades by eliminating redundant work.
Estimated hours taken: 6 Branches: main More compiler speedups for hlc grades by eliminating redundant work. compiler/c_util.m: c_util.set_line_num used to account for 7% of the compilation time on training_cars_full.m, mostly because of unnecessary name mangling, as well as repeated lookups of the line_numbers option. After this diff, we don't mangle names that do not need to be mangled (testing the need for mangling as rarely as possible), and we provide a means for our caller to tell us that line numbers are required, since in some cases they already know. compiler/mlds_to_c.m: Look up the value of the line_numbers option just once, and then remember it. Rename a predicate to avoid an ambiguity. compiler/mlds.m: The code of mercury_type_to_mlds_type could execute the same lookup on the type definition table three times in a row, though this fact was not apparent from the source code. In some circumstances, it could also invoke general-purpose predicates that did several tests even when it already knew their outcomes. This diff avoids the redundant lookup and tests. It also factors out some code into a separate predicate, and notes the similarity of this predicate to one in foreign.m. compiler/foreign.m: Note the similarity of this code to code to mlds.m. compiler/type_util.m: Provide a version of classify_type that allows mlds.m to avoid both redundant tests and redundant lookups of the type table. |
||
|
|
fc601c170d |
Allow UTF-8 string literals in Mercury source files to be written to
Branches: main
compiler/c_util.m:
Allow UTF-8 string literals in Mercury source files to be written to
Java target files unscathed. Each UTF-8 code unit that was part of a
multi-byte sequence (i.e. value > 127) was being individually escaped.
This is assuming the compiler is built in a C grade.
|
||
|
|
3dedf92d05 |
Fix these problems with string and character literals output by the Java
Branches: main
Fix these problems with string and character literals output by the Java
backend, due to using routines originally designed for C literals:
- string literals cannot be broken into multiple segments
- \a, \v escape characters are not supported
- trigraphs are not supported so don't need to avoid them
compiler/c_util.m:
Add versions of existing predicates which take the output language as
an argument.
Fix the above problems for Java.
compiler/mlds_to_java.m:
Use the new predicates.
|
||
|
|
22cead47a7 |
Fix bug #28 in Mantis. The only substantive change is to code_info.m; the
Estimated hours taken: 4 Branches: main Fix bug #28 in Mantis. The only substantive change is to code_info.m; the changes to the other compiler modules are cosmetic only. compiler/code_info.m: Fix bug #28 in Mantis. The problem was with the code that generated the annotation giving the set of live lvalues at calls: it didn't delete from the set the registers used for passing dummy arguments, such as I/O states. A recursive call for an I/O predicate would thus compute the correct set of live lvalues at the start of the predicate body (in the case of the test case, {r1}), but the wrong set at the recursive call ((in the case of the test case, {r1,r2}, with r2 being the register assigned to hold the I/O state argument). The bug was an abort caused by a sanity check looking for this kind of mismatch. compiler/c_util.m: Make two predicates into functions to make them easier to use. compiler/opt_debug.m: Use those functions. compiler/ml_code_gen.m: compiler/pragma_c_gen.m: Conform to the change to c_util. compiler/jumpopt.m: Delete unnecessary module qualifications. tests/valid/testxmlreader.m: tests/valid/xmlreader.m: A regression test for this bug. It is in valid rather than hard_coded because it cannot be made executable without libraries that not all machines have, and which it would be inappropriate to add to the test suite itself. tests/valid/Mmakefile: Enable the new test case. |
||
|
|
ccc2112fcb |
Fix an inverted out-of-bounds check in the code that prevents
Estimated hours taken: 4 Branches: main compiler/c_util.m: Fix an inverted out-of-bounds check in the code that prevents trigraph sequences from being output. |
||
|
|
75a8a4a9b3 |
Add a new pragma, foreign_export_enum, that allows the names of constructors
Estimated hours taken: 30
Branches: main
Add a new pragma, foreign_export_enum, that allows the names of constructors
of Mercury enumeration types to be exported across the foreign language
interface and referred to by code in the foreign language.
The new pragma is intended to be used to avoid a situation that frequently
occurs when creating Mercury bindings to foreign language libraries, namely
arguments and return values being passed across the foreign language boundary
as small integers. Exporting the names of enumeration values to foreign
languages should make this task less error prone and more portable.
Using the new construct programmers can either specify a foreign language name
for each enumeration constructor, or since this is tedious, there is also a
default mapping defined for each foreign language that should work in most
cases for that language. (In the cases where it does not work the compiler
requires the programmer to provide a valid name.)
Currently, pragma foreign_export_enum is only supported by the C backends.
compiler/prog_data.m:
compiler/prog_item.m:
Add a new item to the parse tree for representing
foreign_export_enum pragmas.
compiler/prog_io_pragma.m:
Parse the new pragma.
compiler/module_qual.m:
Handle foreign_export_enum pragmas.
Add a predicate to for module qualifying type_ctors, i.e. a
type identified by its sym_name and arity, for use by the
above.
compiler/mercury_to_mercury.m:
Write out foreign_export_enum pragmas.
compiler/hlds_module.m:
Add a type to represent exported enumerations.
Add a field to the module_info to hold information about
exported enumerations. Add access procedures for this.
compiler/make_hlds_passes.m:
compiler/add_pragma.m:
Handle foreign_export_enum pragmas: generate the set of foreign names
for each of the constructors of an enumeration type and check that
their validity in the foreign language. Attach this information to
the HLDS.
compiler/export.m:
Output #defined constants for C foreign_export_enum pragmas in
.mh files.
compiler/mlds.m:
Add an MLDS specific representation of exported enumerations.
compiler/ml_type_gen.m:
Convert the HLDS representation of exported enumerations into
an MLDS specific one.
compiler/mlds_to_c.m:
Output #defined constants for C foreign_export_enum pragmas in
.mih files.
compiler/ml_code_gen.m:
compiler/ml_elim_nested.m:
compiler/ml_tailcall.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
Conform to the above changes to the MLDS.
compiler/mercury_compile.m:
Pass the list of export enumerations to the code that writes
out .mh files.
compiler/c_util.m:
Add a predicate that tests if a string is a valid C identifier.
compiler/modules.m:
compiler/recompilation.version.m:
Conform to the above changes.
doc/reference_manual.texi:
Document the new pragma.
tests/hard_coded/Mmakefile:
tests/hard_coded/ee_dummy.{m,exp}:
tests/hard_coded/ee_valid.{m,exp}:
Test valid uses of foreign_export_enum pragmas.
tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
tests/invalid/ee_invalid.{m,err_exp}:
Check we generate error messages for invalid
foreign_export_enum pragmas.
NEWS:
Announce the new pragma.
vim/syntax/mercury.vim:
Highlight the new syntax.
|
||
|
|
1adaecaf35 |
Fix a problem I noticed while fixing bootstrap at -O6: determinism warnings for
Estimated hours taken: 4
Branches: main
Fix a problem I noticed while fixing bootstrap at -O6: determinism warnings for
private_builtin.m.
compiler/add_pred.m:
Mark builtin predicates (e.g. the recently added compound_{lt,eq})
for which we generate never-to-be-invoked dummy bodies as just stubs,
to avoid determinism warnings from the compiler.
compiler/c_util.m:
Reorganize the way we categorize binary operators. Instead of a set of
predicates for recognizing each class of binops, have just one
predicate that returns the category, along with the C operator (since
the two are usually needed together.
The reason for the change is that some binary operators, including
compound_{lt,eq} but also others, fell through the cracks. The new
predicate is a det switch on binary_op, so new operators won't be
able to fall through the cracks in future.
Unary operators were already being handled this way, though in a
simpler fashion, since they all fall into one category.
compiler/llds_out.m:
compiler/mlds_to_c.m:
compiler/mlds_to_managed.m:
Conform to the change to c_util.m. This involves switching from
if-then-else chains to switches, and deleting now unneeded predicates.
compiler/opt_debug.m:
Don't go through llds_out to get at the printable representations
of binary operators.
compiler/simplify.m:
Fix the formatting of the simplification of compound_{lt,eq}.
compiler/options.m:
Add a name for the compiler_sufficiently_recent option that will allow
configure scripts to test for the fix.
|
||
|
|
5647714667 |
Make all functions which create strings from characters throw an exception
Estimated hours taken: 15 Branches: main Make all functions which create strings from characters throw an exception or fail if the list of characters contains a null character. This removes a potential source of security vulnerabilities where one part of the program performs checks against the whole of a string passed in by an attacker (processing the string as a list of characters or using `unsafe_index' to look past the null character), but then passes the string to another part of the program or an operating system call that only sees up to the first null character. Even if Mercury stored the length with the string, allowing the creation of strings containing nulls would be a bad idea because it would be too easy to pass a string to foreign code without checking. For examples see: <http://insecure.org/news/P55-07.txt> <http://www.securiteam.com/securitynews/5WP0B1FKKQ.html> <http://www.securityfocus.com/archive/1/445788> <http://www.securityfocus.com/archive/82/368750> <http://secunia.com/advisories/16420/> NEWS: Document the change. library/string.m: Throw an exception if null characters are found in string.from_char_list and string.from_rev_char_list. Add string.from_char_list_semidet and string.from_rev_char_list_semidet which fail rather throwing an exception. This doesn't match the normal naming convention, but string.from_{,rev_}char_list are widely used, so changing their determinism would be a bit too disruptive. Don't allocate an unnecessary extra word for each string created by from_char_list and from_rev_char_list. Explain that to_upper and to_lower only work on un-accented Latin letters. library/lexer.m: Check for invalid characters when reading Mercury strings and quoted names. Improve error messages by skipping to the end of any string or quoted name containing an error. Previously we just stopped processing at the error leaving an unmatched quote. library/io.m: Make io.read_line_as_string and io.read_file_as_string return an error code if the input file contains a null character. Fix an XXX: '\0\' is not recognised as a character constant, but char.det_from_int can be used to make a null character. library/char.m: Explain the workaround for '\0\' not being accepted as a char constant. Explain that to_upper and to_lower only work on un-accented Latin letters. compiler/layout.m: compiler/layout_out.m: compiler/c_util.m: compiler/stack_layout.m: compiler/llds.m: compiler/mlds.m: compiler/ll_backend.*.m: compiler/ml_backend.*.m: Don't pass around strings containing null characters (the string tables for the debugger). This doesn't cause any problems now, but won't work with the accurate garbage collector. Use lists of strings instead, and add the null characters when writing the strings out. tests/hard_coded/null_char.{m,exp}: Change an existing test case to test that creation of a string containing a null throws an exception. tests/hard_coded/null_char.exp2: Deleted because alternative output is no longer needed. tests/invalid/Mmakefile: tests/invalid/null_char.m: tests/invalid/null_char.err_exp: Test error messages for construction of strings containing null characters by the lexer. tests/invalid/unicode{1,2}.err_exp: Update the expected output after the change to the handling of invalid quoted names and strings. |
||
|
|
84ffc0924d |
Fix --warn-unused-imports warnings in some of the modules.
Estimated hours taken: 4 Branches: main library/*.m: compiler/*.m: Fix --warn-unused-imports warnings in some of the modules. |
||
|
|
aeeedd2c13 |
Standardize formatting of comments at the beginning of modules.
compiler/*.m: Standardize formatting of comments at the beginning of modules. |
||
|
|
459847a064 |
Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18 Branches: main Move the univ, maybe, pair and unit types from std_util into their own modules. std_util still contains the general purpose higher-order programming constructs. library/std_util.m: Move univ, maybe, pair and unit (plus any other related types and procedures) into their own modules. library/maybe.m: New module. This contains the maybe and maybe_error types and the associated procedures. library/pair.m: New module. This contains the pair type and associated procedures. library/unit.m: New module. This contains the types unit/0 and unit/1. library/univ.m: New module. This contains the univ type and associated procedures. library/library.m: Add the new modules. library/private_builtin.m: Update the declaration of the type_ctor_info struct for univ. runtime/mercury.h: Update the declaration for the type_ctor_info struct for univ. runtime/mercury_mcpp.h: runtime/mercury_hlc_types.h: Update the definition of MR_Univ. runtime/mercury_init.h: Fix a comment: ML_type_name is now exported from type_desc.m. compiler/mlds_to_il.m: Update the the name of the module that defines univs (which are handled specially by the il code generator.) library/*.m: compiler/*.m: browser/*.m: mdbcomp/*.m: profiler/*.m: deep_profiler/*.m: Conform to the above changes. Import the new modules where they are needed; don't import std_util where it isn't needed. Fix formatting in lots of modules. Delete duplicate module imports. tests/*: Update the test suite to confrom to the above changes. |
||
|
|
be5b71861b |
Convert almost all the compiler modules to use . instead of __ as
Estimated hours taken: 6 Branches: main compiler/*.m: Convert almost all the compiler modules to use . instead of __ as the module qualifier. In some cases, change the names of predicates and types to make them meaningful without the module qualifier. In particular, most of the types that used to be referred to with an "mlds__" prefix have been changed to have a "mlds_" prefix instead of changing the prefix to "mlds.". There are no algorithmic changes. |
||
|
|
5af71b60ac |
Remove support for the Aditi backend. It is a pain to have to update it every
Estimated hours taken: 2 Branches: main Remove support for the Aditi backend. It is a pain to have to update it every time a data structure changes when we don't see any benefit from it, and its presence makes compilation of the compiler directory take about 10% longer (since the Aditi backend modules are roughly 10% of the code in the compiler directory). Deleting the Aditi-specific data structures from the HLDS should also speed up compilation a little bit. I have spoken to Rao and he is fine with this step. Aditi users, if there are any, can continue to use the Aditi support in release 0.12.*. I also tagged the last version on the trunk to support aditi with the name "last_aditi". The need for modifications in this Aditi support is likely to be very rare to nonexistent, if the recent past is any guide: the Aditi backend hasn't seen a nontrivial modification in a year or more. This diff removes a net 31492 lines. compiler/add_aditi.m: compiler/aditi_backend.pp: compiler/aditi_builtin_ops.m: compiler/context.m: compiler/dnf.m: compiler/magic.m: compiler/magic_util.m: compiler/rl.m: compiler/rl_analyse.m: compiler/rl_block.m: compiler/rl_block_opt.m: compiler/rl_code.m: compiler/rl_dump.m: compiler/rl_exprn.m: compiler/rl_file.pp: compiler/rl_gen.m: compiler/rl_info.m: compiler/rl_key.m: compiler/rl_liveness.m: compiler/rl_loop.m: compiler/rl_opt.m: compiler/rl_out.pp: compiler/rl_relops.m: compiler/rl_sort.m: compiler/rl_stream.m: Remove these compiler modules, since they existed only to support the Aditi backend. compiler/hlds_goal.m: Delete the Aditi-specific components of goals (e.g. the aditi-builtin kind of generic calls and Aditi-evaluated lambdas). compiler/hlds_pred.m: Delete the Aditi-specific components of pred_infos. compiler/prog_data.m: Delete the Aditi-specific items. compiler/passes_aux.m: Don't worry about processing all procedures or just all non-Aditi procedures. compiler/add_clause.m: Add a predicate from a deleted module that is now used only here. compiler/*.m: Conform to the data structure changes above. compiler/notes/*.html: Remove references to the Aditi backend. tests/invalid/aditi.m: tests/invalid/aditi_errors.err_exp: tests/invalid/aditi_errors.m: tests/invalid/aditi_private_builtin.m: tests/invalid/aditi_state_errors.err_exp: tests/invalid/aditi_state_errors.m: tests/invalid/aditi_update_derived_relation.err_exp: tests/invalid/aditi_update_derived_relation.m: tests/invalid/aditi_update_errors.err_exp: tests/invalid/aditi_update_errors.m: tests/invalid/aditi_update_mode_errors.err_exp: tests/invalid/aditi_update_mode_errors.m: tests/valid/aditi.m: tests/valid/aditi_calls_mercury.m: tests/valid/aditi_error_bug.m: tests/valid/aditi_error_bug2.m: tests/valid/aditi_error_bug3.m: tests/valid/aditi_private_builtin.m: tests/valid/aditi_query.m: tests/valid/aditi_update.m: tests/valid/base_relation.m: tests/valid/base_relation2.m: tests/valid/ite_to_disj.m: Remove these Aditi-specific tests. tests/*/Mmakefile: Remove the references to these Aditi-specific tests. |