Skip to content

Refresh MIPS support #416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Refresh MIPS support #416

wants to merge 7 commits into from

Conversation

SiarheiVolkau
Copy link

This PR address issues with MIPS platform support.

  • minor bug fixes
  • tuning build flags
  • update mips port code
  • resolve build issues

Tests ran in QEMU and on real hardware (MIPS32r2 + DSP, soft-float) and all passed
for both float and fixed versions.

Due to historical reasons __builtin_clz result is undefined for 0.
Fix that in MIPS port.

Signed-off-by: Siarhei Volkau <[email protected]>
silk_CLZ16 MIPS port does sign extension from opus_int16 to opus_int32.
In case of negative input it will return -16 instead of expected 0.

Input should be zero extended for mips_clz / __builtin_clz.

Signed-off-by: Siarhei Volkau <[email protected]>
While 32-bit MIPS doesn't fit for rules described for OPUS_FAST_INT64
enabling, it has fast 32x32 multiplication with full 64-bit result.

That's enough to enable OPUS_FAST_INT64 for any MIPS since
OPUS_FAST_INT64 guards various multiplication implementation.
Maybe it's worth to get it more precise name? e.g. OPUS_FAST_MULT.

GCC macro __mips covers both 32- and 64-bit MIPS.

Signed-off-by: Siarhei Volkau <[email protected]>
Current MIPS port supports special implementation for CPUs with DSP
extension support. It is enabled by setting MIPSr1_ASM flag for
compiler.

The name MIPSr1_ASM is very confusing, r1 might mean:
- MIPS I
- MIPS32/MIPS64 release 1
- MIPS DSP ASE revision 1 (the correct one)

Let's remove it and check GCC's builtin define __mips_dsp instead.
This allows use default autotools build system instead of hand-crafted
makefile.

Signed-off-by: Siarhei Volkau <[email protected]>
Looks like MIPS port is abandoned? Not surprised though.

There's a lot of updates for mdct too, will be addressed
in another patch.

Signed-off-by: Siarhei Volkau <[email protected]>
GCC supports all MIPS DSP and DSPr2 instructions in form
of builtin functions, this is more convenient way rather than
inline assembly.

Moreover, performance on MIPS heavily depends on instruction scheduling
GCC is unable to schedule inline assembly properly because it
doesn't know what exactly the asm routine do.

Signed-off-by: Siarhei Volkau <[email protected]>
Changes from C version of MDCT algo ported into MIPS variant.

Signed-off-by: Siarhei Volkau <[email protected]>
@rillian
Copy link
Contributor

rillian commented Aug 17, 2025

Android build failures are unrelated breakage.

@rillian
Copy link
Contributor

rillian commented Aug 17, 2025

@SiarheiVolkau thanks for the patches! It would be easier to review if you referenced the commits with the mdct updates you're porting to the mips implementation in the commit messages.

@SiarheiVolkau
Copy link
Author

@rillian well, it is all commits that update clt_mdct_forward and clt_mdct_backward since 2014.
MIPS port never get in sync with C version since it's creation.
Here they are (https://github.com/xiph/opus/commits/main/celt/mdct.c):
f48abe8
19c5406
2739064
382ab79
1a37d4e
3116093
38e535a
c79a9bd
03e0d3a
5beef65
377cfaa
edffe56
60b8f5b
2941f08
74cdcae
08f5ff0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants