Moving data between regs

Dear LLVMers,

     I wish someone could help me to clarify a register allocation question. I will use X86 in this example, but it really does not matter too much.

     Imagine that I have a virtual v stored in register AL, and I am about to cross a function call, that effectively overwrites AL. Well, I have, say, register ESI free, but as it happens, ESI is bigger than AL. It should be technically possible to move the contents of AL into ESI, to avoid spilling 'v', but I don't know if that is possible in LLVM. Basically, ESI is not in the class of 'v', and it has no 8 bit alias. Is
this a problem (the move can't be done), or am I missing something?

all the best,

Fernando

Very interesting idea. Yes, this is doable. On X86 you would copy EAX to ESI, which implicitly saves AL because it's a superclass of AL. MRegisterInfo has information about super and subclass registers, Evan can tell you more.

-Chris

The short answer is this is not currently done. LLVM register allocator does not currently use a move to a different register class in lieu of spills. This is definitely something we should do in the future. Can you file a bugzilla enhancement request?

Thanks,

Evan

Does this depend on vreg subreg support? It sounds as if it could be vaguely related, but I’m not sure it’s necessary.

I consider this an orthogonal issue. While this particular example make use of sub-register info, that’s not always the case. You can conceivably see a target where it’s cheap(er) to move from an integer register to a floating point one, etc.

Evan