[LLVMdev] request for help writing a register allocator

Susan Horwitz horwitz at cs.wisc.edu
Mon Oct 19 17:20:06 PDT 2009


I'm using LLVM for a compiler course, and I'd like to have my students 
implement a graph-coloring register allocator.  I'm having a lot of 
trouble figuring out how this should be done.

Is there anyone who has written an LLVM register allocator who would be 
willing to help me understand the basic ideas?  I understand the 
algorithm, it's LLVM that I don't understand.  For example:

- When allocating registers, how do I know which register class to use,
   and which registers of that class are available?

- How do I know which operands of a Machine Instruction are candidates
   for (simple) register allocation (e.g., are of type int)?

- How do I replace a virtual register with a physical one?

- Do I need to generate spill code to handle virtual registers that
   cannot be replaced with physical ones, and if so, how?


Susan Horwitz




More information about the llvm-dev mailing list