Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying LLVM Cookbook
  • Table Of Contents Toc
  • Feedback & Rating feedback
LLVM Cookbook

LLVM Cookbook

By : Mayur Pandey, Suyog Sarda
2 (9)
close
close
LLVM Cookbook

LLVM Cookbook

2 (9)
By: Mayur Pandey, Suyog Sarda

Overview of this book

The book is for compiler programmers who are familiar with concepts of compilers and want to indulge in understanding, exploring, and using LLVM infrastructure in a meaningful way in their work. This book is also for programmers who are not directly involved in compiler projects but are often involved in development phases where they write thousands of lines of code. With knowledge of how compilers work, they will be able to code in an optimal way and improve performance with clean code.
Table of Contents (11 chapters)
close
close
10
Index

Adding instruction encoding


If the instructions need to be specific for how they are encoded with respect to bit fields, this can be done by specifying the bit field in the .td file when defining an instruction.

How to do it…

To include instruction encoding while defining instructions, proceed with the following steps:

  1. A register operand that will be used to register the add instruction will have some defined encoding for its instruction. The size of the instruction is 32 bits, and the encoding for it is as follows:

    bits 0 to 3 -> src2, second register operand
    bits 4 to 11 -> all zeros
    bits 12 to 15 -> dst, for destination register
    bits 16 to 19 -> src1, first register operand
    bit 20 -> zero
    bit 21 to 24 -> for opcode
    bit 25 to 27 -> all zeros
    bit 28 to 31 -> 1110

    This can be achieved by specifying the preceding bit pattern in the .td files

  2. In the TOYInstrFormats.td file, define a new variable, called Inst:

    class InstTOY<dag outs, dag ins, string asmstr, list<dag&gt...
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
LLVM Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon