Thanks for the information.<div><br></div><div>I still don't know how do I partition registers into different classes from the virtual registers? For instance, I have the function who which iterates over the instructions, but I don't know how to write the function which returns the different register class.</div>
<div><br></div><div><div>void RAOptimal::Gather(MachineFunction &Fn) {</div><div>    // Gather just iterates over the blocks, basicblocks, ect. until </div><div>    // it finds the MachineOperand. When it finds the operand, it</div>
<div>    // checks to see if the operand is a register, if so, it parses</div><div>    // the register to find which set it is suppose to be in.</div><div><br></div><div>    // time is an artificial time used to denote whether an operand came</div>
<div>    // before or after another operand.</div><div>    unsigned time;</div><div>    time = 0; // Initialize time.</div><div><br></div><div>    // For each block:</div><div>    for( MachineFunction::iterator mfi=Fn.begin(), mfe=Fn.end(); mfi != mfe; ++mfi ) {</div>
<div>        // for each byte code line:</div><div>        for( MachineBasicBlock::iterator mbbi = mfi->begin(), mbbe = mfi->end(); mbbi != mbbe; ++mbbi ) {</div><div>            // for each variable used:</div><div>
            for( int opi=0, ope=mbbi->getNumOperands(); opi != ope; ++opi ) {</div><div>                // Get the variable</div><div>                const MachineOperand mop = mbbi->getOperand( opi );</div><div>                // If it is a register, notify the class.</div>
<div>                if( mop.isReg() ) {</div><div>                    // DEBUG( dbgs() << "Found the register " << mop );</div><div>                    if( mop.isDef() || mop.isUse() ) {</div><div>                        // The instruction has defined the register.</div>
<div>                        // Or, the instruction uses the register.</div><div>                        unsigned reg = mop.getReg();</div><div><b>                        <u>unsigned set = who(Fn, mbbi, mop, reg);</u></b></div>
<div>                        RegisterSets[ set ].Notify( reg, time, mbbi );</div><div>                        // Increment time after each Notify to keep the reg's times from</div><div>                        // overlapping.</div>
<div>                        ++time;</div><div>                    } else {</div><div>                        assert( 0 && "The register is always defining or used." );</div><div>                    }</div>
<div>                }</div><div>            }</div><div>        }</div><div>    }</div><div>}</div><div><br></div><div>Thanks, <br>Jeff Kunkel</div><br><div class="gmail_quote">On Sun, Aug 29, 2010 at 8:45 AM, Gergö Barany <span dir="ltr"><<a href="mailto:gergo@complang.tuwien.ac.at">gergo@complang.tuwien.ac.at</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">On Sat, Aug 28, 2010 at 16:20:42 -0400, Jeff Kunkel wrote:<br>
> What I need to know is how to access the machine register classes. Also, I<br>
> need to know which virtual register is to be mapped into each specific<br>
> register class. I assume there is type information on the registers. I need<br>
> to know how to access it.<br>
<br>
</div>MachineRegisterInfo::getRegClass will give you the TargetRegisterClass for a<br>
given virtual register. Each TargetRegisterClass has an "allocation order"<br>
that enumerates all physical registers valid for that class.<br>
<div class="im"><br>
> And a afterthought, does LLVM place casts into<br>
> different virtual registers, or do I need to include casting of floats to<br>
> integers or vice versa when I see ADD i32 float i32?<br>
<br>
</div>The instruction selector creates all necessary conversion instructions.<br>
<font color="#888888"><br>
--<br>
Gergö Barany, research assistant                   <a href="mailto:gergo@complang.tuwien.ac.at">gergo@complang.tuwien.ac.at</a><br>
Institute of Computer Languages        <a href="http://www.complang.tuwien.ac.at/gergo/" target="_blank">http://www.complang.tuwien.ac.at/gergo/</a><br>
Vienna University of Technology                         Tel: +43-1-58801-58522<br>
Argentinierstrasse 8/E185, 1040 Wien, Austria           Fax: +43-1-58801-18598<br>
</font></blockquote></div><br></div>