Add a test to ensure that all-ones vectors are materialized with pcmpeqd.
[oota-llvm.git] / docs / CodeGenerator.html
index 5ace87e33407ae9e17eff92fcb4950755a86b957..d0eb1d51050a5833d509d9415792d5819289cfcd 100644 (file)
@@ -2,6 +2,7 @@
                       "http://www.w3.org/TR/html4/strict.dtd">
 <html>
 <head>
+  <meta http-equiv="content-type" content="text/html; charset=utf-8">
   <title>The LLVM Target-Independent Code Generator</title>
   <link rel="stylesheet" href="llvm.css" type="text/css">
 </head>
@@ -25,7 +26,7 @@
       <li><a href="#targetmachine">The <tt>TargetMachine</tt> class</a></li>
       <li><a href="#targetdata">The <tt>TargetData</tt> class</a></li>
       <li><a href="#targetlowering">The <tt>TargetLowering</tt> class</a></li>
-      <li><a href="#mregisterinfo">The <tt>MRegisterInfo</tt> class</a></li>
+      <li><a href="#targetregisterinfo">The <tt>TargetRegisterInfo</tt> class</a></li>
       <li><a href="#targetinstrinfo">The <tt>TargetInstrInfo</tt> class</a></li>
       <li><a href="#targetframeinfo">The <tt>TargetFrameInfo</tt> class</a></li>
       <li><a href="#targetsubtarget">The <tt>TargetSubtarget</tt> class</a></li>
   <li><a href="#targetimpls">Target-specific Implementation Notes</a>
     <ul>
     <li><a href="#x86">The X86 backend</a></li>
-    <li><a href="#ppc">The PowerPC backend</a></li>
+    <li><a href="#ppc">The PowerPC backend</a>
       <ul>
       <li><a href="#ppc_abi">LLVM PowerPC ABI</a></li>
       <li><a href="#ppc_frame">Frame Layout</a></li>
       <li><a href="#ppc_prolog">Prolog/Epilog</a></li>
       <li><a href="#ppc_dynamic">Dynamic Allocation</a></li>
-      </ul>
-    </ul>
-  </li>
+      </ul></li>
+    </ul></li>
 
 </ol>
 
 <div class="doc_author">
   <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a>,
-                <a href="mailto:isanbard@gmail.com">Bill Wendling</a>, and
+                <a href="mailto:isanbard@gmail.com">Bill Wendling</a>,
                 <a href="mailto:pronesto@gmail.com">Fernando Magno Quintao
-                                                    Pereira</a></p>
+                                                    Pereira</a> and
+                <a href="mailto:jlaskey@mac.com">Jim Laskey</a></p>
 </div>
 
 <div class="doc_warning">
@@ -381,20 +382,19 @@ operations.  Among other things, this class indicates:</p>
   <li>the type to use for shift amounts</li>
   <li>various high-level characteristics, like whether it is profitable to turn
       division by a constant into a multiplication sequence</li>
-</ol>
+</ul>
 
 </div>
 
 <!-- ======================================================================= -->
 <div class="doc_subsection">
-  <a name="mregisterinfo">The <tt>MRegisterInfo</tt> class</a>
+  <a name="targetregisterinfo">The <tt>TargetRegisterInfo</tt> class</a>
 </div>
 
 <div class="doc_text">
 
