[m-dev.] for review: GCC back-end: integrate with mmc

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Jan 16 13:17:22 AEDT 2001


On 16-Jan-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> On 14-Jan-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > +++ mercury/compiler/mlds_to_gcc.m	2001/01/13 18:21:02
> > @@ -9,9 +9,12 @@
> >  
> >  % Note that this does *not* compile to GNU C -- instead it
> >  % actually generates GCC's internal "Tree" representation,
> > +% and then invokes the GCC back-end to compile it to assembler,
> >  % without going via an external file.
> > +% Code using the C interface, however, does get compiled to C;
> > +% this module invokes mlds_to_c.m to do that.
> 
> This could be a bit more informative -- "Code using the C interface"
> could mean anything from the user_target_code to the entire program.
> Also, documenting *how* it gets compiled to C would be good (in other
> words, that you generate calls to such C code and that it gets put into
> a separate __c_code module).

OK, I'll update the comment.

> > @@ -129,6 +327,8 @@
> >  		{ ForeignMLDS = mlds(ModuleName, ForeignCode, Imports,
> >  			ForeignDefns) },
> >  		mlds_to_c__output_mlds(ForeignMLDS),
> > +		% XXX currently the only foreign code we handle is C
> > +		{ ContainsCCode = yes },
> >  		{ NeedInitFn = no }
> >  	),
> 
> Although it is NYI, this shoulden't be a problem.  mlds_to_c only
> handles C code, and it checks for C code before it generates code.
> foreign.m will turn any other code into a separate module (that will be
> processed using some other translator) and replace it with C code.

The problem is that although mlds_to_c may put the non-C foreign code
into a separate file, mercury_compile.m won't know that this non-C
foreign code exists, and so it won't know to invoke the foreign
language compiler, or to link in the object files that result.
To make it work properly we'd need to change the `ContainsCCode'
boolean that we return to instead be a list of the foreign languages
used.

I'll update the comment.

> > Index: gcc/mercury/mercury-gcc.c
> > @@ -700,9 +724,8 @@
> >    free (argv);
> >  
> >    /* XXX We should set errorcount properly, but currently we don't.  */
> > -  if (result != 0 && errorcount == 0) {
> > -  	errorcount++;
> > -  }
> > +  if (result != 0 && errorcount == 0)
> > +    errorcount++;
> >  
> >    return result;
> >  }
> 
> I hate the convention without the braces.  Is that a gcc source code
> convention?

'Fraid so.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list