This is an archive of the discontinued LLVM Phabricator instance.

[driver][mips] Adjust target triple accordingly to provided ABI name
ClosedPublic

Authored by atanasyan on Sep 20 2018, 2:09 AM.

Details

Summary

Explicitly selected MIPS ABI using the -mabi option implies corresponding target triple. For 'O32' ABI it's a 32-bit target triple like mips-linux-gnu. For 'N32' and 'N64' ABIs it's a 64-bit target triple like mips64-linux-gnu. This patch adjusts target triple accordingly these rules like we do for pseudo-target flags '-m64', '-m32' etc already.

Diff Detail

Repository
rL LLVM

Event Timeline

atanasyan created this revision.Sep 20 2018, 2:09 AM
rnk added a comment.Sep 25 2018, 9:05 AM

Should --target=mipsZZZ -mabi=n64 be meaningful? What does clang --target=i686-linux-gnu -m64 do? If this matches that, then let's do it.

I think each listed reviewer is currently at CppCon, hence the delay.

In D52290#1245222, @rnk wrote:

Should --target=mipsZZZ -mabi=n64 be meaningful? What does clang --target=i686-linux-gnu -m64 do? If this matches that, then let's do it.

Thanks. Initially I thought that providing different target triple and -mabi option explicitly is an error. But now I see that it's better and consistent with other targets to adjust a target triple accordingly to -mabi options in any (implicit/explicit) case. I will update the patch soon.

atanasyan updated this revision to Diff 167091.Sep 26 2018, 3:17 AM
atanasyan edited the summary of this revision. (Show Details)

Always adjust target triple (explicitly and implicitly provided) accordingly to ABI name.

rnk added inline comments.Sep 26 2018, 11:08 AM
lib/Driver/Driver.cpp
492 ↗(On Diff #167091)

We should emit a diagnostic for invalid -mabi=values.

atanasyan added inline comments.Sep 26 2018, 1:46 PM
lib/Driver/Driver.cpp
492 ↗(On Diff #167091)

We already do that:

$ clang -target mips-linux-gnu -c test.c -mabi=xxx
error: unknown target ABI 'xxx'
rnk accepted this revision.Sep 26 2018, 2:13 PM

Lgtm, thanks!

This revision is now accepted and ready to land.Sep 26 2018, 2:13 PM

Thanks for review.

This revision was automatically updated to reflect the committed changes.
MaskRay added inline comments.
cfe/trunk/lib/Driver/Driver.cpp
486

getLastArg claims the option for non-mips architecture and makes other architectures silently accept unknown -mabi=. This was fixed by D134671.

Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2022, 12:30 PM