cg is the Onramp code generator. It takes the output of the Onramp Compiler as input and outputs optimized Onramp Assembly.
The intermediate representation used by the code generator depends on the stage.
-
0-asmis written in Onramp Minimal C (omC) and takes a form of Onramp Assembly as input. It is designed to be run on the output ofcci/0andcci/1, the first and second stages of the Onramp compiler. It is similar to a peephole optimizer: it translates the "stack machine" assembly produced by the compilers into something more efficient. -
1-full is written in Onramp Practical C (opC) and takes Onramp Intermediate Representation (IR) as input. It performs register allocation and stack frame layout along with various optimizations. It is designed to be run on the output of
cci/2, the final stage Onramp compiler.