<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><base href="x-msg://3607/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I’ll respond to this in more detail, but briefly, I object strongly to a multipass m3cg. If you need multiple passes then you probably need a different internal representation (just like m3cg has a different internal representation). M3CG is a simple single-pass linear representation of a program. If you need multiple passes to understand it then that is your problem. I imagine that any backend will itself need to be multipass anyway (if it is to do something useful). I think your C backend should be multipass too. It certainly will need to read M3CG IR and import it into some reasonable internal representation. This is exactly the strategy I am taking with M3CG to LLVM IR. I will have some minor tweaks to M3CG just to lift its level of abstraction slightly (to better communicate typed indexing of arrays and fields, for example). But I see no need to make M3CG do any more heavy lifting.<br>
<br><div><div>On Sep 6, 2012, at 4:40 AM, Jay K <<a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="hmmessage" style="font-size: 12pt; font-family: Calibri; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div dir="ltr"><div><font face="Calibri">/* The following is legal C but not C++: */</font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri">struct Foo_t;</font></div><div><font face="Calibri">typedef struct Foo_t Foo_t;</font></div><div><font face="Calibri">static struct Foo_t Foo; /* illegal C++; C forward/tentative definition */</font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri">int F1(void) { return *(int*)&Foo; }</font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri">struct Foo_t { int i; };</font></div><div><font face="Calibri">static Foo_t Foo = { 123 };</font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri">This is a reason that either</font></div><div><font face="Calibri">1) I "need" to make M3C.m3 "multi pass"</font></div><div><font face="Calibri">2) or at least buffer everything in memory</font></div><div><font face="Calibri">in multiple pieces and then concat at the end</font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri"> I could also make it less efficient: </font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri"> struct Foo_t; /* segment */ </font></div><div><font face="Calibri"> typedef struct Foo_t Foo_t; </font></div><div><font face="Calibri"> static struct Foo_t * /*const*/ Foo; </font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri"> int F1(void) { return *(int*)&Foo; } </font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri"> struct Foo_t { int i; };</font></div><div><font face="Calibri"> static Foo_t _Foo = { 123 }; </font></div><div><font face="Calibri"> static Foo_t* /*const*/ Foo = &_Foo;</font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri">But that seems unfortunate.</font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri">I will want to generate C++ at some point, for efficient portable exception</font></div><div><font face="Calibri">handling. But that comes later.</font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri">Also later, the C code needs a reordering in order to refer to fields in "segments".</font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri"><br></font></div><div><font face="Calibri"> - Jay</font></div></div></div></blockquote></div><br></body></html>