Here is how this was meant to work at some point [ since I see all kinds of incorrect things being done ]:
Entry point Code generation ==============================
Pixelshader -------- Baseshader ------- ARB backend Vertexshader ------- ------- GLSL backend
Code should be moving towards the center from both directions. Vertex and pixelshader: Should contain minimum amount of things Baseshader: Should contain anything backend [ and frontend ] independent. I think it's acceptable to put some things that are frontend-dependent in baseshader, as long as they can be written in a generic way, without tons of (if (pshader) do_x else if (vshader) do_y statements).
Pass 0: Tracing: 100% done in baseshader.
Pass 1: Register tracking: 100% done in baseshader.
Pass 2: Backend independent gen code: In baseshader [ this includes the opcode loop, and all "parsing" of the shader asm ]
Pass 2: Backend dependent gen code: In ARB or GLSL files [ ideally should work with pre-processed shader asm, and broken out tokens - a sort of an intermediate representation if you prefer ]