[llvm-commits] [llvm] r77128 - in /llvm/trunk/docs: ReleaseNotes-2.6.html WritingAnLLVMBackend.html

Daniel Dunbar daniel at zuster.org
Sat Jul 25 22:42:14 PDT 2009


Author: ddunbar
Date: Sun Jul 26 00:41:39 2009
New Revision: 77128

URL: http://llvm.org/viewvc/llvm-project?rev=77128&view=rev
Log:
Update target registration description in Writing An LLVM Backend, and add
a mention in release notes.

Modified:
    llvm/trunk/docs/ReleaseNotes-2.6.html
    llvm/trunk/docs/WritingAnLLVMBackend.html

Modified: llvm/trunk/docs/ReleaseNotes-2.6.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes-2.6.html?rev=77128&r1=77127&r2=77128&view=diff

==============================================================================
--- llvm/trunk/docs/ReleaseNotes-2.6.html (original)
+++ llvm/trunk/docs/ReleaseNotes-2.6.html Sun Jul 26 00:41:39 2009
@@ -491,8 +491,15 @@
 </li>
 
 <li>The registration interfaces for backend Targets has changed (what was
-previously TargetMachineRegistry). FIXME: Complete this section, explain client
-changes, point to documentation on new backend interface.</li>
+previously TargetMachineRegistry). For backend authors, see the <a href="WritingAnLLVMBackend.html#TargetRegistration">Writing An LLVM Backend</a> guide. For clients, the notable API changes are:
+  <ul>
+    <li><tt>TargetMachineRegistry</tt> has been renamed
+      to <tt>TargetRegistry</tt>.</li>
+
+    <li>Clients should move to using the <tt>TargetRegistry::lookupTarget()</tt>
+      function to find targets.</li>
+  </ul>
+</li>
 
 <li>llvm-dis now fails if output file exists, instead of dumping to stdout.
 FIXME: describe any other tool changes due to the raw_fd_ostream change.  FIXME:

Modified: llvm/trunk/docs/WritingAnLLVMBackend.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/WritingAnLLVMBackend.html?rev=77128&r1=77127&r2=77128&view=diff

==============================================================================
--- llvm/trunk/docs/WritingAnLLVMBackend.html (original)
+++ llvm/trunk/docs/WritingAnLLVMBackend.html Sun Jul 26 00:41:39 2009
@@ -22,6 +22,7 @@
     <li><a href="#Preliminaries">Preliminaries</a></li>
   </ul>
   <li><a href="#TargetMachine">Target Machine</a></li>
+  <li><a href="#TargetRegistration">Target Registration</a></li>
   <li><a href="#RegisterSet">Register Set and Register Classes</a>
   <ul>
     <li><a href="#RegisterDef">Defining a Register</a></li>
@@ -422,21 +423,62 @@
     alignment, and then ABI preferred alignment.</li>
 </ul>
 
+</div>
+
+<!-- *********************************************************************** -->
+<div class="doc_section">
+  <a name="TargetRegistration">Target Registration</a>
+</div>
+<!-- *********************************************************************** -->
+
+<div class="doc_text">
+
+<p>
+You must also register your target with the <tt>TargetRegistry</tt>, which is
+what other LLVM tools use to be able to lookup and use your target at
+runtime. The <tt>TargetRegistry</tt> can be used directly, but for most targets
+there are helper templates which should take care of the work for you.</p>
+
+<p>
+All targets should declare a global <tt>Target</tt> object which is used to
+represent the target during registration. Then, in the target's TargetInfo
+library, the target should define that object and use
+the <tt>RegisterTarget</tt> template to register the target. For example, the Sparc registration code looks like this:
+</p>
+
+<div class="doc_code">
+<pre>
+Target llvm::TheSparcTarget;
+
+extern "C" void LLVMInitializeSparcTargetInfo() { 
+  RegisterTarget<Triple::sparc, /*HasJIT=*/false> 
+    X(TheSparcTarget, "sparc", "Sparc");
+}
+</pre>
+</div>
+
 <p>
-You must also register your target using the <tt>RegisterTarget</tt>
-template. (See the <tt>TargetMachineRegistry</tt> class.) For example,
-in <tt>SparcTargetMachine.cpp</tt>, the target is registered with:
+This allows the <tt>TargetRegistry</tt> to look up the target by name or by
+target triple. In addition, most targets will also register additional features
+which are available in separate libraries. These registration steps are
+separate, because some clients may wish to only link in some parts of the target
+-- the JIT code generator does not require the use of the assembler printer, for
+example. Here is an example of registering the Sparc assembly printer:
 </p>
 
 <div class="doc_code">
 <pre>
-namespace {
-  // Register the target.
-  RegisterTarget<SparcTargetMachine>X("sparc", "SPARC");
+extern "C" void LLVMInitializeSparcAsmPrinter() { 
+  RegisterAsmPrinter<SparcAsmPrinter> X(TheSparcTarget);
 }
 </pre>
 </div>
 
+<p>
+For more information, see
+"<a href="/doxygen/TargetRegistry_8h-source.html">llvm/Target/TargetRegistry.h</a>".
+</p>
+
 </div>
 
 <!-- *********************************************************************** -->





More information about the llvm-commits mailing list