[llvm-commits] [llvm] r114429 - in /llvm/trunk: include/llvm/CodeGen/PBQP/Heuristics/Briggs.h include/llvm/CodeGen/RegAllocPBQP.h lib/CodeGen/RegAllocPBQP.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Tue Sep 21 07:41:39 PDT 2010


On Sep 21, 2010, at 6:19 AM, Lang Hames wrote:

> Author: lhames
> Date: Tue Sep 21 08:19:36 2010
> New Revision: 114429
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=114429&view=rev
> Log:
> Added an additional PBQP problem builder which adds coalescing costs (both between pairs of virtuals, and between virtuals and physicals).

> +std::auto_ptr<PBQPRAProblem> PBQPBuilderWithCoalescing::build(
> +                                                MachineFunction *mf,
> +                                                const LiveIntervals *lis,
> +                                                const MachineLoopInfo *loopInfo,
> +                                                const RegSet &vregs) {
> +
> +  std::auto_ptr<PBQPRAProblem> p = PBQPBuilder::build(mf, lis, loopInfo, vregs);
> +  PBQP::Graph &g = p->getGraph();
> +
> +  const TargetMachine &tm = mf->getTarget();
> +  CoalescerPair cp(*tm.getInstrInfo(), *tm.getRegisterInfo());

Yay!

> +
> +  // Scan the machine function and add a coalescing cost whenever CoalescerPair
> +  // gives the Ok.
> +  for (MachineFunction::const_iterator mbbItr = mf->begin(),
> +                                       mbbEnd = mf->end();
> +       mbbItr != mbbEnd; ++mbbItr) {
> +    const MachineBasicBlock *mbb = &*mbbItr;
> +
> +    for (MachineBasicBlock::const_iterator miItr = mbb->begin(),
> +                                           miEnd = mbb->end();
> +         miItr != miEnd; ++miItr) {
> +      const MachineInstr *mi = &*miItr;
> +
> +      if (!mi->isCopy() && !mi->isSubregToReg())
> +        continue; // Not coalescable.

This is pretty much the first line of setRegisters(), but it is harmless.

> +      if (!cp.setRegisters(mi))
> +        continue; // Not coalescable.
> +
> +      if (cp.getSrcReg() == cp.getDstReg())
> +        continue; // Already coalesced.
> +
> +      if (cp.isCoalescable(mi)) {

Note that isCoalescable(mi) is implied by setRegisters(mi) returning true. This method is intended to check whether a second copy instruction is compatible with the one given to setRegisters. Is is possible to have a copy between src and dst that is not compatible - it may copy different subregisters.

> +
> +        unsigned dst = cp.getDstReg(),
> +                 src = cp.getSrcReg();
> +

CoalescerPair can also handle subregister joins. In that case SrcReg is joined with a subregister of DstReg indicated by getSubIdx().

This is only relevant when joining two virtual registers. When DstReg is a physreg, it is simply adjusted so no SubIdx is necessary.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100921/53f462f1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100921/53f462f1/attachment.bin>


More information about the llvm-commits mailing list