Thanks for link asgard. Looks like I remembered wrong about gcc. At least I can't find any hints that it uses this kind of optimization. But as the article says some compilers do I'm just to lazy to go digging up which ones.
I did take a look at GCC though and what tool optimisations it uses. It still has a standalone preprocessor, and it does do this step but the preprocessor used is integrated. source:
http://gcc.gnu.org/onlinedocs/gnat_ugn_ ... ssing.html
There used to be a GASP program too (GNU assembler preprocessor) but I can't find it on my system. It served basically the same function as CPP did for the C compiler. Looking at the info file for GAS it says it uses an integrated preprocessor, but that you can use CPP if you need to do more fancy stuff.
As for the other steps, there are two tricks I've used in the past to speed up compiling with GCC. The first is to instruct GCC to use a PIPE instead of an intermediate file to send data between the various stages. You can also instruct GCC to use a filesystem based in RAM, it's called tmpfs unless they changed the name.
I suppose it makes sense for gcc not to skip the assembly step. gcc supports a lot of architectures, so their reason for using a separate assembler is to keep GCC portable. it makes more sense for compilers that only support one processor architecture. since code-generation is the last step performed by the compiler it might as well emit binary code directly instead of assembler. m0skit0 said the assembler would have to be integrated, this isn't right. there's would be nothing to assemble (!). a code-generator built this way does the transition from intermediate code to either binary code directly (or to assembly code).
On GCC making a program would go something like:
Program: C compiler
- PreProcess
- Compile: Translate C code to intermediate code (machine independent)
- Compile: Analyze and optimize Intermediate code
- Compile: Code generation, emit assembly code (machine dependent)
Program: Assembler
- Assemble: translate assembly to machine code
Program: Linker
- Linking: Combine machine code snippets into a complete program.
Another compiler suite could do this:
Program: Preprocessor
- Preprocess
Program: C compiler
- Compile: Translate C code to intermediate code (machine independent)
- Compile: Analyze and optimize Intermediate code
- Compile: Code generation, emit assembly code or binary code (machine dependent)
Program: Linker
- Linking: Combine machine code snippets into a complete program.
And this compiler suite could include a standalone assembler too.
"If you have specific questions ... don't hesitate to ask as the more generic the question is the more philosophic the answer will be" - PSPWizard