Get pragma foreign_type working for the C backend.

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.
This commit is contained in:
Peter Ross
2002-05-07 11:03:17 +00:00
parent e9f73520bb
commit ddd77f6f0e
36 changed files with 597 additions and 136 deletions

View File

@@ -1,5 +1,5 @@
%-----------------------------------------------------------------------------%
% Copyright (C) 1995-2001 The University of Melbourne.
% Copyright (C) 1995-2002 The University of Melbourne.
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
%------------------------------------------------------------------------------%
@@ -599,20 +599,20 @@ exprn_aux__substitute_lval_in_live_lval_info(OldLval, NewLval,
exprn_aux__substitute_lval_in_pragma_c_input(OldLval, NewLval, Out0, Out,
N0, N) :-
Out0 = pragma_c_input(Name, Type, Rval0),
Out0 = pragma_c_input(Name, Type, Rval0, MaybeForeign),
exprn_aux__substitute_lval_in_rval_count(OldLval, NewLval, Rval0, Rval,
N0, N),
Out = pragma_c_input(Name, Type, Rval).
Out = pragma_c_input(Name, Type, Rval, MaybeForeign).
:- pred exprn_aux__substitute_lval_in_pragma_c_output(lval::in, lval::in,
pragma_c_output::in, pragma_c_output::out, int::in, int::out) is det.
exprn_aux__substitute_lval_in_pragma_c_output(OldLval, NewLval, Out0, Out,
N0, N) :-
Out0 = pragma_c_output(Lval0, Type, Name),
Out0 = pragma_c_output(Lval0, Type, Name, MaybeForeign),
exprn_aux__substitute_lval_in_lval_count(OldLval, NewLval, Lval0, Lval,
N0, N),
Out = pragma_c_output(Lval, Type, Name).
Out = pragma_c_output(Lval, Type, Name, MaybeForeign).
:- pred exprn_aux__substitute_lval_in_rval_count(lval::in, lval::in,
rval::in, rval::out, int::in, int::out) is det.