<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><div><font face="Calibri, sans-serif">So, if I just move the code to m3back, you are ok?</font></div><div><font face="Calibri, sans-serif">Clearly m3middle is for front and backends though.</font></div><div><font face="Calibri, sans-serif"> i.e. at least Target, TInt, TFloat is needed by both/all.</font></div><div><font face="Calibri, sans-serif">How does m3front get away w/o having similar functionality?</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">What is the meaning of:</font></div><div><font face="Calibri, sans-serif"> CONST a = 16_7FFFFFFF + 1; </font></div><div><font face="Calibri, sans-serif"> CONST b = 16_7FFFFFFF + 1 - 1; </font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">for a 32bit target?</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">or</font></div><div><font face="Calibri, sans-serif"> CONST c = 16_7FFFFFFFFFFFFFFFL + 1; </font></div><div><font face="Calibri, sans-serif"> CONST d = 16_7FFFFFFFFFFFFFFFL + 1 - 1; </font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">(I should try them and see and read code, granted.</font></div><div><font face="Calibri, sans-serif">I should read more of m3front in general.)</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">Restated, clearly larger-than-host-integer precision</font></div><div><font face="Calibri, sans-serif">arithemetic is needed by the frontend. But I don't see</font></div><div><font face="Calibri, sans-serif">that it is sufficient to have fixed-64-bit-precision arithmetic.</font></div><div><font face="Calibri, sans-serif">It seems to me you would want to further "type" or restrict</font></div><div><font face="Calibri, sans-serif">the precision, depending on context, to one of INT8, UINT8, INT16,</font></div><div><font face="Calibri, sans-serif">UINT16, INT32, UINT32, INT64, UINT64.</font></div><div><font face="Calibri, sans-serif">(where "unsigned" is perhaps "half interval", 0 to the maximum signed</font></div><div><font face="Calibri, sans-serif">number of that precision...though this half interval stuff still</font></div><div><font face="Calibri, sans-serif">makes me uneasy..but I grant that TInt does not implement full range</font></div><div><font face="Calibri, sans-serif">64bit unsigned math, it is really a portable INT64).</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">What I can't immediately guess with high confidence is if the "typing"</font></div><div><font face="Calibri, sans-serif">is appropriate for intermediate results, or only final results.</font></div><div><font face="Calibri, sans-serif">i.e. range checking all along, or only upon some conversion at the end.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">I guess, again, I should read m3front and the language spec more.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">Also, regarding m3middle..M3CG_Ops.i3 does lend itself to an intermediate</font></div><div><font face="Calibri, sans-serif">representation. In-memory that can be processed in multiple passes.</font></div><div><font face="Calibri, sans-serif">I realize using it as such isn't very creative and ultimately</font></div><div><font face="Calibri, sans-serif">one would want to augment it further. But it is useful.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">And so there is the idea that m3middle is code of use to multiple backends,</font></div><div><font face="Calibri, sans-serif">even if not to the frontend at all.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">As well, the idea of actual "shared middle ends" or shared passes.</font></div><div><font face="Calibri, sans-serif">i.e. in M3C I eliminate unused local variables.</font></div><div><font face="Calibri, sans-serif">(not through sophisticated analysis like eliminating locals that</font></div><div><font face="Calibri, sans-serif">are only ever written to..though I could do that...but locals that</font></div><div><font face="Calibri, sans-serif">are neither written to nor read from. If M3CG were in-memory "in an array"</font></div><div><font face="Calibri, sans-serif">and that was a common interface to multiple backends, this trasnform</font></div><div><font face="Calibri, sans-serif">could be shared among backends, or heck, always applied as a matter of course.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">It kind of seems to me that backends should have some characteristics</font></div><div><font face="Calibri, sans-serif">described about them, communicated to the frontend, like requesting</font></div><div><font face="Calibri, sans-serif">the frontend interface with them in one of two or three ways, and</font></div><div><font face="Calibri, sans-serif">requesting certain passes be applied before them.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">Or, look how gcc is structured, as a series of passes.</font></div><div><font face="Calibri, sans-serif">We could do that.</font></div><div><font face="Calibri, sans-serif">passes:</font></div><div><font face="Calibri, sans-serif"> m3front </font></div><div><font face="Calibri, sans-serif"> m3cg function calls to in-memory format </font></div><div><font face="Calibri, sans-serif"> eliminate unused locals </font></div><div><font face="Calibri, sans-serif"> compute operations x types -- i.e. discover if extract is </font></div><div><font face="Calibri, sans-serif"> applied to int32 and/or int64, for backends that want to output</font></div><div><font face="Calibri, sans-serif"> helper functions; not all targets care</font></div><div><font face="Calibri, sans-serif"> compute or estimate maximum compile-time stack depth -- I've been</font></div><div><font face="Calibri, sans-serif"> tempted to add this, but so far haven't done it; it is easy to estimate;</font></div><div><font face="Calibri, sans-serif"> my motivation isn't good -- it is that I don't like the Modula-3</font></div><div><font face="Calibri, sans-serif"> generic mechanism and how it steers me toward "RefSeq" and lots of</font></div><div><font face="Calibri, sans-serif"> NARROW() operations -- slower than needed. I'd rather use an open array</font></div><div><font face="Calibri, sans-serif"> if I can compute the right size early.</font></div><div><font face="Calibri, sans-serif"> move imports ahead of everything </font></div><div><font face="Calibri, sans-serif"> compute frames, maybe </font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">These can all be done reasonably well with the "obvious" internal</font></div><div><font face="Calibri, sans-serif">representation, plus just a little extra data.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">I guess what I'm saying is there could/should be more shared code for</font></div><div><font face="Calibri, sans-serif">backends. Given the two in existance today, that isn't really true, they</font></div><div><font face="Calibri, sans-serif">are too different.</font></div><div><font face="Calibri, sans-serif">But it is perhaps true if we had some other mix of backend implementations.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">Granted, LLVM does "everything" itself anyway, all those passes</font></div><div><font face="Calibri, sans-serif">are trivial for it, most likely. It doesn't need any help.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> - Jay</font></div><br><br><br><br><div style="font-family: Calibri, sans-serif; font-size: 12pt; "><div id="SkyDrivePlaceholder"></div><hr id="stopSpelling">From: hosking@cs.purdue.edu<br>Date: Thu, 25 Oct 2012 10:37:57 -0400<br>To: jay.krell@cornell.edu<br>CC: m3devel@elegosoft.com<br>Subject: Re: [M3devel] what is wrong with TIntN?<br><br>The problem is that you are trying to bring front-end mechanisms into the backend.<div><div>If you want to perform optimizations in your backend they should be standalone and independent of the front end.</div><div>For example, the llvm backend can perform a whole bunch of optimizations in its own IR.</div><div>TInt is a service provided by m3middle to the front-end.</div><div>Feel free to add whatever you like to your backend. I just don’t want to see unnecessary stuff introduced into m3middle.</div><div><br><div><div>On Oct 25, 2012, at 4:12 AM, Jay K <<a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a>> wrote:</div><br class="ecxApple-interchange-newline"><blockquote><div class="ecxhmmessage" 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"><div dir="ltr"><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">When faced with</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif"><br></font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif"><br></font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">VAR a := FIRST(INTEGER) + 1;</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">VAR b := LAST(INTEGER) + 1;</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">VAR c := LAST(INTEGER) + 1 - 1;</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">VAR d := (a > 0);</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif"><br></font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif"><br></font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">I would like backends to optimize initialization a,</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">not optimize initialization of b,</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">and probably not optimize initialization of c,</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">and hopefully optimize initialization of d, but that is more</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">difficult in the C backend.</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif"><br></font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif"><br></font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">Fold constants when it is obviously safe.</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">Do not fold constants when there is a chance of overflow -- even</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">at intermediate points of the expression.</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif"><br></font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif"><br></font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">This is why I believe TIntN is useful.</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif"><br></font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif"><br></font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">I bring this up because I'm about to add constant folding to M3C.m3.</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">And to introduce use of TIntN.</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">Which Tony has insisted is wrong, i.e. use in M3x86.m3.</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif"><br></font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif"><br></font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif"><br></font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif">Thanks,</font></div><div style="font-family:Times;font-size:medium"><font face="Calibri, sans-serif"> - Jay</font></div></div></div></blockquote></div><br></div></div></div> </div></body>
</html>