This is an archive of the discontinued LLVM Phabricator instance.

[X86AsmPrinter] refactor to limit use of Modifier. NFC
ClosedPublic

Authored by nickdesaulniers on Apr 10 2019, 11:31 AM.

Details

Summary

The Modifier memory operands is used in 2 cases of memory references
(H & P ExtraCodes). Rather than pass around the likely nullptr Modifier,
refactor the handling of the Modifier out from printOperand().

The refactorings in this patch:

  • Don't forward declare printOperand, move its definition up.
    • The diff makes it look like there's a change to printPCRelImm (narrator: there's not).
  • Create printModifiedOperand()
    • Move logic for Modifier to there from printOperand
    • Use printModifiedOperand in 3 call sites that actually create Modifiers.
  • Remove now unused Modifier parameter from printOperand
  • Remove default parameter from printLeaMemReference as it only has 1 call site that explicitly passes a parameter.
  • Remove default parameter from printMemReference, make call lone call site explicitly pass nullptr.
  • Drop Modifier parameter from printIntelMemReference, as Intel style memory references don't support the Modifiers in question.

This will allow future changes to printOperand() to make it a pure virtual
method on the base AsmPrinter class, allowing for more generic handling
of some architecture generic constraints. X86AsmPrinter was the only
derived class of AsmPrinter to have additional parameters on its
printOperand function.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptApr 10 2019, 11:31 AM
echristo accepted this revision.Apr 10 2019, 11:53 AM

LGTM. Thanks!

This revision is now accepted and ready to land.Apr 10 2019, 11:53 AM
This revision was automatically updated to reflect the committed changes.