Hi Andrew,<br>thanks for answering<br><br><div class="gmail_quote">On Thu, Apr 15, 2010 at 3:35 PM, Andrew Lenharth <span dir="ltr"><<a href="mailto:andrewl@lenharth.org">andrewl@lenharth.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Thu, Apr 15, 2010 at 3:40 AM, Artur Pietrek <<a href="mailto:pietreka@gmail.com">pietreka@gmail.com</a>> wrote:<br>
> Hi all<br>
> Ups, I'm really sorry for that previous message, I've sent it by mistake.<br>
><br>
> So let me write it once more.<br>
><br>
> I've been working for some time now on a backend for our CPU. However I<br>
> couldn't figure out how to implement some stuff.<br>
> I'd appreciate your help with these.<br>
><br>
> First thing is return address saving. To do that, first I have to copy it to<br>
> a general purpose register. I have no idea how to find an unused gpr<br>
> register in emitPrologue/emitEpilogue. I've noticed that in other backends<br>
> RegScavenger is used for that purpose, but not from inside of those methods.<br>
> So my question is how could I get an unused register from inside of these<br>
> methods?<br>
<br>
</div>Do you have an API specified register where the variable is passed?<br>
If so, it is a matter of copying it to a virtual register in the<br>
prologue which is then a live in to the first basic block. If you<br>
must have it in a specific register, you can make your ret inst take<br>
it as a use and copy the virtual register back to the physical one for<br>
the ret.<br></blockquote><div> </div><div>There is no specific register needed here. It's just dedicated RA register is a special register that could be read/set via a GPR using get/set instructions only. So this is why I need a GPR register in prologue/epilogue.<br>
Aren't prologue/epilogue run after register allocation? If I copy to a virtual register, wouldn't I have to rerun the RA pass?<br> <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
> And my second problem is with returning structures by value. ABI says that<br>
> aggregates up to 32bytes should be returned directly in register. Any advice<br>
> how this could be done?<br>
<br>
</div>This has to be done in the front end, I think.<br></blockquote><div><br>There is no way of doing that in the backend?<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Andrew<br></blockquote></div><br>Thanks,<br>Artur<br>