llvm.org GIT mirror llvm / d6b06b1
Update target registration description in Writing An LLVM Backend, and add a mention in release notes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77128 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 10 years ago
2 changed file(s) with 62 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
490490
491491
492492
  • The registration interfaces for backend Targets has changed (what was
  • 493 previously TargetMachineRegistry). FIXME: Complete this section, explain client
    494 changes, point to documentation on new backend interface.
    493 previously TargetMachineRegistry). For backend authors, see the Writing An LLVM Backend guide. For clients, the notable API changes are:
    494
    495
  • TargetMachineRegistry has been renamed
  • 496 to TargetRegistry.
    497
    498
  • Clients should move to using the TargetRegistry::lookupTarget()
  • 499 function to find targets.
    500
    501
    495502
    496503
  • llvm-dis now fails if output file exists, instead of dumping to stdout.
  • 497504 FIXME: describe any other tool changes due to the raw_fd_ostream change. FIXME:
    2121
  • Preliminaries
  • 2222
    2323
  • Target Machine
  • 24
  • Target Registration
  • 2425
  • Register Set and Register Classes
  • 2526
    2627
  • Defining a Register
  • 421422 alignment, and then ABI preferred alignment.
    422423
    423424
    424

    425 You must also register your target using the RegisterTarget
    426 template. (See the TargetMachineRegistry class.) For example,
    427 in SparcTargetMachine.cpp, the target is registered with:
    428

    429
    430
    431
    
                      
                    
    432 namespace {
    433 // Register the target.
    434 RegisterTarget<SparcTargetMachine>X("sparc", "SPARC");
    425
    426
    427
    428
    429 Target Registration
    430
    431
    432
    433
    434
    435

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

    440
    441

    442 All targets should declare a global Target object which is used to
    443 represent the target during registration. Then, in the target's TargetInfo
    444 library, the target should define that object and use
    445 the RegisterTarget template to register the target. For example, the Sparc registration code looks like this:
    446

    447
    448
    449
    
                      
                    
    450 Target llvm::TheSparcTarget;
    451
    452 extern "C" void LLVMInitializeSparcTargetInfo() {
    453 RegisterTarget
    454 X(TheSparcTarget, "sparc", "Sparc");
    435455 }
    436456
    437457
    458
    459

    460 This allows the TargetRegistry to look up the target by name or by
    461 target triple. In addition, most targets will also register additional features
    462 which are available in separate libraries. These registration steps are
    463 separate, because some clients may wish to only link in some parts of the target
    464 -- the JIT code generator does not require the use of the assembler printer, for
    465 example. Here is an example of registering the Sparc assembly printer:
    466

    467
    468
    469
    
                      
                    
    470 extern "C" void LLVMInitializeSparcAsmPrinter() {
    471 RegisterAsmPrinter X(TheSparcTarget);
    472 }
    473
    474
    475
    476

    477 For more information, see
    478 "llvm/Target/TargetRegistry.h".
    479

    438480
    439481
    440482