[LLVMdev] [LLVMDev] Register Allocation and copy instructions
Jakob Stoklund Olesen
stoklund at 2pi.dk
Mon Nov 8 15:31:03 PST 2010
On Nov 8, 2010, at 12:04 PM, Jeff Kunkel wrote:
> Hi, while writing my register allocator, I have come across a case which confuses me because the llvm definition cannot be mapped to machine code.
>
> For instance I come across (1) and I reduce it to (2). However a copy instruction cannot move from EDX to CX. What mechanics in LLVM will tell me that I cannot make this move during register allocation, or how can I tell from (1) that I cannot execute %reg16385<def> = COPY %reg16390. Furthermore, how should I handle this case.
> BB#0: derived from LLVM BB %entry
> %reg16390<def> = MOVZX32rm16 <fi#-2>, 1, %reg0, 0, %reg0; mem:LD2[FixedStack-2] GR32:%reg16390
> %reg16385<def> = COPY %reg16390:sub_16bit<kill>; GR16:%reg16385 GR32:%reg16390
> %reg16391<def> = MOVZX32rm16 <fi#-1>, 1, %reg0, 0, %reg0; mem:LD2[FixedStack-1] GR32:%reg16391
> %reg16384<def> = COPY %reg16391:sub_16bit<kill>; GR16:%reg16384 GR32:%reg16391
> Successors according to CFG: BB#1
MachineOperands can refer to sub-registers of virtual registers. That is what is happening here. It is not specific to COPY instructions, but it happens a lot for them.
You should look at how the other register allocators are rewriting virtual registers to physicals.
/jakob
More information about the llvm-dev
mailing list