[LLVMdev] Virtual register??

Bill Wendling isanbard at gmail.com
Thu Feb 8 13:15:12 PST 2007


On 2/8/07, Seung Jae Lee <lee225 at uiuc.edu> wrote:
> On the document about writing an LLVM backend, I became to wonder what the 'virtual register' is in the following statement.
>
> "You also need to define register classes to contain these registers, such as the integer register class and floating-point register class, so that you can allocate virtual registers to instructions from these sets, and let the target-independent register allocator automatically choose the actual architected registers. (Writing an LLVM backend @ llvm.org)"
>
> Would you mind telling me the difference between 'virtual register' and just 'register'?
> Thank you so much.

Sure. A "virtual" register represents a variable that's may reside in
a register. LLVM assumes that there are an infinite amount of
registers for variables to reside in. (This isn't true, of course, but
it's a fiction which allows the optimizations to work without having
to worry about physical registers, which are machine-dependent.) This
delision continues until register allocation, which assigns variables
to actual physical registers.

-bw



More information about the llvm-dev mailing list