summaryrefslogtreecommitdiffstats
path: root/docs/WritingAnLLVMBackend.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/WritingAnLLVMBackend.html')
-rw-r--r--docs/WritingAnLLVMBackend.html64
1 files changed, 52 insertions, 12 deletions
diff --git a/docs/WritingAnLLVMBackend.html b/docs/WritingAnLLVMBackend.html
index 8016283..5a95185 100644
--- a/docs/WritingAnLLVMBackend.html
+++ b/docs/WritingAnLLVMBackend.html
@@ -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 @@ SparcTargetMachine::SparcTargetMachine(const Module &amp;M, const std::string &a
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&lt;Triple::sparc, /*HasJIT=*/false&gt;
+ 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&lt;SparcTargetMachine&gt;X("sparc", "SPARC");
+extern "C" void LLVMInitializeSparcAsmPrinter() {
+ RegisterAsmPrinter&lt;SparcAsmPrinter&gt; X(TheSparcTarget);
}
</pre>
</div>
+<p>
+For more information, see
+"<a href="/doxygen/TargetRegistry_8h-source.html">llvm/Target/TargetRegistry.h</a>".
+</p>
+
</div>
<!-- *********************************************************************** -->
@@ -2038,8 +2080,8 @@ SparcTargetAsmInfo::SparcTargetAsmInfo(const SparcTargetMachine &amp;TM) {
<p>
The X86 assembly printer implementation (<tt>X86TargetAsmInfo</tt>) is an
-example where the target specific <tt>TargetAsmInfo</tt> class uses overridden
-methods: <tt>ExpandInlineAsm</tt> and <tt>PreferredEHDataFormat</tt>.
+example where the target specific <tt>TargetAsmInfo</tt> class uses an
+overridden methods: <tt>ExpandInlineAsm</tt>.
</p>
<p>
@@ -2122,9 +2164,7 @@ in <tt>XXXGenAsmWriter.inc</tt> contains an implementation of the
The implementations of <tt>printDeclare</tt>, <tt>printImplicitDef</tt>,
<tt>printInlineAsm</tt>, and <tt>printLabel</tt> in <tt>AsmPrinter.cpp</tt> are
generally adequate for printing assembly and do not need to be
-overridden. (<tt>printBasicBlockLabel</tt> is another method that is implemented
-in <tt>AsmPrinter.cpp</tt> that may be directly used in an implementation of
-<tt>XXXAsmPrinter</tt>.)
+overridden.
</p>
<p>
@@ -2523,7 +2563,7 @@ with assembler.
<a href="http://www.woo.com">Mason Woo</a> and <a href="http://misha.brukman.net">Misha Brukman</a><br>
<a href="http://llvm.org">The LLVM Compiler Infrastructure</a>
<br>
- Last modified: $Date: 2009-04-05 02:44:06 +0200 (Sun, 05 Apr 2009) $
+ Last modified: $Date: 2009-09-13 00:57:37 +0200 (Sun, 13 Sep 2009) $
</address>
</body>
OpenPOWER on IntegriCloud