This is an archive of the discontinued LLVM Phabricator instance.

[mips] Add a -mmips3d command line option to clang
Needs ReviewPublic

Authored by michael-roe on Nov 1 2020, 12:46 PM.

Details

Reviewers
atanasyan

Diff Detail

Event Timeline

michael-roe created this revision.Nov 1 2020, 12:46 PM
michael-roe requested review of this revision.Nov 1 2020, 12:46 PM
michael-roe retitled this revision from [mips] to [mips] Add a -mmips3d command line option to clang.
michael-roe added a reviewer: atanasyan.
michael-roe set the repository for this revision to rG LLVM Github Monorepo.
Herald added a project: Restricted Project. · View Herald TranscriptNov 1 2020, 12:48 PM

What's a goal of this change? Do you want to suppress an error message when the option provided to Clang? If so, is it a real-life case?

michael-roe added a comment.EditedNov 3 2020, 10:47 AM

The goal of this patch is that if you have some C code with inline MIPS assembly language that uses MIPS3D instructions, you can get it to compile by passing -mmips3d on the command line. (Without this command line option, there's an awkward workaround that involves putting .set mips3d in your inline assembly language).

I will admit that not many MIPS cores support MIPS3D. The CHERI MIPS FPGA soft core, which may be one of the few remaining MIPS cores that anyone still cares about, currently supports the MIPS V paired single instructions but not (at present) MIPS3D, though instructions can easily be added.

The high-level view of the use case is digital signal processing code that can benefit from using MIPS3D in a few critical loops, running on a MIPS soft core that can be configured to support the desired instructions.

My bad, I missed that you implemented passing the option to backend.

Could you add some improvements to the patch?

  1. As far as I know GCC does not accept -mmips3d option. It uses -mips3d. We need do the same.
  1. Add test cases. For the reference you might take a look at the -mdspr2 option in the following tests:
test/Driver/mips-as.c
test/Driver/mips-features.c
test/Driver/mips-integrated-as.c
  1. GCC defines #define __mips3d 1 macro when the -mips3d option is provided. Take a look at the MipsTargetInfo::getTargetDefines() as a point for implementation.
  1. As far as I remember MIPS 3D requires 64-bit floating-point registers. We need to check that 64-bit is enabled and show an error otherwise like GCC does.

3 and 4 need test cases.

Thanks!

I agree with those changes; I'll implement them and then resubmit a patch.