[Mono-list] Re: From one Cyber Wiz to others

BioChem333 biochem333@nyc.rr.com
21 Jul 2002 02:43:27 -0400


Hi,

	You can't use rtl to emit stack based code; rtl is for register
machines only. The design of gcc is such that you have to split away
from the normal compilation path before it reaches the frontend->rtl
process. The compilation process makes many assumptions early on about
what is and what is not needed by the rtl, but the discarded metadata is
vital to producing CIL, java bytecodes, etc. The design of rtl itself is
such that any attempt to produce stack based code using it would result
in a mess. The gcj execution path splits from the normal gcc path early
on for just this reason, and, afaik, still doesn't produce very good
bytecode.

	If you really want CIL or similar stack based output from gcc you have
to rip gcc's guts out. There are two ways to go about this. The first
is, you can invent an intermediate language like rtl which is designed
for stack machines, and redesign gcc (which means rewriting frontends)
so that the frontends can hook into either intermediate language
backend. Your second option is to get rid of rtl altogether and invent
an intermediate language that understands both register and stack based
machines; this would also require rewriting the frontends. The
translation: you would have to replace most of gcc.

	If I haven't scared you off and you still want to make this work, you
should consider taking a look at Rhys Weatherly's treecc program; it's
the program he wrote to help him write the Portable.NET compiler for the
DotGNU project. It helps to deal with a lot of the complexity of writing
compilers (and, considering that pnet is almost as far along as mcs but
only has one hacker really working on it, it works). Although I'm pretty
inexperienced and my skills are therefore somewhat lacking, I'd be
interested in contributing to such a project, so if you do go ahead with
it please let me know. Thanks.

Rich


On Sat, 2002-07-20 at 11:03, Cyber Wiz wrote:
> i know about the CIL docs it's gcc andall this stuff with rtl that confuses 
> me i am not sure which files i have to alter and from what i can see the gcc 
> docs are not too helpful could you tell me where to find what function is 
> called for gcc that uses the others in rtl.c so it culd be changed. or if 
> possible if gcc emits assemble code could it just be scanned to create 
> metadata and the passes through an ilasm  ? (like with egcs-jvm) also i 
> might be able to write the lib but am new to c# it's pretty simple though 
> because it's like c++ how to contribute?