mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-03 09:21:02 +00:00
update this a little bit to talk about the dag combiner and remove inaccuracies.
This still doesn't talk about autogen much git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23757 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
750dbd5950
commit
e35d3bb84e
@ -15,7 +15,8 @@
|
|||||||
<li><a href="#introduction">Introduction</a>
|
<li><a href="#introduction">Introduction</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#required">Required components in the code generator</a></li>
|
<li><a href="#required">Required components in the code generator</a></li>
|
||||||
<li><a href="#high-level-design">The high-level design of the code generator</a></li>
|
<li><a href="#high-level-design">The high-level design of the code
|
||||||
|
generator</a></li>
|
||||||
<li><a href="#tablegen">Using TableGen for target description</a></li>
|
<li><a href="#tablegen">Using TableGen for target description</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
@ -46,8 +47,10 @@
|
|||||||
Construction</a></li>
|
Construction</a></li>
|
||||||
<li><a href="#selectiondag_legalize">SelectionDAG Legalize Phase</a></li>
|
<li><a href="#selectiondag_legalize">SelectionDAG Legalize Phase</a></li>
|
||||||
<li><a href="#selectiondag_optimize">SelectionDAG Optimization
|
<li><a href="#selectiondag_optimize">SelectionDAG Optimization
|
||||||
Phase</a></li>
|
Phase: the DAG Combiner</a></li>
|
||||||
<li><a href="#selectiondag_select">SelectionDAG Select Phase</a></li>
|
<li><a href="#selectiondag_select">SelectionDAG Select Phase</a></li>
|
||||||
|
<li><a href="#selectiondag_sched">SelectionDAG Scheduling and Emission
|
||||||
|
Phase</a></li>
|
||||||
<li><a href="#selectiondag_future">Future directions for the
|
<li><a href="#selectiondag_future">Future directions for the
|
||||||
SelectionDAG</a></li>
|
SelectionDAG</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
@ -631,23 +634,15 @@ explains how they work and some of the rationale behind their design.</p>
|
|||||||
Instruction Selection is the process of translating LLVM code presented to the
|
Instruction Selection is the process of translating LLVM code presented to the
|
||||||
code generator into target-specific machine instructions. There are several
|
code generator into target-specific machine instructions. There are several
|
||||||
well-known ways to do this in the literature. In LLVM there are two main forms:
|
well-known ways to do this in the literature. In LLVM there are two main forms:
|
||||||
the old-style 'simple' instruction selector (which effectively peephole selects
|
the SelectionDAG based instruction selector framework and an old-style 'simple'
|
||||||
each LLVM instruction into a series of machine instructions), and the new
|
instruction selector (which effectively peephole selects each LLVM instruction
|
||||||
SelectionDAG based instruction selector.
|
into a series of machine instructions). We recommend that all targets use the
|
||||||
|
SelectionDAG infrastructure.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>The 'simple' instruction selectors are tedious to write, require a lot of
|
<p>Portions of the DAG instruction selector are generated from the target
|
||||||
boiler plate code, and are difficult to get correct. Additionally, any
|
description files (<tt>*.td</tt>) files. Eventually, we aim for the entire
|
||||||
optimizations written for a simple instruction selector cannot be used by other
|
instruction selector to be generated from these <tt>.td</tt> files.</p>
|
||||||
targets. For this reason, LLVM is moving to a new SelectionDAG based
|
|
||||||
instruction selector, which is described in this section. If you are starting a
|
|
||||||
new port, we recommend that you write the instruction selector using the
|
|
||||||
SelectionDAG infrastructure.</p>
|
|
||||||
|
|
||||||
<p>In time, most of the target-specific code for instruction selection will be
|
|
||||||
auto-generated from the target description (<tt>*.td</tt>) files. For now,
|
|
||||||
however, the <a href="#selectiondag_select">Select Phase</a> must still be
|
|
||||||
written by hand.</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- _______________________________________________________________________ -->
|
<!-- _______________________________________________________________________ -->
|
||||||
@ -744,8 +739,12 @@ SelectionDAG-based instruction selection consists of the following steps:
|
|||||||
eliminate inefficiencies introduced by legalization.</li>
|
eliminate inefficiencies introduced by legalization.</li>
|
||||||
<li><a href="#selectiondag_select">Select instructions from DAG</a> - Finally,
|
<li><a href="#selectiondag_select">Select instructions from DAG</a> - Finally,
|
||||||
the target instruction selector matches the DAG operations to target
|
the target instruction selector matches the DAG operations to target
|
||||||
instructions, emitting them and building the MachineFunction being
|
instructions. This process translates the target-independent input DAG into
|
||||||
compiled.</li>
|
another DAG of target instructions.</li>
|
||||||
|
<li><a href="#selectiondag_sched">SelectionDAG Scheduling and Emission</a>
|
||||||
|
- The last phase assigns a linear order to the instructions in the
|
||||||
|
target-instruction DAG and emits them into the MachineFunction being
|
||||||
|
compiled. This step uses traditional prepass scheduling techniques.</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<p>After all of these steps are complete, the SelectionDAG is destroyed and the
|
<p>After all of these steps are complete, the SelectionDAG is destroyed and the
|
||||||
@ -822,7 +821,8 @@ a DAG.
|
|||||||
|
|
||||||
<!-- _______________________________________________________________________ -->
|
<!-- _______________________________________________________________________ -->
|
||||||
<div class="doc_subsubsection">
|
<div class="doc_subsubsection">
|
||||||
<a name="selectiondag_optimize">SelectionDAG Optimization Phase</a>
|
<a name="selectiondag_optimize">SelectionDAG Optimization Phase: the DAG
|
||||||
|
Combiner</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="doc_text">
|
<div class="doc_text">
|
||||||
@ -838,8 +838,9 @@ special cases.
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
One important class of optimizations that this pass will do in the future is
|
One important class of optimizations performed is optimizing inserted sign and
|
||||||
optimizing inserted sign and zero extension instructions. Here are some good
|
zero extension instructions. We currently use ad-hoc techniques, but could move
|
||||||
|
to more rigorous techniques in the future. Here are some good
|
||||||
papers on the subject:</p>
|
papers on the subject:</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -875,6 +876,23 @@ want to make the Select phase as simple and mechanical as possible.</p>
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- _______________________________________________________________________ -->
|
||||||
|
<div class="doc_subsubsection">
|
||||||
|
<a name="selectiondag_sched">SelectionDAG Scheduling and Emission Phase</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="doc_text">
|
||||||
|
|
||||||
|
<p>The scheduling phase takes the DAG of target instructions from the selection
|
||||||
|
phase and assigns an order. The scheduler can pick an order depending on
|
||||||
|
various constraints of the machines (i.e. order for minimal register pressure or
|
||||||
|
try to cover instruction latencies). Once an order is established, the DAG is
|
||||||
|
converted to a list of <a href="#machineinstr">MachineInstr</a>s and the
|
||||||
|
Selection DAG is destroyed.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- _______________________________________________________________________ -->
|
<!-- _______________________________________________________________________ -->
|
||||||
<div class="doc_subsubsection">
|
<div class="doc_subsubsection">
|
||||||
<a name="selectiondag_future">Future directions for the SelectionDAG</a>
|
<a name="selectiondag_future">Future directions for the SelectionDAG</a>
|
||||||
@ -883,12 +901,8 @@ want to make the Select phase as simple and mechanical as possible.</p>
|
|||||||
<div class="doc_text">
|
<div class="doc_text">
|
||||||
|
|
||||||
<ol>
|
<ol>
|
||||||
<li>Optional whole-function selection.</li>
|
<li>Optional function-at-a-time selection.</li>
|
||||||
<li>Select is a graph translation phase.</li>
|
<li>Auto-generate entire selector from .td file.</li>
|
||||||
<li>Place the machine instructions resulting from Select according to register
|
|
||||||
pressure or a schedule.</li>
|
|
||||||
<li>DAG Scheduling.</li>
|
|
||||||
<li>Auto-generate the Select phase from the target description (*.td) files.
|
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user