[M3devel] why this loop/multipass stuff
Jay K
jay.krell at cornell.edu
Wed Aug 22 16:56:31 CEST 2012
I'm implementing M3CG_Ops.m3.
I don't trust m3tk -- it isn't the compiler.
I'm somewhat familiar with m3cg.
Given another M3CG, I know how to plug in to cm3, config files, etc.
(e.g. add a new target, AMD64_NT, that will use this. :) )
On the other hand...I have a little more insight this morning.
Variables have an "uplevel" parameter -- are they accessed from nested functions.
I should be able to link variables to their containing procedure, and therefore its level.
So "load(var)" I guess can be:
text := ""
for i := current_level to var.proc.level do (* typically an empty loop *)
text := text & "_static_link->"
end;
if uplevel AND current_level = var.proc.level (* relatively rare *)
text := text & "_locals.";
end;
text := text & var.name;
or somesuch.
I think I should get back to M3C with the assumption I don't need multiple passes...fil in more pieces..see where I get...
- Jay
> To: jay.krell at cornell.edu
> CC: hosking at cs.purdue.edu; m3devel at elegosoft.com
> Subject: Re: [M3devel] why this loop/multipass stuff
> Date: Wed, 22 Aug 2012 07:41:09 -0700
> From: mika at async.caltech.edu
>
> Jay I've been following what you've been writing with one eye.
>
> But I'm not clear exactly what framework you're fitting into. Are you
> processing the output of m3front?
>
> There's always m3tk. Since it is claimed it was used to write a compiler
> it ought to be able to process MODULEs but I've only ever used it to
> process INTERFACEs. What's the story about that?
>
> Mika
>
> Tony Hosking writes:
> >
> >--Apple-Mail=_ED26DAAF-73B8-4147-B1C9-82D48C3720BF
> >Content-Transfer-Encoding: quoted-printable
> >Content-Type: text/plain;
> > charset=iso-8859-1
> >
> >
> >Antony Hosking | Associate Professor | Computer Science | Purdue =
> >University
> >305 N. University Street | West Lafayette | IN 47907 | USA
> >Mobile +1 765 427 5484
> >
> >
> >
> >
> >
> >On Aug 22, 2012, at 10:24 AM, Jay K <jay.krell at cornell.edu> wrote:
> >
> >> why this loop/multipass stuff
> >>=20
> >>=20
> >> So people understand where I'm going here -- and Tony asked. I had =
> >already written this up..
> >>=20
> >>=20
> >>=20
> >> 1) in the past working on m3cc/parse.c, I found that "declare"s
> >> weren't always "topologically sorted".
> >>=20
> >>=20
> >> That is, like, I might see:
> >>=20
> >> given TYPE T1 =3D INTEGER;
> >> TYPE T2 =3D RECORD =3D a:T1; END;
> >>=20
> >>=20
> >> I might have seen type T1 declared before T2, or not.
> >> I'm not sure if it was record/fields or other relationships.
> >> I just remember that building up a map of typeid to data, and
> >> looking up it when needed, didn't always work, with one pass.
> >>=20
> >>=20
> >> So what I did is that I was willing to "skip" declares
> >> that referred to typeids I hadn't seen yet, and then loop
> >> again, hoping for progress at each loop (fewer skips).
> >
> >Was this all in aid of building up proper type descriptors?
> >
> >> 2) It looks like declare_local/temp don't all come in
> >> "at the start" of a procedure. I'm not sure if I'm generating
> >> C or C++, but if I'm generating C, it helps to have declare_local/temp
> >> right after begin_procedure/block. Multiple passes let me make that
> >> so, without changing m3front.
> >> (Upon further looking..it seems this is mostly done right, but
> >> not for "try" blocks; maybe reasonable to change m3front here.).
> >>=20
> >>=20
> >> Now, generating C++ is an option, and I'm ignoring all declares
> >> currently anyway, so these don't force the matter, but:
> >>=20
> >>=20
> >> 3) nested functions.
> >> If a function contains any nested functions, I want to put all of
> >> its locals in a local struct, and use the address of that struct
> >> as the "static link". Or at least the locals that are referenced
> >> by nested functions.
> >
> >Preferably these only, or else you will cause all locals to be in memory =
> >instead of registers.
> >
> >> As well, m3front contains options as to
> >> the order of outputing functions. It uses one order for m3back and
> >> a different order for m3cc. I wouldn't mind if M3C.m3 worked either
> >> way.
> >>=20
> >>=20
> >> There are possibly other benefits that could be derived from multiple =
> >passes.
> >> Nothing offhand though.
> >>=20
> >>=20
> >> - Jay
> >
> >
> >--Apple-Mail=_ED26DAAF-73B8-4147-B1C9-82D48C3720BF
> >Content-Transfer-Encoding: quoted-printable
> >Content-Type: text/html;
> > charset=iso-8859-1
> >
> ><html><head><meta http-equiv=3D"Content-Type" content=3D"text/html =
> >charset=3Diso-8859-1"><base href=3D"x-msg://3740/"></head><body =
> >style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
> >-webkit-line-break: after-white-space; "><br><div>
> ><span class=3D"Apple-style-span" style=3D"border-collapse: separate; =
> >color: rgb(0, 0, 0); font-family: Helvetica; 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-border-horizontal-spacing: 0px; =
> >-webkit-border-vertical-spacing: 0px; =
> >-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
> >auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span =
> >class=3D"Apple-style-span" style=3D"border-collapse: separate; color: =
> >rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: =
> >normal; font-variant: normal; font-weight: normal; letter-spacing: =
> >normal; line-height: normal; orphans: 2; text-indent: 0px; =
> >text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; =
> >-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
> >0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
> >auto; -webkit-text-stroke-width: 0px; "><div style=3D"word-wrap: =
> >break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
> >after-white-space; "><span class=3D"Apple-style-span" =
> >style=3D"border-collapse: separate; -webkit-border-horizontal-spacing: =
> >0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); =
> >font-family: Helvetica; font-size: 12px; font-style: normal; =
> >font-variant: normal; font-weight: normal; letter-spacing: normal; =
> >line-height: normal; -webkit-text-decorations-in-effect: none; =
> >text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; =
> >orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div =
> >style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
> >-webkit-line-break: after-white-space; "><span class=3D"Apple-style-span" =
> >style=3D"border-collapse: separate; -webkit-border-horizontal-spacing: =
> >0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); =
> >font-family: Helvetica; font-size: 12px; font-style: normal; =
> >font-variant: normal; font-weight: normal; letter-spacing: normal; =
> >line-height: normal; -webkit-text-decorations-in-effect: none; =
> >text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; =
> >orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span =
> >class=3D"Apple-style-span" style=3D"border-collapse: separate; =
> >-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
> >0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; =
> >font-style: normal; font-variant: normal; font-weight: normal; =
> >letter-spacing: normal; line-height: normal; =
> >-webkit-text-decorations-in-effect: none; text-indent: 0px; =
> >-webkit-text-size-adjust: auto; text-transform: none; orphans: 2; =
> >white-space: normal; widows: 2; word-spacing: 0px; "><span =
> >class=3D"Apple-style-span" style=3D"border-collapse: separate; =
> >-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
> >0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; =
> >font-style: normal; font-variant: normal; font-weight: normal; =
> >letter-spacing: normal; line-height: normal; =
> >-webkit-text-decorations-in-effect: none; text-indent: 0px; =
> >-webkit-text-size-adjust: auto; text-transform: none; orphans: 2; =
> >white-space: normal; widows: 2; word-spacing: 0px; "><span =
> >class=3D"Apple-style-span" style=3D"border-collapse: separate; =
> >-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
> >0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; =
> >font-style: normal; font-variant: normal; font-weight: normal; =
> >letter-spacing: normal; line-height: normal; =
> >-webkit-text-decorations-in-effect: none; text-indent: 0px; =
> >-webkit-text-size-adjust: auto; text-transform: none; orphans: 2; =
> >white-space: normal; widows: 2; word-spacing: 0px; "><span =
> >class=3D"Apple-style-span" style=3D"border-collapse: separate; =
> >-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
> >0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; =
> >font-style: normal; font-variant: normal; font-weight: normal; =
> >letter-spacing: normal; line-height: normal; =
> >-webkit-text-decorations-in-effect: none; text-indent: 0px; =
> >-webkit-text-size-adjust: auto; text-transform: none; orphans: 2; =
> >white-space: normal; widows: 2; word-spacing: 0px; "><span =
> >class=3D"Apple-style-span" style=3D"border-collapse: separate; =
> >-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
> >0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; =
> >font-style: normal; font-variant: normal; font-weight: normal; =
> >letter-spacing: normal; line-height: normal; =
> >-webkit-text-decorations-in-effect: none; text-indent: 0px; =
> >-webkit-text-size-adjust: auto; text-transform: none; orphans: 2; =
> >white-space: normal; widows: 2; word-spacing: 0px; "><span =
> >class=3D"Apple-style-span" style=3D"border-collapse: separate; =
> >-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
> >0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; =
> >font-style: normal; font-variant: normal; font-weight: normal; =
> >letter-spacing: normal; line-height: normal; =
> >-webkit-text-decorations-in-effect: none; text-indent: 0px; =
> >-webkit-text-size-adjust: auto; text-transform: none; orphans: 2; =
> >white-space: normal; widows: 2; word-spacing: 0px; "><span =
> >class=3D"Apple-style-span" style=3D"border-collapse: separate; =
> >-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
> >0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; =
> >font-style: normal; font-variant: normal; font-weight: normal; =
> >letter-spacing: normal; line-height: normal; =
> >-webkit-text-decorations-in-effect: none; text-indent: 0px; =
> >-webkit-text-size-adjust: auto; text-transform: none; orphans: 2; =
> >white-space: normal; widows: 2; word-spacing: 0px; "><div><font =
> >class=3D"Apple-style-span" color=3D"#0000FF"><font =
> >class=3D"Apple-style-span" face=3D"Gill Sans"><span =
> >class=3D"Apple-style-span" style=3D"color: rgb(0, 0, 255); font-family: =
> >'Gill Sans'; "><span class=3D"Apple-style-span" style=3D"color: rgb(0, =
> >0, 255); font-family: 'Gill Sans'; ">Antony =
> >Hosking</span></span></font></font><font class=3D"Apple-style-span" =
> >face=3D"Gill Sans"><span class=3D"Apple-style-span" style=3D"font-family: =
> >'Gill Sans'; "><span class=3D"Apple-style-span" style=3D"font-family: =
> >'Gill Sans'; "><span class=3D"Apple-converted-space"> </span>|<span =
> >class=3D"Apple-converted-space"> </span></span></span><span =
> >class=3D"Apple-style-span" style=3D"font-family: 'Gill Sans'; "><span =
> >class=3D"Apple-style-span" style=3D"font-family: 'Gill Sans'; =
> >">Associate Professor</span></span><span class=3D"Apple-style-span" =
> >style=3D"font-family: 'Gill Sans'; "><span class=3D"Apple-style-span" =
> >style=3D"font-family: 'Gill Sans'; "> | Computer Science | Purdue =
> >University</span></span></font></div><div><font class=3D"Apple-style-span"=
> > face=3D"GillSans-Light"><span class=3D"Apple-style-span" =
> >style=3D"font-family: GillSans-Light; ">305 N. University Street | West =
> >Lafayette | IN 47907 | USA</span></font></div><div><font =
> >class=3D"Apple-style-span" color=3D"#0000FF" face=3D"Gill Sans"><span =
> >class=3D"Apple-style-span" style=3D"color: rgb(0, 0, 255); font-family: =
> >'Gill Sans'; "><span class=3D"Apple-style-span" style=3D"color: rgb(0, =
> >0, 255); font-family: 'Gill Sans'; ">Mobile</span></span></font><font =
> >class=3D"Apple-style-span" face=3D"GillSans-Light"><span =
> >class=3D"Apple-style-span" style=3D"font-family: GillSans-Light; "><span =
> >class=3D"Apple-style-span" style=3D"font-family: GillSans-Light; "><span =
> >class=3D"Apple-converted-space"> </span>+1 765 427 =
> >5484</span></span></font></div><div><font class=3D"Apple-style-span" =
> >face=3D"GillSans-Light"><br =
> >class=3D"khtml-block-placeholder"></font></div></span></span></span></span=
> >></span></span></span><br =
> >class=3D"Apple-interchange-newline"></span></div></span></div></span><br =
> >class=3D"Apple-interchange-newline"></span><br =
> >class=3D"Apple-interchange-newline">
> ></div>
> ><br><div><div>On Aug 22, 2012, at 10:24 AM, Jay K <<a =
> >href=3D"mailto:jay.krell at cornell.edu">jay.krell at cornell.edu</a>> =
> >wrote:</div><br class=3D"Apple-interchange-newline"><blockquote =
> >type=3D"cite"><div class=3D"hmmessage" style=3D"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=3D"ltr">why this loop/multipass stuff<br><br><br>So people =
> >understand where I'm going here -- and Tony asked. I had already written =
> >this up..<br><br><br><br>1) in the past working on m3cc/parse.c, I found =
> >that "declare"s<br>weren't always "topologically =
> >sorted".<br><br><br>That is, like, I might see:<br><br>given TYPE T1 =3D =
> >INTEGER;<br>TYPE T2 =3D RECORD =3D a:T1; END;<br><br><br>I might have =
> >seen type T1 declared before T2, or not.<br>I'm not sure if it was =
> >record/fields or other relationships.<br>I just remember that building =
> >up a map of typeid to data, and<br>looking up it when needed, didn't =
> >always work, with one pass.<br><br><br>So what I did is that I was =
> >willing to "skip" declares<br>that referred to typeids I hadn't seen =
> >yet, and then loop<br>again, hoping for progress at each loop (fewer =
> >skips).<br></div></div></blockquote><div><br></div><div>Was this all in =
> >aid of building up proper type descriptors?</div><br><blockquote =
> >type=3D"cite"><div class=3D"hmmessage" style=3D"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=3D"ltr">2) It looks like declare_local/temp don't all come in<br>"at =
> >the start" of a procedure. I'm not sure if I'm generating<br>C or C++, =
> >but if I'm generating C, it helps to have declare_local/temp<br>right =
> >after begin_procedure/block. Multiple passes let me make that<br>so, =
> >without changing m3front.<br>(Upon further looking..it seems this is =
> >mostly done right, but<br>not for "try" blocks; maybe reasonable to =
> >change m3front here.).<br><br><br>Now, generating C++ is an option, and =
> >I'm ignoring all declares<br>currently anyway, so these don't force the =
> >matter, but:<br><br><br>3) nested functions.<br>If a function contains =
> >any nested functions, I want to put all of<br>its locals in a local =
> >struct, and use the address of that struct<br>as the "static link". Or =
> >at least the locals that are referenced<br>by nested =
> >functions.</div></div></blockquote><div><br></div><div>Preferably these =
> >only, or else you will cause all locals to be in memory instead of =
> >registers.</div><br><blockquote type=3D"cite"><div class=3D"hmmessage" =
> >style=3D"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=3D"ltr">As well, m3front contains options as to<br>the order =
> >of outputing functions. It uses one order for m3back and<br>a different =
> >order for m3cc. I wouldn't mind if M3C.m3 worked =
> >either<br>way.<br><br><br>There are possibly other benefits that could =
> >be derived from multiple passes.<br>Nothing offhand =
> >though.<br><br><br> - =
> >Jay<br></div></div></blockquote></div><br></body></html>=
> >
> >--Apple-Mail=_ED26DAAF-73B8-4147-B1C9-82D48C3720BF--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20120822/2981a88f/attachment-0002.html>
More information about the M3devel
mailing list