This is an archive of the discontinued LLVM Phabricator instance.

MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple
ClosedPublic

Authored by wzssyqa on Mar 16 2023, 7:20 PM.

Details

Summary

In general, MIPS support ELF format like

ELF 32-bit LSB relocatable, MIPS, MIPS64 rel2 version 1 (SYSV)

and Linux's VDSO uses it.

Currently clang stop CMDs like

clang -march=mips64r2 -mabi=32

While it is not needed now, since the the backend support the combination now.

This patch also allows something like

clang --target=mipsel-linux-gnu -mabi=64

Since the triple can convert to right 64bit one automaticly.

Diff Detail

Event Timeline

wzssyqa created this revision.Mar 16 2023, 7:20 PM
wzssyqa requested review of this revision.Mar 16 2023, 7:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 16 2023, 7:20 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
wzssyqa retitled this revision from MIPS: allow o32 abi with 64bit CPU to MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple.Mar 16 2023, 7:24 PM
wzssyqa edited the summary of this revision. (Show Details)
wzssyqa updated this revision to Diff 506482.Mar 20 2023, 12:50 AM

Tests?

Added.

wzssyqa updated this revision to Diff 506814.Mar 20 2023, 6:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 20 2023, 6:41 PM
wzssyqa updated this revision to Diff 506838.Mar 20 2023, 8:45 PM

ping

@MaskRay is offline until Tuesday April 11.

MaskRay accepted this revision.Apr 18 2023, 7:40 PM
MaskRay added inline comments.
llvm/lib/Target/Mips/MipsSubtarget.cpp
107
This revision is now accepted and ready to land.Apr 18 2023, 7:40 PM
wzssyqa updated this revision to Diff 516277.Apr 23 2023, 11:07 PM
wzssyqa marked an inline comment as done.

@MaskRay can you help to submit this patch?

MaskRay added inline comments.Apr 27 2023, 9:23 PM
clang/test/Driver/mips-cpu64abi32.c
2

Use /// for non-CHECK non-RUN comments.

6

-target is legacy. Use --target=.

Driver tests should not test code generation. Just check that %clang ... passes the right options to cc1.

10

Don't add ^//$ lines. Just use a blank line.

wzssyqa updated this revision to Diff 517903.Apr 28 2023, 6:48 AM
wzssyqa marked 2 inline comments as done.Apr 29 2023, 7:18 PM
wzssyqa marked an inline comment as done.

Is this the new GCC behavior?

clang -target mipsel-linux-gnu -mabi=64

Use --target=

wzssyqa edited the summary of this revision. (Show Details)May 16 2023, 3:15 PM

Is this the new GCC behavior?

Marking o32 objects with 64bit CPU is a long history gas behaviour, maybe appeared in 1990s, or even in the era of Irix.
I guess the reason is that to achive something like:

-mabi=32 -march=octeon

Octeon is a 64bit CPU.
Since no matter about the -march value, due to all of them are using o32 abi,
they can interlink.
And thus Linux kernel uses this behaviour.

clang -target mipsel-linux-gnu -mabi=64

Use --target=

Done

This revision was landed with ongoing or failed builds.May 16 2023, 3:31 PM
This revision was automatically updated to reflect the committed changes.