This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Implement more of the ABI
ClosedPublic

Authored by wangleiat on Jul 21 2022, 4:40 AM.

Details

Summary

According to the description of the LoongArch abi documentation,
(https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html)
the calling convention of LoongArch is almost the same as the RISCV's
(except for the vector part), so we borrow the implementation of RISCV.

This patch only guarantees the correctness of lp64d, because only the
part of lp64d is described in detail in the documentation.

Depends on D130248

Diff Detail

Event Timeline

wangleiat created this revision.Jul 21 2022, 4:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 21 2022, 4:40 AM
wangleiat requested review of this revision.Jul 21 2022, 4:40 AM

I've lightly checked the test cases and they seem good, thanks.

The patch seems to be implementing more of the necessary ABI handling, not "improvement", so maybe a summary of "[LoongArch] Implement more of the ABI" is more appropriate.

llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
837

duplicate word

845

nit: please rephrase, aren't all FPRs treated as non-existent on soft-float ABIs? Maybe moving this to the front of the sentence is better.

907–908

nit: singular form for "no": "no FPR is"

BTW you can use GPR and FPR across the whole patch to shorten lines. People working with this code are expected to understand such abbreviations (and many more).

918

"Unimplemented" would be better?

1029–1036

bit-cast?

Thank you very much for your comments and I will revise these.

llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
837

thanks

845

thanks

907–908

thanks

918

thanks

1029–1036

thanks again :)

Address @xen0n's comments.

wangleiat retitled this revision from [LoongArch] Improve the calling convention to [LoongArch] Implement more of the ABI.Jul 31 2022, 11:58 PM
xen0n accepted this revision.Aug 1 2022, 12:02 AM

LGTM, thanks. Let's wait a bit for others' opinions though.

This revision is now accepted and ready to land.Aug 1 2022, 12:02 AM
xen0n added inline comments.Aug 4 2022, 4:49 AM
llvm/test/CodeGen/LoongArch/calling-conv-lp64d.ll
505

Hmm. Check returning doubles could be better, I was bored just now and decided to review the pending LLVM changes once more, then I misunderstood this as "double IR ret insns" which is obviously impossible.

wangleiat updated this revision to Diff 450213.Aug 4 2022, 8:03 PM

Address @xen0n's comment, Thanks.

This revision was landed with ongoing or failed builds.Aug 5 2022, 12:15 AM
This revision was automatically updated to reflect the committed changes.