This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Allow parsing dot '.' in assembly
ClosedPublic

Authored by JohnLLVM on Jun 21 2019, 1:38 PM.

Details

Summary

Useful for jumps, such as j ..

I am not sure who should review this. Do not hesitate to change the reviewers if needed.

Diff Detail

Event Timeline

JohnLLVM created this revision.Jun 21 2019, 1:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 21 2019, 1:38 PM

Ping on this?

lenary added a subscriber: lenary.Jul 3 2019, 3:38 AM

This looks good! It seems to match what other implementations do, so I'd be happy for this to land.

lenary accepted this revision.Jul 3 2019, 3:39 AM
lenary added a reviewer: lenary.
lenary requested changes to this revision.Jul 3 2019, 3:52 AM

Ok, after further discussion, I'm not sure about the test coverage of this change.

  1. The tests you've added should probably go with the other tests of the j instruction in llvm/test/MC/RISCV/rvi-aliases-valid.s (and should match the others in that file).
  2. Please add a test of jalr %lo(.) to rv32i-valid.s. This will test that . can go in more complex places, and is not an instruction alias.
  3. Please add a test to rv32i-aliases-invalid.s to test something like addi x1, . which will show what happens if someone provides . as an immediate somewhere that doesn't make sense.
This revision now requires changes to proceed.Jul 3 2019, 3:52 AM
JohnLLVM updated this revision to Diff 208504.Jul 8 2019, 2:15 PM

Address feedback.

JohnLLVM added a comment.EditedJul 8 2019, 2:17 PM
  1. The tests you've added should probably go with the other tests of the j instruction in llvm/test/MC/RISCV/rvi-aliases-valid.s (and should match the others in that file).

Done. I have left a single one in the non-alias file, which I have reworked to not use an alias: this way, we also have an encoding test.

  1. Please add a test of jalr %lo(.) to rv32i-valid.s. This will test that . can go in more complex places, and is not an instruction alias.

These advanced cases are not handled by this review (even j .+4 does not work). I intend to look at it after this review; currently, I am not sure how to proceed.

  1. Please add a test to rv32i-aliases-invalid.s to test something like addi x1, . which will show what happens if someone provides . as an immediate somewhere that doesn't make sense.

Done.

JohnLLVM marked an inline comment as done.Jul 8 2019, 2:18 PM
JohnLLVM added inline comments.
llvm/test/MC/RISCV/rvi-aliases-valid.s
121 ↗(On Diff #208504)

I am not sure if .Ltmp0 if robust enough for tests. If not, what should go here?

JohnLLVM marked an inline comment as not done.Jul 8 2019, 2:18 PM
jrtc27 added inline comments.Jul 8 2019, 2:31 PM
llvm/test/MC/RISCV/rvi-aliases-valid.s
121 ↗(On Diff #208504)

You could do something like:

# CHECK-S-NOALIAS: [[LABEL:.L[[:alnum:]_]+]]:
# CHECK-S-NOALIAS-NEXT: jal zero, [[LABEL]]
# CHECK-S: [[LABEL:.L[[:alnum:]_]+]]:
# CHECK-S-NEXT: j [[LABEL]]
lenary accepted this revision.Jul 9 2019, 2:28 AM

If you make the test change suggested by @jrtc27, I'm happy for this to land.

This revision is now accepted and ready to land.Jul 9 2019, 2:28 AM
JohnLLVM updated this revision to Diff 209056.Jul 10 2019, 1:39 PM

Feedback from @jrtc27.

JohnLLVM updated this revision to Diff 209057.Jul 10 2019, 1:40 PM

Feedback from @jrtc27.

JohnLLVM added a comment.EditedJul 10 2019, 1:42 PM

@jrtc27: done, thanks!

@lenary: done. I do not have commit rights, so I cannot land it myself.

This revision was automatically updated to reflect the committed changes.