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:
signature.asc
Description: OpenPGP digital signature