O'Reilly logo

LLVM Cookbook by Suyog Sarda, Mayur Pandey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Registering a target

For running the llc tool in the TOY target architecture, it has to be registered with the llc tool. This recipe demonstrates which configuration files need to be modified to register a target. The build files are modified in this recipe.

How to do it…

To register a target with a static compiler, follow these steps:

  1. First, add the entry of the TOY backend to llvm_root_dir/CMakeLists.txt:
    set(LLVM_ALL_TARGETS
      AArch64
      ARM
      …
      …
      TOY
      )
  2. Then add the toy entry to llvm_root_dir/include/llvm/ADT/Triple.h:
    class Triple {
    public:
      enum ArchType {
        UnknownArch,
    
        arm,        // ARM (little endian): arm, armv.*, xscale
        armeb,      // ARM (big endian): armeb
        aarch64,    // AArch64 (little endian): aarch64
        …
       …
    
    toy     // TOY: toy
    };
  3. Add the toy entry to llvm_root_dir/include/llvm/ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required