[PATCH] [FastISel][X86] Constrain register operand class in foldOperandImpl

Pete Cooper peter_cooper at apple.com
Mon Jun 8 19:56:15 PDT 2015


> On Jun 8, 2015, at 7:28 PM, Keno Fischer <kfischer at college.harvard.edu> wrote:
> 
> The `i` in the for loop is actually required as it's passed into `constrainOperandRegClass`.
Ah, no worries in that case then.
> For the other one, the success case of `constrainRegClass`, does also lead to the second return statement, so I think it's cleaner this way than
> 
>  unsigned MachineRegisterInfo::constrainOperandRegClass(
>      MachineFunction &MF, MachineBasicBlock::iterator InsertPt, DebugLoc DL,
>      const MCInstrDesc &II, unsigned Op, unsigned OpNum,
>      const TargetInstrInfo &TII, const TargetRegisterInfo &TRI) {
>    if (!TargetRegisterInfo::isVirtualRegister(Op))
>      return Op;
>    const TargetRegisterClass *RegClass = TII.getRegClass(II, OpNum, &TRI, MF);
>    if (constrainRegClass(Op, RegClass))
>      return Op;
>    // If it's not legal to COPY between the register classes, something
>    // has gone very wrong before we got here.
>    unsigned NewOp = createVirtualRegister(RegClass);
>    BuildMI(*InsertPt->getParent(), InsertPt, DL, TII.get(TargetOpcode::COPY),
>            NewOp)
>        .addReg(Op);
>    return NewOp;
>  }
> 
> but I have no strong opinion.
I prefer the above, but not strongly.  If you have a preference just go for it.

Cheers,
Pete
> 
> 
> REPOSITORY
>  rL LLVM
> 
> http://reviews.llvm.org/D6262
> 
> EMAIL PREFERENCES
>  http://reviews.llvm.org/settings/panel/emailpreferences/
> 
> 





More information about the llvm-commits mailing list