Book Image

LLVM Cookbook

Book Image

LLVM Cookbook

Overview of this book

Table of Contents (16 chapters)
LLVM Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Implementing the MachineFunction class


Similar to the LLVM IR FunctionBlock class, a MachineFunction class contains a series of MachineBasicBlocks classes. These MachineFunction classes map to LLVM IR functions that are given as input to the instruction selector. In addition to a list of basic blocks, the MachineFunction class contains the MachineConstantPool, MachineFrameInfo, MachineFunctionInfo, and MachineRegisterInfo classes.

How to do it…

Many functions are defined in the MachineFunction class, which does specific tasks. There are also many class member objects that keep information, such as the following:

  • RegInfo keeps information about each register that is in use in the function:

    MachineRegisterInfo *RegInfo;
  • MachineFrameInfo keeps track of objects allocated on the stack:

    MachineFrameInfo *FrameInfo;
  • ConstantPool keeps track of constants that have been spilled to the memory:

    MachineConstantPool *ConstantPool;
  • JumpTableInfo keeps track of jump tables for switch instructions:

    MachineJumpTableInfo...