Defining registers and registers sets

This recipe shows you how to define registers and register sets in .td files. The tablegen function will convert this .td file into .inc files, which will be the #include declarative in our .cpp files and refer to registers.

Getting ready

We have defined our toy target machine to have four registers (r0-r3), a stack register (sp), and a link register (lr). These can be specified in the TOYRegisterInfo.td file. The tablegen function provides the Register class, which can be extended to specify the registers.

How to do it…

To define the backend architecture using target descriptor files, proceed with the following steps.

  1. Create a new folder in lib/Target named TOY:
    $ mkdir llvm_root_directory/lib/Target/TOY
    
  2. Create ...

Get LLVM Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.