This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Implement handling of triple-implied ABIs
ClosedPublic

Authored by xen0n on Jan 26 2023, 8:43 PM.

Details

Summary

According to the LoongArch Toolchain Conventions
it is possible to specify the ABI modifier (the "D" part of "LP64D")
via the environment field in the target triple. This is needed for
proper support for Debian-style multiarch tuples as well, so add triple
awareness to LoongArchSubtarget via addition of
LoongArchABI::computeTargetABI. Let the explicit --target-abi
argument intuitively take precedence over the triple-implied ABI.

Diff Detail

Event Timeline

xen0n created this revision.Jan 26 2023, 8:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2023, 8:43 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
xen0n requested review of this revision.Jan 26 2023, 8:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2023, 8:43 PM

Thanks. Overall LGTM except the handling of FeatureBits (maybe can be handled in a seperate patch) and some nits.

llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchBaseInfo.cpp
24

Shall we handle FeatureBits as well?

50–52

Missing test?

llvm/test/CodeGen/LoongArch/target-abi-from-triple.ll
2

Is this test autogenerated?

3

I'm not sure whether we should add tests causing crash that may slow down testing. I remeber @MaskRay once suggested me not to do so.

81–85

Are these lines useful?

xen0n added inline comments.Jan 29 2023, 5:51 AM
llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchBaseInfo.cpp
24

I saw RISCV include FeatureBits in their computeTargetABI, but right now we're not making use of it (we don't base our selection of bitness on the parsed FeatureBits). I'd say let's add it later when needed.

50–52

Thanks for checking, I'll cover this branch later.

llvm/test/CodeGen/LoongArch/target-abi-from-triple.ll
2

The generated code is, but the other isn't. Given you already hesitated on this matter, let me adjust then.

3

I vaguely remember such an occasion too, let me remove the crash assertions and replace with simple comments then. It's not like I'm not coming back to remove the TODOs ;-)

81–85

They're added automatically by the update_llc_test_checks.py script. I'll remove them.

xen0n updated this revision to Diff 493795.Jan 31 2023, 5:35 PM
xen0n marked 4 inline comments as done.

rebase and update testcase

SixWeining accepted this revision.Jan 31 2023, 5:41 PM

LGTM. Thanks!

This revision is now accepted and ready to land.Jan 31 2023, 5:41 PM