diff --git a/docs/WritingAnLLVMBackend.html b/docs/WritingAnLLVMBackend.html new file mode 100644 index 00000000000..1fb88a36332 --- /dev/null +++ b/docs/WritingAnLLVMBackend.html @@ -0,0 +1,245 @@ + + + + Writing an LLVM backend + + + + + +
+ Writing an LLVM backend +
+ +
    +
  1. Introduction +
  2. Writing a backend +
      +
    1. Machine backends
    2. +
        +
      1. Outline
      2. +
      3. Implementation details
      4. +
      +
    3. Machine backends
    4. +
    5. Language backends
    6. +
  3. +
  4. Related reading material +
+ +
+

Written by Misha Brukman

+
+ + +
+ Introduction +
+ + +
+ +

This document describes techniques for writing backends for LLVM which +convert the LLVM representation to machine assembly code or other languages.

+ +
+ + +
+ Writing a backend +
+ + + +
+ Machine backends +
+ + +
+ Outline +
+ +
+ +

In general, you want to follow the format of X86 or PowerPC (in +lib/Target).

+ +

To create a static compiler (one that emits text assembly), you need to +implement the following:

+ + + +

Now, for static code generation you also need to write an instruction +selector for your platform: see lib/Target/*/*ISelSimple.cpp which +is no longer "simple" but it gives you the idea: you have to be able to create +MachineInstrs for any given LLVM instruction using the InstVisitor +pattern, and produce a MachineFunction with +MachineBasicBlocks full of MachineInstrs for a +corresponding LLVM Function. Creating an instruction selector is perhaps the +most time-consuming part of creating a back-end.

+ +

To create a JIT for your platform:

+ + + +

Note that lib/target/Skeleton is a clean skeleton for a new target, +so you might want to start with that and adapt it for your target, and if you +are wondering how things are done, peek in the X86 or PowerPC target.

+ +

The Skeleton target is non-functional but provides the basic building blocks +you will need for your endeavor.

+ +
+ + +
+ Implementation details +
+ +
+ + + +
+ + +
+ Language backends +
+ +
+ +

For now, just take a look at lib/Target/CBackend for an example of +how the C backend is written.

+ +
+ + +
+ Related reading material +
+ + +
+ + + +
+ + + +
+
+ Valid CSS! + Valid HTML 4.01! + + Misha Brukman
+ The LLVM Compiler Infrastructure +
+ Last modified: $Date$ +
+ + +