Live Intervals and Register Classes

Given a live interval LI, what's the right way to get the
register class of the interval?

I'm assuming that all LiveRange entries in the LiveInterval
are consistent in that if allocated to a register they would
all go in the same register class. Fair assumption?

If I take the first LiveRange LR from LI, look up its
instruction/operand at "start" and then look at its
TargetOperandInfo and send TOI::RegClass to
MRegisterInfo:getRegClass, is that sufficient.

It seems way overly complicated.

After LiveIntervalAnalysis runs we have a set of LIs we can
iterate over. What's the most efficient way to get the
register classes for these intervals so I know which machine
registers they can go into?

                              -Dave

David Greene wrote:

If I take the first LiveRange LR from LI, look up its
instruction/operand at "start" and then look at its
TargetOperandInfo and send TOI::RegClass to
MRegisterInfo:getRegClass, is that sufficient.

It seems way overly complicated.

Umm...yeah. That way be dragons. :-/

Fortunately, I found
MachineFunction::getSSARegMap()->getRegClass(LI.reg) which
works swimmingly.

                              -Dave

Yep, that's exactly the right way to go for vregs. It won't work for physregs, primarily because they can be in multiple reg classes :slight_smile:

-Chris

David,

Probably, you’ll find a lot of useful information here along with the answer to your question (that you’ve found already):
http://llvm.org/docs/CodeGenerator.html#regalloc

Anton.