X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FWritingAnLLVMBackend.html;h=29dc1127c576f0a4c8e697069ceefd7cf8454cd4;hb=916afdbc2d4af2596894c4ccc179b4445fe659a7;hp=a1dc34c75b07434c829250e92ca8e3bf5b555b92;hpb=4a2bca8bc39d24b7cae6704ff92f793ce27bb051;p=oota-llvm.git diff --git a/docs/WritingAnLLVMBackend.html b/docs/WritingAnLLVMBackend.html index a1dc34c75b0..29dc1127c57 100644 --- a/docs/WritingAnLLVMBackend.html +++ b/docs/WritingAnLLVMBackend.html @@ -2,6 +2,7 @@ "http://www.w3.org/TR/html4/strict.dtd"> + Writing an LLVM Compiler Backend @@ -21,6 +22,7 @@
  • Preliminaries
  • Target Machine
  • +
  • Target Registration
  • Register Set and Register Classes + + + +
    + Target Registration +
    + + +
    + +

    +You must also register your target with the TargetRegistry, which is +what other LLVM tools use to be able to lookup and use your target at +runtime. The TargetRegistry can be used directly, but for most targets +there are helper templates which should take care of the work for you.

    + +

    +All targets should declare a global Target 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 RegisterTarget template to register the target. For example, the Sparc registration code looks like this: +

    + +
    +
    +Target llvm::TheSparcTarget;
    +
    +extern "C" void LLVMInitializeSparcTargetInfo() { 
    +  RegisterTarget 
    +    X(TheSparcTarget, "sparc", "Sparc");
    +}
    +
    +
    +

    -You must also register your target using the RegisterTarget -template. (See the TargetMachineRegistry class.) For example, -in SparcTargetMachine.cpp, the target is registered with: +This allows the TargetRegistry 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:

    -namespace {
    -  // Register the target.
    -  RegisterTarget<SparcTargetMachine>X("sparc", "SPARC");
    +extern "C" void LLVMInitializeSparcAsmPrinter() { 
    +  RegisterAsmPrinter X(TheSparcTarget);
     }
     
    +

    +For more information, see +"llvm/Target/TargetRegistry.h". +

    +
    @@ -2037,8 +2080,8 @@ SparcTargetAsmInfo::SparcTargetAsmInfo(const SparcTargetMachine &TM) {

    The X86 assembly printer implementation (X86TargetAsmInfo) is an -example where the target specific TargetAsmInfo class uses overridden -methods: ExpandInlineAsm and PreferredEHDataFormat. +example where the target specific TargetAsmInfo class uses an +overridden methods: ExpandInlineAsm.

    @@ -2259,6 +2302,8 @@ XXXSubtarget::XXXSubtarget(const Module &M, const std::string &FS) { + +

    JIT Support