This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add pseudo instruction for calls with explicit register
ClosedPublic

Authored by lewis-revill on May 30 2019, 8:57 AM.

Details

Summary

This patch adds the PseudoCALLReg instruction which allows using an explicit register operand as the destination for the return address.

GCC can successfully parse this form of the call instruction, which would be used for calls to functions which do not use ra as the return address register, such as the __riscv_save libcalls. This patch forms the first part of an implementation of -msave-restore for RISC-V.

Diff Detail

Repository
rL LLVM

Event Timeline

lewis-revill created this revision.May 30 2019, 8:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 30 2019, 8:57 AM
asb accepted this revision.Jun 18 2019, 9:35 AM

This looks good to me if you make the following minor changes:

  • add a test for call a0, foo@plt
  • add negative tests to function-call-invalid.s as well e.g. call foo, bar etc.

Thanks!

This revision is now accepted and ready to land.Jun 18 2019, 9:35 AM

Should the error change at all? We'll still get 'error: operand must be a bare symbol name' for call foo, bar. I guess this patch doesn't put us in a greate situation now that parseCallSymbol can return NoMatch even though technically we parsed a call symbol...

asb added a comment.Jun 19 2019, 8:48 AM

Should the error change at all? We'll still get 'error: operand must be a bare symbol name' for call foo, bar. I guess this patch doesn't put us in a greate situation now that parseCallSymbol can return NoMatch even though technically we parsed a call symbol...

The error message could certainly be improved, but I don't mind that it's not perfect for those sort of edge case inputs - just that we check an error is produced and we don't get some weird internal assert or anything.

Added additional tests

Quick end-of-file newline fix

This revision was automatically updated to reflect the committed changes.