Code Generation

The term for the last phase of a compiler that emits code in the target language.

Once the operating system has read an object and understood what to do with it, it has to produce the "code" that the hardware will run to evaluate the object. We at the TUNES project are convinced that code generation should be based on meta-programmable partial evaluation.

The simplest solutions for code generation are to write an interpreter that directly evaluates the internal encoding of objects, or an interpreter for an intermediate machine that is a compromise between the low-level hardware computing model and the high-level computing model. These solutions should be used as the default one in TUNES. But as some objects get used frequently (or are intended to be used frequently), the partial evaluator triggers and tries to optimize these objects, spending no more time optimizing than is expected to be saved by the optimizations.

The user, as always, can give more or less explicit and thorough hints about where to focus code generation efforts, and how to try to generate good code; they will associate code to be optimized and tactics to optimize code with, or give hints about such association for the system to look for automatically. Such tactics could look like:

Such tactics would prove much easier to use, much more portable, much surer as for efficiency (if tactic fails to yield better code, it can be semi-automatically ignored) and much faster to tweak (when a proper library is available) than any low-level coding, while bringing the same expressive power as this low-level coding; more importantly, they wouldn't tie code to old hardware or software hacks, and could be managed dynamically.

See also Run-Time Code Generation.

This page is linked from: Decentralized   Multipop   Optimizer   PoLITe project   Preemption and Cooperation   Program Transformation   Run-Time Code Generation   Synthesis   Synthetix