Extracting native code from C
chase at world.std.com
Wed Mar 13 18:48:11 UTC 2002
Perhaps I have had my nose up the wrong end of a compiler
for far too long, but none of this stuff is much in the way
of rocket science. The most annoying part is tracking down
the different platform conventions for page protections
(are you allowed to execute pages you can write, e.g.) and
cache flushing. You've got to be sure you've got that right;
there's nothing worse than code that "mostly" works.
PowerPC, at least in some cases, has a peculiar
idea of what a function pointer looks like. Otherwise,
well, you just do what needs to be done. You might
define some tree-structured IL for your "code", and then
just set a pattern-matching code generator loose on it.
Biggest problem I see is that you can't use the "small"
forms of branches for forward branches in a naive system
(assuming you are targeting Pentium -- Risc architectures,
this is not usually a problem).
Umm -- except, IA64 might be a bit more of a crock for this
approach than most other architectures.
If you have ambitions to do greater amounts of optimization,
life gets more complex. My default answer is usually "SSA
form"; that might not be right for Squeak.
I don't have tons of time to talk about doing this stuff
(normally, it is what I get paid to do, after all) but
perhaps I can help a little.
More information about the Squeak-dev