diff options
author | Matthijs Kooijman <matthijs@stdin.nl> | 2008-09-29 11:52:22 +0000 |
---|---|---|
committer | Matthijs Kooijman <matthijs@stdin.nl> | 2008-09-29 11:52:22 +0000 |
commit | 6aa812704fb05413b83955b52f87e105b567b4fe (patch) | |
tree | e26af5fbb7a56ab0aedfc002ff812dd7868fbbc7 /docs/WritingAnLLVMBackend.html | |
parent | 5df3186f598163258fabf3448d9372843804d1ab (diff) | |
download | external_llvm-6aa812704fb05413b83955b52f87e105b567b4fe.zip external_llvm-6aa812704fb05413b83955b52f87e105b567b4fe.tar.gz external_llvm-6aa812704fb05413b83955b52f87e105b567b4fe.tar.bz2 |
Add some hands-on documentation about which files to create and edit when
adding a backend.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56783 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/WritingAnLLVMBackend.html')
-rw-r--r-- | docs/WritingAnLLVMBackend.html | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/docs/WritingAnLLVMBackend.html b/docs/WritingAnLLVMBackend.html index 909432e..bddc021 100644 --- a/docs/WritingAnLLVMBackend.html +++ b/docs/WritingAnLLVMBackend.html @@ -218,6 +218,56 @@ e.g.:</p> how the C backend is written.</p> </div> +<!-- ======================================================================= --> +<div class="doc_subsection"> + <a name="files">Files to create/modify</a> +</div> + +<div class="doc_text"> + +<p>To actually create your backend, you need to create and modify a few files. +Here, the absolute minimum will be discussed. To actually use LLVM's target +independent codegenerator, you must <a href="CodeGenerator.html">implement extra +things</a>.</p> + +<p>First of all, you should create a subdirectory under <tt>lib/Target</tt>, +which will hold all the files related to your target. Let's assume that our +target is called, "Dummy", we would create the directory +<tt>lib/Target/Dummy</tt>.</p> + +<p>In this new directory, you should put a <tt>Makefile</tt>. You can probably +copy one from another target and modify it. It should at least contain the +<tt>LEVEL</tt>, <tt>LIBRARYNAME</tt> and <tt>TARGET</tt> variables, and then +include <tt>$(LEVEL)/Makefile.common</tt>. Be careful to give the library the +correct name, it must be named <tt>LLVMDummy</tt> (see the MIPS target, for +example). Alternatively, you can split the library into +<tt>LLVMDummyCodeGen</tt> and <tt>LLVMDummyAsmPrinter</tt>, the latter of which +should be implemented in a subdirectory below <tt>lib/Target/Dummy</tt> (see the +PowerPC target, for example).</p> + +<p>Note that these two naming schemes are hardcoded into llvm-config. Using any +other naming scheme will confuse llvm-config and produce lots of (seemingly +unrelated) linker errors when linking <tt>llc</tt>.</p> + +<p>To make your target actually do something, you need to implement a subclass +of <tt>TargetMachine</tt>. This implementation should typically be in the file +<tt>lib/Target/DummyTargetMachine.cpp</tt>, but any file in the +<tt>lib/Target</tt> directory will be built and should work. To use LLVM's <a +href="CodeGenerator.html">target independent code generator</a>, you should +create a subclass of <tt>LLVMTargetMachine</tt>. This is what all current +machine backends do. To create a target from scratch, create a subclass of +<tt>TargetMachine</tt>. This is what the current language backends do.</p> + +<p>To get LLVM to actually build and link your target, you also need to add it +to the <tt>TARGETS_TO_BUILD</tt> variable. To do this, you need to modify the +<tt>configure</tt> script to know about your target when parsing the +<tt>--enable-targets</tt> option. Search the <tt>configure</tt> script for +<tt>TARGETS_TO_BUILD</tt>, add your target to the lists there (some creativity +required) and then reconfigure. Alternatively, you can change +<tt>autotools/configure.ac</tt> and regenerate <tt>configure</tt> by running +<tt>./autoconf/AutoRegen.sh</tt>. + +</div> <!-- *********************************************************************** --> <div class="doc_section"> |