Estimated hours taken: 2
Branches: main
compiler/*.m:
Import only one compiler module per line. Sort the blocks of imports.
This makes it easier to merge in changes.
In a couple of places, remove unnecessary imports.
Estimated hours taken: 70
Branches: main
Add Java support to the foreign language interface.
mercury/compiler/compile_target_code.m:
mercury/compiler/make.module_target.m:
mercury/compiler/mercury_compile.m:
Pass `compile_java_file' a Java filename rather than a module name.
mercury/compiler/globals.m:
Add `java' as a `foreign_language'.
mercury/compiler/handle_options.m:
Allow Java as a back-end foreign language if the target language
is Java.
mercury/compiler/hlds_data.m:
Allow Java foreign_types.
mercury/compiler/intermod.m:
mercury/compiler/foreign.m:
mercury/compiler/make.util.m:
mercury/compiler/make_hlds.m:
mercury/compiler/mercury_compile.m:
mercury/compiler/mercury_to_mercury.m:
mercury/compiler/ml_code_gen.m:
mercury/compiler/mlds.m:
mercury/compiler/mlds_to_c.m:
mercury/compiler/mlds_to_il.m:
mercury/compiler/mlds_to_ilasm.m:
mercury/compiler/mlds_to_java.m:
mercury/compiler/pragma_c_gen.m:
mercury/compiler/prog_data.m:
mercury/compiler/prog_io_pragma.m:
Add or modify existing code to support `java' as a `foreign_language'
and Java `foreign_type's.
mercury/compiler/mlds_to_java.m:
Nicely indent the generated code that unboxes arguments from
return-argument arrays which are used for methods with multiple
return arguments.
Estimated hours taken: 0.25
Branches: main
mercury/compiler/mlds_to_java.m:
Fix a bug where dummy arguments were not being recognised by the
Java back-end due to the addition of `.' as a module seperator.
Estimated hours taken: 2
Branches: main
mercury/compiler/mlds_to_java.m:
Fix a bug in the Java back-end where incorrect code was being
generated for assignments if the Lval was a field with type
enum_type.
Add a new function `mlds_lval_type' that returns the type of an
lval.
Estimated hours taken:
Branches: main, release
Reorganize the code in the compiler to centralize the code which handles
output of floating point literals.
compiler/c_util.m:
Add new routines make_float_literal and output_float_literal.
These output to 17 digits precision.
Also add some comments.
compiler/mlds_to_c.m:
compiler/llds_out.m:
compiler/mlds_to_java.m:
compiler/ilasm.m:
Use the new routines.
Also add some comments.
tests/hard_coded/Mmakefile:
tests/hard_coded/float_consistency.m:
tests/hard_coded/float_consistency.exp:
A regression test.
Estimated hours taken: 32
Branches: main
Another step towards RTTI in Mercury.
This step redefines the representation of type_ctor_infos inside the compiler
to be identical to the representation we will need for efficient interpretation
of RTTI data structures in Mercury, following on from an earlier step which
did the same for (pseudo)typeinfos.
Instead of the type_ctor_info being broken down into its components in
type_ctor_info.m, the breakdown process is now performed in rtti_out.m (for the
LLDS backend) and rtti_to_mlds.m (for the MLDS backend). Eventually, the IL and
Java backends will stop using rtti_to_mlds.m for this purpose, and will instead
write out the type_ctor_data structures as static data to be interpreted
directly.
We now predefine the C types representing type_info and pseudo_type_infos
for types of arity up to 20 for the LLDS C backend as well as for the
MLDS C backend. The LLDS backend can define them for higher arities
on demand; the MLDS backend (for now) still cannot.
runtime/mercury_type_info.h:
To be able to represent all the kinds of types we now support
- add a data structure for converting values of reserved_addr types
from their printable representation to their internal representation
(it was previously missing), and
- add a type_ctor_rep to represent foreign types.
Add missing MR_ prefixes on some field names.
Add typedefs for all the types that the rtti_names can refer to.
There were already such typedefs in runtime/mercury.h for the MLDS
grades, we now have them for the LLDS grades too.
Predefine the C types representing type_info and pseudo_type_infos
for types of arity up to 20. There were already such typedefs in
runtime/mercury.h for the MLDS grades, we now have them for the
LLDS grades too.
runtime/mercury.h:
Delete the typedefs that are now in mercury_type_info.h.
runtime/mercury.h:
Delete the definitions of the C types representing type_info and
pseudo_type_infos, since these are now in mercury_type_info.h.
#include mercury_type_info.h.
compiler/rtti.m:
Add new, purely Mercury data structures for representing
type_ctor_infos and their components, designed both for efficient
interpretation and as a source for the generation of static data
structures in C.
This entailed deleting most of the alternatives of the rtti_data type
while preserving their rtti_name equivalents; the deleted alternatives
represent tables are no longer created in type_ctor_info.m but which
are created dynamically in rtti_out.m and rtti_to_mlds.m (which need
a way for one table to refer to another).
Centralize the correspondence between rtti_names and the C and Java
types of the corresponding structures (the C and Java names differ in
prefixes only). Among other things, this remove the double maintenance
problem we have previously with the LLDS and MLDS backends maintaining
their own maps of the correspondence.
Add utility predicates on the new data structures for use by both
rtti_out.m and rtti_to_mlds.m.
compiler/hlds_module.m:
Always store the ids of unification and comparison procedures in
type_ctor_gen_infos, to simplify their handling.
compiler/type_ctor_info.m:
Generate the new data structures for representing type_ctor_infos.
Conform to the changed data structures for type_ctor_gen_infos.
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
Rewrite substantial parts of these modules to convert the new data
structures for representing type_ctor_infos to sets of discrete
structures dynamically.
Most of the dynamically created structures are unique by construction,
but this is not true for typeinfos and pseudo-typeinfos. Therefore
add mechanisms to ensure that we don't generate redundant structures
representing typeinfos and pseudo-typeinfos.
compiler/mlds_to_c.m:
compiler/mlds_to_java.m:
Use the standard mechanisms for creating C and Java type names.
compiler/mlds_to_gcc.m:
Conform to the changed data structures in rtti.m and
mercury_type_info.h.
compiler/opt_debug.m:
Conform to the changed data structures in rtti.m.
compiler/dead_proc_elim.m:
Conform to the changed data structures for type_ctor_gen_infos.
compiler/pseudo_type_info.m:
Add a predicate to construct a representation of a type that may or may
not be ground.
compiler/mlds_to_gcc.m:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
library/rtti_implemenation.m:
runtime/mercury_mcpp.{cpp,h}:
Add the type_ctor_rep for foreign types to the lists of type_ctor_reps.
library/construct.m:
library/deconstruct.m:
Add missing MR_ prefixes on field names.
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_info.c:
runtime/mercury_unify_compare_body.h:
Handle the type_ctor_rep for foreign types.
Add missing MR_ prefixes on field names.
library/list.m:
Add two utility predicates, is_empty and is_not_empty, for use with
higher order code.
NEWS:
Mention the new predicates in list.m. Delete a duplicate entry.
Estimated hours taken: 40
Branches: main
Output Managed C++ code using the same mechanisms as we do for C#
code, rather than using pragma_c_gen to generate MC++ code. This
fixes the problem that functions couldn't be defined in MC++, and also
should make the code more maintainable in the future as MC++ is much
more similar to C# than to C.
compiler/mlds.m:
Add a new field to outline_foreign_proc. This field has
information which links the mlds variables with the variable
names used in the foreign code.
compiler/ml_code_gen.m:
Generate a foreign proc for MC++ the same way we generate a
foreign proc for C#.
Generate the data for the new field in outline_foreign_proc.
Use the context of the string which contains the pragma foreign
proc body for the context of the foreign proc. This ensures that
error messages refer to the correct line number.
compiler/mlds_to_il.m:
Add to the list of foreign languages defined in the module to
include those which don't have a foreign_proc defined in them.
Move the relevant code from atomic_statement_to_il to
generate_method so that we handle external procedures correctly.
compiler/mlds_to_ilasm.m:
Call mlds_to_managed.
compiler/ml_backend.m:
Add the new module and remove mlds_to_mcpp and mlds_to_csharp.
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_java.m:
Minor changes to handling the new field in outline_foreign_proc.
compiler/mlds_to_csharp.m:
compiler/mlds_to_mcpp.m:
Removed files whose functionality has been subsumed by
mlds_to_managed.
library/construct.m:
library/float.m:
library/io.m:
library/std_util.m:
library/type_desc.m:
Changes required to get the library to be able compile in the
ilc grade.
Estimated hours taken: 25
Branches: main
Fix problems with the compiler-generated header files:
1. the header files are grade dependent, but the header files
can only be installed for one grade.
2. the generated header files can clash with system headers.
To solve these problems, the compiler now generates a
grade dependent `.mih' file containing the declarations
needed when a module is imported in a high-level C code
grade, and a grade independent `.mh' file, which contains
the prototypes for `:- pragma export' declarations.
compiler/export.m:
Generate a `.mh' rather than a `.h' file for the `:- pragma export'
declarations.
Allow the header file generated by export.m to be used with
`--high-level-code'.
compiler/modules.m:
library/Mmakefile:
Add a module.install_grade_hdrs target to install the `.mih'
files in a grade-dependent directory.
compiler/arg_info.m:
compiler/hlds_out.m:
compiler/hlds_pred.m:
Make it easier to tell if the arg_info field of the proc_info
has been set.
compiler/mlds_to_c.m:
Include both the `.mh' and `.mih' files for imported modules.
The type used as the return value for a semidet procedure
exported to C is `MR_bool', not `MR_Word'.
compiler/mlds_to_c.m:
compiler/modules.m:
Don't add a `mercury.' prefix to the standard library
header file names. They can't clash with the system
headers any more.
compiler/mercury_compile.m:
compiler/mlds_to_c.m:
Use export.m to generate the header file for `:- pragma export'
declarations even in hlc grades.
compiler/mlds.m:
compiler/ml*.m:
Distinguish between the `.mh' and `.mih' files
in `mlds__import's.
compiler/handle_options.m:
scripts/Mmake.vars.in:
scripts/mgnuc.in:
Add C include directory options for the installed grade
dependent `.mih' files.
Mmakefile:
scripts/Mmake.rules:
s/h/mih/ in the commands to save the grade dependent
files when installing the library grades.
compiler/make.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
compiler/make.util.m:
Handle dependencies on `.mh' and `.mih' files.
NEWS:
doc/user_guide.texi:
Document the change.
Estimated hours taken: 16
Branches: main
Get pragma foreign_type working for the C backend.
doc/reference_manual.texi:
Document C pragma foreign_types.
compiler/prog_data.m:
Add il_foreign_type and c_foreign_type which contain all the
necessary data to output a foreign_type on the respective backends.
Change foreign_language_type to refer to these new types.
compiler/prog_io_pragma.m:
Handle the changes to foreign_language_type, and parse C
foreign_type declarations.
compiler/hlds_data.m:
Change the hlds_data__foreign_type type so that it records both the
C and IL foreign types. This will allow one to output both foreign
type declarations when doing intermodule optimization.
compiler/make_hlds.m:
Changes so that we store both the IL and C foreign types in
hlds_data__foreign_type.
Also add an error checking pass where we check that there is a
foreign type for the back-end we are currently compiling to.
compiler/foreign.m:
Change to_exported_type so that it works for both the C and IL
backends by getting either the C or IL foreign_type definition.
compiler/llds.m:
compiler/pragma_c_gen.m:
Change pragma_c_input and pragma_c_output so that they record
whether or not a type is a foreign_type and if so what is the string
which represents that foreign_type.
compiler/llds_out.m:
When outputting pragma c_code variables that represent foreign_types
get the casts correct. Note that this adds the constraint on C
foreign types that they are word sized, as all we are doing is
casts, not boxing and unboxing.
compiler/mlds.m:
Change mlds__foreign_type so that we store whether a type is an IL
type or a C type. It is the responsibility of the code generator
that we never create a reference to a IL foreign type when on the C
back-end, and vice versa.
compiler/mercury_to_mercury.m:
Handle changes to prog_data__foreign_type.
compiler/hlds_out.m:
compiler/intermod.m:
compiler/magic_util.m:
compiler/ml_code_gen.m:
compiler/ml_type_gen.m:
compiler/recompilation_usage.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unify_proc.m:
Handle changes to hlds_data__foreign_type.
compiler/exprn_aux.m:
compiler/livemap.m:
compiler/middle_rec.m:
compiler/opt_util.m:
Handle changes to the pragma_c_input and pragma_c_output types.
compiler/ml_code_util.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_c.m:
Handle changes to mlds__foreign_type.
Estimated hours taken: 40
Branches: main
A step towards RTTI in Mercury.
This step redefines the representation of pseudo-typeinfos inside the compiler
to be identical to the representation we will need for efficient interpretation
of RTTI data structures in Mercury. Later steps will do likewise for
typectorinfos. In the end, we will have two implementations of RTTI:
the current low-level, very efficient one written in C, which will be used
by the C backends (both LLDS and MLDS), and a new, higher-level one
which will use Mercury data structures and Mercury predicates for
interpretation (along the lines of library/rtti_implementation.m)
for the Java and IL backends.
A large part of this change concerns the fact that pseudo-typeinfos can now
contain typeinfos as well as other pseudo-typeinfos, and they do in the
frequent case that the type of an argument is ground. Given that typeinfos
are just special cases of pseudo-typeinfos, the code for handling the two
types is usually similar, with common code factored out when relevant.
In the process of redesigning the data structures concerning (pseudo-)
typeinfos, I also fixed an old naming scheme that has become misleading.
The representation of a (pseudo-) typeinfo depends on whether the principal
type constructor is fixed arity or not. We used to denote this distinction
with the phrases first-order vs higher-order, since at first the only variable
arity type constructors were pred and func. However, this hasn't been true
since we added tuples. I have changed the naming scheme to be fixed-arity vs
variable-arity.
compiler/rtti.m:
Add new, purely Mercury data structures for representing typeinfos
and pseudo-typeinfos, designed both for efficient interpretation
and as a source for the generation of static data structures in C.
compiler/pseudo_type_info.m:
Delete the type definitions here, since they are superseded by the new
definitions in rtti.m.
Add predicates for constructing typeinfos as well as pseudo-typeinfos,
since now we need those too.
Conform to the changed data structures for (pseudo-) typeinfos.
compiler/ll_pseudo_type_info.m:
compiler/ml_closure_gen.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/opt_debug.m:
compiler/type_ctor_info.m:
Conform to the changed data structures for (pseudo-) typeinfos.
compiler/mlds.m:
Since the MLDS now refers to type_infos, add their type
(mlds__type_info_type) to the list of types the MLDS knows about.
compiler/ml_code_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
Handle mlds__type_info_type.
compiler/mlds_to_gcc.m:
Conform to the changed data structures for (pseudo-) typeinfos,
and handle mlds__type_info_type.
runtime/mercury_bootstrap.h:
Override the compiler-generated names of the type_ctor_infos of the
variable arity type constructors. The MLDS backend requires these
to be module qualified; the LLDS backend requires them to be
unqualified. This is a problem because the same code now generates
the compiler's internal representation of pseudo-typeinfos for both
backends.
The temporary solution is to have the compiler generate these names
module qualified, and have these macros convert them to the unqualified
form. (The long term solution should be to always module qualify
everything, but doing that is for another change.)
runtime/mercury_type_info.h:
Change the naming scheme from first order vs higher order to fixed
arity vs variable arity.
library/construct.m:
library/deconstruct.m:
runtime/mercury.c:
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_make_type_info_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_desc.c:
runtime/mercury_type_info.c:
runtime/mercury_unify_compare_body.h:
Conform to the new naming scheme.
runtime/mercury.h:
Conform to the new naming scheme.
Declare fixed and variable arity types for typeinfos as well as
pseudo-typeinfos, since pseudo-typeinfos can now refer to typeinfos.
Estimated hours taken: 4
Branches: main
Fix a bug with accurate GC.
compiler/mlds.m:
Rename the `is_tail_call' enumeration as `call_kind',
rename the `call' alternative as `ordinary_call', and
and add a new alternative `no_return_call'.
compiler/ml_call_gen.m:
Use `no_return_call' rather than `tail_call' for calls to
procecures with determinism `erroneous'.
compiler/ml_elim_nested.m:
Fix a bug: when adding code to unchain the stack frame before
tail calls, add a `return' statement after each tail call, to
ensure that we don't try to unchain the stack frame twice.
But don't do this for calls marked `no_return_call', since
it's not needed in that case. (This is mandatory, not just
an optimization: we can't construct a proper return statement
for no_return_calls, since the return values in a `no_return_call'
might not match the return types of the caller.)
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/ml_util.m:
compiler/ml_tailcall.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
Minor changes to handle the new `no_return_call' alternative
and the renaming of `call' as `ordinary_call'.
The main aim of this change is to make the overall, high-level structure
of the compiler clearer, and to encourage better encapsulation of the
major components.
compiler/libs.m:
compiler/backend_libs.m:
compiler/parse_tree.m:
compiler/hlds.m:
compiler/check_hlds.m:
compiler/transform_hlds.m:
compiler/bytecode_backend.m:
compiler/aditi_backend.m:
compiler/ml_backend.m:
compiler/ll_backend.m:
compiler/top_level.m:
New files. One module for each of the major components of the
Mercury compiler. These modules contain (as separate sub-modules)
all the other modules in the Mercury compiler, except gcc.m and
mlds_to_gcc.m.
Mmakefile:
compiler/Mmakefile:
Handle the fact that the top-level module is now `top_level',
not `mercury_compile' (since `mercury_compile' is a sub-module
of `top_level').
compiler/Mmakefile:
Update settings of *FLAGS-<modulename> to use the appropriate
nested module names.
compiler/recompilation_check.m:
compiler/recompilation_version.m:
compiler/recompilation_usage.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/recompilation.version.m:
Convert the `recompilation_*' modules into sub-modules of the
`recompilation' module.
compiler/*.m:
compiler/*.pp:
Module-qualify the module names in `:- module', `:- import_module',
and `:- use_module' declarations.
compiler/base_type_info.m:
compiler/base_type_layout.m:
Deleted these unused empty modules.
compiler/prog_data.m:
compiler/globals.m:
Move the `foreign_language' type from prog_data to globals.
compiler/mlds.m:
compiler/ml_util.m:
compiler/mlds_to_il.m:
Import `globals', for `foreign_language'.
Mmake.common.in:
trace/Mmakefile:
runtime/Mmakefile:
Rename the %.check.c targets as %.check_hdr.c,
to avoid conflicts with compiler/recompilation.check.c.
===================================================================
Estimated hours taken: 32
Branches: main
Do not generate unreachable code in the Java back-end, and re-enable
optimized tailcalls which were previously generating unreachable code.
mercury/compiler/handle_options.m:
Enable optimized tailcalls when compiling to Java.
mercury/compiler/mlds_to_java.m:
Prevent generation of unreachable code when compiling to Java.
Estimated hours taken: 0.25
Branches: main
compiler/mlds_to_java.m:
Add more whitespace in the output generated for class definitions:
put the `extends ...' and `implements ...' parts on lines of
their own.
Estimated hours taken: 2
Branches: main
Implement tail call optimization for the Java back-end.
compiler/mlds.m:
Add support for C-style `break' and `continue' statements:
change the argument of the MLDS `goto' statement from a label
to a new type `goto_target' which is either `break', `continue',
or a label.
compiler/ml_optimize.m:
Add a new predicate `target_supports_break_and_continue',
and for targets where this predicate succeeds, generate tail
recursion using while/break/continue rather than label/goto.
compiler/ml_simplify_switch.m:
compiler/ml_string_switch.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
Minor changes to handle the new type for the argument of the
`goto' statement.
Estimated hours taken: 50
Branches: main
Bug fixes and additions to the Java back-end so that it will now successfully
compile and run mercury programs which contain higher order code as well as
non-deterministic code.
With some hacked up Mercury library code (in Java) I am able to compile 10 of
the 11 files in the tests/benchmarks directory into Java and run them to
receive the correct output.
mercury/compiler/mlds_to_java.m:
Many small bug fixes.
Disabled current (incomplete) name mangling code. All class, package
and method names apart from java.* and mercury.runtime.* will be
output as lowercase for the moment.
Added code to prefix some classes/packages so we don't run into the
problem of having a class or package name which is also a Java reserved
word. This is the case with the mercury library modules int and char.
Added code to implement commits.
mercury/compiler/java_util.m:
Added a few missing Java reserved words.
mercury/compiler/ml_code_util.m:
A small change so that in one case where they weren't, multiple return
values are now generated in the MLDS.
mercury/java/Commit.java:
Added this file, a throwable class used for the implementation of
commits.
mercury/java/ProcAddr.java:
mercury/java/Compare.java:
mercury/java/Unify.java:
Removed these files, they're now obsolete as they all use the standard
interface for method pointers provided by MethodPtr.java.
mercury/java/TypeCtorInfo_Struct.java:
Altered to reference mercury.runtime.MethodPtr instead of
mercury.runtime.[Unify|Compare].
Estimated hours taken: 8
Branches: main
More improvements to accurate GC for the MLDS->C back-end.
runtime/mercury_accurate_gc.h:
runtime/mercury_accurate_gc.c:
Add new routine MR_garbage_collect().
runtime/mercury_memory_handlers.c:
Wrap `#ifndef MR_HIGHLEVEL_CODE' around some LLDS-specific
code for accurate GC.
runtime/mercury_accurate_gc.c:
runtime/mercury_memory_handlers.c:
Fix some software rot: missing `MR_' and `MR_eng_' prefixes.
runtime/mercury.h:
Add MR_GC_check() macro, which invokes MR_garbage_collect()
if needed.
compiler/mlds.m:
Add gc_check as a new mlds__atomic_statement.
compiler/ml_elim_nested.m:
Insert gc_check statements at the start of every procedure
that does any heap allocation.
compiler/ml_elim_nested.m:
compiler/mlds_to_c.m:
compiler/mlds_to_java.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
Minor changes to handle gc_check statements.
compiler/ml_code_util.m:
Fix some bugs in the way that we were calling
private_builtin__gc_trace/1.
Estimated hours taken: 90
Branches: main
Changes and additions to the Java back-end so that:
o While tags shouldn't be generated, they do get generated in some cases
and are now handled correctly.
o The Java back-end now generates class constructors.
o The Java back-end is now able to simulate the behaviour of function
pointers, which are used for closures, continuations, as well as unify
and compare.
mercury/compiler/mlds_to_java.m:
Extensive changes to existing code to implement tags and class
constructors. Also, addition of code to search MLDS for uses of
function pointers and to generate MLDS for wrapper classes. As well
as many small bug fixes.
Removed some (unfinished) code for dealing with Unify and Compare, this
code was redundant now that function pointers have been implemented.
mercury/compiler/java_util.m:
Updated to return noops for most tag operators.
mercury/java/MethodPtr.java:
New file. This is the interface which the wrapper classes used for
function pointers extend.
Estimated hours taken: 4
Branches: main
Allow the foreign_type declaration to accept value types.
compiler/prog_data.m:
Add an indicator to il foreign types whether or not they are
reference or value types.
compiler/prog_io_pragma.m:
Parse whether or not the foreign type is a reference or a value type.
compiler/make_hlds.m:
Decide whether or not a foreign_type is already boxed.
compiler/hlds_data.m:
compiler/mlds.m:
Add to the foreign_type an indicator of whether or not it is already
boxed.
compiler/mlds_to_il.m:
Remove code which attempted to determine when a value type was
incorrectly defined as a reference type.
Unboxed types on the .NET backend are value types.
Fix a bug where converting a value_class to a value_class was
failing.
compiler/ilasm.m:
Remove name_to_simple_type from the interface as it is no longer
needed in mlds_to_il.
compiler/mercury_to_mercury.m:
Output the new foreign_type format.
compiler/foreign.m:
compiler/hlds_out.m:
compiler/intermod.m:
compiler/magic_util.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_type_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_java.m:
compiler/recompilation_usage.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unify_proc.m:
Changes to handle the boxed indicator.
doc/reference_manual.texi:
Document how to specify a value type.
Branches: main
Estimated hours taken: 50
Another substantial step towards supporting accurate garbage
collection for the MLDS->C back-end: generate code for the
GC tracing functions.
compiler/mlds.m:
Add new fields to store, with each local variable or argument
declaration, the code for the GC to trace that local variable
or argument.
compiler/ml_code_util.m:
Add a new procedure ml_gen_maybe_gc_trace_code to generate the
code for GC tracing a variable. The generated MLDS code calls
private_builtin:gc_trace/1, passing the variable's address and
the type_info for that variable. This code is generated by
invoking polymorphism__make_type_info_var to generate HLDS code
to build the type_infos needed, and then calling ml_code_gen.m
to convert that to MLDS.
library/private_builtin.m:
Add a new procedure gc_trace, which calls MR_agc_deep_copy().
This gets invoked by the code generated by ml_code_util.m.
compiler/polymorphism.m:
Export polymorphism__make_type_info_var, for use by ml_code_util.m.
compiler/mercury_compile.m:
Invoke the chain_gc_stack_frames pass before invoking the
hoist_nested_functions pass, since otherwise it doesn't work.
compiler/handle_options.m
Add a couple of checks for options that are not supported
in combination with `--gc accurate'.
compiler/ml_call_gen.m:
compiler/ml_code_gen.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_string_switch.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_csharp.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_mcpp.m:
compiler/rtti_to_mlds.m:
Various changes to handle the GC trace code field for variable and
argument declarations.
Estimated hours taken: 0.5
Branches: main
Port the change to handle foreign imports onto the main branch.
If we wish to use the following foreign type
:- pragma foreign_type(xmldoc, 'System__Xml__XmlDoc', il("System.Xml")).
then we must include in the generated code a reference to the assembly
System.Xml so as to obtain the definition of System.Xml.XmlDoc. This
change implements this.
compiler/mlds.m:
Change the import type so that it distinguishes between mercury and
foreign imports.
compiler/ml_code_gen.m:
For each foreign type add its location to the list of mlds imports.
compiler/mlds_to_il.m:
Changes due to the new mlds__import definition.
Only output calls to the class constructors for those modules which
are mercury modules.
compiler/mlds_to_c.m:
compiler/mlds_to_java.m:
Changes due to the new mlds__import definition.
Estimated hours taken: 10
Branches: main
Merge the foreign_type pragma changes from the dotnet branch to the main
branch, plus do some more development work to generalise the change.
compiler/prog_data.m:
Add a type to hold the data from parsing a pragma foreign_type decl.
compiler/prog_io_pragma.m:
Parse the pragma foreign_type. This code is currently commented
out, while we decide on the syntax.
compiler/hlds_data.m:
Add a new alternative to hlds_type_body where the body of the type
is a foreign type.
compiler/make_hlds.m:
Place the foreign_type pragmas into the HLDS.
compiler/foreign.m:
Implement to_type_string which replaces export__type_to_type_string,
unlike export__type_to_type_string foreign__to_type_string takes an
argument specifying which language the representation is meant to be
in. to_type_string also needs to take a module_info to handle
foreign_types correctly. To avoid the need for the module_info to
be passed around the MLDS backend we provide a new type
exported_type which provides enough information for an alternate
version of to_type_string to be called.
compiler/export.m:
Delete export__type_to_type_string.
compiler/llds.m:
Since foreign__to_type_string needs a module_info, we add a new
field to pragma_c_arg_decl which is the result of calling
foreign__to_type_string. This avoids threading the module_info
around various llds passes.
compiler/mlds.m:
Record with in the mercury_type the exported_type, this avoids
passing the module_info around the MLDS backend.
Also add the foreign_type alternative to mlds__type.
Update mercury_type_to_mlds_type so that it handles types which are
foreign types.
compiler/mlds_to_il.m:
Convert a mlds__foreign_type into an ilds__type.
compiler/ilds.m:
The CLR spec requires that System.Object and System.String be
treated specially in the IL assembly so add them as simple types.
compiler/ilasm.m:
Before outputting a class name into the IL assembly check whether it
it can be simplified to a builtin type, and if so output that name
instead as required by the ECMA spec.
Changes for the addition of string and object as simple types.
doc/reference_manual.texi:
Document the new pragma, this is currently commented out because it
refers to syntax that has not yet been finalised.
compiler/fact_table.m:
compiler/llds_out.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_simplify_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_csharp.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_java.m:
compiler/mlds_to_mcpp.m:
compiler/pragma_c_gen.m:
compiler/rtti_to_mlds.m:
Changes to handle using foreign__to_type_string.
compiler/hlds_out.m:
compiler/intermod.m:
compiler/magic_util.m:
compiler/ml_type_gen.m:
compiler/recompilation_usage.m:
compiler/recompilation_version.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unify_proc.m:
Changes to handle the new hlds_type_body.
compiler/mercury_to_mercury.m:
Output the pragma foreign_type declaration.
compiler/module_qual.m:
Qualify the pragma foreign_type declarations.
compiler/modules.m:
Pragma foreign_type is allowed in the interface.
Branches: main
Estimated hours taken: 2
compiler/mlds_to_il.m:
compiler/mlds.m:
Fix a place in mlds_to_il.m where we were assuming that the
arguments always included a secondary tag; this assumption is
not robust and will be broken by my change to represent
constants in discriminated union types using reserved addresses.
This fix required adding a new boolean field to the `new_object'
instruction to record whether or not the arguments include a
secondary tag.
compiler/ml_elim_nested.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_mcpp.m:
Update to handle the new field of `new_object'.
Estimated hours taken: 2
Branches: main
Merge changes to add attributes to the HLDS, MLDS and ILDS from the
dotnet-foreign branch. We don't merge the changes to add syntax for
attributes, as the syntax is still very experimental.
compiler/hlds_pred.m:
compiler/prog_data.m:
Add attributes to the pred_info (they are a bit like markers,
but are more than just boolean flags).
compiler/ilasm.m:
Add custom attributes to appropriate positions (on assemblies,
IL types and methods).
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_util.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_csharp.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_java.m:
compiler/mlds_to_mcpp.m:
Add mlds__attributes, which are the MLDS version of custom attributes.
Convert hlds_pred__attributes into mlds__attributes.
Add a list of mlds__attributes to the mlds__function defn.
compiler/mlds_to_il.m:
Convert MLDS attributes to IL custom attributes.
Estimated hours taken: 15
Branches: main
Implement arrays in the .NET backend.
Arrays are implemented in an unusual way.
array(T) is mapped to the .NET type T[] for all concrete types T.
However, if T is a type variable, we map array(T) to System.Array.
System.Array is the superclass of all array types, so we can always
pass T[] where System.Array is expected.
This mapping allows us to use the Mercury array library module to
operate on arrays that may be exposed by other .NET components (for
example Byte[] or int[]).
In some cases the Mercury compiler will know the value of T, but it may
be calling code that operates on array(T) in a generic fashion.
If the callee returns an array(T), the Mercury compiler can be sure
that this is really T[], but the .NET backend is not that clever.
In that case we have to cast from System.Array to T[] after the call.
(This is very similar to how we unbox return values with type T where T is
known in the caller but not the callee).
We also insert casts from T[] to System.Array -- although they are not
strictly necessary.
compiler/ml_call_gen.m:
Implement the cast to the known instance of array(T) for return
values of array.
compiler/mlds.m:
Add a new MLDS type mlds__mercury_array_type to represent the
Mercury array/1 type.
Turn the Mercury type array/1 into mlds__mercury_array_type.
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
Use MR_Word to represent mlds__mercury_array_type, unless we are
using --high-level-data, in which case we use the appropriately
named high-level-data type.
compiler/mlds_to_il.m:
Draw a distinction between the il_object_array_type (object[])
and the il_generic_array_type (class System.Array).
Map mlds__mercury_array_type(ElemType) to class System.Array if
ElemType is a type variable, or ElemType[] otherwise.
compiler/mlds_to_java.m:
Map mlds__mercury_array_type(ElemType) to class Object[] if
ElemType is a type variable, or ElemType[] otherwise.
(type variables are mapped to Object anyway, so this falls
out of the code anyway).
(This is untested).
Estimated hours taken: 0.75
Branches: main
Use a new mlds__function_body type to represent function bodies, as the old
usage of maybe/1 was error prone ("no" meant the function had been declared
using :- pragma external, not merely that the body was missing).
compiler/mlds.m:
Add mlds__function_body type.
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_csharp.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_mcpp.m:
Handle this change.
Estimated hours taken: 40
Branches: main
Refactor the top level of mlds_to_il so that we only do one pass over
the MLDS to generate the ILDS. As a side effect of this change nondet
code now works again.
compiler/mlds_to_il.m:
Do a MLDS to MLDS transformation which places all the procedures and
data into the mercury_code class. Then modify all the qualifiers to
take account of this change to the code.
Rewrite the top level so that it only does one pass over the MLDS
data structure.
Examine the flags when deciding which attributes to place on a
method, field or class.
compiler/mlds.m:
Add a new field to mlds__class_defn which is the list of
defns which are constructors for this class.
Add the functions mlds__append_mercury_code and mlds__append_name
which append either "mercury_code" or an arbitary string to the
module qualifier of a name.
compiler/ml_elim_nested.m:
Rather then hardcoding the generation of the constructor for the
environment class, we generate it here as an MLDS method.
On the IL backend the mercury code is placed in a seperate class to
the environment data, so the env_type decls must be public so as to
be accessible from the code.
compiler/ml_code_util.m:
Wrapper functions should be static methods not instance methods.
Fix ml_gen_label_func_decl_flags to make this true.
compiler/rtti_to_mlds.m:
Rtti data structures should be one_copy (ie static) not per_instance.
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_java.m:
Misc changes to handle the additon of a list of constructors to the
mlds__class_defn.
compiler/mlds_to_csharp.m:
compiler/mlds_to_mcpp.m:
Use the function class_name rather then mercury_module_name_to_mlds.
Estimated hours taken: 8
Branches: main
Add type information to the array_index operator.
This is needed for both the GCC back-end and the IL back-end.
compiler/builtin_ops.m:
In the array_index constructor for the unary_op type,
add the array element type as a field.
compiler/ml_string_switch.m:
compiler/string_switch.m:
compiler/mlds_to_java.m:
When generating array_index operators, generate the new field.
compiler/bytecode.m:
compiler/llds.m:
compiler/llds_out.m:
compiler/mlds_to_c.m:
compiler/mlds_to_java.m:
When consuming array_index operators, ignore the new field.
compiler/mlds_to_gcc.m:
When consuming array_index operators, use the array element type,
rather than wrongly assuming the element type is always 'MR_Integer'.
compiler/mlds_to_il.m:
Add code to handle the array_index operator,
rather than calling `throw_unimplemented'.
compiler/bytecode.m:
Delete the reverse mode of binop_code. This was not used,
it was just there to get the compiler to check that we didn't
map two different binary operators to the same code. This
mode no longer works, since we map array_index operators to
the same code regardless of the the array element type.
compiler/rtti_to_mlds.m:
compiler/ml_string_switch.m:
compiler/ml_code_util.m:
To avoid code duplication, move ml_string_type, which was defined in
both rtti_to_mlds.m and ml_string_switch.m, into ml_code_util.m.
compiler/ml_string_switch.m:
Minor changes to avoid some code duplication.
compiler/mlds_to_java.m:
Fix a bug where it was using the wrong type for the `args' variable.
Add an XXX comment about what looks to me like another bug.
Estimated hours taken: 4
Branches: main
The .NET backend requires that names are not only qualified with their
namespace but the source package the name comes from. In this change we
back out a previous solution to this problem and implement a much
neater solution where we hide the package name in the abstract type
mlds_module_name.
This solution is neater because the package name shouldn't change once
the name is defined. All that we may have to change is the qualifiers
to the name.
compiler/mlds.m:
Add the package name to the abstract type mlds_module_name.
compiler/ml_call_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_csharp.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_mcpp.m:
compiler/rtti_to_mlds.m:
Back out previous solution.
Estimated hours taken: 0.5
Branches: main
Add the self rval (ie this pointer in C++) for use on OO backends.
compiler/mlds.m:
Add the self rval.
compiler/ml_elim_nested.m:
compiler/mlds_to_c.m:
compiler/mlds_to_csharp.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_mcpp.m:
Code to handle the new rval.
Estimated hours taken: 16
Branches: main
The .NET backend requires that names are not only qualified with their
namespace but the source package the name comes from. In this change we
add to the name type the name of the source package which this name is
defined in. This change will be needed for implementing foreign_class
in the .NET backend where it will no longer be possible to determine
the package name from the fully qualified name.
compiler/mlds.m:
Add the new field to the mlds__fully_qualified_name type.
compiler/ml_call_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_csharp.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_mcpp.m:
compiler/rtti_to_mlds.m:
Propogate the changes around.
Estimated hours taken: 5
Branches: main, dotnet-foreign
Minimize the amount of procedure name mangling done by the .NET backend.
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_util.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_java.m:
compiler/rtti_to_mlds.m:
Add the code_model and a boolean indicating whether this
function (if it is a function) *doesn't* have a return value
(i.e. it has a non-default mode).
Also move is_output_det_function into ml_code_util.m and rename it
ml_is_output_det_function.
compiler/mlds_to_il.m:
Mangle much more carefully. We still mangle in a predictable,
context-insensitive manner, however we take advantage of the
overloading available in the .NET backend to avoid name clashes
in most cases.
Estimated hours taken: 45
Branches: main
Implement a C# interface for the .NET backend.
To use it, you currently need to set
--backend-foreign-language csharp --use-foreign-language csharp
in your MCFLAGS.
The C# foreign language interface works by introducing a new sort of
MLDS statement called outline_foreign_proc. outline_foreign_proc is expected
to be turned into a separate procedure in a separate file. This is
quite different to normal foreign code which has been renamed as inline
target code, as it is really intended to be generated inline, inside the
generated code.
Because outline_foreign_proc is expected to be generated outside the
normal code, we don't need to generate variable renamings,
initializations, casts and other complicated interfacing code.
Any marshalling is done by the backend, which knows how to marshall
arguments across the boundary into the outline code and back. In the
case of marshalling to C# from the .NET backend, we currently don't do
anything special (part of the point of .NET is that data
representation don't have to change very often just because you are
using different languages, so this is a property we should try to
preserve).
The actual implementation of the foreign code is therefore very simple.
Simply generate an appropriate procedure, and insert the user's code in
the middle.
The bulk of this change to delay the mangling of MLDS var names, so we
can still use the original user's var name when we output the outline
procedure (since the user's foreign code will refer to these var names,
it's important to keep them around).
compiler/foreign.m:
Handle the csharp foreign language.
compiler/globals.m:
Fix an XXX about converting to lowercase to do language name
comparisons.
Add new predicates to make conversion of foreign languages
to strings more uniform.
compiler/handle_options.m:
Don't set backend_foreign_language to the default if it has
already been set by hand.
compiler/ml_call_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
Delay the mangling of MLDS var names by keeping the variable
number around until the output phase.
Slightly generalize the handling of foreign language interfacing.
Handle C# foreign language interfacing.
Add value_output_vars to the ml_gen_info, which are the variables
returned rather than passed by reference. We need to know
these variables for C# interfacing so that we can handle the return
value of the forwarding function.
Mark the beginning and end of the MLDS foreign language processing as
a "sub-module" (in comments at least). Later I may put this code
into a separate module.
Rename some predicates from c_code to foreign_code.
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_string_switch.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/rtti_to_mlds.m:
Handle the new var_name type, and the new target_code constructors.
compiler/mlds.m:
Add outline_foreign_proc which is handled differently to the old
target_code (which has been renamed inline_target_code).
Change the definiton for mlds__var_name.
compiler/mlds_to_c.m:
Factor out mlds_output_to_file.
Handle the new var_name type, and the new target_code constructors.
compiler/mlds_to_csharp.m:
A new module to generate C# code suitable for foreign language
interfacing. This is largely lifted from the MC++ code, with a few
changes to the output syntax.
compiler/mlds_to_il.m:
Return the set of foreign languages processed instead of a bool
saying wither MC++ was present. This is so we can generate the
appropriate output .cs or .cpp files, and because we need to keep
track of all the external assembly references we need to put in the
.il file.
Handle the inline_target_code and mlds__var_name changes.
compiler/mlds_to_ilasm.m:
Output .cpp and .cs files conditionally.
Factor out output_to_file.
Move MC++ output code to mlds_to_mcpp.m
compiler/mlds_to_java.m:
Factor out output_to_file.
Handle the new var_name type, and the new target_code constructors.
compiler/mlds_to_mcpp.m:
New file to handle generating MC++ code suitable for foreign language
interfacing.
compiler/options.m:
Add a way of setting the backend-foreign-language option.
compiler/passes_aux.m:
Add output_to_file which is used by the MLDS backend to generate
output files.
compiler/prog_data.m:
Uncomment csharp as a foreign language.
Estimated hours taken: 200
Converts MLDS to Java source code. The following features
do not work/have not yet been implemented:
* RTTI
* foreign language interface
* multidet and nondet predicates
* higher order predicates
* enforced usage of Java coding conventions
compiler/mlds_to_java.m:
Replaces existing file.
compiler/java_util.m:
New file. Contains utility predicates that are used
by the Java backend.
compiler/c_util.m:
Added comment about Java backend.
Estimated hours taken: 4
Added new compiler options to support the Java backend and
updated documentation to reflect this.
compiler/globals.m:
Removed comment about Java backend not being implemented.
Replaced it by one say that it is work in progress.
compiler/mercury_compile.m:
If Target = java then call the Java backend.
compiler/options.m:
Added new options for compiling Java files:
`--java'
`--java-only'
`--java-compiler' ('--javac')
`--java-flags'
`--java-classpath'
`--java-object-file-extension'
compiler/handle_options.m:
If compiling to Java then don't link.
Added "java" grade.
compiler/mlds_to_java.m
New file.
XXX Currently just prints an error message about
the Java backend not being implemented.
doc/user_guide.texi:
Documented new options for compiling Java files.
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/final_grade_options.sh-subr:
Added support for "java" grade.