This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Fix test for inline asm z constraint modifier
ClosedPublic

Authored by luismarques on Jan 3 2020, 2:52 AM.

Details

Summary

The inline assembly z constraint modifier is handled by the following code in RISCVAsmPrinter.cpp:

case 'z':      // Print zero register if zero, regular printing otherwise.
  if (MO.isImm() && MO.getImm() == 0) {
    OS << RISCVInstPrinter::getRegisterName(RISCV::X0);
    return false;
  }
  break;

Because the test was using an r operand constraint, the condition MO.isImm() wouldn't trigger, so we didn't actually have a test for the z modifier. The zero we were seeing in the test CHECK line was unrelated to the modifier, and would even persist if the modifier wasn't used.

This patch changes the relevant tests to use an i constraint, which does trigger the z constraint modifier handling code.

Diff Detail

Event Timeline

luismarques created this revision.Jan 3 2020, 2:52 AM
lenary accepted this revision.Jan 13 2020, 5:47 AM

LGTM. Please wait for @jrtc27 to approve this before landing.

This revision is now accepted and ready to land.Jan 13 2020, 5:47 AM
jrtc27 accepted this revision.Jan 14 2020, 3:13 AM

Oh, yes, that was silly.

This revision was automatically updated to reflect the committed changes.