-<p>The <tt>MRegisterInfo</tt> class (which will eventually be renamed to
-<tt>TargetRegisterInfo</tt>) is used to describe the register file of the
-target and any interactions between the registers.</p>
+<p>The <tt>TargetRegisterInfo</tt> class is used to describe the register
+file of the target and any interactions between the registers.</p>
 
 <p>Registers in the code generator are represented in the code generator by
 unsigned integers.  Physical registers (those that actually exist in the target
@@ -407,8 +407,8 @@ register (used for assembly output and debugging dumps) and a set of aliases
 (used to indicate whether one register overlaps with another).
 </p>
 
-<p>In addition to the per-register description, the <tt>MRegisterInfo</tt> class
-exposes a set of processor specific register classes (instances of the
+<p>In addition to the per-register description, the <tt>TargetRegisterInfo</tt>
+class exposes a set of processor specific register classes (instances of the
 <tt>TargetRegisterClass</tt> class).  Each register class contains sets of
 registers that have the same properties (for example, they are all 32-bit
 integer registers).  Each SSA virtual register created by the instruction
@@ -718,8 +718,7 @@ comes from.</p>
 corresponds one-to-one with the LLVM function input to the instruction selector.
 In addition to a list of basic blocks, the <tt>MachineFunction</tt> contains a
 a <tt>MachineConstantPool</tt>, a <tt>MachineFrameInfo</tt>, a
-<tt>MachineFunctionInfo</tt>, a <tt>SSARegMap</tt>, and a set of live in and
-live out registers for the function.  See
+<tt>MachineFunctionInfo</tt>, and a <tt>MachineRegisterInfo</tt>.  See
 <tt>include/llvm/CodeGen/MachineFunction.h</tt> for more information.</p>
 
 </div>
@@ -747,16 +746,14 @@ explains how they work and some of the rationale behind their design.</p>
 <p>
 Instruction Selection is the process of translating LLVM code presented to the
 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:
-the SelectionDAG based instruction selector framework and an old-style 'simple'
-instruction selector, which effectively peephole selects each LLVM instruction
-into a series of machine instructions.  We recommend that all targets use the
-SelectionDAG infrastructure.
+well-known ways to do this in the literature.  LLVM uses a SelectionDAG based
+instruction selector.
 </p>
 
 <p>Portions of the DAG instruction selector are generated from the target 
 description (<tt>*.td</tt>) files.  Our goal is for the entire instruction
-selector to be generated from these <tt>.td</tt> files.</p>
+selector to be generated from these <tt>.td</tt> files, though currently
+there are still things that require custom C++ code.</p>
 </div>
 
 <!-- _______________________________________________________________________ -->
@@ -864,7 +861,11 @@ of the code compiled (if you only get errors printed to the console while using
 this, you probably <a href="ProgrammersManual.html#ViewGraph">need to configure
 your system</a> to add support for it).  The <tt>-view-sched-dags</tt> option
 views the SelectionDAG output from the Select phase and input to the Scheduler
-phase.</p>
+phase.  The <tt>-view-sunit-dags</tt> option views the ScheduleDAG, which is
+based on the final SelectionDAG, with nodes that must be scheduled as a unit
+bundled together into a single node, and with immediate operands and other
+nodes that aren't relevent for scheduling omitted.
+</p>
 
 </div>
 
@@ -1110,11 +1111,12 @@ primarily because it is a work in progress and is not yet finished:</p>
 <li>There is no great way to support matching complex addressing modes yet.  In
     the future, we will extend pattern fragments to allow them to define
     multiple values (e.g. the four operands of the <a href="#x86_memory">X86
-    addressing mode</a>).  In addition, we'll extend fragments so that a
+    addressing mode</a>, which are currently matched with custom C++ code).
+    In addition, we'll extend fragments so that a
     fragment can match multiple different patterns.</li>
 <li>We don't automatically infer flags like isStore/isLoad yet.</li>
 <li>We don't automatically generate the set of supported registers and
-    operations for the <a href="#"selectiondag_legalize>Legalizer</a> yet.</li>
+    operations for the <a href="#selectiondag_legalize">Legalizer</a> yet.</li>
 <li>We don't have a way of tying in custom legalized nodes yet.</li>
 </ul>
 
@@ -1155,7 +1157,6 @@ SelectionDAGs.</p>
 <ol>
 <li>Optional function-at-a-time selection.</li>
 <li>Auto-generate entire selector from <tt>.td</tt> file.</li>
-</li>
 </ol>
 
 </div>
@@ -1246,8 +1247,6 @@ variable is live.</p>
 
 <p><i><b>More to come...</b></i></p>
 
-</ol>
-
 </div>
 
 <!-- ======================================================================= -->
@@ -1292,7 +1291,7 @@ X86 architecture, the registers <tt>EAX</tt>, <tt>AX</tt> and
 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>MRegisterInfo::getAliasSet(p_reg)</tt> returns an array containing
+<tt>TargetRegisterInfo::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>.
@@ -1307,13 +1306,13 @@ this code can be used:
 
 <div class="doc_code">
 <pre>
-bool RegMapping_Fer::compatible_class(MachineFunction &mf,
+bool RegMapping_Fer::compatible_class(MachineFunction &amp;mf,
                                       unsigned v_reg,
                                       unsigned p_reg) {
-  assert(MRegisterInfo::isPhysicalRegister(p_reg) &&
+  assert(TargetRegisterInfo::isPhysicalRegister(p_reg) &amp;&amp;
          "Target register must be physical");
-  const TargetRegisterClass *trc = mf.getSSARegMap()->getRegClass(v_reg);
-  return trc->contains(p_reg);
+  const TargetRegisterClass *trc = mf.getRegInfo().getRegClass(v_reg);
+  return trc-&gt;contains(p_reg);
 }
 </pre>
 </div>
@@ -1335,14 +1334,14 @@ physical registers, different virtual registers never share the same
 number. The smallest virtual register is normally assigned the number
 1024. This may change, so, in order to know which is the first virtual
 register, you should access
-<tt>MRegisterInfo::FirstVirtualRegister</tt>. Any register whose
+<tt>TargetRegisterInfo::FirstVirtualRegister</tt>. Any register whose
 number is greater than or equal to
-<tt>MRegisterInfo::FirstVirtualRegister</tt> is considered a virtual
+<tt>TargetRegisterInfo::FirstVirtualRegister</tt> is considered a virtual
 register. Whereas physical registers are statically defined in a
 <tt>TargetRegisterInfo.td</tt> file and cannot be created by the
 application developer, that is not the case with virtual registers.
 In order to create new virtual registers, use the method
-<tt>SSARegMap::createVirtualRegister()</tt>. This method will return a
+<tt>MachineRegisterInfo::createVirtualRegister()</tt>. This method will return a
 virtual register with the highest code.
 </p>
 
@@ -1359,7 +1358,7 @@ if that register is being used by the instruction. The method
 <tt>MachineOperand::isDef()</tt> informs if that registers is being
 defined.</p>
 
-<p>We will call physical registers present in the LLVM bytecode before
+<p>We will call physical registers present in the LLVM bitcode before
 register allocation <i>pre-colored registers</i>. Pre-colored
 registers are used in many different situations, for instance, to pass
 parameters of functions calls, and to store results of particular
@@ -1394,7 +1393,7 @@ overwritten by the values of virtual registers while still alive.</p>
 
 <p>There are two ways to map virtual registers to physical registers (or to
 memory slots). The first way, that we will call <i>direct mapping</i>,
-is based on the use of methods of the classes <tt>MRegisterInfo</tt>,
+is based on the use of methods of the classes <tt>TargetRegisterInfo</tt>,
 and <tt>MachineOperand</tt>. The second way, that we will call
 <i>indirect mapping</i>, relies on the <tt>VirtRegMap</tt> class in
 order to insert loads and stores sending and getting values to and from
@@ -1408,8 +1407,8 @@ target function being compiled in order to get and store values in
 memory. To assign a physical register to a virtual register present in
 a given operand, use <tt>MachineOperand::setReg(p_reg)</tt>. To insert
 a store instruction, use
-<tt>MRegisterInfo::storeRegToStackSlot(...)</tt>, and to insert a load
-instruction, use <tt>MRegisterInfo::loadRegFromStackSlot</tt>.</p>
+<tt>TargetRegisterInfo::storeRegToStackSlot(...)</tt>, and to insert a load
+instruction, use <tt>TargetRegisterInfo::loadRegFromStackSlot</tt>.</p>
 
 <p>The indirect mapping shields the application developer from the
 complexities of inserting load and store instructions. In order to map
@@ -1529,7 +1528,7 @@ instance, a sequence of instructions such as:</p>
 </div>
 
 <p>Instructions can be folded with the
-<tt>MRegisterInfo::foldMemoryOperand(...)</tt> method. Care must be
+<tt>TargetRegisterInfo::foldMemoryOperand(...)</tt> method. Care must be
 taken when folding instructions; a folded instruction can be quite
 different from the original instruction. See
 <tt>LiveIntervals::addIntervalsForSpills</tt> in
@@ -1630,11 +1629,9 @@ are specific to the code generator for a particular target.</p>
 <div class="doc_text">
 
 <p>The X86 code generator lives in the <tt>lib/Target/X86</tt> directory.  This
-code generator currently targets a generic P6-like processor.  As such, it
-produces a few P6-and-above instructions (like conditional moves), but it does
-not make use of newer features like MMX or SSE.  In the future, the X86 backend
-will have sub-target support added for specific processor families and 
-implementations.</p>
+code generator is capable of targeting a variety of x86-32 and x86-64
+processors, and includes support for ISA extensions such as MMX and SSE.
+</p>
 
 </div>
 
@@ -1753,11 +1750,11 @@ relative (PIC) or static addressing for accessing global values, so no TOC (r2)
 is used. Second, r31 is used as a frame pointer to allow dynamic growth of a
 stack frame.  LLVM takes advantage of having no TOC to provide space to save
 the frame pointer in the PowerPC linkage area of the caller frame.  Other
-details of PowerPC ABI can be found at <a
-href="http://developer.apple.com/documentation/DeveloperTools/Conceptual/
-LowLevelABI/Articles/32bitPowerPC.html" target="_blank">PowerPC ABI.</a> Note:
-This link describes the 32 bit ABI.  The 64 bit ABI is similar except space for
-GPRs are 8 bytes wide (not 4) and r13 is reserved for system use.</p>
+details of PowerPC ABI can be found at <a href=
+"http://developer.apple.com/documentation/DeveloperTools/Conceptual/LowLevelABI/Articles/32bitPowerPC.html"
+>PowerPC ABI.</a> Note: This link describes the 32 bit ABI.  The
+64 bit ABI is similar except space for GPRs are 8 bytes wide (not 4) and r13 is
+reserved for system use.</p>
 </div>
 
 <!-- _______________________________________________________________________ -->
@@ -1767,7 +1764,7 @@ GPRs are 8 bytes wide (not 4) and r13 is reserved for system use.</p>
 
 <div class="doc_text">
 <p>The size of a PowerPC frame is usually fixed for the duration of a
-function&apos;s invocation.  Since the frame is fixed size, all references into
+function&rsquo;s invocation.  Since the frame is fixed size, all references into
 the frame can be accessed via fixed offsets from the stack pointer.  The
 exception to this is when dynamic alloca or variable sized arrays are present,
 then a base pointer (r31) is used as a proxy for the stack pointer and stack
@@ -1942,7 +1939,9 @@ makes it convenient to locate programatically and during debugging.</p>
 <p></p>
 </div>
 
-<i>TODO - More to come.</i>
+<div class="doc_text">
+<p><i>TODO - More to come.</i></p>
+</div>
 
 
 <!-- *********************************************************************** -->