linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Writing compilers, and example.c vs compile-i386.c
@ 2008-06-16 23:04 David Given
  2008-06-16 23:50 ` Mike Frysinger
  2008-06-17  0:49 ` Christopher Li
  0 siblings, 2 replies; 8+ messages in thread
From: David Given @ 2008-06-16 23:04 UTC (permalink / raw)
  To: linux-sparse

[-- Attachment #1: Type: text/plain, Size: 2134 bytes --]

I'm wanting to write a compiler-like tool that's capable of generating
machine-code-like-stuff (don't ask, long story), and as such, have been
looking around for C compiler front ends that will make my life easier.
sparse looks extremely promising.

As such, I've been examining the two sample compilers, example.c and
compile-i386.c. These appear to generate i386-ish machine code, but do
so in entirely different ways. If I've understood them correctly,
example.c enumerates the instructions inside each function's basic
blocks, and uses sparse's pseudo_t support for doing register
allocation; while compile-i386.c enumerates the statements inside each
function, and does it's own register allocation.

Some basic testing with show_statement() and show_insn() reveals that
both approaches seem to yield similar but *different* pseudocode... with
different SSA phi functions. What's the difference between the two, and
do you have any suggestions as to which approach I should look at?

In addition, I'm afraid I'm going to have to use the D word... has
anyone written down anything about how all this stuff works? I'm afraid
it's rather a large mass of code to try and absorb in one go, and any
overview information would help me considerably. For example: if I put
together a noddy program that enumerates basic blocks (the example.c
approach) I see phi functions. Calling unssa() doesn't seem to help.
However, inserting instrumentation into example.c indicates that it
*doesn't* see phi functions (as far as I can tell). There's something
I'm simply not getting here --- does the removal of phis actually happen
inside the register allocator (which seems like the intuitive place for
it), and if so, what does unssa() actually do?

This is all with sparse 0.4.1. Is that current?

-- 
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-06-24 13:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-16 23:04 Writing compilers, and example.c vs compile-i386.c David Given
2008-06-16 23:50 ` Mike Frysinger
2008-06-17  0:49 ` Christopher Li
2008-06-17 23:35   ` David Given
2008-06-18  0:41     ` Christopher Li
2008-06-20 23:46       ` David Given
2008-06-21  1:40         ` Christopher Li
2008-06-24 13:29           ` David Given

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).