O'Reilly logo

Getting Started with LLVM Core Libraries by Rafael Auler, Bruno Cardoso Lopes

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

Writing your own machine pass

In this section, we will show how you can write a custom machine pass to count, just before code emission, how many machine instructions each function has. Differing from IR passes, you cannot run this pass with the opt tool, or load the pass and schedule it to happen via the command line. Machine passes are determined by the backend code. Therefore, we will modify an existing backend to run with our custom pass to see it in practice. We will choose SPARC for that end.

Recall from the Demonstrating the pluggable pass interface section in Chapter 3, Tools and Design, and from the white boxes in the first diagram of this chapter, that we have many options to decide where our pass should run. To use these methods, we ...

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