X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FWritingAnLLVMBackend.html;h=d909a1a3fb72e5b1774929aa42f92ef7a7a90c93;hb=170f06ebe2e80ce8bda87425081541493056fb10;hp=b430d4dd3f4bf706432ee85b141ff47faa55032e;hpb=e6b487931c8defe867a9c51295463d2b2a79bbea;p=oota-llvm.git diff --git a/docs/WritingAnLLVMBackend.html b/docs/WritingAnLLVMBackend.html index b430d4dd3f4..d909a1a3fb7 100644 --- a/docs/WritingAnLLVMBackend.html +++ b/docs/WritingAnLLVMBackend.html @@ -22,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<Triple::sparc, /*HasJIT=*/false>
    +    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<SparcAsmPrinter> X(TheSparcTarget);
     }
     
    +

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

    +
    @@ -521,8 +561,7 @@ def AL : Register<"AL">, DwarfRegNum<[0, 0, 0]>;

    This defines the register AL and assigns it values (with DwarfRegNum) that are used by gcc, gdb, or a debug -information writer (such as DwarfWriter -in llvm/lib/CodeGen/AsmPrinter) to identify a register. For register +information writer to identify a register. For register AL, DwarfRegNum takes an array of 3 values representing 3 different modes: the first element is for X86-64, the second for exception handling (EH) on X86-32, and the third is generic. -1 is a special Dwarf number @@ -874,9 +913,6 @@ implementation in SparcRegisterInfo.cpp:

  • getCalleeSavedRegs — Returns a list of callee-saved registers in the order of the desired callee-save stack frame offset.
  • -
  • getCalleeSavedRegClasses — Returns a list of preferred - register classes with which to spill each callee saved register.
  • -
  • getReservedRegs — Returns a bitset indexed by physical register numbers, indicating if a particular register is unavailable.
  • @@ -2038,8 +2074,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.

    @@ -2110,21 +2146,13 @@ in XXXGenAsmWriter.inc contains an implementation of the

  • printImplicitDef
  • printInlineAsm
  • - -
  • printLabel
  • - -
  • printPICJumpTableEntry
  • - -
  • printPICJumpTableSetLabel
  • The implementations of printDeclare, printImplicitDef, printInlineAsm, and printLabel in AsmPrinter.cpp are generally adequate for printing assembly and do not need to be -overridden. (printBasicBlockLabel is another method that is implemented -in AsmPrinter.cpp that may be directly used in an implementation of -XXXAsmPrinter.) +overridden.