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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access