<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Code_generation_%28compiler%29</id>
	<title>Code generation (compiler) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Code_generation_%28compiler%29"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Code_generation_(compiler)&amp;action=history"/>
	<updated>2026-05-12T13:20:04Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Code_generation_(compiler)&amp;diff=3444826&amp;oldid=prev</id>
		<title>imported&gt;PriyathamKat: Fixed a grammatical error.</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Code_generation_(compiler)&amp;diff=3444826&amp;oldid=prev"/>
		<updated>2025-10-11T13:26:56Z</updated>

		<summary type="html">&lt;p&gt;Fixed a grammatical error.&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Previous revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:26, 11 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l4&quot;&gt;Line 4:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 4:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{distinguish|text = Code generation in the context of [[Vibe coding]]}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{distinguish|text = Code generation in the context of [[Vibe coding]]}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In [[computing]], &#039;&#039;&#039;code generation&#039;&#039;&#039; is part of the process chain of a [[compiler]], in which an [[intermediate representation]] of [[source code]] is converted into a form (e.g., [[machine code]]) that &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;can be readily executed by &lt;/del&gt;the target system.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In [[computing]], &#039;&#039;&#039;code generation&#039;&#039;&#039; is part of the process chain of a [[compiler]], in which an [[intermediate representation]] of [[source code]] is converted into a form (e.g., [[machine code]]) that the target system &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;can readily execute&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Sophisticated compilers typically perform &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[multipass compiler|&lt;/del&gt;multiple passes&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]] &lt;/del&gt;over various intermediate forms. This multi-stage process is used because many [[&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;algorithm&lt;/del&gt;]]&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;s &lt;/del&gt;for [[code optimization]] are easier to apply one at a time, or because the input to one optimization relies on the completed processing performed by another optimization. This organization also facilitates the creation of a single compiler that can target multiple architectures, as only the last of the code generation stages (the &#039;&#039;backend&#039;&#039;) needs to change from target to target. (For more information on compiler design, see [[Compiler]].)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Sophisticated compilers typically perform multiple passes over various intermediate forms. This multi-stage process is used because many [[&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Algorithms for calculating variance|algorithms&lt;/ins&gt;]] for [[code optimization]] are easier to apply one at a time, or because the input to one optimization relies on the completed processing performed by another optimization. This organization also facilitates the creation of a single compiler that can target multiple architectures, as only the last of the code generation stages (the &#039;&#039;backend&#039;&#039;) needs to change from target to target. (For more information on compiler design, see [[Compiler]].)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The input to the code generator typically consists of a [[parse tree]] or an [[abstract syntax tree]].&amp;lt;ref name=&quot;MuchnickAssociates1997&quot;&amp;gt;{{cite book|author1=Steven Muchnick|author2=Muchnick and Associates|title=Advanced Compiler Design Implementation|url=https://archive.org/details/advancedcompiler00much|url-access=registration|quote=code generation.|date=15 August 1997|publisher=Morgan Kaufmann|isbn=978-1-55860-320-2}}&amp;lt;/ref&amp;gt; The tree is converted into a linear sequence of instructions, usually in an [[intermediate language]] such as [[three-address code]]. Further stages of compilation may or may not be referred to as &quot;code generation&quot;, depending on whether they involve a significant change in the representation of the program. (For example, a [[peephole optimization]] pass would not likely be called &quot;code generation&quot;, although a code generator might incorporate a peephole optimization pass.)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The input to the code generator typically consists of a [[parse tree]] or an [[&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Abstract syntax tree interpreter|&lt;/ins&gt;abstract syntax tree]].&amp;lt;ref name=&quot;MuchnickAssociates1997&quot;&amp;gt;{{cite book|author1=Steven Muchnick|author2=Muchnick and Associates|title=Advanced Compiler Design Implementation|url=https://archive.org/details/advancedcompiler00much|url-access=registration|quote=code generation.|date=15 August 1997|publisher=Morgan Kaufmann|isbn=978-1-55860-320-2}}&amp;lt;/ref&amp;gt; The tree is converted into a linear sequence of instructions, usually in an [[intermediate language]] such as [[three-address code]]. Further stages of compilation may or may not be referred to as &quot;code generation&quot;, depending on whether they involve a significant change in the representation of the program. (For example, a [[peephole optimization]] pass would not likely be called &quot;code generation&quot;, although a code generator might incorporate a peephole optimization pass.)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Major tasks==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Major tasks==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In addition to &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;the basic conversion from &lt;/del&gt;an intermediate representation into a linear sequence of machine instructions, a typical code generator tries to optimize the generated code &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;in some way&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In addition to &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;converting &lt;/ins&gt;an intermediate representation into a linear sequence of machine instructions, a typical code generator tries to optimize the generated code.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Tasks which are typically part of a sophisticated compiler&amp;#039;s &amp;quot;code generation&amp;quot; phase include:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Tasks which are typically part of a sophisticated compiler&amp;#039;s &amp;quot;code generation&amp;quot; phase include:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Instruction selection]]: which instructions to use.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Instruction selection]]: which instructions to use.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Instruction scheduling]]: in which order to put those instructions. Scheduling is a speed optimization that can &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;have a critical effect on &lt;/del&gt;[[instruction pipeline|pipeline]]d machines.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Instruction scheduling]]: in which order to put those instructions. Scheduling is a speed optimization that can &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;critically affect &lt;/ins&gt;[[instruction pipeline|pipeline]]d machines.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Register allocation]]: the allocation of [[Variable (programming)|variables]] to [[processor register]]s&amp;lt;ref name=ASU&amp;gt;{{Cite book|title=Compilers: Principles, Techniques, and Tools|last=Aho|first=Alfred V. |author2=Ravi Sethi |author3=Jeffrey D. Ullman|year=1987|publisher=Addison-Wesley|isbn=0-201-10088-6|page=15}}&amp;lt;!--|access-date=June 15, 2012--&amp;gt;&amp;lt;/ref&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Register allocation]]: the allocation of [[Variable (programming)|variables]] to [[processor register]]s&amp;lt;ref name=ASU&amp;gt;{{Cite book|title=Compilers: Principles, Techniques, and Tools|last=Aho|first=Alfred V. |author2=Ravi Sethi |author3=Jeffrey D. Ullman|year=1987|publisher=Addison-Wesley|isbn=0-201-10088-6|page=15}}&amp;lt;!--|access-date=June 15, 2012--&amp;gt;&amp;lt;/ref&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Debugging data format|Debug data]] generation if required so the code can be [[Debugging|debugged]].&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Debugging data format|Debug data]] generation if required&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, &lt;/ins&gt;so &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;that &lt;/ins&gt;the code can be [[Debugging|debugged]].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Instruction selection is typically carried out by doing a [[recursion|recursive]] [[postorder traversal]] on the abstract syntax tree, matching particular tree configurations against templates; for example, the tree &amp;lt;code&amp;gt;W := ADD(X,MUL(Y,Z))&amp;lt;/code&amp;gt; might be transformed into a linear sequence of instructions by recursively generating the sequences for &amp;lt;code&amp;gt;t1 := X&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;t2 := MUL(Y,Z)&amp;lt;/code&amp;gt;, and then emitting the instruction &amp;lt;code&amp;gt;ADD W, t1, t2&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Instruction selection is typically carried out by doing a [[recursion|recursive]] [[postorder traversal]] on the abstract syntax tree, matching particular tree configurations against templates; for example, the tree &amp;lt;code&amp;gt;W := ADD(X,MUL(Y,Z))&amp;lt;/code&amp;gt; might be transformed into a linear sequence of instructions by recursively generating the sequences for &amp;lt;code&amp;gt;t1 := X&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;t2 := MUL(Y,Z)&amp;lt;/code&amp;gt;, and then emitting the instruction &amp;lt;code&amp;gt;ADD W, t1, t2&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In a compiler that uses an intermediate language, there may be two instruction selection stages&amp;amp;mdash;one to convert the parse tree into intermediate code, and a second phase much later to convert the intermediate code into instructions from the [[instruction set]] of the target machine. This second phase does not require a tree traversal; it can be done linearly, and typically involves a simple replacement of intermediate-language operations with their corresponding [[opcode]]s. However, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;if &lt;/del&gt;the compiler is &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;actually &lt;/del&gt;a [[Transcompiler|language translator]] (for example, one that converts [[Java (programming language)|Java]] to [[C++]]), &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;then &lt;/del&gt;the second code-generation phase may involve &#039;&#039;building&#039;&#039; a tree from the linear intermediate code.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In a compiler that uses an intermediate language, there may be two instruction selection stages&amp;amp;mdash;one to convert the parse tree into intermediate code, and a second phase&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, &lt;/ins&gt;much later&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, &lt;/ins&gt;to convert the intermediate code into instructions from the [[instruction set]] of the target machine. This second phase does not require a tree traversal; it can be done linearly, and typically involves a simple replacement of intermediate-language operations with their corresponding [[opcode]]s. However, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;suppose &lt;/ins&gt;the compiler is a [[Transcompiler|language translator]] (for example, one that converts [[Java (programming language)|Java]] to [[C++]])&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;. In that case&lt;/ins&gt;, the second code-generation phase may involve &#039;&#039;building&#039;&#039; a tree from the linear intermediate code.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Runtime code generation==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Runtime code generation==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;When code generation occurs at [[Run time (program lifecycle phase)|runtime]], as in [[just-in-time compilation]] (JIT), &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;it is important that &lt;/del&gt;the entire process be [[Algorithmic efficiency|efficient]] with respect to space and time. For example, when [[regular expression]]s are interpreted and used to generate code at runtime, a non-deterministic [[finite-state machine]] is often generated instead of a deterministic one&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, &lt;/del&gt;because &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;usually &lt;/del&gt;the former can be created more quickly and occupies less memory space than the latter. Despite &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;its &lt;/del&gt;generally generating less efficient code, JIT code generation can take advantage of [[Profiling (computer programming)|profiling]] information that is available only at runtime.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;When code generation occurs at [[Run time (program lifecycle phase)|runtime]], as in [[just-in-time compilation]] (JIT), the entire process &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;must &lt;/ins&gt;be [[Algorithmic efficiency|efficient]] with respect to space and time. For example, when [[regular expression]]s are interpreted and used to generate code at runtime, a non-deterministic [[finite-state machine]] is often generated instead of a deterministic one because the former can &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;usually &lt;/ins&gt;be created more quickly and occupies less memory space than the latter. Despite generally generating less efficient code, JIT code generation can take advantage of [[Profiling (computer programming)|profiling]] information that is available only at runtime.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Related concepts==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Related concepts==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The fundamental task of taking input in one language and producing output in a non-trivially different language can be understood in terms of the core [[Transformational grammar|transformational]] operations of [[formal language theory]]. Consequently, some techniques &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;that were originally &lt;/del&gt;developed for use in compilers have come to be employed in other ways &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;as well&lt;/del&gt;. For example, [[YACC]] (Yet Another [[compiler-compiler|Compiler-Compiler]]) takes input in [[Backus–Naur form]] and converts it to a parser in [[C (programming language)|C]]. Though it was &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;originally &lt;/del&gt;created for automatic generation of a parser for a compiler, yacc is also often used to automate writing code that needs to be modified each time specifications are changed.&amp;lt;ref&amp;gt;[http://www.artima.com/weblogs/viewpost.jsp?thread=152273 Code Generation: The Real Lesson of Rails]. Artima.com (2006-03-16). Retrieved on 2013-08-10.&amp;lt;/ref&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The fundamental task of taking input in one language and producing output in a non-trivially different language can be understood in terms of the core [[Transformational grammar|transformational]] operations of [[formal language theory]]. Consequently, some techniques &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;initially &lt;/ins&gt;developed for use in compilers have come to be employed in other ways. For example, [[YACC]] (Yet Another [[compiler-compiler|Compiler-Compiler]]) takes input in [[Backus–Naur form]] and converts it to a parser in [[C (programming language)|C]]. Though it was &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;initially &lt;/ins&gt;created for automatic generation of a parser for a compiler, yacc is also often used to automate writing code that needs to be modified each time specifications are changed.&amp;lt;ref&amp;gt;[http://www.artima.com/weblogs/viewpost.jsp?thread=152273 Code Generation: The Real Lesson of Rails]. Artima.com (2006-03-16). Retrieved on 2013-08-10.&amp;lt;/ref&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Many [[integrated development environment]]s (IDEs) support some form of automatic [[source-code generation]], often using algorithms in common with compiler code generators, although commonly less complicated. (See also: [[Program transformation]]&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, &lt;/del&gt;[[Data transformation]].)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Many [[integrated development environment]]s (IDEs) support some form of automatic [[source-code generation]], often using algorithms in common with compiler code generators, although commonly less complicated. (See also: [[Program transformation]] &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;and &lt;/ins&gt;[[Data transformation]].)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Reflection===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Reflection===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In general, a syntax and semantic analyzer tries to retrieve the structure &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;of the program &lt;/del&gt;from the source code, while a code generator uses this structural information (e.g., [[data type]]s) to produce code. In other words, the former &#039;&#039;adds&#039;&#039; information while the latter &#039;&#039;loses&#039;&#039; some &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;of the information&lt;/del&gt;. One consequence of this information loss is that [[Reflection (computer science)|reflection]] becomes difficult or even impossible. To counter this problem, code generators often embed syntactic and semantic information &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;in addition to &lt;/del&gt;the code necessary for execution.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In general, a syntax and semantic analyzer tries to retrieve the &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;program&#039;s &lt;/ins&gt;structure from the source code, while a code generator uses this structural information (e.g., [[data type]]s) to produce code. In other words, the former &#039;&#039;adds&#039;&#039; information while the latter &#039;&#039;loses&#039;&#039; some. One consequence of this information loss is that [[Reflection (computer science)|reflection]] becomes difficult or even impossible. To counter this problem, code generators often embed syntactic and semantic information &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;and &lt;/ins&gt;the code necessary for execution.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==See also==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==See also==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>imported&gt;PriyathamKat</name></author>
	</entry>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Code_generation_(compiler)&amp;diff=1686723&amp;oldid=prev</id>
		<title>2001:4C4C:121A:F500:35BB:CF4D:B475:6CD0: Undid revision 1295907421 by 49.237.13.104 (talk)</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Code_generation_(compiler)&amp;diff=1686723&amp;oldid=prev"/>
		<updated>2025-06-24T08:13:40Z</updated>

		<summary type="html">&lt;p&gt;Undid revision &lt;a href=&quot;/wiki143/index.php?title=Special:Diff/1295907421&quot; title=&quot;Special:Diff/1295907421&quot;&gt;1295907421&lt;/a&gt; by &lt;a href=&quot;/wiki143/index.php?title=Special:Contributions/49.237.13.104&quot; title=&quot;Special:Contributions/49.237.13.104&quot;&gt;49.237.13.104&lt;/a&gt; (&lt;a href=&quot;/wiki143/index.php?title=User_talk:49.237.13.104&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;User talk:49.237.13.104 (page does not exist)&quot;&gt;talk&lt;/a&gt;)&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Previous revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:13, 24 June 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l4&quot;&gt;Line 4:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 4:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{distinguish|text = Code generation in the context of [[Vibe coding]]}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{distinguish|text = Code generation in the context of [[Vibe coding]]}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[tuo.maxnam]] &lt;/del&gt;[[computing]], &#039;&#039;&#039;code generation&#039;&#039;&#039; is part of the process chain of a [[compiler]], in which an [[intermediate representation]] of [[source code]] is converted into a form (e.g., [[machine code]]) that can be readily executed by the target system.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;In &lt;/ins&gt;[[computing]], &#039;&#039;&#039;code generation&#039;&#039;&#039; is part of the process chain of a [[compiler]], in which an [[intermediate representation]] of [[source code]] is converted into a form (e.g., [[machine code]]) that can be readily executed by the target system.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Sophisticated compilers typically perform [[multipass compiler|multiple passes]] over various intermediate forms. This multi-stage process is used because many [[algorithm]]s for [[code optimization]] are easier to apply one at a time, or because the input to one optimization relies on the completed processing performed by another optimization. This organization also facilitates the creation of a single compiler that can target multiple architectures, as only the last of the code generation stages (the &amp;#039;&amp;#039;backend&amp;#039;&amp;#039;) needs to change from target to target. (For more information on compiler design, see [[Compiler]].)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Sophisticated compilers typically perform [[multipass compiler|multiple passes]] over various intermediate forms. This multi-stage process is used because many [[algorithm]]s for [[code optimization]] are easier to apply one at a time, or because the input to one optimization relies on the completed processing performed by another optimization. This organization also facilitates the creation of a single compiler that can target multiple architectures, as only the last of the code generation stages (the &amp;#039;&amp;#039;backend&amp;#039;&amp;#039;) needs to change from target to target. (For more information on compiler design, see [[Compiler]].)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>2001:4C4C:121A:F500:35BB:CF4D:B475:6CD0</name></author>
	</entry>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Code_generation_(compiler)&amp;diff=673334&amp;oldid=prev</id>
		<title>49.237.13.104: www.http://google.mobile.com</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Code_generation_(compiler)&amp;diff=673334&amp;oldid=prev"/>
		<updated>2025-06-16T15:45:02Z</updated>

		<summary type="html">&lt;p&gt;www.http://google.mobile.com&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Previous revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:45, 16 June 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l4&quot;&gt;Line 4:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 4:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{distinguish|text = Code generation in the context of [[Vibe coding]]}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{distinguish|text = Code generation in the context of [[Vibe coding]]}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;In &lt;/del&gt;[[computing]], &#039;&#039;&#039;code generation&#039;&#039;&#039; is part of the process chain of a [[compiler]], in which an [[intermediate representation]] of [[source code]] is converted into a form (e.g., [[machine code]]) that can be readily executed by the target system.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[tuo.maxnam]] &lt;/ins&gt;[[computing]], &#039;&#039;&#039;code generation&#039;&#039;&#039; is part of the process chain of a [[compiler]], in which an [[intermediate representation]] of [[source code]] is converted into a form (e.g., [[machine code]]) that can be readily executed by the target system.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Sophisticated compilers typically perform [[multipass compiler|multiple passes]] over various intermediate forms. This multi-stage process is used because many [[algorithm]]s for [[code optimization]] are easier to apply one at a time, or because the input to one optimization relies on the completed processing performed by another optimization. This organization also facilitates the creation of a single compiler that can target multiple architectures, as only the last of the code generation stages (the &amp;#039;&amp;#039;backend&amp;#039;&amp;#039;) needs to change from target to target. (For more information on compiler design, see [[Compiler]].)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Sophisticated compilers typically perform [[multipass compiler|multiple passes]] over various intermediate forms. This multi-stage process is used because many [[algorithm]]s for [[code optimization]] are easier to apply one at a time, or because the input to one optimization relies on the completed processing performed by another optimization. This organization also facilitates the creation of a single compiler that can target multiple architectures, as only the last of the code generation stages (the &amp;#039;&amp;#039;backend&amp;#039;&amp;#039;) needs to change from target to target. (For more information on compiler design, see [[Compiler]].)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>49.237.13.104</name></author>
	</entry>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Code_generation_(compiler)&amp;diff=133849&amp;oldid=prev</id>
		<title>37.123.180.70 at 19:29, 25 April 2025</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Code_generation_(compiler)&amp;diff=133849&amp;oldid=prev"/>
		<updated>2025-04-25T19:29:59Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Converting computer code into a machine readable form}}&lt;br /&gt;
{{Refimprove|Code generation intro|date=November 2006}}&lt;br /&gt;
&lt;br /&gt;
{{distinguish|text = Code generation in the context of [[Vibe coding]]}}&lt;br /&gt;
&lt;br /&gt;
In [[computing]], &amp;#039;&amp;#039;&amp;#039;code generation&amp;#039;&amp;#039;&amp;#039; is part of the process chain of a [[compiler]], in which an [[intermediate representation]] of [[source code]] is converted into a form (e.g., [[machine code]]) that can be readily executed by the target system.&lt;br /&gt;
&lt;br /&gt;
Sophisticated compilers typically perform [[multipass compiler|multiple passes]] over various intermediate forms. This multi-stage process is used because many [[algorithm]]s for [[code optimization]] are easier to apply one at a time, or because the input to one optimization relies on the completed processing performed by another optimization. This organization also facilitates the creation of a single compiler that can target multiple architectures, as only the last of the code generation stages (the &amp;#039;&amp;#039;backend&amp;#039;&amp;#039;) needs to change from target to target. (For more information on compiler design, see [[Compiler]].)&lt;br /&gt;
&lt;br /&gt;
The input to the code generator typically consists of a [[parse tree]] or an [[abstract syntax tree]].&amp;lt;ref name=&amp;quot;MuchnickAssociates1997&amp;quot;&amp;gt;{{cite book|author1=Steven Muchnick|author2=Muchnick and Associates|title=Advanced Compiler Design Implementation|url=https://archive.org/details/advancedcompiler00much|url-access=registration|quote=code generation.|date=15 August 1997|publisher=Morgan Kaufmann|isbn=978-1-55860-320-2}}&amp;lt;/ref&amp;gt; The tree is converted into a linear sequence of instructions, usually in an [[intermediate language]] such as [[three-address code]]. Further stages of compilation may or may not be referred to as &amp;quot;code generation&amp;quot;, depending on whether they involve a significant change in the representation of the program. (For example, a [[peephole optimization]] pass would not likely be called &amp;quot;code generation&amp;quot;, although a code generator might incorporate a peephole optimization pass.)&lt;br /&gt;
&lt;br /&gt;
==Major tasks==&lt;br /&gt;
In addition to the basic conversion from an intermediate representation into a linear sequence of machine instructions, a typical code generator tries to optimize the generated code in some way.&lt;br /&gt;
&lt;br /&gt;
Tasks which are typically part of a sophisticated compiler&amp;#039;s &amp;quot;code generation&amp;quot; phase include:&lt;br /&gt;
* [[Instruction selection]]: which instructions to use.&lt;br /&gt;
* [[Instruction scheduling]]: in which order to put those instructions. Scheduling is a speed optimization that can have a critical effect on [[instruction pipeline|pipeline]]d machines.&lt;br /&gt;
* [[Register allocation]]: the allocation of [[Variable (programming)|variables]] to [[processor register]]s&amp;lt;ref name=ASU&amp;gt;{{Cite book|title=Compilers: Principles, Techniques, and Tools|last=Aho|first=Alfred V. |author2=Ravi Sethi |author3=Jeffrey D. Ullman|year=1987|publisher=Addison-Wesley|isbn=0-201-10088-6|page=15}}&amp;lt;!--|access-date=June 15, 2012--&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
* [[Debugging data format|Debug data]] generation if required so the code can be [[Debugging|debugged]].&lt;br /&gt;
&lt;br /&gt;
Instruction selection is typically carried out by doing a [[recursion|recursive]] [[postorder traversal]] on the abstract syntax tree, matching particular tree configurations against templates; for example, the tree &amp;lt;code&amp;gt;W := ADD(X,MUL(Y,Z))&amp;lt;/code&amp;gt; might be transformed into a linear sequence of instructions by recursively generating the sequences for &amp;lt;code&amp;gt;t1 := X&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;t2 := MUL(Y,Z)&amp;lt;/code&amp;gt;, and then emitting the instruction &amp;lt;code&amp;gt;ADD W, t1, t2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In a compiler that uses an intermediate language, there may be two instruction selection stages&amp;amp;mdash;one to convert the parse tree into intermediate code, and a second phase much later to convert the intermediate code into instructions from the [[instruction set]] of the target machine. This second phase does not require a tree traversal; it can be done linearly, and typically involves a simple replacement of intermediate-language operations with their corresponding [[opcode]]s. However, if the compiler is actually a [[Transcompiler|language translator]] (for example, one that converts [[Java (programming language)|Java]] to [[C++]]), then the second code-generation phase may involve &amp;#039;&amp;#039;building&amp;#039;&amp;#039; a tree from the linear intermediate code.&lt;br /&gt;
&lt;br /&gt;
==Runtime code generation==&lt;br /&gt;
When code generation occurs at [[Run time (program lifecycle phase)|runtime]], as in [[just-in-time compilation]] (JIT), it is important that the entire process be [[Algorithmic efficiency|efficient]] with respect to space and time. For example, when [[regular expression]]s are interpreted and used to generate code at runtime, a non-deterministic [[finite-state machine]] is often generated instead of a deterministic one, because usually the former can be created more quickly and occupies less memory space than the latter. Despite its generally generating less efficient code, JIT code generation can take advantage of [[Profiling (computer programming)|profiling]] information that is available only at runtime.&lt;br /&gt;
&lt;br /&gt;
==Related concepts==&lt;br /&gt;
The fundamental task of taking input in one language and producing output in a non-trivially different language can be understood in terms of the core [[Transformational grammar|transformational]] operations of [[formal language theory]]. Consequently, some techniques that were originally developed for use in compilers have come to be employed in other ways as well. For example, [[YACC]] (Yet Another [[compiler-compiler|Compiler-Compiler]]) takes input in [[Backus–Naur form]] and converts it to a parser in [[C (programming language)|C]]. Though it was originally created for automatic generation of a parser for a compiler, yacc is also often used to automate writing code that needs to be modified each time specifications are changed.&amp;lt;ref&amp;gt;[http://www.artima.com/weblogs/viewpost.jsp?thread=152273 Code Generation: The Real Lesson of Rails]. Artima.com (2006-03-16). Retrieved on 2013-08-10.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many [[integrated development environment]]s (IDEs) support some form of automatic [[source-code generation]], often using algorithms in common with compiler code generators, although commonly less complicated. (See also: [[Program transformation]], [[Data transformation]].)&lt;br /&gt;
&lt;br /&gt;
===Reflection===&lt;br /&gt;
In general, a syntax and semantic analyzer tries to retrieve the structure of the program from the source code, while a code generator uses this structural information (e.g., [[data type]]s) to produce code. In other words, the former &amp;#039;&amp;#039;adds&amp;#039;&amp;#039; information while the latter &amp;#039;&amp;#039;loses&amp;#039;&amp;#039; some of the information. One consequence of this information loss is that [[Reflection (computer science)|reflection]] becomes difficult or even impossible. To counter this problem, code generators often embed syntactic and semantic information in addition to the code necessary for execution.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Automatic programming]]&lt;br /&gt;
* [[Comparison of code generation tools]]&lt;br /&gt;
* [[Source-to-source compiler|Source-to-source compilation]]: automatic translation of a computer program from one programming language to another&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
&lt;br /&gt;
{{Authority control}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Machine code]]&lt;br /&gt;
[[Category:Compiler construction]]&lt;/div&gt;</summary>
		<author><name>37.123.180.70</name></author>
	</entry>
</feed>