PATCH: llvm-top git support and out-of-tree building for llvm

What: The original scripts in llvm-top assume that they're dealing with
a subversion working copy. The patch adds support for a git repository
cloned using git svn.

The other two patches make llvm (core) do an out-of-tree build, i.e.,
the source tree is kept clean, and tells llvm-gcc-4.2 to find llvm in
the right (new) place.

Why: Using git it is possible to fiddle locally with the code, have the
original as well as the changes in version control, and keep up with
updates from the central SVN repository.

Out-of-tree builds make it easier to distinguish what files are changed,
added, or generated.

Michael

llvm-gcc-out-of-tree.diff (1.18 KB)

llvm-out-of-tree.diff (1.62 KB)

llvm-top-git.diff (2.65 KB)

Hi Michael,

What: The original scripts in llvm-top assume that they're dealing with
a subversion working copy. The patch adds support for a git repository
cloned using git svn.

The other two patches make llvm (core) do an out-of-tree build, i.e.,
the source tree is kept clean, and tells llvm-gcc-4.2 to find llvm in
the right (new) place.

Why: Using git it is possible to fiddle locally with the code, have the
original as well as the changes in version control, and keep up with
updates from the central SVN repository.

Out-of-tree builds make it easier to distinguish what files are changed,
added, or generated.

these look good to me, but unfortunately I am unable to test them for
the moment, otherwise I would have applied them.

Ciao,

Duncan.

Please don't skip the testing. I'm pretty new to LLVM and not a git
expert either, so my changes may introduce subtle or not so subtle
problems that I didn't think of.

Michael

Hi Michael, I've applied these (with some tweaks).
Thanks for working on this!

Ciao,

Duncan.

Hi,
I'm implementing storeRegToStackSlot() and, in order to store some specific registers (floating point regs and address regs) I've to copy them to more standard regs and copy these last ones to the slot.
I tried to generate instructions that use physical registers, but by doing that I overwrote registers already assigned by the register allocator.
Is it possible to use virtual registers in the instructions generated by storeRegToStackSlot()?
This function is called by the register allocator. So, if it needs to store regs on a slot, this means that there is no more registers available. So, I cannot believe that it is able to allocate new virtual registers generated by storeRegToStackSlot().
What is the good way to implement this ?
Thanks a lot
Gab

Hi,
I'm implementing storeRegToStackSlot() and, in order to store some specific registers (floating point regs and address regs) I've to copy them to more standard regs and copy these last ones to the slot.
I tried to generate instructions that use physical registers, but by doing that I overwrote registers already assigned by the register allocator.
Is it possible to use virtual registers in the instructions generated by storeRegToStackSlot()?
This function is called by the register allocator. So, if it needs to store regs on a slot, this means that there is no more registers available. So, I cannot believe that it is able to allocate new virtual registers generated by storeRegToStackSlot().

Your analysis here sounds right. The current design with
storeRegToStackSlot currently assumes that any register
can be stored without requiring intermediate registers.

What is the good way to implement this ?

It looks like you'll have to make your own way here. If
you find a good solution, perhaps others with similar needs
may be able to follow.

Dan

Dan Gohman a écrit :

Hi,
I'm implementing storeRegToStackSlot() and, in order to store some specific registers (floating point regs and address regs) I've to copy them to more standard regs and copy these last ones to the slot.
I tried to generate instructions that use physical registers, but by doing that I overwrote registers already assigned by the register allocator.
Is it possible to use virtual registers in the instructions generated by storeRegToStackSlot()?
This function is called by the register allocator. So, if it needs to store regs on a slot, this means that there is no more registers available. So, I cannot believe that it is able to allocate new virtual registers generated by storeRegToStackSlot().
    
Your analysis here sounds right. The current design with
storeRegToStackSlot currently assumes that any register
can be stored without requiring intermediate registers.

What is the good way to implement this ?
    
It looks like you'll have to make your own way here. If
you find a good solution, perhaps others with similar needs
may be able to follow.
  

An easy way (but not very efficient) is to reserve a register for this (just disallow automatic selection of this register). It is just a few line to change in your td files. You may also want to check how it is done in the PIC16 backend. I think they also need a register at spill time (to compute the destination adress) but I may be wrong.
I didn't work much with llvm, so I may be wrong

regards,

Cédric

We also (in PIC16) have the same issue but we found a nasty workaround for this. Our architecture only has one WREG and 2 pointer register. And to spill the pointer registers, we needed to use WREG. Now what happens for us is since there is only one WREG, during the lowering of indirect load/store, we can detect if WREG already contains a value or not and then we can spill it manually and make it available for the pointers, because even to load the pointer registers, we need WREG.
So I think our situation is slightly different from yours.

Regardless, I think we could benefit if llvm knew what to do when a register class is corrupted as result of spilling a different register class.

Regards
Ali

It is finally what I did. I need a very specific register to store value in the stack so I reserved one register to save and restore the value of this specific register. So, I save the specific register, I use it and I restore it.
To improve the efficiency, I could check if my specific register is used or not in the location where I'm inserting the store to slot. If it is not used, I don't need to save and restore it. But how to know if a register is used from within the storeRegToStackSlot() function?
For the moment, I keep this solution as it is.
Thanks for your help.
Gab