This is an archive of the discontinued LLVM Phabricator instance.

[MachineInstr] Implement new operand accessors all_defs and all_uses
ClosedPublic

Authored by foad on May 25 2023, 4:28 AM.

Diff Detail

Event Timeline

foad created this revision.May 25 2023, 4:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2023, 4:28 AM
Herald added a subscriber: StephenFan. · View Herald Transcript
foad requested review of this revision.May 25 2023, 4:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2023, 4:28 AM

Q: What is the type of auto? Can it be spelled explicitly or is it unspellable?

I guess the overloads should also be doxygenated? (Methods above use @copydoc).

foad added a comment.May 25 2023, 5:47 AM

Q: What is the type of auto? Can it be spelled explicitly or is it unspellable?

I'm sure it can be spelled. See other methods that use make_filter_range like:

iterator_range<filter_iterator<const MachineOperand *,
                               std::function<bool(const MachineOperand &Op)>>>
getDebugOperandsForReg(Register Reg) const {
  return MachineInstr::getDebugOperandsForReg<const MachineOperand,
                                              const MachineInstr>(this, Reg);
}

But I'm not sure that spelling it out in that much detail is useful. Perhaps there is a simpler type that would work? I don't know.

foad updated this revision to Diff 525565.May 25 2023, 5:51 AM

\copydoc

foad updated this revision to Diff 525580.May 25 2023, 6:36 AM

Here's a version with non-auto return types. I don't love it.

Here's a version with non-auto return types. I don't love it.

I'm fine with auto here, I think this is one of the cases where auto does more good than harm. Also, std::function is not cheap while a lambda can be inlined.
I asked because I thought it could be as simple as iterator_range<const_mop_iterator> above.

qcolombet accepted this revision.Jun 1 2023, 6:39 AM
This revision is now accepted and ready to land.Jun 1 2023, 6:39 AM
foad added a comment.Jun 1 2023, 7:36 AM

@qcolombet I was planning to go back to the previous diff which used auto for the return types: https://reviews.llvm.org/D151423?vs=on&id=525565. Do you have a preference?

@qcolombet I was planning to go back to the previous diff which used auto for the return types: https://reviews.llvm.org/D151423?vs=on&id=525565. Do you have a preference?

I prefer with the explicit types personally.