This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Handle FRMArg as an optional operand instead of using InstAliases.
ClosedPublic

Authored by craig.topper on Jan 31 2023, 1:08 AM.

Details

Summary

Instead of having InstAliases without operand. Use the optional
operand infrastructure.

Still use the PrintAliases/NoAlias controls to determine if we
print "dyn" or not.

Diff Detail

Event Timeline

craig.topper created this revision.Jan 31 2023, 1:08 AM
craig.topper requested review of this revision.Jan 31 2023, 1:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 31 2023, 1:08 AM
asb accepted this revision.Jan 31 2023, 2:06 AM

Yet another nice cleanup - thanks!

This revision is now accepted and ready to land.Jan 31 2023, 2:06 AM
This revision was landed with ongoing or failed builds.Jan 31 2023, 9:08 AM
This revision was automatically updated to reflect the committed changes.
joshua-arch1 added a subscriber: joshua-arch1.EditedJan 31 2023, 7:26 PM
void RISCVInstPrinter::printFRMArg(const MCInst *MI, unsigned OpNo,
                                   const MCSubtargetInfo &STI, raw_ostream &O) {
  auto FRMArg =
      static_cast<RISCVFPRndMode::RoundingMode>(MI->getOperand(OpNo).getImm());
  if (PrintAliases && !NoAliases && FRMArg == RISCVFPRndMode::RoundingMode::DYN)
    return;
  O << ", " << RISCVFPRndMode::roundingModeToString(FRMArg);
}

In printFRMArg(), there is an extra "," before the FRM output. Why?
e.g. I get fcvtmod.w.d a1, ft1, , rtz for the MC output.

void RISCVInstPrinter::printFRMArg(const MCInst *MI, unsigned OpNo,
                                   const MCSubtargetInfo &STI, raw_ostream &O) {
  auto FRMArg =
      static_cast<RISCVFPRndMode::RoundingMode>(MI->getOperand(OpNo).getImm());
  if (PrintAliases && !NoAliases && FRMArg == RISCVFPRndMode::RoundingMode::DYN)
    return;
  O << ", " << RISCVFPRndMode::roundingModeToString(FRMArg);
}

In printFRMArg(), there is an extra "," before the FRM output. Why?
e.g. I get fcvtmod.w.d a1, ft1, , rtz for the MC output.

Need to remove the comma from the AsmString on the instruction as I did in this patch