[LLVMdev] Some backend questions

Vladimir Prus ghost at cs.msu.su
Fri Jun 4 09:10:01 PDT 2004


Ok, I'm now trying to write instruction selector and have some questions

1. The MachineInstrBuilder has methods to add register operand and immediate 
operand. However, what would be really nice is a method to add Value*.  So, I 
would write:

    BuildMI(*BB, NM::add, 1).add(I.getOperand(0), I.getOperand(1));

and depending on whether the passed Value* is contant or instruction, the add 
method would either add immediate constant or allocate/get new virtual 
register. 

2. Why SSARegMap is called this way. As far as I can see, it's does not 
implement any mapping, it simply allocates registers given a register class.

3. Maybe, the allocation of virtual registers for Value* should be made more 
reusable. The X86 backend has the code for that in getReg method in 
InstSelectSimple.cpp which:

   - uses SSARegMap instance
   - keeps internal Value* -> register mapping
   - copies constants into register when needed

At least first two things will be necessary for my backend too. I start to 
wonder if it makes sense to make a "BasicInstructionSelector" which will have 
such reusable logic?

Sorry if the above is not very clear -- I'm only starting to getting underting 
of LLVM codebase.

- Volodya




More information about the llvm-dev mailing list