Remove llvm-ld and llvm-stub (which is only used by llvm-ld).
[oota-llvm.git] / docs / CodeGenerator.html
index f42af12720e50a1e3495d15cc23cc13f4edb6aa6..c4b15dfe377e8a4962dd1d24350e9159d9326c42 100644 (file)
@@ -50,6 +50,7 @@
     <li><a href="#machinebasicblock">The <tt>MachineBasicBlock</tt>
                                      class</a></li>
     <li><a href="#machinefunction">The <tt>MachineFunction</tt> class</a></li>
+    <li><a href="#machineinstrbundle"><tt>MachineInstr Bundles</tt></a></li>
     </ul>
   </li>
   <li><a href="#mc">The "MC" Layer</a>
@@ -706,6 +707,21 @@ ret
 
 </div>
 
+<!-- _______________________________________________________________________ -->
+<h4>
+  <a name="callclobber">Call-clobbered registers</a>
+</h4>
+
+<div>
+
+<p>Some machine instructions, like calls, clobber a large number of physical
+   registers.  Rather than adding <code>&lt;def,dead&gt;</code> operands for
+   all of them, it is possible to use an <code>MO_RegisterMask</code> operand
+   instead.  The register mask operand holds a bit mask of preserved registers,
+   and everything else is considered to be clobbered by the instruction.  </p>
+
+</div>
+
 <!-- _______________________________________________________________________ -->
 <h4>
   <a name="ssa">Machine code in SSA form</a>
@@ -761,6 +777,90 @@ ret
 
 </div>
 
+<!-- ======================================================================= -->
+<h3>
+  <a name="machineinstrbundle"><tt>MachineInstr Bundles</tt></a>
+</h3>
+
+<div>
+
+<p>LLVM code generator can model sequences of instructions as MachineInstr
+   bundles. A MI bundle can model a VLIW group / pack which contains an
+   arbitrary number of parallel instructions. It can also be used to model
+   a sequential list of instructions (potentially with data dependencies) that
+   cannot be legally separated (e.g. ARM Thumb2 IT blocks).</p>
+
+<p>Conceptually a MI bundle is a MI with a number of other MIs nested within:
+</p>
+
+<div class="doc_code">
+<pre>
+--------------
+|   Bundle   | ---------
+--------------          \
+       |           ----------------
+       |           |      MI      |
+       |           ----------------
+       |                   |
+       |           ----------------
+       |           |      MI      |
+       |           ----------------
+       |                   |
+       |           ----------------
+       |           |      MI      |
+       |           ----------------
+       |
+--------------
+|   Bundle   | --------
+--------------         \
+       |           ----------------
+       |           |      MI      |
+       |           ----------------
+       |                   |
+       |           ----------------
+       |           |      MI      |
+       |           ----------------
+       |                   |
+       |                  ...
+       |
+--------------
+|   Bundle   | --------
+--------------         \
+       |
+      ...
+</pre>
+</div>
+
+<p> MI bundle support does not change the physical representations of
+    MachineBasicBlock and MachineInstr. All the MIs (including top level and
+    nested ones) are stored as sequential list of MIs. The "bundled" MIs are
+    marked with the 'InsideBundle' flag. A top level MI with the special BUNDLE
+    opcode is used to represent the start of a bundle. It's legal to mix BUNDLE
+    MIs with indiviual MIs that are not inside bundles nor represent bundles.
+</p>
+
+<p> MachineInstr passes should operate on a MI bundle as a single unit. Member
+    methods have been taught to correctly handle bundles and MIs inside bundles.
+    The MachineBasicBlock iterator has been modified to skip over bundled MIs to
+    enforce the bundle-as-a-single-unit concept. An alternative iterator
+    instr_iterator has been added to MachineBasicBlock to allow passes to
+    iterate over all of the MIs in a MachineBasicBlock, including those which
+    are nested inside bundles. The top level BUNDLE instruction must have the
+    correct set of register MachineOperand's that represent the cumulative
+    inputs and outputs of the bundled MIs.</p>
+
+<p> Packing / bundling of MachineInstr's should be done as part of the register
+    allocation super-pass. More specifically, the pass which determines what
+    MIs should be bundled together must be done after code generator exits SSA
+    form (i.e. after two-address pass, PHI elimination, and copy coalescing).
+    Bundles should only be finalized (i.e. adding BUNDLE MIs and input and
+    output register MachineOperands) after virtual registers have been
+    rewritten into physical registers. This requirement eliminates the need to
+    add virtual register operands to BUNDLE instructions which would effectively
+    double the virtual register def and use lists.</p>
+
+</div>
+
 </div>
 
 <!-- *********************************************************************** -->
@@ -1517,9 +1617,9 @@ def : Pat&lt;(i32 imm:$imm),
    range from 1 to 1023. To see how this numbering is defined for a particular
    architecture, you can read the <tt>GenRegisterNames.inc</tt> file for that
    architecture. For instance, by
-   inspecting <tt>lib/Target/X86/X86GenRegisterNames.inc</tt> we see that the
-   32-bit register <tt>EAX</tt> is denoted by 15, and the MMX register
-   <tt>MM0</tt> is mapped to 48.</p>
+   inspecting <tt>lib/Target/X86/X86GenRegisterInfo.inc</tt> we see that the
+   32-bit register <tt>EAX</tt> is denoted by 43, and the MMX register
+   <tt>MM0</tt> is mapped to 65.</p>
 
 <p>Some architectures contain registers that share the same physical location. A
    notable example is the X86 platform. For instance, in the X86 architecture,
@@ -1527,7 +1627,7 @@ def : Pat&lt;(i32 imm:$imm),
    bits. These physical registers are marked as <i>aliased</i> in LLVM. Given a
    particular architecture, you can check which registers are aliased by
    inspecting its <tt>RegisterInfo.td</tt> file. Moreover, the method
-   <tt>TargetRegisterInfo::getAliasSet(p_reg)</tt> returns an array containing
+   <tt>MCRegisterInfo::getAliasSet(p_reg)</tt> returns an array containing
    all the physical registers aliased to the register <tt>p_reg</tt>.</p>
 
 <p>Physical registers, in LLVM, are grouped in <i>Register Classes</i>.
@@ -2408,6 +2508,7 @@ is the key:</p>
   <td><a href="#feat_segstacks">segmented stacks</a></td>
   <td class="no"></td> <!-- ARM -->
   <td class="no"></td> <!-- CellSPU -->
+  <td class="no"></td> <!-- Hexagon -->
   <td class="no"></td> <!-- MBlaze -->
   <td class="no"></td> <!-- MSP430 -->
   <td class="no"></td> <!-- Mips -->