Code Generation

What Does Code Generation Mean?

Code generation is a mechanism where a compiler takes the source code as an input and converts it into machine code. This machine code is actually executed by the system. Code generation is generally considered the last phase of compilation, although there are multiple intermediate steps performed before the final executable is produced. These intermediate steps are used to perform optimization and other relevant processes.

Advertisements

Techopedia Explains Code Generation

The code generation process is performed by a component known as a code generator, part of the compiler program. The original source code of any program passes through multiple phases before the final executable is generated. This final executable code is actually the machine code, which computer systems can execute readily.

In the intermediate phases of compilation, code optimization rules are applied one at a time. Sometimes these optimization processes are dependent on each other, so they are applied one after another based on the dependency hierarchy. After passing multiple phases, a parse tree or an abstract syntax tree is generated and that is the input to the code generator. At this point, the code generator converts it into linear sequential instructions. After this stage, there may be some more steps depending upon the compiler. The final optimized code is the machine code for execution and output generation.

Advertisements

Related Terms

Latest Software Development Terms

Related Reading

Margaret Rouse

Margaret Rouse is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical, business audience. Over the past twenty years her explanations have appeared on TechTarget websites and she's been cited as an authority in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine and Discovery Magazine.Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages. If you have a suggestion for a new definition or how to improve a technical explanation, please email Margaret or contact her…