[M3devel] C backend -- mode or call quake?
Jay K
jay.krell at cornell.edu
Sat Oct 13 06:44:57 CEST 2012
Aha, you like a new mode, IntegratedC? A bit more of a change in cm3/Builder, but leaves M3C.m3 ignorant of quake? Ok. I like it too. I had it working. I sent the diff. The only perhaps controversial part is I changed an error to be "more fatal" (stop right away, I think).
I can bring that back.
- Jay
From: hosking at cs.purdue.edu
Date: Sat, 13 Oct 2012 00:25:11 -0400
To: jay.krell at cornell.edu
CC: m3devel at elegosoft.com; antony.hosking at gmail.com
Subject: Re: [M3devel] C backend -- mode or call quake?
On Oct 12, 2012, at 1:46 PM, Jay K <jay.krell at cornell.edu> wrote:Emulating the gcc-based approach is not good.
We have four modes currently:ExternalAssembly, ExternalObject, IntegratedAssembly, IntegratedObject(They have numbers like 0, 1, 2, 3, but I gave them sensible names too.)
NT/x86 uses IntegratedObject gcc/m3cg uses ExternalAssembly "External" means "produce .mc files and run the quake function m3back()" "Object" means we got .o files and are "done". "Assembly" means cm3/Builder should then use quake or whatever to run the assembler.
currently I am using ExternalObject; via config file changes where the quake function m3back calls m3cgcat to go .mc to .c, and then m3back calls compile_c to go .c to .o.
"External" anything is convenient for development and testing, bad for performance. It writes and reads the .mc files. Besides development/testing, it also is used for licensing reasons -- communication through files instead of "linking" code.
"Object" is preferable to "Assembly" in this case because going from .c to .o is "easier" than going from .c to .s..sort of. Due to the requirements of gcc/m3cg, we do already have fully developed/configured ability to run the assembler.. so ease/portability are kind of moot -- cc -c foo.c -o bar.o isn't actually portable enough (e.g. it doesn't work for Darwin/amd64), we still have to be somewhat expert in C compiler invocation/flags, and we are. But some C compilers do output .o files directly without going through an assembler, so it should be faster. e.g. NT and I believe clang, Sun CC, that is, everything but gcc. So "Object" is faster than "Assembly".
So that leaves us with IntegratedObject.M3C.m3 will have to interact with quake.
Yuck!
OR I can introduce "IntegratedC". Leave M3C ignorant of quake and leave it up to cm3/Builder to compile the output. (Still skipping the .mc files and m3cgcat).
Yes!
It shouldn't be a big deal either way.
cm3/Builder still has to new up a different backend.
For LLVM you'll likely follow a similar course."External" is convenient for development and testing, but slower."Object" and "Assembly" are probably both options and you can probably go "directly" to "Object", skipping "Assembly".You won't need to invoke a C compiler or assembler, and IntegratedObject will work more directly for you. Still/again you'll have to teach cm3/Builder to new up your backend, instead of the one Integrated backend.
Agreed, but that is not so difficult.
- Jay
From: hosking at cs.purdue.edu
Date: Fri, 12 Oct 2012 13:23:59 -0400
To: jay.krell at cornell.edu
CC: m3devel at elegosoft.com; antony.hosking at gmail.com
Subject: Re: [M3devel] C backend -- mode or call quake?
Why not treat it like the current gcc-based approach? The builder generates C and quake invokes the C compiler. Just like for gcc: the builder generates .mc and quake invokes m3cgc1. I will want much the same for LLVM. The builder will generate LLVM IR binaries and the LLVM tools will do the rest (invoked from quake). This makes it relatively easy to do cross builds from quake.
On Oct 12, 2012, at 12:50 PM, Jay K <jay.krell at cornell.edu> wrote:Clarification: it is "integrated" either way -- no production of .mc files.Just that cm3/builder would know that "IntegratedC" produce a .c file (or perhaps is writing to a pipe) and to then run the C compiler. Vs. pushing that into the backend itself and leaving cm3/builder with "IntegratedObject" that it already knows how to deal with. Either way cm3/builder has to change.
Currently I'm going through config-only changes.
- Jay
CC: m3devel at elegosoft.com
From: antony.hosking at gmail.com
Subject: Re: [M3devel] C backend -- mode or call quake?
Date: Fri, 12 Oct 2012 09:12:53 -0400
To: jay.krell at cornell.edu
I vote for integrated.
Sent from my iPhone
On Oct 12, 2012, at 0:43, Jay K <jay.krell at cornell.edu> wrote:
ok..so..I think time to make this decision and implement it.
- add a "mode" for C and deal with it in Builder.m3 I implemented and tested that and presented the diff a few weeks ago It is reasonable, simple, works..but it isn't strictly needed.
or
- use IntegratedObject and have the C backend call the C compiler "itself" (via theexisting quake/config files)I can go ahead and implement that.
Either way, cm3 likely must know about the C backend.It at least has to "new" it, and maybe pass down function pointers for runningthe C compiler -- or maybe M3C can get the pointers itself.
Or I can put this off a bit longer and improve the generated C...Using "integrated" saves us from writing and reading back the .mc files.More efficient.
- Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20121013/e45df129/attachment-0002.html>
More information about the M3devel
mailing list