diff --git a/configure b/configure index 60e380d83d..ce0ed2397d 100755 --- a/configure +++ b/configure @@ -2597,6 +2597,7 @@ TOOLCHAIN_FEATURES=" ibm_asm inline_asm_direct_symbol_refs inline_asm_nonlocal_labels + loongson_mmi_mnemonics pragma_deprecated rsync_contimeout symver_asm_label @@ -6658,7 +6659,14 @@ elif enabled mips; then enabled loongson3 && check_inline_asm loongson3 '"gsldxc1 $f0, 0($2, $3)"' '-mloongson-ext' && append MMIFLAGS '-mloongson-ext' # MMI can be detected at runtime too - enabled mmi && check_inline_asm mmi '"pxor $f0, $f0, $f0"' '-mloongson-mmi' && append MMIFLAGS '-mloongson-mmi' + enabled mmi && { + check_inline_asm loongson_mmi_mnemonics '"pxor $f0, $f0, $f0\n\tssrld $f0, $f0, $f0"' '-mloongson-mmi' || { + # the MMI code does not build for O32 and assumes little-endian + disable mmi + enabled mips64 && ! enabled bigendian && + check_inline_asm mmi '"xor $f0, $f0, $f0"' '-mloongson-mmi' + } + } && append MMIFLAGS '-mloongson-mmi' if enabled bigendian && enabled msa; then disable msa diff --git a/libavutil/mips/mmiutils.h b/libavutil/mips/mmiutils.h index 7991e14e84..47cdb19f1c 100644 --- a/libavutil/mips/mmiutils.h +++ b/libavutil/mips/mmiutils.h @@ -29,6 +29,16 @@ #include "libavutil/mem_internal.h" #include "libavutil/mips/asmdefs.h" +#if !HAVE_LOONGSON_MMI_MNEMONICS +/* GNU binutils lacks Loongson's names for these MMI instructions */ +__asm__(".macro pxor d, s, t\n\txor \\d, \\s, \\t\n\t.endm\n" + ".macro pand d, s, t\n\tand \\d, \\s, \\t\n\t.endm\n" + ".macro por d, s, t\n\tor \\d, \\s, \\t\n\t.endm\n" + ".macro pnor d, s, t\n\tnor \\d, \\s, \\t\n\t.endm\n" + ".macro ssrld d, s, t\n\tdsrl \\d, \\s, \\t\n\t.endm\n" + ".macro sslld d, s, t\n\tdsll \\d, \\s, \\t\n\t.endm\n"); +#endif + /* * These were used to define temporary registers for MMI marcos * however now we're using $at. They're theoretically unnecessary