This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Move printing MO_Immediate operands to MachineOperand::print
ClosedPublic

Authored by thegameg on Dec 7 2017, 9:17 AM.

Details

Reviewers
MatzeB
qcolombet
Summary

Work towards the unification of MIR and debug output by refactoring the interfaces.

Add support for operand subreg index as an immediate to debug printing and use ::print in the MIRPrinter.

No tests were affected as all the %subreg. tests were all checking MIR output.

Diff Detail

Event Timeline

thegameg created this revision.Dec 7 2017, 9:17 AM
thegameg updated this revision to Diff 125982.Dec 7 2017, 9:29 AM

Make MIRLangRef more clear about subreg index immediate operands.

MatzeB added inline comments.Dec 7 2017, 10:35 AM
include/llvm/CodeGen/MachineOperand.h
248–259

Would it make sense to move the subreg index printing into its own function instead of a toggle flag? As in that case most of the other arguments won't be used.

lib/CodeGen/MachineInstr.cpp
1262–1266

This case must be a register def I think, so it cannot be a subregidx operand.

1295–1299

An ASM also wouldn't have subregidx operands.

1345–1348

DBG_VALUEs also don't have subregidx operands.

thegameg updated this revision to Diff 126107.Dec 8 2017, 2:43 AM
thegameg marked 4 inline comments as done.
MatzeB accepted this revision.Dec 8 2017, 1:04 PM

LGTM

lib/CodeGen/MIRPrinter.cpp
857–868

I guess this could be:

case MachineOperand::MO_Immediate:
  if (MI.isOperandSubregIdx(OpIdx)) {
    printSubReg();
    break;
   }
   LLVM_FALLTHROUGH;
case MachineOperand::MO_Register:
   //...
This revision is now accepted and ready to land.Dec 8 2017, 1:04 PM
thegameg closed this revision.Dec 8 2017, 2:59 PM
thegameg marked an inline comment as done.

Committed as r320209: [CodeGen] Move printing MO_Immediate operands to MachineOperand::print (failed the commit message...)