Jeff Kunkel
2010-Aug-31 19:26 UTC
[LLVMdev] [LLVMDev] [Question] The TargetRegisterClass has a confusing method.
The method below takes in a register and returns a register. To me this makes no sense because when I already have a register, why would I need to get it? Could someone please explain the transformation that is happening here? /// getRegister - Return the specified register in the class. /// unsigned getRegister(unsigned i) const { assert(i < getNumRegs() && "Register number out of range!"); return RegsBegin[i]; } -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100831/facf3c3c/attachment.html>
Bill Wendling
2010-Aug-31 20:29 UTC
[LLVMdev] [LLVMDev] [Question] The TargetRegisterClass has a confusing method.
On Aug 31, 2010, at 12:26 PM, Jeff Kunkel wrote:> The method below takes in a register and returns a register. To me this makes no sense because > when I already have a register, why would I need to get it? Could someone please explain the > transformation that is happening here? > > /// getRegister - Return the specified register in the class. > /// > unsigned getRegister(unsigned i) const { > assert(i < getNumRegs() && "Register number out of range!"); > return RegsBegin[i]; > } >The "i" in here isn't the register but an index into the RegsBegin array. -bw
Jeff Kunkel
2010-Sep-01 10:46 UTC
[LLVMdev] [LLVMDev] [Question] The TargetRegisterClass has a confusing method.
Aye, I understand it's an index into an array, but what is the difference between the index i and the return value. Do I have to worry that register values from a TargetRegisterClass could be either zero based or some other base? Are there other methods that rely on zero based in the TargetRegisterClass? I thought register values were "global," but this transformation makes a register value dependent on it's TargetRegisterClass. Basically, I find it confusing to have two integer indexes for the same value. On Tue, Aug 31, 2010 at 3:26 PM, Jeff Kunkel <jdkunk3 at gmail.com> wrote:> The method below takes in a register and returns a register. To me this > makes no sense because > when I already have a register, why would I need to get it? Could someone > please explain the > transformation that is happening here? > > /// getRegister - Return the specified register in the class. > /// > unsigned getRegister(unsigned i) const { > assert(i < getNumRegs() && "Register number out of range!"); > return RegsBegin[i]; > } > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100901/71bf0fc7/attachment.html>
Bill Wendling
2010-Sep-02 00:27 UTC
[LLVMdev] [LLVMDev] [Question] The TargetRegisterClass has a confusing method.
The registers themselves are part of a "register class". They may not start at 0 and may not be in order. For instance, target classes for control registers, floating point registers, etc. Look at the "*.inc" files in one of the back-ends for examples of how the TargetRegisterClass objects are created. They are in the build directory under lib/Target/X86/X86Gen*.inc (replace X86 with your favorite architecture). -bw On Sep 1, 2010, at 3:46 AM, Jeff Kunkel wrote:> Aye, I understand it's an index into an array, but what is the difference between the index i and the return value. > > Do I have to worry that register values from a TargetRegisterClass could be either zero based or some other base? Are there other methods that rely on zero based in the TargetRegisterClass? > > I thought register values were "global," but this transformation makes a register value dependent on it's TargetRegisterClass. > > Basically, I find it confusing to have two integer indexes for the same value. > > > On Tue, Aug 31, 2010 at 3:26 PM, Jeff Kunkel <jdkunk3 at gmail.com> wrote: > The method below takes in a register and returns a register. To me this makes no sense because > when I already have a register, why would I need to get it? Could someone please explain the > transformation that is happening here? > > /// getRegister - Return the specified register in the class. > /// > unsigned getRegister(unsigned i) const { > assert(i < getNumRegs() && "Register number out of range!"); > return RegsBegin[i]; > } > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Apparently Analagous Threads
- [LLVMdev] [LLVMDev] [Question] The TargetRegisterClass has a confusing method.
- [LLVMdev] The type or size of virtual registers
- [LLVMdev] [Query] Programming Register Allocation
- [LLVMdev] [LLVMDev] [Question] How do I get the number of machine registers.
- [LLVMdev] [LLVMDev] [Question] How do I get the number of machine registers.