This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][MC] Allow symbol diff expression directly as LI operand
AbandonedPublic

Authored by jobnoorman on Aug 25 2023, 3:09 AM.

Details

Summary

D135960 implemented support for symbol differences as an operand of LI.
However, it only worked when the symbol difference expression was first
stored in a symbol using .set/.equ. This patch makes sure the
expression can be used directly as an LI operand.

Note that when using -filetype=asm, the instruction printer is not
able to convert the generated ADDI back to LI, presumably because the
symbol difference expression is not recognized as an simm12 so the
alias does not match. This means a .s -> .s round-trip produces an
ADDI instruction where there used to be an LI. Since ADDI doesn't
currently accept symbol difference expressions, the result of the
round-trip is rejected by MC.

I'm not quite sure what the best way forward is here. Is there a way to
recognize this alias without implementing support for symbol differences
for ADDI (which would be a separate patch)? Or can we just ignore this
issue for now as it seems unlikely to cause problems?

Fixes #64623

Diff Detail

Event Timeline

jobnoorman created this revision.Aug 25 2023, 3:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2023, 3:09 AM
jobnoorman requested review of this revision.Aug 25 2023, 3:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2023, 3:09 AM

FYI: I think D157694 is related.

FYI: I think D157694 is related.

Thanks for that! That patch covers the case here as well so might be preferable. If it gets accepted, I'll modify this patch to only keep the test cases.

From discussing out-of-band with @jobnoorman we think D157694 augmented with the test cases from this patch is probably the way to go.

jobnoorman abandoned this revision.Sep 6 2023, 12:59 AM

Abandon in favor of D157694.