<div>I am using allocation_order_begin() and allocation_order_end(). Thank you about the caveat about reserved registers. </div><div><br><br><div class="gmail_quote">On Fri, Sep 3, 2010 at 2:54 PM, Jim Grosbach <span dir="ltr"><<a href="mailto:grosbach@apple.com">grosbach@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im"><br>
On Sep 3, 2010, at 10:46 AM, Jeff Kunkel wrote:<br>
<br>
> It's not too much of a problem then. I can make a DenseMap between the registers and my registers. It's just one more intermediate step for a lookup.<br>
><br>
> I wish to mimic all the of the registers on the machine with my std::vector<RegisterInfo> RegisterIndexes; vector. Then when a register is used I can assign it easily. I know about alias register and those are taken care of ever so cleverly.<br>

<br>
</div>Is this because you want to control the order in which the physical registers are allocated? If so, it'll normally  be better to use the TargetRegisterClass::allocation_order_begin() and allocation_order_end() functions to control that. These can be overridden directly in the .td file (see the ARMRegisterInfo.td file for examples) if you want. Other pieces of the compiler also use those iterators to walk the available registers in a register class for local allocation needs, so it's best to keep that logic together (the register scavenger and the anti-dependency breaker, in particular, use them).<br>

<br>
Within a register class, the registers will be sorted by name, so if they're named generically ("R0, R1, R2..."), they'll be ordered as you'd expect (including knowing that R10 > R1, I believe). The default allocation order just has begin() be the first register of the class and end() be one past the last register in the class (i.e., it's all the registers in the register class, in order).<br>

<br>
One thing to keep in mind is that the an allocator should explicitly check for reserved registers and avoid allocating them. Allocation orders are not required to omit reserved registers (although some do). See the recent series of patches the RegAlloc*.cpp for reference.<br>

<br>
Regards,<br>
<font color="#888888">  Jim<br>
</font><div><div></div><div class="h5"><br>
><br>
> If this can be done without an extra lookup, it would improve performance. I have one too many as is in some parts.<br>
><br>
> Thanks,<br>
> Jeff Kunkel<br>
><br>
> On Fri, Sep 3, 2010 at 12:57 PM, Jim Grosbach <<a href="mailto:grosbach@apple.com">grosbach@apple.com</a>> wrote:<br>
> TargetRegisterInfo::getNumRegs().<br>
><br>
> Generally, it's best not to make any assumptions about the internal ordering or numbering if you can avoid it. What are you looking to do?<br>
><br>
> -Jim<br>
><br>
> On Sep 3, 2010, at 9:37 AM, Jeff Kunkel wrote:<br>
><br>
> > How do I get the total number of machine registers? I have currently a MachineFunction and some derivatives.<br>
> ><br>
> > How are the machine registers ordered internally? Can I index them off of a zero based array or do I have to create a map to have them be zero based?<br>
> ><br>
> > Thanks,<br>
> > Jeff Kunkel<br>
> > _______________________________________________<br>
> > LLVM Developers mailing list<br>
> > <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div>