<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>I fixed Builder.m3 and cleaned it up a little.</div><div>Hopefully didn't break the LLVM paths.</div><div><br></div><div><br></div><div>I think the model I followed for C is a good one.</div><div><br></div><div><br></div><div>I extended m3cgcat to have more output types, i.e. </div><div>so it can input m3cg (same as before) and output C (new).</div><div><br></div><div><br></div><div>cm3cgcat is the Modula-3 BSD-licensed executable that can</div><div>read the .mc files.</div><div><br></div><div><br></div><div>(Unfortunately we have no basis for BSD-licensed C/C++ reading .mc files.</div><div>If someone could make a "preprocessor-friendly cm3cg description"</div><div>outside of the m3cc directory, that'd be good..)</div><div><br></div><div><br></div><div>I used an existing mode: ExternalObject</div><div><br></div><div><br></div><div>I introduced a config variable:</div><div> USE_C_BACKEND_VIA_M3CGCAT</div><div> </div><div><br></div><div>Maybe not the best name.</div><div><br></div><div><br></div><div>And then conditionally replaced m3_backend in cm3cfg.common:</div><div><br></div><div><br></div><div>if USE_C_BACKEND_VIA_M3CGCAT</div><div>M3_BACKEND_MODE = "ExternalObject"</div><div><br></div><div><br></div><div>proc m3_backend(source, object, optimize, debug) is</div><div> ret_code = try_exec("m3cgcat", "-in-binary:" & source, "-out-c:" & source & ".c")</div><div> if not equal(ret_code, 0)</div><div> return ret_code</div><div> end</div><div> return compile_c(source & ".c", object, [ ], FALSE, TRUE)</div><div>end</div><div>end</div><div><br></div><div><br></div><div><br></div><div>Builder.m3 didn't need any changes to get everything working and for</div><div>quicker turnaround on small changes. Efficiency compiling the entire</div><div>tree was a bit off.</div><div><br></div><div><br></div><div>And then, I ran cm3, I guess cm3 -boot or cm3 -keep. It was a while ago. :)</div><div>Generating a bunch of ".mc" files.</div><div><br></div><div><br></div><div>I then ran cm3cgat in my "inner loop".</div><div><br></div><div><br></div><div>Once things were further along, I added the C mode for efficiency,</div><div>to avoid writing/reading the .mc files.</div><div><br></div><div>More likely I should have added a separate variable:</div><div><span style="font-size: 12pt; "> InternalBackend = "C".</span></div><div> </div><div><br></div><div>I think in your work, you'd again want the .mc files for the bulk</div><div>of development time, and then you'd want, I think just one LLVM mode afterward,</div><div>that constructs the LLVM IR in memory and writes out object files.</div><div><br></div><div><br></div><div>If you have the wherewithall to write LLVM IR bit code w/o linking to LLVM,</div><div>then that might be another mode.</div><div><br></div><div><br></div><div> - Jay</div><br><br><br><br><div><hr id="stopSpelling">From: jay.krell@cornell.edu<br>To: rodney.m.bates@acm.org<br>CC: m3commit@elegosoft.com<br>Subject: RE: [M3commit] [modula3/cm3] 9ee098: Add backend modes for standalone cm3-IR->llvm-IR t...<br>Date: Sat, 8 Aug 2015 22:09:00 +0000<br><br>
<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}
.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}
--></style>
<div dir="ltr">This or the previous seems to have broken the C mode.<div>I'm debugging.</div><div> - Jay<br><br><br><br><br><div>> Date: Thu, 6 Aug 2015 21:55:27 -0500<br>> From: rodney_bates@lcwb.coop<br>> To: jay.krell@cornell.edu<br>> CC: m3commit@elegosoft.com<br>> Subject: Re: [M3commit] [modula3/cm3] 9ee098: Add backend modes for standalone cm3-IR->llvm-IR t...<br>> <br>> <br>> <br>> On 08/06/2015 04:28 PM, Jay wrote:<br>> > Not contradicting this necessarily but I'd like a separate flag to indicate save the IR, even if it isn't being used.<br>> ><br>> <br>> Besides -keep? Writing the cm3 IR, even when using a linked-in (to cm3) backend?<br>> That would not be hard.<br>> <br>> > And then, indeed contradicting this, I wonder if "mode" is the right parameter. Maybe we can have "pipeline" and user lists a sequence of functions to call?<br>> ><br>> > Heck, maybe we should have quake functions for:<br>> > save IR<br>> > convert IR file to C in-proc<br>> > convert IR file to LLVM IR<br>> > save LLVM IR to file<br>> > etc?<br>> ><br>> > Problem is that IR cannot be represented in quake?<br>> ><br>> <br>> In working on this, I've thought about a Cartesian factoring of the various<br>> modes. But there are already way more combinations than anybody has any<br>> use for now, or even likely use. It does get complicated, figuring out<br>> the sequence of input and output file names, etc. And it's full of stuff<br>> to include files in various intermediate formats that were not produced<br>> by the cm3 compiler.<br>> <br>> > - Jay<br>> ><br>> > On Aug 6, 2015, at 1:33 PM, Rodney Bates <rodney.m.bates@acm.org> wrote:<br>> ><br>> >> Branch: refs/heads/master<br>> >> Home: https://github.com/modula3/cm3<br>> >> Commit: 9ee0988a34e2ccfe8a0d95b9e12a249f8251be66<br>> >> https://github.com/modula3/cm3/commit/9ee0988a34e2ccfe8a0d95b9e12a249f8251be66<br>> >> Author: Rodney Bates <rodney.m.bates@acm.org><br>> >> Date: 2015-08-06 (Thu, 06 Aug 2015)<br>> >><br>> >> Changed paths:<br>> >> M m3-sys/cm3/src/Builder.m3<br>> >> M m3-sys/cm3/src/llvmdummy/LLGen.i3<br>> >> M m3-sys/cm3/src/llvmdummy/LLGen.m3<br>> >> M m3-sys/cm3/src/m3makefile<br>> >> M m3-sys/cm3/src/version.quake<br>> >> M m3-sys/cminstall/src/config-no-install/Unix.common<br>> >> M m3-sys/m3middle/src/Target.i3<br>> >><br>> >> Log Message:<br>> >> -----------<br>> >> Add backend modes for standalone cm3-IR->llvm-IR translator executable.<br>> >><br>> >> On branch master<br>> >> Changes to be committed:<br>> >><br>> >> modified: m3-sys/cm3/src/Builder.m3<br>> >> modified: m3-sys/cm3/src/llvmdummy/LLGen.i3<br>> >> modified: m3-sys/cm3/src/llvmdummy/LLGen.m3<br>> >> modified: m3-sys/cm3/src/m3makefile<br>> >> modified: m3-sys/cm3/src/version.quake<br>> >> modified: m3-sys/cminstall/src/config-no-install/Unix.common<br>> >> modified: m3-sys/m3middle/src/Target.i3<br>> >><br>> >> Add new backend modes StAloneLlvmAsm and StAloneLlvmObj.<br>> >> These produce cm3-IR (.ic/.mc) in cm3, run "m3llvm" as a separate executable,<br>> >> to translate to llvm-IR bitcode (.ib/.mb), run llc to compile that, and,<br>> >> in the case of StAloneLlvmAsm, run asm separately.<br>> >><br>> >><br>> >> _______________________________________________<br>> >> M3commit mailing list<br>> >> M3commit@elegosoft.com<br>> >> https://mail.elegosoft.com/cgi-bin/mailman/listinfo/m3commit<br>> ><br>> <br>> -- <br>> Rodney Bates<br>> rodney.m.bates@acm.org<br></div></div> </div></div> </div></body>
</html>